Login  Register

Re: re position ROIs at certain stacks

Posted by Krs5 on Feb 04, 2014; 4:39pm
URL: http://imagej.273.s1.nabble.com/re-position-ROIs-at-certain-stacks-tp5006379p5006405.html

I had thought about this in the past while doing FRAP experiments and after the start of this macro by Jan Brocher have used his code as basis for a macro that when you move the ROI it automatically updates the ROI for all following images in the stack and moves automatically to the next image in the stack.

You can change the sensitivity of the repositioning of the ROI by changing the wait(350) at line 61 of the code.

Not extensively tested but seems to work.

Best wishes

Kees

Dr Ir K.R. Straatman
Senior Experimental Officer
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif (notice new website!)




-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jan Brocher - BioVoxxel
Sent: 04 February 2014 10:10
To: [hidden email]
Subject: Re: re position ROIs at certain stacks

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

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

Move_ROI3.txt (3K) Download Attachment