Hi
I have been trying to use macro to batch process my .oif images. The macro works when both .oif and .oif.files are in the directory that I've selected but doesn't work when they are in one of the subfolders. For example: C:\Users\SeiHien\Desktop\Macros\FV10_2011\Track0001 It works only when I select "Track0001" and both Image0001_01.oif/.oif.files are in "Track0001" It doesn't work when I select "FV10_2011" where I have Track0001 to Track0012. The error message pops up as "Sorry, there was a problem during input" and in the log it is stated as "loci.formats.FormatException: Required directory Image0001_01.oif.files was not found." May I know if there is any way for me to overcome this problem? Below is the code I use, I've deleted the image processing part for easy viewing: Thanks! -SeiHien requires("1.33s"); dir = getDirectory("Choose a Directory "); setBatchMode(true); count = 0; countFiles(dir); n = 0; processFiles(dir); print(count+" files processed"); function countFiles(dir) { list = getFileList(dir); for (i=0; i<list.length; i++) { if (endsWith(list[i], "/")) countFiles(""+dir+list[i]); else if(endsWith(list[i], ".oif")) count++; } } function processFiles(dir) { list = getFileList(dir); for (i=0; i<list.length; i++) { if (endsWith(list[i], "/")) processFiles(""+dir+list[i]); else if(endsWith(list[i], ".oif")){ showProgress(n++, count); path = dir+list[i]; print(dir); processFile(path, list[i], dir); } } } function processFile(path, name, dir) { if (endsWith(name, ".oif")) { run("Bio-Formats Importer", "open="+path+" autoscale color_mode=Default concatenate_series crop open_all_series split_channels view=Hyperstack stack_order=XYCZT x_coordinate_1=0 y_coordinate_1=0 width_1=640 height_1=900"); |
Hi
I've tested the code on someone's Mac and it works like charm but not on my PC. Anyone knows what is the possible reason that causes this? Thanks! Best Sei Hien |
In reply to this post by SeiHien
Hi SeiHien,
> I have been trying to use macro to batch process my .oif images. The macro > works when both .oif and .oif.files are in the directory that I've selected > but doesn't work when they are in one of the subfolders. For example: > > C:\Users\SeiHien\Desktop\Macros\FV10_2011\Track0001 > > It works only when I select "Track0001" and both Image0001_01.oif/.oif.files > are in "Track0001" > It doesn't work when I select "FV10_2011" where I have Track0001 to > Track0012. The error message pops up as > > "Sorry, there was a problem during input" > > and in the log it is stated as > > "loci.formats.FormatException: Required directory Image0001_01.oif.files was > not found." The problem is that any subdirectories returned by the getFileList(dir) command will have a "/" appended, regardless of the platform's file separator character ("/" on Mac/Linux, "\" on Windows). This causes interesting behavior on Windows, because you will end up with file names like this: C:\path\to\file/Image0001.oif Perhaps the easiest way around this is to modify the "processFile" function: // -- begin modified function -- function processFile(path, name, dir) { path = replace(path, "/", File.separator); run("Bio-Formats Importer", "open="+path+" autoscale color_mode=Default concatenate_series crop open_all_series split_channels view=Hyperstack stack_order=XYCZT x_coordinate_1=0 y_coordinate_1=0 width_1=640 height_1=900"); } // -- end modified function -- Regards, -Melissa On Wed, Feb 29, 2012 at 02:36:24PM -0800, SeiHien wrote: > Hi > > I have been trying to use macro to batch process my .oif images. The macro > works when both .oif and .oif.files are in the directory that I've selected > but doesn't work when they are in one of the subfolders. For example: > > C:\Users\SeiHien\Desktop\Macros\FV10_2011\Track0001 > > It works only when I select "Track0001" and both Image0001_01.oif/.oif.files > are in "Track0001" > It doesn't work when I select "FV10_2011" where I have Track0001 to > Track0012. The error message pops up as > > "Sorry, there was a problem during input" > > and in the log it is stated as > > "loci.formats.FormatException: Required directory Image0001_01.oif.files was > not found." > > May I know if there is any way for me to overcome this problem? Below is the > code I use, I've deleted the image processing part for easy viewing: > > Thanks! > > -SeiHien > > requires("1.33s"); > dir = getDirectory("Choose a Directory "); > setBatchMode(true); > count = 0; > countFiles(dir); > n = 0; > processFiles(dir); > print(count+" files processed"); > > function countFiles(dir) { > list = getFileList(dir); > for (i=0; i<list.length; i++) { > if (endsWith(list[i], "/")) > countFiles(""+dir+list[i]); > else if(endsWith(list[i], ".oif")) > count++; > } > } > > function processFiles(dir) { > list = getFileList(dir); > for (i=0; i<list.length; i++) { > if (endsWith(list[i], "/")) > processFiles(""+dir+list[i]); > else if(endsWith(list[i], ".oif")){ > showProgress(n++, count); > path = dir+list[i]; > print(dir); > processFile(path, list[i], dir); > } > } > } > > function processFile(path, name, dir) { > if (endsWith(name, ".oif")) { > run("Bio-Formats Importer", "open="+path+" autoscale > color_mode=Default concatenate_series crop open_all_series split_channels > view=Hyperstack stack_order=XYCZT x_coordinate_1=0 y_coordinate_1=0 > width_1=640 height_1=900"); > > -- > View this message in context: http://imagej.1557.n6.nabble.com/Bio-Formats-Importer-Couldn-t-Read-OIF-in-Subfolders-During-Batch-Processing-tp4533132p4533132.html > Sent from the ImageJ mailing list archive at Nabble.com. |
Free forum by Nabble | Edit this page |