Révision 2

bin/image2geometry/curvature_map_segmentation.py (revision 2)
1
import os
2

  
3
'''
4
Input:
5
 - directory with detected sepal contour stacks .tif
6
 
7
Output:
8
 - segmented meshes (up and down surfaces treated as cells)
9
 - csv file / sepale containing : up and down surface areas, perimeter
10

  
11
'''
12

  
13
# cubesize for mesh creation
14
cubesize=str(30)
15

  
16
# size of neighbourhood for the segmented curvature map
17
curv_neighb=str(50)
18

  
19
# directory with detected sepal contours
20
filedata1='/directory/of/sepal/contour/stacks'
21

  
22

  
23
filedata=filedata1+'/'
24
meshresult=filedata1+'-MGX-mesh'+cubesize+'/'
25
csvresult=filedata1+'-MGX-csv/'
26
segresult=filedata1+'-MGX-seg/'
27

  
28

  
29
os.system("mkdir "+meshresult)
30
os.system("mkdir "+csvresult)
31
os.system("mkdir "+segresult)
32

  
33
listfiles=os.listdir(filedata)
34

  
35
Process.Stack__System__Clear_Work_Stack('0')
36
Process.Stack__System__Clear_Main_Stack('0')
37
Process.Stack__System__Clear_Main_Stack('1')
38
Process.Stack__System__Clear_Work_Stack('1')
39
for i in listfiles:	
40
	Process.Stack__System__Set_Current_Stack('Main', '0')
41
	Process.Stack__System__Open(filedata+i, 'Main', '0')
42
	Process.Mesh__Creation__Marching_Cubes_Surface('30', '5000')
43
	Process.Mesh__Structure__Smooth_Mesh('1', 'No')
44
	Process.Mesh__Structure__Smooth_Mesh('1', 'No')
45
	Process.Mesh__Structure__Smooth_Mesh('1', 'No')
46
	Process.Mesh__Structure__Smooth_Mesh('1', 'No')
47
	csvname=i[:-4]+'-carte-courbure-Maximal'+curv_neighb+'.csv'
48
	Process.Mesh__Signal__Project_Mesh_Curvature(csvresult+csvname, 'Maximal', '50', 'Yes', '-50.0', '50.0', '85')
49
	meshname=i[:-4]+'-mesh.mgxm'
50
	Process.Mesh__System__Save(meshresult+meshname, 'no', '0')
51
	Process.Stack__System__Clear_Work_Stack('0')
52
	Process.Stack__System__Clear_Main_Stack('0')
53
	Process.Stack__System__Clear_Main_Stack('1')
54
	Process.Stack__System__Clear_Work_Stack('1')
55
	#testing autosegmentation with updated parameters
56
	Process.Mesh__Segmentation__Auto_Segmentation('Yes', 'No', '170.0', '170.0', '65', '200.0', '100.0', '1.8')
57
	segname=i[:-4]+'-seg.mgxm'
58
	Process.Mesh__System__Save(meshresult+segname, 'no', '0')
59
	csvname=i[:-4]+'-area.csv'
60
	Process.Mesh__Heat_Map__Heat_Map_Classic('Area', 'Geometry', csvresult+csvname, 'Geometry', 'No', '0', '65535', 'Yes', 'No', 'None', 'No', 'Decreasing', 'Ratio', '0.001', '1')
61

  
62
	"""print("Please put two seeds on the two sides of the sepal :-) ... ")
63
	a=input("")
64
	Process.Mesh__Segmentation__Watershed_Segmentation('50000')
65
	csvname=i[:-4]+'-area.csv'
66
	Process.Mesh__Heat_Map__Heat_Map_Classic('Area', 'Geometry', csvresult+csvname, 'Geometry', 'No', '0', '65535', 'Yes', 'No', 'None', 'No', 'Decreasing', 'Ratio', '0.001', '1')
67
"""
68

  
69
#Process.Mesh__Segmentation__Watershed_Segmentation('50000')
70
#Process.Mesh__Heat_Map__Heat_Map_Classic('Area', 'Geometry', '/home/biophysics/Desktop/Alexis/10_3Dshape/oriented-sepals-tif-test-MGX-csv/spreadsheet.csv', 'Geometry', 'No', '0', '65535', 'Yes', 'No', 'None', 'No', 'Decreasing', 'Ratio', '0.001', '1')
bin/image2geometry/orient_sepal.py (revision 2)
21 21

  
22 22
from titk_tools.io import imread, imsave, SpatialImage
23 23
from titk_tools.rw.registration import isotropic_resampling_seg
24
from titk_tools.rw.registration import apply_transfo_on_seg1
24 25

  
25 26
from bib_sepals import *
26 27

  
bin/image2geometry/flip-vertically-mgx.ijm (revision 2)
1
//////////////////////////////////////////////////////////////////////////////////
2

  
3
//The script will process all your .inr.gz files in the chosen folder.
4
//The stacks will be saved in subfolders named as the treated lif files.
5

  
6
print ("===========================");
7
print ("==== Macro flip-vertically-mgx.ijm ====");
8

  
9

  
10
//Choose the directory containing your .inr.gz files//
11
dir = getDirectory("Choose a directory")
12
setBatchMode(true);
13
list = getFileList(dir);
14

  
15
print(dir);
16
ShortNameDir=substring(dir,0,lastIndexOf(dir,"/"));
17
print (ShortNameDir);
18
dirout=ShortNameDir+"-flipped/";
19
print("Creating output directory ",dirout);
20
File.makeDirectory(dirout);
21

  
22
for (FileInd=0; FileInd<list.length; FileInd++){
23
	FileName = list[FileInd];
24
	if(endsWith (FileName, ".tif")){
25
		print ("### Processing ",FileName," ###");
26
		path = dir+FileName;
27
		pathout = dirout+FileName;
28
		print("avant open", FileName,"!");
29
		//run("Bio-Formats Importer", "open=["+path+"] color_mode=Default view=Hyperstack stack_order=XYCZT use_virtual_stack open_all_series ");
30
		open(path);
31
		print("apres open", FileName,"!");
32
		run("Flip Vertically", "stack");
33
		saveAs("Tiff", pathout);
34
		print("avant close", FileName,"!");
35
		run("Close All");
36
		print("Done with", FileName,"!");
37
	} else {
38
	print("### ",FileName," Not a .tif file ###");
39
	};
40
};	
41
print("Done with this folder!!!");
42

  
43

  
44

  
45

  

Formats disponibles : Unified diff