root / bin / image2geometry / lif2tif.ijm @ 1
Historique | Voir | Annoter | Télécharger (2,37 ko)
1 |
////////////////////////////////////////////////////////////////////////////////// |
---|---|
2 |
|
3 |
//The script will process all your .lif 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 lif2tif.ijm ========="); |
8 |
print ("===================================="); |
9 |
|
10 |
//Choose the directory containing your .lif file// |
11 |
dir = getDirectory("Choose a directory") |
12 |
setBatchMode(true); |
13 |
list = getFileList(dir); |
14 |
|
15 |
//Find .lif experiment// |
16 |
for (FileInd=0; FileInd<list.length; FileInd++){ |
17 |
FileName = list[FileInd]; |
18 |
if(endsWith (FileName, "lif")){ |
19 |
print ("### Processing ",FileName," ###"); |
20 |
path = dir+FileName; |
21 |
ShortName=substring(FileName,0,indexOf(FileName,".lif")); |
22 |
print("Creating output directory ",ShortName); |
23 |
File.makeDirectory(dir+ShortName); |
24 |
//Open .lif// |
25 |
run("Bio-Formats Importer", "open=["+path+"] color_mode=Default view=Hyperstack stack_order=XYCZT use_virtual_stack open_all_series "); |
26 |
//Saving as .tif the content of the .lif files, in their destination folders// |
27 |
list = getList("image.titles"); |
28 |
//get the name of each image opened// |
29 |
ids=newArray(nImages); |
30 |
for (j=0; j<list.length; j++){ |
31 |
//print(list[j]); |
32 |
selectImage(j+1); |
33 |
ids[j]=getTitle; |
34 |
//Get experiment name (title of the .lif file)// |
35 |
experiment_name=substring(ids[j],0,indexOf(ids[j],".lif")); |
36 |
//Remove the name of the .lif file that is included in each image// |
37 |
short_name1 = substring(ids[j], indexOf(ids[j], "- "), lastIndexOf(ids[j], "")); |
38 |
short_name = replace(short_name1, "- ", ""); |
39 |
//If not a stack, save directly as .tif with a short name// |
40 |
if (nSlices==1){ |
41 |
print("Not a stack"); |
42 |
run("8-bit"); |
43 |
saveAs("Tiff", dir+File.separator+experiment_name+File.separator+short_name); |
44 |
print(short_name, ">>> Image saved as .tif"); |
45 |
//If a stack, reverse and save as .tif with a short name// |
46 |
} else { |
47 |
run("Reverse"); |
48 |
run("8-bit"); |
49 |
saveAs("Tiff", dir+File.separator+experiment_name+File.separator+short_name); |
50 |
print("----- ",short_name, " >>> Reversed and saved as .tif"); |
51 |
}; |
52 |
getPixelSize(unit, pw, ph, pd); |
53 |
print("Voxelsize="+pw+"x"+ph+"x"+pd+" "+unit+"^3"); |
54 |
print("nSlices="+nSlices); |
55 |
}; |
56 |
run("Close All"); |
57 |
print("Done with", FileName,"!"); |
58 |
} else { |
59 |
print("### ",FileName," Not a .lif file###"); |
60 |
}; |
61 |
}; |
62 |
print("Done with this folder!!!"); |
63 |
|
64 |
|
65 |
|
66 |
|