Posted by
Krs5 on
May 20, 2014; 4:08pm
URL: http://imagej.273.s1.nabble.com/Recursive-processing-of-a-directory-not-working-correctly-tp5007797p5007806.html
Dear matsojr22(???),
Your line: run("Bio-Formats Windowless Importer", "open=inBase + path color_mode=Default view=Hyperstack stack_order=XYCZT");
should read; run("Bio-Formats Windowless Importer", "open="+inBase + path+" color_mode=Default view=Hyperstack stack_order=XYCZT"); as 'inBase' and 'path' contain a string that will create the name of the file you want to open; you don't want to open the file with the name: "inBase + path.vsi"
There is also a typo in saveAs("Tiff", outbase + path); which needs outBase instead of outbase.
Hope this solves your problem.
Best wishes
Kees
Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif-----Original Message-----
From: ImageJ Interest Group [mailto:
[hidden email]] On Behalf Of matsojr22
Sent: 20 May 2014 00:15
To:
[hidden email]
Subject: Recursive processing of a directory not working correctly
I've been combing this forum looking at other examples of code similar to mine but I still have not been able to solve the issue.
I am processing images in Fiji/imageJ using a macro code. The code is meant to recursively search a given directory for image files (in this case .vsi
files) and convert them to .tiff using the built in bioformats functions.
I have cobbled the following code together from several examples (I am not a programmer, I have a biology degree), and I am returning an error that the specified file does not exist. Printout and debug console show the error occurs on the /run("Bio-Formats.../ line of the macro.
For reference:
All of my images have the following general directory structure:
~/Brain_01/Slice_01/Slice_01_01.vsi
An actual example is as follows for the second image in this set:
~/K259_tlx3cre/K259_1of3_02/K259_1of3_01_02.vsi
I really, really appreciate all the help you guys provide! I am completely stuck right now and am just banging my head against the keyboard at this point. Also, I think I've followed all the rules for posting. If not please just point out the error of my ways.
Finally here is the macro code I have written so far is attached as a text file which formats well in notepad++, and I will also paste the code here but have no idea how it will format once the post goes up.
Dialog.create("File type");
Dialog.addString("File suffix: ", ".vsi", 5); Dialog.show(); suffix = Dialog.getString();
inDir = getDirectory("Choose Directory Containing " + suffix + " Files "); outDir = getDirectory("Choose Directory for TIFF Output "); setBatchMode(true); processFiles(inDir, outDir, ""); print("Done!");
function processFiles(inBase, outBase, sub) {
flattenFolders = true; // this flag controls output directory structure
print("Processing folder: " + sub);
list = getFileList(inBase + sub);
if (!flattenFolders) File.makeDirectory(outBase + sub);
for (i=0; i<list.length; i++) {
path = sub + list[i];
//upath = toUpperCase(path); only need if the file extension is case sensitive
upath = path; //avoids the previous line
if (endsWith(path, "/")) {
processFiles(inBase, outBase, path);
}
else if (endsWith(upath, suffix)) {
print("Importing " + suffix + " = " + list[i]);
run("Bio-Formats Windowless Importer", "open=inBase + path color_mode=Default view=Hyperstack stack_order=XYCZT");
print("Blue...");
selectImage(1);
title1 = getTitle();
run("Blue");
print("Green...");
selectImage(2);
title2 = getTitle();
run("Green");
print("Red...");
selectImage(3);
title3 = getTitle();
run("Red");
print("Merging Channels...");
run("Merge Channels...", "red=&title3 green=&title2 blue=&title1
gray=*None* cyan=*None* magenta=*None* yellow=*None* create keep");
print("Converting to RGB");
run("RGB Color");
saveAs("Tiff", outbase + path);
run("Close All");
}
}
}
--
View this message in context:
http://imagej.1557.x6.nabble.com/Recursive-processing-of-a-directory-not-working-correctly-tp5007797.htmlSent from the ImageJ mailing list archive at Nabble.com.
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html