Re: Batch processing of .oib
Posted by mditzel on Feb 28, 2011; 3:22pm
URL: http://imagej.273.s1.nabble.com/Re-Batch-processing-of-oib-tp3685528p3685531.html
Dear All,
First I must say that I have been pulling what little hair I have left out trying to do what should be a simple task.
Second, I am a total novice at macros / scripts etc. However, following the thread I have modified the Recurssive TIFF convert file to read OIB files (see below). I had to delete the last line about Garbage as IMAGE J did not like it.
When run, the macro log window proceeds and ends (see below), however I can not find the saved TIFF file in the designated TIFF output folder. There are no error messages. Does anyone have ideas what's wrong.
My hair thanks you in advance,
Mark
// recursiveTiffConvert.txt
2 // Written by Curtis Rueden
3 // Last updated on 2011 Feb 22
4
5 // Recursively converts files to TIFF using Bio-Formats.
6
7 // It was originally written to convert Gatan DM3 files, but you can easily
8 // change the code to work with any or all extensions of your choice.
9
10 // Thanks to Chris Zahm for suggestions and improvements:
11 // - Save as OME-TIFF using Bio-Formats Exporter, to preserve metadata
12 // - Run garbage collection after each exported file
13
14 /// ext ; // this variable controls the extension of source files
15
16 requires("1.39u");
17 inDir = getDirectory("Choose Directory Containing " + "OIB" + " Files ");
18 outDir = getDirectory("Choose Directory for TIFF Output ");
19 setBatchMode(true);
20 processFiles(inDir, outDir, "");
21 print("-- Done --");
22
23 function processFiles(inBase, outBase, sub) {
24 flattenFolders = true; // this flag controls output directory structure
25 print("-- Processing folder: " + sub + " --");
26 list = getFileList(inBase + sub);
27 if (!flattenFolders) File.makeDirectory(outBase + sub);
28 for (i=0; i<list.length; i++) {
29 path = sub + list[i];
30 upath = toUpperCase(path);
31 if (endsWith(path, "/")) {
32 // recurse into subdirectories
33 processFiles(inBase, outBase, path);
34 }
35 else if (endsWith(upath, "." + "OIB")) {
36 print("-- Processing file: " + path + " --");
37 run("Bio-Formats Importer", "open='" + inBase + path + "' color_mode=Default view=[Standard ImageJ] stack_order=Default use_virtual_stack");
38 outFile = outBase + path + ".ome.tif";
39 if (flattenFolders) outFile = replace(outFile, "/", "_");
40 run("Bio-Formats Exporter", "save=[" + outFile + "] compression=Uncompressed");
41 close();
42
43 }
44 }
45 }
LOG:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
24
25
-- Processing folder: --
26
27
28
29
30
31
35
36
-- Processing file: Image0023.oib --
37
38
39
40
41
42
43
44
29
30
31
35
36
-- Processing file: Image0025.oib --
37
38
39
40
41
42
43
44
29
30
31
35
36
-- Processing file: Image0028.oib --
37
38
39
40
41
42
43
44
29
30
31
35
36
-- Processing file: Image0030.oib --
37
38
39
40
41
42
43
44
29
30
31
32
33
24
25
-- Processing folder: TIFF Convereted/ --
26
27
28
45
34
35
44
45
21
-- Done --
22
23