Login  Register

ROI post processing help: split in two equal surfaces

Posted by julcanada on Mar 30, 2011; 3:59pm
URL: http://imagej.273.s1.nabble.com/ROI-post-processing-help-split-in-two-equal-surfaces-tp3685206.html

hey all

so i am analyzing particles and after using the particle analyzer module to identify the boundaries, i can create nice ROI. now im trying to extract intensity (integrated density actually) for the two halves of these particles. a macro was written to automate the process and it's at the end of this message. it finds the center of mass (generally its pretty much the same as the centroid), then split the ROI vertically through it, leaving me with a left and a right ROI that i can use for my calculations.

my main problem is that the particles are not perfectly spherical, so when this macro is run, the ROIs have a different surface, and hence the integrated density measurement is biased. What i would like to do, is adjust the position of the division axis so that the surfaces are equal. any idea on how i would code this?

thanks for your help!


run("Set Measurements...", "area mean standard modal min centroid center perimeter bounding fit shape feret's integrated median skewness kurtosis area_fraction stack limit display scientific redirect=None decimal=9"); //Ensure that all properties are met in the results table
imgw = getWidth();

org = roiManager("Count");

srcDir = File.directory(); //Stores the directory path of the file.
srcNam = File.name(); //Stores the name of the file with the extension.

setFont("Cambria",20," italic antialiased"); //Set font properties for the particle labeler function.
drwCol = 255; //Set font colour of the particle labeler function.

doit();

function doit()
{
 for (i=org;i>0;i--)
 {

n = roiManager("Count") - 1; //this is the number of rois in the list, then -1 accounts for the select list with 0 being the first number

//Left Side

roiManager("Select", n);
roiManager("Rename", "Cell " + n);
run("Measure");
makeRectangle(round(getResult("XM",0)), 0, imgw - round(getResult("XM",0)), imgw);

roiManager("Add");
roiManager("Select", n);
run("Make Inverse");
roiManager("Add");

roiManager("Select", n+1);
setKeyDown("shift");
roiManager("Select", n+2);
setKeyDown("none");

run("Make Inverse");
roiManager("Add");

roiManager("Select", n+3);
roiManager("Rename", "Partition Left " + n);

//Right Side

roiManager("Select", n+1);
run("Make Inverse");
roiManager("Add");

roiManager("Select", n+2);
roiManager("Add");

roiManager("Select", n+4);
setKeyDown("shift");
roiManager("Select", n+5);
setKeyDown("none");

run("Make Inverse");
roiManager("Add");

roiManager("Select", n+6);
roiManager("Rename", "Partition Right " + n);

//Clean up

roiManager("Select", n+1);
roiManager("Delete");
roiManager("Select", n+1);
roiManager("Delete");
roiManager("Select", n+2);
roiManager("Delete");
roiManager("Select", n+2);
roiManager("Delete");

//Save

//roiManager("Save",srcDir+srcNam+i+".zip");


saveAs("Measurements",srcDir+i+".xls");

print("Cell: "+i+" Intensity: "+getResult("IntDen", 2)/getResult("IntDen", 1));
//drawString(i, getResult("XM",0), getResult("YM",0));
run("Clear Results");