-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_File_Extraction_from_RAW_Data_Mac.ijm
executable file
·67 lines (61 loc) · 2.06 KB
/
1_File_Extraction_from_RAW_Data_Mac.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
s=File.separator;
Dialog.create("Bruker Data Manager");
Dialog.addCheckbox("Input Directory = Output Directory", false);
Dialog.addMessage("Image Extraction from Raw Data:");
Dialog.addCheckbox("Extract Files from RAW Data", true);
Dialog.addMessage("(Make sure there are no RAWDATA Folders!)");
Dialog.show();
inDisOutDir=Dialog.getCheckbox();
Extr=Dialog.getCheckbox();
inDir=getDirectory("Choose the Raw Data Containing Folder");
if (inDisOutDir==true) {
outDir=inDir;
}
else {
outDir=getDirectory("Choose Output Folder");
if ((inDir==outDir) || (startsWith(outDir, inDir))) {
exit("Input folder must be different from and not within output folder!");
}
}
setBatchMode(true);
if (Extr==true) {
ExtractFiles(inDir,outDir);
print("Done!");
}
setBatchMode(false);
function ExtractFiles(inDir,outDir) {
list = getFileList(inDir);
for (i=0; i<list.length; i++) {
if (endsWith(list[i], "/")) {
DuplicatePath=replace(inDir+s+list[i], inDir, outDir);
if (!File.exists(DuplicatePath) && !endsWith(DuplicatePath, "MIP/") && !endsWith(DuplicatePath, "References/")) {
File.makeDirectory(DuplicatePath);
}
ExtractFiles(inDir+list[i],outDir+list[i]);
}
else if (endsWith(list[i], ".xml")) {
ExtractedFilePath=replace(inDir+s+list[i], inDir, outDir);
//For windows users the .xml format can not be used. They have to use the import image sequence function
ExtractedFile=replace(ExtractedFilePath, ".xml", "_Stack_Extr.tif");
if (!File.exists(ExtractedFile)) {
run("Bio-Formats", "open=["+inDir+list[i]+"] autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
name=File.getName(outDir+list[i]);
selectWindow(name);
sln=nSlices;
if (sln>1) {
Stack.setChannel(1);
resetMinAndMax();
Stack.setChannel(2);
resetMinAndMax();
saveAs("tiff", replace(ExtractedFilePath, ".xml", "_Stack_Extr.tif"));
}
else {
saveAs("tiff", replace(ExtractedFilePath, ".xml", "_Extr.tif"));
}
run("Close All");
run("Collect Garbage");
close("Log");
}
}
}
}