Login  Register

Re: re position ROIs at certain stacks

Posted by gankaku on Feb 04, 2014; 10:09am
URL: http://imagej.273.s1.nabble.com/re-position-ROIs-at-certain-stacks-tp5006379p5006390.html

Hi Pablo, hi Jacob

potentially you can check the following macro. It might do, what you need.
I simply put it together quickly, so if there is a problem contact me again.

What you have to do:

1.) draw the ROI you want to put into the image
2.) choose the color of the ROI using the color picker tool
3.) run the macro I attached here
4.) go through your slices and if you need to manually move a selection do the following
     5.) keep [Alt] pressed and click inside your ROI (thus you reactivate it
     6.) move it or change its appearance
     7.) click somewhere outside the ROI to add it back to the overlay layer
     8.) press Ok in the small dialog box

--> This will add all the ROIs to teh ROI-Manager and using this one you can select >More >Multi Measure with the choice to measure all slices active and you will get the analyses of all the ROIs in all slices in teh results table.


Macro code:

/**Macro written by Jan Brocher/BioVoxxel
 * NO WARRENTY of functionality and no liability for any damages.
 */

getDimensions(width, height, channels, slices, frames);
Dialog.create("ROI setup");
        Dialog.addChoice("label:", newArray( "frames", "slices", "channels"), "frames");
        Dialog.show();
        dimension = Dialog.getChoice();

color = toHex(getValue("rgb.foreground"));

run("Overlay Options...", "stroke="+color+" width=0 fill=none set");

setBatchMode(true);
if(dimension=="frames") {
        if(frames<2) {
                exit("no multiple frames available");
        } else {
                toLabel = frames;
        }
} else if(dimension=="slices") {
        if(slices<2) {
                exit("no multiple slices available");
        } else {
                toLabel = slices;
        }
} else if(dimension=="channels") {
        if(channels<2) {
                exit("no multiple channels available");
        } else {
                toLabel = channels;
        }
}

roiManager("reset");
for(i=1; i<=toLabel; i++) {
        if(dimension=="frames") {
                Stack.setFrame(i);
        } else if(dimension=="slices") {
                Stack.setSlice(i);
        } else if(dimension=="channels") {
                Stack.setChannel(i);
        }


        run("Add Selection...");
}

//reset Stack position
if(dimension=="frames") {
                Stack.setFrame(1);
} else if(dimension=="slices") {
                Stack.setSlice(1);
} else if(dimension=="channels") {
                Stack.setChannel(1);
}

setBatchMode(true);
//enable manual adjustments to the individual ROIs
waitForUser("adjust overlays and press Ok");
run("To ROI Manager");
exit();

//end of macro---------------------------------------------

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html