Plotting mean of an ROI and saving to excel
Posted by
DanielatAmthorLab on
Jan 16, 2015; 3:22am
URL: http://imagej.273.s1.nabble.com/Plotting-mean-of-an-ROI-and-saving-to-excel-tp5011245.html
Hi all, and Thank you for checking out my question!
I am trying to use ImageJ to collect some .tiff sequences from a directory apply ROIs (saved in a second directory) and finally save the Mean of the ROI for each frame of each .tiff sequence in a third directory as an excel readable file. I have the directory navigation down, and I have several methods for collecting the mean of the ROIs. The end result should be an excel file for each ROI, with the plots of each video inside.
What I can't do...
...(after about a week) is save the mean values for each .tiff sequence to a file that I can read with excel. I would like columns to be the individual videos and the rows to be the mean of the ROI in each frame. How do I do this?
This is the code I have so far. It is in the Imagej macro language.
//this macro takes the z plot of different ROIs for a directory of tiff videos
if (nImages!=0){exit("Close all open images!");}
//Ask user to select input/output
dir1 = getDirectory("Select input directory"); //tiff sequences
dir2 = getDirectory("Select output directory"); //excel file for each ROI
dir3 = getDirectory("Select saved ROI directory"); //where the .roi files are
inlist=getFileList(dir1);
ROIlist=getFileList(dir3);
namlng=inlist.length;
savfnamstart=replace(inlist[0], ".tif", " ");//name creation for excel files
//set ROI manager to measure the mean of the ROIs
run("Set Measurements...", " mean redirect=None decimal=3");
run("ROI Manager...");
//roiManager("Deselect");
//roiManager("Delete"); //clear any ROIs in the manager
for (R=0; R<ROIlist.length; R++){
roiManager("Open", dir3+ROIlist[R] );}//Open all ROIs to manager
for (H=0; H<ROIlist.length; H++){
roiManager("Select", H);
thisROI=ROIlist[H];
ROInam=replace(thisROI, ".roi", "");//get a name for current ROI
f = File.open(dir2+savfnamstart+"To"+namlng+ROInam+".xls");
//create an excel file to save data to.
for (i=0; i<inlist.length; i++) {
//this is where i have trouble. after I have looked at each video, how do I save its means for the ROI?
}
}