Posted by
Francomazzei on
URL: http://imagej.273.s1.nabble.com/Batch-process-images-with-specific-ROis-tp5021442.html
Dear all,
I don't have much experience coding but after reading your guides and
tutorials I was able to make a code for measuring the area of the
thresholded pixels in my images. the code looks like this :
#@File(label = "Input directory", style = "directory") input
#@File(label = "Output directory", style = "directory") output
#@String(label = "File suffix", value = ".tif") suffix
processFolder(input);
// function to scan folders/subfolders/files to find files with correct
suffix
function processFolder(input) {
list = getFileList(input);
for (i = 0; i < list.length; i++) {
if(File.isDirectory(input + File.separator + list[i]))
processFolder("" + input + File.separator + list[i]);
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
function processFile(input, output, file) {
setBatchMode(true);
run("Bio-Formats", "open=[" + input + "/" + file +"] autoscale
color_mode=Default rois_import=[ROI manager] view=Hyperstack
stack_order=XYCZT");
id = getImageID(); // get original image id
run("Duplicate...", " ");
run("8-bit");
run("Subtract Background...", "rolling=50");
run("Median...", "radius=1.5");
save(output + "/Processed_filter_" + file);
setAutoThreshold("Otsu dark");
//run("Threshold...");
run("Create Mask");
run("Fill Holes");
run("Analyze Particles...", "add");
selectImage(id);
roiManager("Show All with labels"); // overlay ROIs
roiManager("Deselect");
roiManager("Measure"); // measure on original image
// save ROIs for current image
roiManager("Deselect");
roiManager("Save", output+ "/" + file + "_Amyloid_ROI.zip"); // saves Rois
zip file
roiManager("Deselect");
roiManager("Delete");
saveAs("Results", output+ "/" + file + "_Amyloid_Results.csv") ;
run("Clear Results");
}
Now I would like to apply this same analysis but to specific previously made
ROIs in the same images.
To be more clear what I would like to do is:
1. Open image file from a specified image directory using bioformats.
2. Load matching ROIs previously saved as zip into the image.
3. Perform the analysis described in the macro I posted above to each ROI
and save the results separately.
5. close all windows and start over with another image and a different set
of ROIs ( each image has a specific and different set of ROIs).
Is it possible to do so? I am very lost at the moment, any help would be
highly appreciated.
Thank you so much beforehand.
Best,
Franco
--
Sent from:
http://imagej.1557.x6.nabble.com/--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html