Login  Register

Re: Measuring mulitple species from a single image

Posted by Straub, Volko A. (Dr.) on Jul 15, 2014; 8:42pm
URL: http://imagej.273.s1.nabble.com/Measuring-mulitple-species-from-a-single-image-tp5008690p5008758.html

Dear Gail,

Here is a little macro that might be useful to you. It doesn't use the
ROI - instead it creates a new image and colour codes the selected shape
based on the number key that you click. In order to use it, copy the
code to the script editor and install the macro. Once it is installed,
make a selection with the wand tool (or any other selection tool you
would like to use). When you are happy with your selection, press a
number (currently any value between 1 and 5 - to extent it simply copy
the macro "shapeX [X]"{addShape(getTitle(),X);} part and replace X with
additional numbers).
The first time you do this, the macro will create a new black image with
the original image title + Shapes. It will then add the selected region
to the new image and colour it according to the key you pressed
(currently 10 for key 1, 20 for key 2, etc - but you could change this
easily).
When you select a second region and press a key between 1 and 5, that
region will be added to the shapes image, and so on.

When you have gone through all your particles of interest, you can then
simply use a small loop to threshold the image to select individual
types (i.e. all shapes with a value of 10, etc) and use the particle
analyser to count and measure these shapes.

Hope this is of some use,
Volko


macro "shape1 [1]"{
     addShape(getTitle(),1);
}
macro "shape2 [2]"{
     addShape(getTitle(),2);
}
macro "shape3 [3]"{
     addShape(getTitle(),3);
}
macro "shape4 [4]"{
     addShape(getTitle(),4);
}
macro "shape5 [5]"{
     addShape(getTitle(),5);
}


function addShape(image,type){
     if (!isOpen(image+"_Shapes")){
         selectImage(image);
         getDimensions(width, height, channels, slices, frames);
         getPixelSize(unit,pixelWidth,pixelHeight);
         newImage(image+"_Shapes","8-bit black",width, height,1);
         setVoxelSize(pixelWidth, pixelHeight,1, unit);
     };
     selectImage(image+"_Shapes");
     run("Restore Selection");
     changeValues(0,255,type*10);
     selectImage(image);
}


On 15/07/2014 18:57, gaton wrote:

> Hi Norbert,
> The description of ROIcounter on the link you sent sounded perfect. Either I
> am not using it correctly, or I misinterpreted the description. I thought I
> would be able to hover over ROIs I had already created using the Wand, press
> [1] and have them stored as Object Type1. But instead, I have to select
> Type1, then still draw around the ROI using the ObjectJ Marker Tool in order
> to define the area.
> The problem with the ROIcounter/Cellcounter in ObjectJ is that you have to
> manually draw around the ROI- not select it using the wand tool- which is
> much more accurate for outlining an individual (given my mouse manipulation
> skills).
> Any other suggestions?
> Thanks,
> Gail
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Measuring-mulitple-species-from-a-single-image-tp5008690p5008750.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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