Login  Register

Re: flip ROI selection

Posted by Tiago Ferreira-2 on Dec 06, 2014; 5:08pm
URL: http://imagej.273.s1.nabble.com/flip-ROI-selection-tp5010816p5010818.html

Dear Liz,

On Dec 6, 2014, at 10:27, Liz Bless <[hidden email]> wrote:
> I would like a mirror image of the ROI I have made.

The two macros below would do it:
Install them, create a selection, and press F1/F2 to obtain dorsal-caudal/ventral-dorsal mirrors of the active ROI.

These used to be present in earlier versions of the ROI Manager Tools[1], but somehow got removed as were deemed
too specific (they were mainly used for manual quantification of in-situ slices). They could be re-introduced if
you think they are of broader scope. In that case, they would be made available through the BAR update site[2].

To install: Copy the snippet below, paste it into ImageJ, then used the Install command in the editor window.

Hope it helps,
-tiago

[1] http://imagej.net//plugins/roi-manager-tools/
[2] http://fiji.sc/BAR


// Begin of snippet
macro "Contralateral in X [F1]" {
        mirrorROI(-1, 1);
}
macro "Contralateral in Y [F2]" {
        mirrorROI(1, -1);
}

function mirrorROI(fx, fy) {
        roi = selectionType();
        if (roi>8 || roi<0)
                exit("Cannot mirror current selection");
        getSelectionBounds(x, y, width, height);
        originalX = x;
        originalY = y;
        getSelectionCoordinates(x, y);
        aX= newArray(x.length);
        aY= newArray(x.length);
        for (i=0; i<x.length; i++) {
                aX[i] = fx*x[i];
                aY[i] = fy*y[i];
        }
        makeSelection(roi, aX, aY);
        setSelectionLocation(originalX, originalY);
}
// End of snippet

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