Disjoint ROI selection using macro language

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Disjoint ROI selection using macro language

BenTupper
Hi All,

I think I have managed to completely confuse myself and would love  
some help getting straightened out...

(1) As I manually select an item in the ROI Manager list it is not the  
item highlighted in the mask. For example, highlighting the first item  
in the ROI Manager list will outline the second particle in the mask.  
(I often confuse the indices between roiManager("select", x); and  
getResults("Something", x); where x is either zero-based or one-based.  
This is going to really drive me bonkers.)

(2) I expected the total area of the new combined ROI to equal the sum  
of the areas in the selection (they do not equal - in fact, it looks  
like only the first particle is added.)  A year ago I thought I had  
this all figured out, but now I can't get it to behave as I would  
like.  I have written a macro (below) is to select some arbitrary  
number of ROIs and combine them into one.

//START MACRO
run("Blobs (25K)");
setAutoThreshold();
//run("Threshold...");
setThreshold(125, 255);
run("Convert to Mask");
run("Set Measurements...", "area mean standard modal min centroid  
center perimeter bounding fit shape feret's integrated median skewness  
kurtosis redirect=None decimal=3");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00  
show=Nothing display clear record add");

//combine items 0, 3 and 7 into one ROI
index = newArray(0,3,7);
area = 0;
for (i=0; i<index.length; i++){
        a = getResult("Area", index[i]);
        area = area + a;
        print("area[", index[i], "]=", a);
}
print("Expected total area for 3 items=", area);

setKeyDown("shift")
roiManager("select", 0);
setKeyDown("shift")
roiManager("select", 3);
setKeyDown("shift")
roiManager("select", 7);

roiManager("Add");
roiManager("Measure");
print("after measure, nResults=", nResults ," area=" +  
getResult("Area", nResults-1));

//END MACRO

I note there is a bug-fix in ROI manager regarding combining ROIs for  
v1.42f, but I am running v1.42l.


Ben Tupper



Java properties applets can read:
   java.version: 1.5.0_16
   java.vendor: Apple Inc.
   mrj.version: 1050.1.5.0_16-284
   os.name: Mac OS X
   os.version: 10.5.6
   os.arch: i386
   file.separator: /
   path.separator: :
   line.separator: <lf>

Java properties only applications can read:
   user.name: ben
   user.home: /Users/ben
   user.dir: /Applications/ImageJ
   user.country: US
   file.encoding: MacRoman
   java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
1.5.0/Home
   java.class.path: /Applications/ImageJ/ImageJ.app/../ij.jar:/System/
Library/Java/Extensions/QTJava.zip
   java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/
Home/lib/ext
   java.io.tmpdir: /tmp

Other properties:
   IJ.getVersion: 1.42l
   IJ.isJava2: true
   IJ.isJava15: true
   IJ.isJava16: false
   IJ.isLinux: false
   IJ.isMacintosh: true
   IJ.isMacOSX: true
   IJ.isWindows: false
   IJ.isVista: false
   IJ.is64Bit: false
   Menus.getPlugInsPath: /Applications/ImageJ/plugins/
   Menus.getMacrosPath: /Applications/ImageJ/macros/
   Prefs.getHomeDir: /Applications/ImageJ
   Prefs.getThreads: 2 (2 cores)
   Prefs.open100Percent: false
   Prefs.blackBackground: false
   Prefs.useJFileChooser: false
   Prefs.weightedColor: false
   Prefs.blackCanvas: false
   Prefs.pointAutoMeasure: false
   Prefs.pointAutoNextSlice: false
   Prefs.requireControlKey: false
   Prefs.useInvertingLut: false
   Prefs.antialiasedTools: true
   Prefs.useInvertingLut: false
   Prefs.intelByteOrder: false
   Prefs.doubleBuffer: false
   Prefs.noPointLabels: false
   Prefs.disableUndo: false
   Prefs dir: /Users/ben/Library/Preferences
   Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
   Sample images dir: http://rsb.info.nih.gov/ij/images/
   Screen size: 1440x900
   Memory in use: 11MB of 400MB (2%)
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Michael Schmid
Hi Ben,

using a very similar system (but MacOS 10.4.11, not 10.5), I have  
neither problems with 1.42l nor with the nightly build of a few days  
ago.

Selecting the ROIs manually works as expected.

After running the macro, the log says:
area[ 0 ]= 433
area[ 3 ]= 434
area[ 7 ]= 278
Expected total area for 3 items= 1145
after measure, nResults= 129  area=1145

ImageJ Properties:

Java properties applets can read:
   java.version: 1.5.0_16
   java.vendor: Apple Computer, Inc.
   mrj.version: 1040.1.5.0_16-275
   os.name: Mac OS X
   os.version: 10.4.11
   os.arch: i386
   file.separator: /
   path.separator: :
   line.separator: <lf>

Java properties only applications can read:
(...)
   user.country: US
   file.encoding: MacRoman
   java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
1.5.0/Home
   java.class.path: (...) /ij.jar:/System/Library/Java/Extensions/
QTJava.zip:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/
Classes/.compatibility/14compatibility.jar
   java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/
Home/lib/ext
   java.io.tmpdir: /tmp

Other properties:
(... same as yours)
   Prefs.weightedColor: true
   Prefs.blackCanvas: false
   Prefs.pointAutoMeasure: false
   Prefs.pointAutoNextSlice: false
   Prefs.requireControlKey: false
   Prefs.useInvertingLut: false
   Prefs.antialiasedTools: true
   Prefs.useInvertingLut: false
   Prefs.intelByteOrder: false
   Prefs.doubleBuffer: false
   Prefs.noPointLabels: true
   Prefs.disableUndo: false
(...)
   Sample images dir: http://rsb.info.nih.gov/ij/images/
   Screen size: 1680x1050
   Memory in use: 3738K of 800MB (<1%)

Is it really 1.42l or a nightly build previous to 1.42l that you are  
using?
The released 1.42l ij.jar has 1.373.997 bytes.

Maybe something got stuck - does the problem go away if you restart  
ImageJ?


Michael
________________________________________________________________

On 16 Apr 2009, at 19:44, Ben Tupper wrote:

> Hi All,
>
> I think I have managed to completely confuse myself and would love  
> some help getting straightened out...
>
> (1) As I manually select an item in the ROI Manager list it is not  
> the item highlighted in the mask. For example, highlighting the  
> first item in the ROI Manager list will outline the second particle  
> in the mask.  (I often confuse the indices between roiManager
> ("select", x); and getResults("Something", x); where x is either  
> zero-based or one-based. This is going to really drive me bonkers.)
>
> (2) I expected the total area of the new combined ROI to equal the  
> sum of the areas in the selection (they do not equal - in fact, it  
> looks like only the first particle is added.)  A year ago I thought  
> I had this all figured out, but now I can't get it to behave as I  
> would like.  I have written a macro (below) is to select some  
> arbitrary number of ROIs and combine them into one.
>
> //START MACRO
> run("Blobs (25K)");
> setAutoThreshold();
> //run("Threshold...");
> setThreshold(125, 255);
> run("Convert to Mask");
> run("Set Measurements...", "area mean standard modal min centroid  
> center perimeter bounding fit shape feret's integrated median  
> skewness kurtosis redirect=None decimal=3");
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00  
> show=Nothing display clear record add");
>
> //combine items 0, 3 and 7 into one ROI
> index = newArray(0,3,7);
> area = 0;
> for (i=0; i<index.length; i++){
> a = getResult("Area", index[i]);
> area = area + a;
> print("area[", index[i], "]=", a);
> }
> print("Expected total area for 3 items=", area);
>
> setKeyDown("shift")
> roiManager("select", 0);
> setKeyDown("shift")
> roiManager("select", 3);
> setKeyDown("shift")
> roiManager("select", 7);
>
> roiManager("Add");
> roiManager("Measure");
> print("after measure, nResults=", nResults ," area=" + getResult
> ("Area", nResults-1));
>
> //END MACRO
>
> I note there is a bug-fix in ROI manager regarding combining ROIs  
> for v1.42f, but I am running v1.42l.
>
>
> Ben Tupper
>
>
>
> Java properties applets can read:
>   java.version: 1.5.0_16
>   java.vendor: Apple Inc.
>   mrj.version: 1050.1.5.0_16-284
>   os.name: Mac OS X
>   os.version: 10.5.6
>   os.arch: i386
>   file.separator: /
>   path.separator: :
>   line.separator: <lf>
>
> Java properties only applications can read:
>   user.name: ben
>   user.home: /Users/ben
>   user.dir: /Applications/ImageJ
>   user.country: US
>   file.encoding: MacRoman
>   java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
> 1.5.0/Home
>   java.class.path: /Applications/ImageJ/ImageJ.app/../ij.jar:/
> System/Library/Java/Extensions/QTJava.zip
>   java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
> 1.5.0/Home/lib/ext
>   java.io.tmpdir: /tmp
>
> Other properties:
>   IJ.getVersion: 1.42l
>   IJ.isJava2: true
>   IJ.isJava15: true
>   IJ.isJava16: false
>   IJ.isLinux: false
>   IJ.isMacintosh: true
>   IJ.isMacOSX: true
>   IJ.isWindows: false
>   IJ.isVista: false
>   IJ.is64Bit: false
>   Menus.getPlugInsPath: /Applications/ImageJ/plugins/
>   Menus.getMacrosPath: /Applications/ImageJ/macros/
>   Prefs.getHomeDir: /Applications/ImageJ
>   Prefs.getThreads: 2 (2 cores)
>   Prefs.open100Percent: false
>   Prefs.blackBackground: false
>   Prefs.useJFileChooser: false
>   Prefs.weightedColor: false
>   Prefs.blackCanvas: false
>   Prefs.pointAutoMeasure: false
>   Prefs.pointAutoNextSlice: false
>   Prefs.requireControlKey: false
>   Prefs.useInvertingLut: false
>   Prefs.antialiasedTools: true
>   Prefs.useInvertingLut: false
>   Prefs.intelByteOrder: false
>   Prefs.doubleBuffer: false
>   Prefs.noPointLabels: false
>   Prefs.disableUndo: false
>   Prefs dir: /Users/ben/Library/Preferences
>   Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
>   Sample images dir: http://rsb.info.nih.gov/ij/images/
>   Screen size: 1440x900
>   Memory in use: 11MB of 400MB (2%)
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

BenTupper
Hi Michael,

Thanks for responding so quickly.

The first issue is a result of my own boneheadedness.   Note that the  
left most particle looks like it is labeled "0".  It is actually "10"  
but the label was cutoff and I fooled myself.

I can confirm that the ij.jar is the size you specify and that ImageJ  
thinks it is v1.42l.  Restarting ImageJ seems to make no difference.

Can you explain how you made those selections manually?  I can't make  
that happen manually or in the macro.

Thanks again,
Ben





On Apr 16, 2009, at 2:23 PM, Michael Schmid wrote:

> Hi Ben,
>
> using a very similar system (but MacOS 10.4.11, not 10.5), I have  
> neither problems with 1.42l nor with the nightly build of a few days  
> ago.
>
> Selecting the ROIs manually works as expected.
>
> After running the macro, the log says:
> area[ 0 ]= 433
> area[ 3 ]= 434
> area[ 7 ]= 278
> Expected total area for 3 items= 1145
> after measure, nResults= 129  area=1145
>
> ImageJ Properties:
>
> Java properties applets can read:
>  java.version: 1.5.0_16
>  java.vendor: Apple Computer, Inc.
>  mrj.version: 1040.1.5.0_16-275
>  os.name: Mac OS X
>  os.version: 10.4.11
>  os.arch: i386
>  file.separator: /
>  path.separator: :
>  line.separator: <lf>
>
> Java properties only applications can read:
> (...)
>  user.country: US
>  file.encoding: MacRoman
>  java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
> 1.5.0/Home
>  java.class.path: (...) /ij.jar:/System/Library/Java/Extensions/
> QTJava.zip:/System/Library/Frameworks/JavaVM.framework/Versions/
> 1.5.0/Classes/.compatibility/14compatibility.jar
>  java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
> 1.5.0/Home/lib/ext
>  java.io.tmpdir: /tmp
>
> Other properties:
> (... same as yours)
>  Prefs.weightedColor: true
>  Prefs.blackCanvas: false
>  Prefs.pointAutoMeasure: false
>  Prefs.pointAutoNextSlice: false
>  Prefs.requireControlKey: false
>  Prefs.useInvertingLut: false
>  Prefs.antialiasedTools: true
>  Prefs.useInvertingLut: false
>  Prefs.intelByteOrder: false
>  Prefs.doubleBuffer: false
>  Prefs.noPointLabels: true
>  Prefs.disableUndo: false
> (...)
>  Sample images dir: http://rsb.info.nih.gov/ij/images/
>  Screen size: 1680x1050
>  Memory in use: 3738K of 800MB (<1%)
>
> Is it really 1.42l or a nightly build previous to 1.42l that you are  
> using?
> The released 1.42l ij.jar has 1.373.997 bytes.
>
> Maybe something got stuck - does the problem go away if you restart  
> ImageJ?
>
>
> Michael
> ________________________________________________________________
>
> On 16 Apr 2009, at 19:44, Ben Tupper wrote:
>
>> Hi All,
>>
>> I think I have managed to completely confuse myself and would love  
>> some help getting straightened out...
>>
>> (1) As I manually select an item in the ROI Manager list it is not  
>> the item highlighted in the mask. For example, highlighting the  
>> first item in the ROI Manager list will outline the second particle  
>> in the mask.  (I often confuse the indices between  
>> roiManager("select", x); and getResults("Something", x); where x is  
>> either zero-based or one-based. This is going to really drive me  
>> bonkers.)
>>
>> (2) I expected the total area of the new combined ROI to equal the  
>> sum of the areas in the selection (they do not equal - in fact, it  
>> looks like only the first particle is added.)  A year ago I thought  
>> I had this all figured out, but now I can't get it to behave as I  
>> would like.  I have written a macro (below) is to select some  
>> arbitrary number of ROIs and combine them into one.
>>
>> //START MACRO
>> run("Blobs (25K)");
>> setAutoThreshold();
>> //run("Threshold...");
>> setThreshold(125, 255);
>> run("Convert to Mask");
>> run("Set Measurements...", "area mean standard modal min centroid  
>> center perimeter bounding fit shape feret's integrated median  
>> skewness kurtosis redirect=None decimal=3");
>> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00  
>> show=Nothing display clear record add");
>>
>> //combine items 0, 3 and 7 into one ROI
>> index = newArray(0,3,7);
>> area = 0;
>> for (i=0; i<index.length; i++){
>> a = getResult("Area", index[i]);
>> area = area + a;
>> print("area[", index[i], "]=", a);
>> }
>> print("Expected total area for 3 items=", area);
>>
>> setKeyDown("shift")
>> roiManager("select", 0);
>> setKeyDown("shift")
>> roiManager("select", 3);
>> setKeyDown("shift")
>> roiManager("select", 7);
>>
>> roiManager("Add");
>> roiManager("Measure");
>> print("after measure, nResults=", nResults ," area=" +  
>> getResult("Area", nResults-1));
>>
>> //END MACRO
>>
>> I note there is a bug-fix in ROI manager regarding combining ROIs  
>> for v1.42f, but I am running v1.42l.
>>
>>
>> Ben Tupper
>>
>>
>>
>> Java properties applets can read:
>>  java.version: 1.5.0_16
>>  java.vendor: Apple Inc.
>>  mrj.version: 1050.1.5.0_16-284
>>  os.name: Mac OS X
>>  os.version: 10.5.6
>>  os.arch: i386
>>  file.separator: /
>>  path.separator: :
>>  line.separator: <lf>
>>
>> Java properties only applications can read:
>>  user.name: ben
>>  user.home: /Users/ben
>>  user.dir: /Applications/ImageJ
>>  user.country: US
>>  file.encoding: MacRoman
>>  java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>> 1.5.0/Home
>>  java.class.path: /Applications/ImageJ/ImageJ.app/../ij.jar:/System/
>> Library/Java/Extensions/QTJava.zip
>>  java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>> 1.5.0/Home/lib/ext
>>  java.io.tmpdir: /tmp
>>
>> Other properties:
>>  IJ.getVersion: 1.42l
>>  IJ.isJava2: true
>>  IJ.isJava15: true
>>  IJ.isJava16: false
>>  IJ.isLinux: false
>>  IJ.isMacintosh: true
>>  IJ.isMacOSX: true
>>  IJ.isWindows: false
>>  IJ.isVista: false
>>  IJ.is64Bit: false
>>  Menus.getPlugInsPath: /Applications/ImageJ/plugins/
>>  Menus.getMacrosPath: /Applications/ImageJ/macros/
>>  Prefs.getHomeDir: /Applications/ImageJ
>>  Prefs.getThreads: 2 (2 cores)
>>  Prefs.open100Percent: false
>>  Prefs.blackBackground: false
>>  Prefs.useJFileChooser: false
>>  Prefs.weightedColor: false
>>  Prefs.blackCanvas: false
>>  Prefs.pointAutoMeasure: false
>>  Prefs.pointAutoNextSlice: false
>>  Prefs.requireControlKey: false
>>  Prefs.useInvertingLut: false
>>  Prefs.antialiasedTools: true
>>  Prefs.useInvertingLut: false
>>  Prefs.intelByteOrder: false
>>  Prefs.doubleBuffer: false
>>  Prefs.noPointLabels: false
>>  Prefs.disableUndo: false
>>  Prefs dir: /Users/ben/Library/Preferences
>>  Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
>>  Sample images dir: http://rsb.info.nih.gov/ij/images/
>>  Screen size: 1440x900
>>  Memory in use: 11MB of 400MB (2%)

Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Michael Schmid
Hi Ben,

the ROI Manager items have labels 0001-... to 0064-..., corresponding  
to the labels in the binary image, but they have line numbers 0 to 63  
- maybe this causes part of the confusion?

I did succeed in selecting three items manually (lines 0, 3, 7, i.e.  
0001-..., 0004.. and 0008-...) together with command-click and then  
use More>Combine. It is a bit nasty since the context menus  
interferes with it. Measure on the combined ROI gave me an area of  
1145 again.
I don't know how to do this in a macro; at least I am not aware of a  
setKeyDown("command") or setKeyDown("ctrl")

With "shift", one would select a contiguous range of lines.


Best wishes,

Michael
________________________________________________________________

On 16 Apr 2009, at 21:03, Ben Tupper wrote:

> Hi Michael,
>
> Thanks for responding so quickly.
>
> The first issue is a result of my own boneheadedness.   Note that  
> the left most particle looks like it is labeled "0".  It is  
> actually "10" but the label was cutoff and I fooled myself.
>
> I can confirm that the ij.jar is the size you specify and that  
> ImageJ thinks it is v1.42l.  Restarting ImageJ seems to make no  
> difference.
>
> Can you explain how you made those selections manually?  I can't  
> make that happen manually or in the macro.
>
> Thanks again,
> Ben
>
>
>
>
>
> On Apr 16, 2009, at 2:23 PM, Michael Schmid wrote:
>
>> Hi Ben,
>>
>> using a very similar system (but MacOS 10.4.11, not 10.5), I have  
>> neither problems with 1.42l nor with the nightly build of a few  
>> days ago.
>>
>> Selecting the ROIs manually works as expected.
>>
>> After running the macro, the log says:
>> area[ 0 ]= 433
>> area[ 3 ]= 434
>> area[ 7 ]= 278
>> Expected total area for 3 items= 1145
>> after measure, nResults= 129  area=1145
>>
>> ImageJ Properties:
>>
>> Java properties applets can read:
>>  java.version: 1.5.0_16
>>  java.vendor: Apple Computer, Inc.
>>  mrj.version: 1040.1.5.0_16-275
>>  os.name: Mac OS X
>>  os.version: 10.4.11
>>  os.arch: i386
>>  file.separator: /
>>  path.separator: :
>>  line.separator: <lf>
>>
>> Java properties only applications can read:
>> (...)
>>  user.country: US
>>  file.encoding: MacRoman
>>  java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>> 1.5.0/Home
>>  java.class.path: (...) /ij.jar:/System/Library/Java/Extensions/
>> QTJava.zip:/System/Library/Frameworks/JavaVM.framework/Versions/
>> 1.5.0/Classes/.compatibility/14compatibility.jar
>>  java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>> 1.5.0/Home/lib/ext
>>  java.io.tmpdir: /tmp
>>
>> Other properties:
>> (... same as yours)
>>  Prefs.weightedColor: true
>>  Prefs.blackCanvas: false
>>  Prefs.pointAutoMeasure: false
>>  Prefs.pointAutoNextSlice: false
>>  Prefs.requireControlKey: false
>>  Prefs.useInvertingLut: false
>>  Prefs.antialiasedTools: true
>>  Prefs.useInvertingLut: false
>>  Prefs.intelByteOrder: false
>>  Prefs.doubleBuffer: false
>>  Prefs.noPointLabels: true
>>  Prefs.disableUndo: false
>> (...)
>>  Sample images dir: http://rsb.info.nih.gov/ij/images/
>>  Screen size: 1680x1050
>>  Memory in use: 3738K of 800MB (<1%)
>>
>> Is it really 1.42l or a nightly build previous to 1.42l that you  
>> are using?
>> The released 1.42l ij.jar has 1.373.997 bytes.
>>
>> Maybe something got stuck - does the problem go away if you  
>> restart ImageJ?
>>
>>
>> Michael
>> ________________________________________________________________
>>
>> On 16 Apr 2009, at 19:44, Ben Tupper wrote:
>>
>>> Hi All,
>>>
>>> I think I have managed to completely confuse myself and would  
>>> love some help getting straightened out...
>>>
>>> (1) As I manually select an item in the ROI Manager list it is  
>>> not the item highlighted in the mask. For example, highlighting  
>>> the first item in the ROI Manager list will outline the second  
>>> particle in the mask.  (I often confuse the indices between  
>>> roiManager("select", x); and getResults("Something", x); where x  
>>> is either zero-based or one-based. This is going to really drive  
>>> me bonkers.)
>>>
>>> (2) I expected the total area of the new combined ROI to equal  
>>> the sum of the areas in the selection (they do not equal - in  
>>> fact, it looks like only the first particle is added.)  A year  
>>> ago I thought I had this all figured out, but now I can't get it  
>>> to behave as I would like.  I have written a macro (below) is to  
>>> select some arbitrary number of ROIs and combine them into one.
>>>
>>> //START MACRO
>>> run("Blobs (25K)");
>>> setAutoThreshold();
>>> //run("Threshold...");
>>> setThreshold(125, 255);
>>> run("Convert to Mask");
>>> run("Set Measurements...", "area mean standard modal min centroid  
>>> center perimeter bounding fit shape feret's integrated median  
>>> skewness kurtosis redirect=None decimal=3");
>>> run("Analyze Particles...", "size=0-Infinity  
>>> circularity=0.00-1.00 show=Nothing display clear record add");
>>>
>>> //combine items 0, 3 and 7 into one ROI
>>> index = newArray(0,3,7);
>>> area = 0;
>>> for (i=0; i<index.length; i++){
>>> a = getResult("Area", index[i]);
>>> area = area + a;
>>> print("area[", index[i], "]=", a);
>>> }
>>> print("Expected total area for 3 items=", area);
>>>
>>> setKeyDown("shift")
>>> roiManager("select", 0);
>>> setKeyDown("shift")
>>> roiManager("select", 3);
>>> setKeyDown("shift")
>>> roiManager("select", 7);
>>>
>>> roiManager("Add");
>>> roiManager("Measure");
>>> print("after measure, nResults=", nResults ," area=" + getResult
>>> ("Area", nResults-1));
>>>
>>> //END MACRO
>>>
>>> I note there is a bug-fix in ROI manager regarding combining ROIs  
>>> for v1.42f, but I am running v1.42l.
>>>
>>>
>>> Ben Tupper
>>>
>>>
>>>
>>> Java properties applets can read:
>>>  java.version: 1.5.0_16
>>>  java.vendor: Apple Inc.
>>>  mrj.version: 1050.1.5.0_16-284
>>>  os.name: Mac OS X
>>>  os.version: 10.5.6
>>>  os.arch: i386
>>>  file.separator: /
>>>  path.separator: :
>>>  line.separator: <lf>
>>>
>>> Java properties only applications can read:
>>>  user.name: ben
>>>  user.home: /Users/ben
>>>  user.dir: /Applications/ImageJ
>>>  user.country: US
>>>  file.encoding: MacRoman
>>>  java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>>> 1.5.0/Home
>>>  java.class.path: /Applications/ImageJ/ImageJ.app/../ij.jar:/
>>> System/Library/Java/Extensions/QTJava.zip
>>>  java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>>> 1.5.0/Home/lib/ext
>>>  java.io.tmpdir: /tmp
>>>
>>> Other properties:
>>>  IJ.getVersion: 1.42l
>>>  IJ.isJava2: true
>>>  IJ.isJava15: true
>>>  IJ.isJava16: false
>>>  IJ.isLinux: false
>>>  IJ.isMacintosh: true
>>>  IJ.isMacOSX: true
>>>  IJ.isWindows: false
>>>  IJ.isVista: false
>>>  IJ.is64Bit: false
>>>  Menus.getPlugInsPath: /Applications/ImageJ/plugins/
>>>  Menus.getMacrosPath: /Applications/ImageJ/macros/
>>>  Prefs.getHomeDir: /Applications/ImageJ
>>>  Prefs.getThreads: 2 (2 cores)
>>>  Prefs.open100Percent: false
>>>  Prefs.blackBackground: false
>>>  Prefs.useJFileChooser: false
>>>  Prefs.weightedColor: false
>>>  Prefs.blackCanvas: false
>>>  Prefs.pointAutoMeasure: false
>>>  Prefs.pointAutoNextSlice: false
>>>  Prefs.requireControlKey: false
>>>  Prefs.useInvertingLut: false
>>>  Prefs.antialiasedTools: true
>>>  Prefs.useInvertingLut: false
>>>  Prefs.intelByteOrder: false
>>>  Prefs.doubleBuffer: false
>>>  Prefs.noPointLabels: false
>>>  Prefs.disableUndo: false
>>>  Prefs dir: /Users/ben/Library/Preferences
>>>  Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
>>>  Sample images dir: http://rsb.info.nih.gov/ij/images/
>>>  Screen size: 1440x900
>>>  Memory in use: 11MB of 400MB (2%)
>
> Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

BenTupper
On Apr 16, 2009, at 3:22 PM, Michael Schmid wrote:

> Hi Ben,
>
> the ROI Manager items have labels 0001-... to 0064-...,  
> corresponding to the labels in the binary image, but they have line  
> numbers 0 to 63 - maybe this causes part of the confusion?

Yes, I am always sawing back-and-forth between different indexing  
schemes.  It is very taxing on my walnut-sized-brain. It wasn't so bad  
when it was just Java and IDL (0-based) but now throw in R and the  
results table (1-based)...  argh!


>
> I did succeed in selecting three items manually (lines 0, 3, 7, i.e.  
> 0001-..., 0004.. and 0008-...) together with command-click and then  
> use More>Combine. It is a bit nasty since the context menus  
> interferes with it. Measure on the combined ROI gave me an area of  
> 1145 again.


OK, I can do this now and get the same result as you using the click-
command.  With the fictional click-command it works as long as the  
menu command "Measure" is used - not the roiManager("Measure") command.

roiManager("Select", 0);  with click-command
roiManager("Select", 3);  with click-command
roiManager("Select", 7);  with click-command
roiManager("Combine");
run("Measure");  <--- note: it isn't roiManager("Measure");


I had been assuming that I could run "Analyze particles..." with  
additions to the ROI Manager.  Then I thought I could step through the  
items in the list to see if they meet my qualifications - finally I  
would select only those that qualify.   Since the click-command is  
fictional, I'll have to change my filtering so that I only add those  
items that qualify.

Thanks again for your help!
Ben



>
> I don't know how to do this in a macro; at least I am not aware of a  
> setKeyDown("command") or setKeyDown("ctrl")
>
> With "shift", one would select a contiguous range of lines.
>
>
> Best wishes,
>
> Michael
> ________________________________________________________________
>
> On 16 Apr 2009, at 21:03, Ben Tupper wrote:
>
>> Hi Michael,
>>
>> Thanks for responding so quickly.
>>
>> The first issue is a result of my own boneheadedness.   Note that  
>> the left most particle looks like it is labeled "0".  It is  
>> actually "10" but the label was cutoff and I fooled myself.
>>
>> I can confirm that the ij.jar is the size you specify and that  
>> ImageJ thinks it is v1.42l.  Restarting ImageJ seems to make no  
>> difference.
>>
>> Can you explain how you made those selections manually?  I can't  
>> make that happen manually or in the macro.
>>
>> Thanks again,
>> Ben
>>
>>
>>
>>
>>
>> On Apr 16, 2009, at 2:23 PM, Michael Schmid wrote:
>>
>>> Hi Ben,
>>>
>>> using a very similar system (but MacOS 10.4.11, not 10.5), I have  
>>> neither problems with 1.42l nor with the nightly build of a few  
>>> days ago.
>>>
>>> Selecting the ROIs manually works as expected.
>>>
>>> After running the macro, the log says:
>>> area[ 0 ]= 433
>>> area[ 3 ]= 434
>>> area[ 7 ]= 278
>>> Expected total area for 3 items= 1145
>>> after measure, nResults= 129  area=1145
>>>
>>> ImageJ Properties:
>>>
>>> Java properties applets can read:
>>> java.version: 1.5.0_16
>>> java.vendor: Apple Computer, Inc.
>>> mrj.version: 1040.1.5.0_16-275
>>> os.name: Mac OS X
>>> os.version: 10.4.11
>>> os.arch: i386
>>> file.separator: /
>>> path.separator: :
>>> line.separator: <lf>
>>>
>>> Java properties only applications can read:
>>> (...)
>>> user.country: US
>>> file.encoding: MacRoman
>>> java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>>> 1.5.0/Home
>>> java.class.path: (...) /ij.jar:/System/Library/Java/Extensions/
>>> QTJava.zip:/System/Library/Frameworks/JavaVM.framework/Versions/
>>> 1.5.0/Classes/.compatibility/14compatibility.jar
>>> java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>>> 1.5.0/Home/lib/ext
>>> java.io.tmpdir: /tmp
>>>
>>> Other properties:
>>> (... same as yours)
>>> Prefs.weightedColor: true
>>> Prefs.blackCanvas: false
>>> Prefs.pointAutoMeasure: false
>>> Prefs.pointAutoNextSlice: false
>>> Prefs.requireControlKey: false
>>> Prefs.useInvertingLut: false
>>> Prefs.antialiasedTools: true
>>> Prefs.useInvertingLut: false
>>> Prefs.intelByteOrder: false
>>> Prefs.doubleBuffer: false
>>> Prefs.noPointLabels: true
>>> Prefs.disableUndo: false
>>> (...)
>>> Sample images dir: http://rsb.info.nih.gov/ij/images/
>>> Screen size: 1680x1050
>>> Memory in use: 3738K of 800MB (<1%)
>>>
>>> Is it really 1.42l or a nightly build previous to 1.42l that you  
>>> are using?
>>> The released 1.42l ij.jar has 1.373.997 bytes.
>>>
>>> Maybe something got stuck - does the problem go away if you  
>>> restart ImageJ?
>>>
>>>
>>> Michael
>>> ________________________________________________________________
>>>
>>> On 16 Apr 2009, at 19:44, Ben Tupper wrote:
>>>
>>>> Hi All,
>>>>
>>>> I think I have managed to completely confuse myself and would  
>>>> love some help getting straightened out...
>>>>
>>>> (1) As I manually select an item in the ROI Manager list it is  
>>>> not the item highlighted in the mask. For example, highlighting  
>>>> the first item in the ROI Manager list will outline the second  
>>>> particle in the mask.  (I often confuse the indices between  
>>>> roiManager("select", x); and getResults("Something", x); where x  
>>>> is either zero-based or one-based. This is going to really drive  
>>>> me bonkers.)
>>>>
>>>> (2) I expected the total area of the new combined ROI to equal  
>>>> the sum of the areas in the selection (they do not equal - in  
>>>> fact, it looks like only the first particle is added.)  A year  
>>>> ago I thought I had this all figured out, but now I can't get it  
>>>> to behave as I would like.  I have written a macro (below) is to  
>>>> select some arbitrary number of ROIs and combine them into one.
>>>>
>>>> //START MACRO
>>>> run("Blobs (25K)");
>>>> setAutoThreshold();
>>>> //run("Threshold...");
>>>> setThreshold(125, 255);
>>>> run("Convert to Mask");
>>>> run("Set Measurements...", "area mean standard modal min centroid  
>>>> center perimeter bounding fit shape feret's integrated median  
>>>> skewness kurtosis redirect=None decimal=3");
>>>> run("Analyze Particles...", "size=0-Infinity  
>>>> circularity=0.00-1.00 show=Nothing display clear record add");
>>>>
>>>> //combine items 0, 3 and 7 into one ROI
>>>> index = newArray(0,3,7);
>>>> area = 0;
>>>> for (i=0; i<index.length; i++){
>>>> a = getResult("Area", index[i]);
>>>> area = area + a;
>>>> print("area[", index[i], "]=", a);
>>>> }
>>>> print("Expected total area for 3 items=", area);
>>>>
>>>> setKeyDown("shift")
>>>> roiManager("select", 0);
>>>> setKeyDown("shift")
>>>> roiManager("select", 3);
>>>> setKeyDown("shift")
>>>> roiManager("select", 7);
>>>>
>>>> roiManager("Add");
>>>> roiManager("Measure");
>>>> print("after measure, nResults=", nResults ," area=" +  
>>>> getResult("Area", nResults-1));
>>>>
>>>> //END MACRO
>>>>
>>>> I note there is a bug-fix in ROI manager regarding combining ROIs  
>>>> for v1.42f, but I am running v1.42l.
>>>>
>>>>
>>>> Ben Tupper
>>>>
>>>>
>>>>
>>>> Java properties applets can read:
>>>> java.version: 1.5.0_16
>>>> java.vendor: Apple Inc.
>>>> mrj.version: 1050.1.5.0_16-284
>>>> os.name: Mac OS X
>>>> os.version: 10.5.6
>>>> os.arch: i386
>>>> file.separator: /
>>>> path.separator: :
>>>> line.separator: <lf>
>>>>
>>>> Java properties only applications can read:
>>>> user.name: ben
>>>> user.home: /Users/ben
>>>> user.dir: /Applications/ImageJ
>>>> user.country: US
>>>> file.encoding: MacRoman
>>>> java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>>>> 1.5.0/Home
>>>> java.class.path: /Applications/ImageJ/ImageJ.app/../ij.jar:/
>>>> System/Library/Java/Extensions/QTJava.zip
>>>> java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>>>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>>>> 1.5.0/Home/lib/ext
>>>> java.io.tmpdir: /tmp
>>>>
>>>> Other properties:
>>>> IJ.getVersion: 1.42l
>>>> IJ.isJava2: true
>>>> IJ.isJava15: true
>>>> IJ.isJava16: false
>>>> IJ.isLinux: false
>>>> IJ.isMacintosh: true
>>>> IJ.isMacOSX: true
>>>> IJ.isWindows: false
>>>> IJ.isVista: false
>>>> IJ.is64Bit: false
>>>> Menus.getPlugInsPath: /Applications/ImageJ/plugins/
>>>> Menus.getMacrosPath: /Applications/ImageJ/macros/
>>>> Prefs.getHomeDir: /Applications/ImageJ
>>>> Prefs.getThreads: 2 (2 cores)
>>>> Prefs.open100Percent: false
>>>> Prefs.blackBackground: false
>>>> Prefs.useJFileChooser: false
>>>> Prefs.weightedColor: false
>>>> Prefs.blackCanvas: false
>>>> Prefs.pointAutoMeasure: false
>>>> Prefs.pointAutoNextSlice: false
>>>> Prefs.requireControlKey: false
>>>> Prefs.useInvertingLut: false
>>>> Prefs.antialiasedTools: true
>>>> Prefs.useInvertingLut: false
>>>> Prefs.intelByteOrder: false
>>>> Prefs.doubleBuffer: false
>>>> Prefs.noPointLabels: false
>>>> Prefs.disableUndo: false
>>>> Prefs dir: /Users/ben/Library/Preferences
>>>> Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
>>>> Sample images dir: http://rsb.info.nih.gov/ij/images/
>>>> Screen size: 1440x900
>>>> Memory in use: 11MB of 400MB (2%)
>>
>> Ben Tupper

Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Fabrice Senger
Ben Tupper a écrit :

> On Apr 16, 2009, at 3:22 PM, Michael Schmid wrote:
>
>> Hi Ben,
>>
>> the ROI Manager items have labels 0001-... to 0064-..., corresponding
>> to the labels in the binary image, but they have line numbers 0 to 63
>> - maybe this causes part of the confusion?
>
> Yes, I am always sawing back-and-forth between different indexing
> schemes.  It is very taxing on my walnut-sized-brain. It wasn't so bad
> when it was just Java and IDL (0-based) but now throw in R and the
> results table (1-based)...  argh!
>
>
>>
>> I did succeed in selecting three items manually (lines 0, 3, 7, i.e.
>> 0001-..., 0004.. and 0008-...) together with command-click and then
>> use More>Combine. It is a bit nasty since the context menus
>> interferes with it. Measure on the combined ROI gave me an area of
>> 1145 again.
>
>
> OK, I can do this now and get the same result as you using the
> click-command.  With the fictional click-command it works as long as
> the menu command "Measure" is used - not the roiManager("Measure")
> command.
>
> roiManager("Select", 0);  with click-command
> roiManager("Select", 3);  with click-command
> roiManager("Select", 7);  with click-command
> roiManager("Combine");
> run("Measure");  <--- note: it isn't roiManager("Measure");
>
>
> I had been assuming that I could run "Analyze particles..." with
> additions to the ROI Manager.  Then I thought I could step through the
> items in the list to see if they meet my qualifications - finally I
> would select only those that qualify.   Since the click-command is
> fictional, I'll have to change my filtering so that I only add those
> items that qualify.
>
> Thanks again for your help!
> Ben
>
>
>
>>
>> I don't know how to do this in a macro; at least I am not aware of a
>> setKeyDown("command") or setKeyDown("ctrl")
>>
>> With "shift", one would select a contiguous range of lines.
>>
>>
>> Best wishes,
>>
>> Michael
>> ________________________________________________________________
>>
>> On 16 Apr 2009, at 21:03, Ben Tupper wrote:
>>
>>> Hi Michael,
>>>
>>> Thanks for responding so quickly.
>>>
>>> The first issue is a result of my own boneheadedness.   Note that
>>> the left most particle looks like it is labeled "0".  It is actually
>>> "10" but the label was cutoff and I fooled myself.
>>>
>>> I can confirm that the ij.jar is the size you specify and that
>>> ImageJ thinks it is v1.42l.  Restarting ImageJ seems to make no
>>> difference.
>>>
>>> Can you explain how you made those selections manually?  I can't
>>> make that happen manually or in the macro.
>>>
>>> Thanks again,
>>> Ben
>>>
>>>
>>>
>>>
>>>
>>> On Apr 16, 2009, at 2:23 PM, Michael Schmid wrote:
>>>
>>>> Hi Ben,
>>>>
>>>> using a very similar system (but MacOS 10.4.11, not 10.5), I have
>>>> neither problems with 1.42l nor with the nightly build of a few
>>>> days ago.
>>>>
>>>> Selecting the ROIs manually works as expected.
>>>>
>>>> After running the macro, the log says:
>>>> area[ 0 ]= 433
>>>> area[ 3 ]= 434
>>>> area[ 7 ]= 278
>>>> Expected total area for 3 items= 1145
>>>> after measure, nResults= 129  area=1145
>>>>
>>>> ImageJ Properties:
>>>>
>>>> Java properties applets can read:
>>>> java.version: 1.5.0_16
>>>> java.vendor: Apple Computer, Inc.
>>>> mrj.version: 1040.1.5.0_16-275
>>>> os.name: Mac OS X
>>>> os.version: 10.4.11
>>>> os.arch: i386
>>>> file.separator: /
>>>> path.separator: :
>>>> line.separator: <lf>
>>>>
>>>> Java properties only applications can read:
>>>> (...)
>>>> user.country: US
>>>> file.encoding: MacRoman
>>>> java.home:
>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
>>>> java.class.path: (...)
>>>> /ij.jar:/System/Library/Java/Extensions/QTJava.zip:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/.compatibility/14compatibility.jar
>>>>
>>>> java.ext.dirs:
>>>> /Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext
>>>>
>>>> java.io.tmpdir: /tmp
>>>>
>>>> Other properties:
>>>> (... same as yours)
>>>> Prefs.weightedColor: true
>>>> Prefs.blackCanvas: false
>>>> Prefs.pointAutoMeasure: false
>>>> Prefs.pointAutoNextSlice: false
>>>> Prefs.requireControlKey: false
>>>> Prefs.useInvertingLut: false
>>>> Prefs.antialiasedTools: true
>>>> Prefs.useInvertingLut: false
>>>> Prefs.intelByteOrder: false
>>>> Prefs.doubleBuffer: false
>>>> Prefs.noPointLabels: true
>>>> Prefs.disableUndo: false
>>>> (...)
>>>> Sample images dir: http://rsb.info.nih.gov/ij/images/
>>>> Screen size: 1680x1050
>>>> Memory in use: 3738K of 800MB (<1%)
>>>>
>>>> Is it really 1.42l or a nightly build previous to 1.42l that you
>>>> are using?
>>>> The released 1.42l ij.jar has 1.373.997 bytes.
>>>>
>>>> Maybe something got stuck - does the problem go away if you restart
>>>> ImageJ?
>>>>
>>>>
>>>> Michael
>>>> ________________________________________________________________
>>>>
>>>> On 16 Apr 2009, at 19:44, Ben Tupper wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I think I have managed to completely confuse myself and would love
>>>>> some help getting straightened out...
>>>>>
>>>>> (1) As I manually select an item in the ROI Manager list it is not
>>>>> the item highlighted in the mask. For example, highlighting the
>>>>> first item in the ROI Manager list will outline the second
>>>>> particle in the mask.  (I often confuse the indices between
>>>>> roiManager("select", x); and getResults("Something", x); where x
>>>>> is either zero-based or one-based. This is going to really drive
>>>>> me bonkers.)
>>>>>
>>>>> (2) I expected the total area of the new combined ROI to equal the
>>>>> sum of the areas in the selection (they do not equal - in fact, it
>>>>> looks like only the first particle is added.)  A year ago I
>>>>> thought I had this all figured out, but now I can't get it to
>>>>> behave as I would like.  I have written a macro (below) is to
>>>>> select some arbitrary number of ROIs and combine them into one.
>>>>>
>>>>> //START MACRO
>>>>> run("Blobs (25K)");
>>>>> setAutoThreshold();
>>>>> //run("Threshold...");
>>>>> setThreshold(125, 255);
>>>>> run("Convert to Mask");
>>>>> run("Set Measurements...", "area mean standard modal min centroid
>>>>> center perimeter bounding fit shape feret's integrated median
>>>>> skewness kurtosis redirect=None decimal=3");
>>>>> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
>>>>> show=Nothing display clear record add");
>>>>>
>>>>> //combine items 0, 3 and 7 into one ROI
>>>>> index = newArray(0,3,7);
>>>>> area = 0;
>>>>> for (i=0; i<index.length; i++){
>>>>>     a = getResult("Area", index[i]);
>>>>>     area = area + a;
>>>>>     print("area[", index[i], "]=", a);
>>>>> }
>>>>> print("Expected total area for 3 items=", area);
>>>>>
>>>>> setKeyDown("shift")
>>>>> roiManager("select", 0);
>>>>> setKeyDown("shift")
>>>>> roiManager("select", 3);
>>>>> setKeyDown("shift")
>>>>> roiManager("select", 7);
>>>>>
>>>>> roiManager("Add");
>>>>> roiManager("Measure");
>>>>> print("after measure, nResults=", nResults ," area=" +
>>>>> getResult("Area", nResults-1));
>>>>>
>>>>> //END MACRO
>>>>>
>>>>> I note there is a bug-fix in ROI manager regarding combining ROIs
>>>>> for v1.42f, but I am running v1.42l.
>>>>>
>>>>>
>>>>> Ben Tupper
>>>>>
>>>>>
>>>>>
>>>>> Java properties applets can read:
>>>>> java.version: 1.5.0_16
>>>>> java.vendor: Apple Inc.
>>>>> mrj.version: 1050.1.5.0_16-284
>>>>> os.name: Mac OS X
>>>>> os.version: 10.5.6
>>>>> os.arch: i386
>>>>> file.separator: /
>>>>> path.separator: :
>>>>> line.separator: <lf>
>>>>>
>>>>> Java properties only applications can read:
>>>>> user.name: ben
>>>>> user.home: /Users/ben
>>>>> user.dir: /Applications/ImageJ
>>>>> user.country: US
>>>>> file.encoding: MacRoman
>>>>> java.home:
>>>>> /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
>>>>> java.class.path:
>>>>> /Applications/ImageJ/ImageJ.app/../ij.jar:/System/Library/Java/Extensions/QTJava.zip
>>>>>
>>>>> java.ext.dirs:
>>>>> /Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext
>>>>>
>>>>> java.io.tmpdir: /tmp
>>>>>
>>>>> Other properties:
>>>>> IJ.getVersion: 1.42l
>>>>> IJ.isJava2: true
>>>>> IJ.isJava15: true
>>>>> IJ.isJava16: false
>>>>> IJ.isLinux: false
>>>>> IJ.isMacintosh: true
>>>>> IJ.isMacOSX: true
>>>>> IJ.isWindows: false
>>>>> IJ.isVista: false
>>>>> IJ.is64Bit: false
>>>>> Menus.getPlugInsPath: /Applications/ImageJ/plugins/
>>>>> Menus.getMacrosPath: /Applications/ImageJ/macros/
>>>>> Prefs.getHomeDir: /Applications/ImageJ
>>>>> Prefs.getThreads: 2 (2 cores)
>>>>> Prefs.open100Percent: false
>>>>> Prefs.blackBackground: false
>>>>> Prefs.useJFileChooser: false
>>>>> Prefs.weightedColor: false
>>>>> Prefs.blackCanvas: false
>>>>> Prefs.pointAutoMeasure: false
>>>>> Prefs.pointAutoNextSlice: false
>>>>> Prefs.requireControlKey: false
>>>>> Prefs.useInvertingLut: false
>>>>> Prefs.antialiasedTools: true
>>>>> Prefs.useInvertingLut: false
>>>>> Prefs.intelByteOrder: false
>>>>> Prefs.doubleBuffer: false
>>>>> Prefs.noPointLabels: false
>>>>> Prefs.disableUndo: false
>>>>> Prefs dir: /Users/ben/Library/Preferences
>>>>> Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
>>>>> Sample images dir: http://rsb.info.nih.gov/ij/images/
>>>>> Screen size: 1440x900
>>>>> Memory in use: 11MB of 400MB (2%)
>>>
>>> Ben Tupper
>
> Ben Tupper
Hi there,

i'm sorry to not have the answer to your problem but I take the
opportunity to talk about a problem I have. I'm segmenting cells and add
them to the manager what I would do next is extract each cell to
generate a new image by using the corresponding ROI.
Did someone allready tried such an approach ?

Thanks,

Fabrice.

--
Senger Fabrice
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Michael Schmid
In reply to this post by BenTupper
Hi Ben,

maybe deleting those particles that don't match from the roi manager  
would be a solution?

Michael
________________________________________________________________

On 16 Apr 2009, at 21:52, Ben Tupper wrote:

> On Apr 16, 2009, at 3:22 PM, Michael Schmid wrote:
>
>> Hi Ben,
>>
>> the ROI Manager items have labels 0001-... to 0064-...,  
>> corresponding to the labels in the binary image, but they have  
>> line numbers 0 to 63 - maybe this causes part of the confusion?
>
> Yes, I am always sawing back-and-forth between different indexing  
> schemes.  It is very taxing on my walnut-sized-brain. It wasn't so  
> bad when it was just Java and IDL (0-based) but now throw in R and  
> the results table (1-based)...  argh!
>
>
>>
>> I did succeed in selecting three items manually (lines 0, 3, 7,  
>> i.e. 0001-..., 0004.. and 0008-...) together with command-click  
>> and then use More>Combine. It is a bit nasty since the context  
>> menus interferes with it. Measure on the combined ROI gave me an  
>> area of 1145 again.
>
>
> OK, I can do this now and get the same result as you using the  
> click-command.  With the fictional click-command it works as long  
> as the menu command "Measure" is used - not the roiManager
> ("Measure") command.
>
> roiManager("Select", 0);  with click-command
> roiManager("Select", 3);  with click-command
> roiManager("Select", 7);  with click-command
> roiManager("Combine");
> run("Measure");  <--- note: it isn't roiManager("Measure");
>
>
> I had been assuming that I could run "Analyze particles..." with  
> additions to the ROI Manager.  Then I thought I could step through  
> the items in the list to see if they meet my qualifications -  
> finally I would select only those that qualify.   Since the click-
> command is fictional, I'll have to change my filtering so that I  
> only add those items that qualify.
>
> Thanks again for your help!
> Ben
>
>
>
>>
>> I don't know how to do this in a macro; at least I am not aware of  
>> a setKeyDown("command") or setKeyDown("ctrl")
>>
>> With "shift", one would select a contiguous range of lines.
>>
>>
>> Best wishes,
>>
>> Michael
>> ________________________________________________________________
>>
>> On 16 Apr 2009, at 21:03, Ben Tupper wrote:
>>
>>> Hi Michael,
>>>
>>> Thanks for responding so quickly.
>>>
>>> The first issue is a result of my own boneheadedness.   Note that  
>>> the left most particle looks like it is labeled "0".  It is  
>>> actually "10" but the label was cutoff and I fooled myself.
>>>
>>> I can confirm that the ij.jar is the size you specify and that  
>>> ImageJ thinks it is v1.42l.  Restarting ImageJ seems to make no  
>>> difference.
>>>
>>> Can you explain how you made those selections manually?  I can't  
>>> make that happen manually or in the macro.
>>>
>>> Thanks again,
>>> Ben
>>>
>>>
>>>
>>>
>>>
>>> On Apr 16, 2009, at 2:23 PM, Michael Schmid wrote:
>>>
>>>> Hi Ben,
>>>>
>>>> using a very similar system (but MacOS 10.4.11, not 10.5), I  
>>>> have neither problems with 1.42l nor with the nightly build of a  
>>>> few days ago.
>>>>
>>>> Selecting the ROIs manually works as expected.
>>>>
>>>> After running the macro, the log says:
>>>> area[ 0 ]= 433
>>>> area[ 3 ]= 434
>>>> area[ 7 ]= 278
>>>> Expected total area for 3 items= 1145
>>>> after measure, nResults= 129  area=1145
>>>>
>>>> ImageJ Properties:
>>>>
>>>> Java properties applets can read:
>>>> java.version: 1.5.0_16
>>>> java.vendor: Apple Computer, Inc.
>>>> mrj.version: 1040.1.5.0_16-275
>>>> os.name: Mac OS X
>>>> os.version: 10.4.11
>>>> os.arch: i386
>>>> file.separator: /
>>>> path.separator: :
>>>> line.separator: <lf>
>>>>
>>>> Java properties only applications can read:
>>>> (...)
>>>> user.country: US
>>>> file.encoding: MacRoman
>>>> java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>>>> 1.5.0/Home
>>>> java.class.path: (...) /ij.jar:/System/Library/Java/Extensions/
>>>> QTJava.zip:/System/Library/Frameworks/JavaVM.framework/Versions/
>>>> 1.5.0/Classes/.compatibility/14compatibility.jar
>>>> java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>>>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>>>> 1.5.0/Home/lib/ext
>>>> java.io.tmpdir: /tmp
>>>>
>>>> Other properties:
>>>> (... same as yours)
>>>> Prefs.weightedColor: true
>>>> Prefs.blackCanvas: false
>>>> Prefs.pointAutoMeasure: false
>>>> Prefs.pointAutoNextSlice: false
>>>> Prefs.requireControlKey: false
>>>> Prefs.useInvertingLut: false
>>>> Prefs.antialiasedTools: true
>>>> Prefs.useInvertingLut: false
>>>> Prefs.intelByteOrder: false
>>>> Prefs.doubleBuffer: false
>>>> Prefs.noPointLabels: true
>>>> Prefs.disableUndo: false
>>>> (...)
>>>> Sample images dir: http://rsb.info.nih.gov/ij/images/
>>>> Screen size: 1680x1050
>>>> Memory in use: 3738K of 800MB (<1%)
>>>>
>>>> Is it really 1.42l or a nightly build previous to 1.42l that you  
>>>> are using?
>>>> The released 1.42l ij.jar has 1.373.997 bytes.
>>>>
>>>> Maybe something got stuck - does the problem go away if you  
>>>> restart ImageJ?
>>>>
>>>>
>>>> Michael
>>>> ________________________________________________________________
>>>>
>>>> On 16 Apr 2009, at 19:44, Ben Tupper wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I think I have managed to completely confuse myself and would  
>>>>> love some help getting straightened out...
>>>>>
>>>>> (1) As I manually select an item in the ROI Manager list it is  
>>>>> not the item highlighted in the mask. For example, highlighting  
>>>>> the first item in the ROI Manager list will outline the second  
>>>>> particle in the mask.  (I often confuse the indices between  
>>>>> roiManager("select", x); and getResults("Something", x); where  
>>>>> x is either zero-based or one-based. This is going to really  
>>>>> drive me bonkers.)
>>>>>
>>>>> (2) I expected the total area of the new combined ROI to equal  
>>>>> the sum of the areas in the selection (they do not equal - in  
>>>>> fact, it looks like only the first particle is added.)  A year  
>>>>> ago I thought I had this all figured out, but now I can't get  
>>>>> it to behave as I would like.  I have written a macro (below)  
>>>>> is to select some arbitrary number of ROIs and combine them  
>>>>> into one.
>>>>>
>>>>> //START MACRO
>>>>> run("Blobs (25K)");
>>>>> setAutoThreshold();
>>>>> //run("Threshold...");
>>>>> setThreshold(125, 255);
>>>>> run("Convert to Mask");
>>>>> run("Set Measurements...", "area mean standard modal min  
>>>>> centroid center perimeter bounding fit shape feret's integrated  
>>>>> median skewness kurtosis redirect=None decimal=3");
>>>>> run("Analyze Particles...", "size=0-Infinity  
>>>>> circularity=0.00-1.00 show=Nothing display clear record add");
>>>>>
>>>>> //combine items 0, 3 and 7 into one ROI
>>>>> index = newArray(0,3,7);
>>>>> area = 0;
>>>>> for (i=0; i<index.length; i++){
>>>>> a = getResult("Area", index[i]);
>>>>> area = area + a;
>>>>> print("area[", index[i], "]=", a);
>>>>> }
>>>>> print("Expected total area for 3 items=", area);
>>>>>
>>>>> setKeyDown("shift")
>>>>> roiManager("select", 0);
>>>>> setKeyDown("shift")
>>>>> roiManager("select", 3);
>>>>> setKeyDown("shift")
>>>>> roiManager("select", 7);
>>>>>
>>>>> roiManager("Add");
>>>>> roiManager("Measure");
>>>>> print("after measure, nResults=", nResults ," area=" + getResult
>>>>> ("Area", nResults-1));
>>>>>
>>>>> //END MACRO
>>>>>
>>>>> I note there is a bug-fix in ROI manager regarding combining  
>>>>> ROIs for v1.42f, but I am running v1.42l.
>>>>>
>>>>>
>>>>> Ben Tupper
>>>>>
>>>>>
>>>>>
>>>>> Java properties applets can read:
>>>>> java.version: 1.5.0_16
>>>>> java.vendor: Apple Inc.
>>>>> mrj.version: 1050.1.5.0_16-284
>>>>> os.name: Mac OS X
>>>>> os.version: 10.5.6
>>>>> os.arch: i386
>>>>> file.separator: /
>>>>> path.separator: :
>>>>> line.separator: <lf>
>>>>>
>>>>> Java properties only applications can read:
>>>>> user.name: ben
>>>>> user.home: /Users/ben
>>>>> user.dir: /Applications/ImageJ
>>>>> user.country: US
>>>>> file.encoding: MacRoman
>>>>> java.home: /System/Library/Frameworks/JavaVM.framework/Versions/
>>>>> 1.5.0/Home
>>>>> java.class.path: /Applications/ImageJ/ImageJ.app/../ij.jar:/
>>>>> System/Library/Java/Extensions/QTJava.zip
>>>>> java.ext.dirs: /Library/Java/Extensions:/System/Library/Java/
>>>>> Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/
>>>>> 1.5.0/Home/lib/ext
>>>>> java.io.tmpdir: /tmp
>>>>>
>>>>> Other properties:
>>>>> IJ.getVersion: 1.42l
>>>>> IJ.isJava2: true
>>>>> IJ.isJava15: true
>>>>> IJ.isJava16: false
>>>>> IJ.isLinux: false
>>>>> IJ.isMacintosh: true
>>>>> IJ.isMacOSX: true
>>>>> IJ.isWindows: false
>>>>> IJ.isVista: false
>>>>> IJ.is64Bit: false
>>>>> Menus.getPlugInsPath: /Applications/ImageJ/plugins/
>>>>> Menus.getMacrosPath: /Applications/ImageJ/macros/
>>>>> Prefs.getHomeDir: /Applications/ImageJ
>>>>> Prefs.getThreads: 2 (2 cores)
>>>>> Prefs.open100Percent: false
>>>>> Prefs.blackBackground: false
>>>>> Prefs.useJFileChooser: false
>>>>> Prefs.weightedColor: false
>>>>> Prefs.blackCanvas: false
>>>>> Prefs.pointAutoMeasure: false
>>>>> Prefs.pointAutoNextSlice: false
>>>>> Prefs.requireControlKey: false
>>>>> Prefs.useInvertingLut: false
>>>>> Prefs.antialiasedTools: true
>>>>> Prefs.useInvertingLut: false
>>>>> Prefs.intelByteOrder: false
>>>>> Prefs.doubleBuffer: false
>>>>> Prefs.noPointLabels: false
>>>>> Prefs.disableUndo: false
>>>>> Prefs dir: /Users/ben/Library/Preferences
>>>>> Current dir: /Users/Shared/data/441.2009-04-23.400A4X_03 2/
>>>>> Sample images dir: http://rsb.info.nih.gov/ij/images/
>>>>> Screen size: 1440x900
>>>>> Memory in use: 11MB of 400MB (2%)
>>>
>>> Ben Tupper
>
> Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

BenTupper
In reply to this post by Fabrice Senger
On Apr 17, 2009, at 4:08 AM, Senger Fabrice wrote:

>>
> Hi there,
>
> i'm sorry to not have the answer to your problem but I take the  
> opportunity to talk about a problem I have. I'm segmenting cells and  
> add them to the manager what I would do next is extract each cell to  
> generate a new image by using the corresponding ROI.
> Did someone allready tried such an approach ?
>
> Thanks,
>
> Fabrice.
>
>


Hi Fabrice,

If you want to transfer a region from one image to another then you  
could do it with something like the following (note that ROI Manager  
is not used).

//START MACRO

run("Blobs (25K)");
setAutoThreshold();
//run("Threshold...");
setThreshold(125, 255);
run("Convert to Mask");
maskID = getImageID();
run("Set Measurements...", "area mean standard modal min centroid  
center perimeter bounding fit shape feret's integrated median skewness  
kurtosis redirect=None decimal=3");
run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00  
show=Nothing display clear record ");

//first method creates a new image to accept the subimage
ix = 22;
bx = getResult("BX", ix);
by = getResult("BY", ix);
w = getResult("Width", ix);
h = getResult("Height", ix);

name = "#" + ix+1;
newImage(name, "8-bit White", w,h,1);
img23ID = getImageID();

selectImage(maskID);
makeRectangle(bx,by,w,h);
run("Copy");
selectImage(img23ID);
run("Paste");
run("Invert");


// the second method exploits the File > New > Internal Clipboard menu  
item
ix = 30;
bx = getResult("BX", ix);
by = getResult("BY", ix);
w = getResult("Width", ix);
h = getResult("Height", ix);

selectImage(maskID);
makeRectangle(bx,by,w,h);
run("Copy");
name = "#" + ix+1;
run("Internal Clipboard");
rename(name);

//END MACRO



Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

BenTupper
In reply to this post by Michael Schmid
On Apr 17, 2009, at 4:23 AM, Michael Schmid wrote:

> Hi Ben,
>
> maybe deleting those particles that don't match from the roi manager  
> would be a solution?


That might be a solution - I have not tried that. In the meantime, I  
think I have figured out a way to do this - but the approach is to add  
to the Manager only those particles that I want in there.  It turns it  
into a "front-end" problem rather than a "back-end" problem.  I was  
trying the back end solution because I mistakenly thought that I  
needed to use the ROI manager is I wanted to use...

xs = getResult("XStart", i);
ys = getResult("YStart", i);
doWand(xs, ys);
getSelectionCoordinates(xc,yc);

It turns out that it works even if the particle is not added to the  
ROI Manager but has a record in the results table (you might think the  
"getResult" would have been an obvious clue for me.  Doh!)

My current solution doesn't even use the ROI Manager now.  (Whew!)

In case you are interested, I want to determine the smallest distance  
between particle perimeters - if two or more are close enough then I  
want to consider them a single object (like a chain of pearls).  I  
think this macro ...

http://www.tidewater.net/~pemaquid/FITVIS_neighbors.ijm

... shows what I mean.

Thanks again for all the help!
Cheers,
Ben



Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Fabrice Senger
In reply to this post by BenTupper
Ben Tupper a écrit :

> On Apr 17, 2009, at 4:08 AM, Senger Fabrice wrote:
>>>
>> Hi there,
>>
>> i'm sorry to not have the answer to your problem but I take the
>> opportunity to talk about a problem I have. I'm segmenting cells and
>> add them to the manager what I would do next is extract each cell to
>> generate a new image by using the corresponding ROI.
>> Did someone allready tried such an approach ?
>>
>> Thanks,
>>
>> Fabrice.
>>
>>
>
>
> Hi Fabrice,
>
> If you want to transfer a region from one image to another then you
> could do it with something like the following (note that ROI Manager
> is not used).
>
> //START MACRO
>
> run("Blobs (25K)");
> setAutoThreshold();
> //run("Threshold...");
> setThreshold(125, 255);
> run("Convert to Mask");
> maskID = getImageID();
> run("Set Measurements...", "area mean standard modal min centroid
> center perimeter bounding fit shape feret's integrated median skewness
> kurtosis redirect=None decimal=3");
> run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00
> show=Nothing display clear record ");
>
> //first method creates a new image to accept the subimage
> ix = 22;
> bx = getResult("BX", ix);
> by = getResult("BY", ix);
> w = getResult("Width", ix);
> h = getResult("Height", ix);
>
> name = "#" + ix+1;
> newImage(name, "8-bit White", w,h,1);
> img23ID = getImageID();
>
> selectImage(maskID);
> makeRectangle(bx,by,w,h);
> run("Copy");
> selectImage(img23ID);
> run("Paste");
> run("Invert");
>
>
> // the second method exploits the File > New > Internal Clipboard menu
> item
> ix = 30;
> bx = getResult("BX", ix);
> by = getResult("BY", ix);
> w = getResult("Width", ix);
> h = getResult("Height", ix);
>
> selectImage(maskID);
> makeRectangle(bx,by,w,h);
> run("Copy");
> name = "#" + ix+1;
> run("Internal Clipboard");
> rename(name);
>
> //END MACRO
>
>
>
> Ben Tupper
Hi,

your mail some how gives me a first answer but actually my question is
more like :

I have a picture with 10 cells in it.
I'm able to segment them.
Next for each cell I would create a new picture.
So I don't want to copy one specific particle, I would like to create
one image for each particle.
This is part of an analysis scheme where I plan to isolate cells from a
picture into a folder and then batch process this folder with another macro.

--
Senger Fabrice
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Gabriel Landini
On Friday 17 April 2009, Senger Fabrice wrote:
> I have a picture with 10 cells in it.
> I'm able to segment them.
> Next for each cell I would create a new picture.
> So I don't want to copy one specific particle, I would like to create
> one image for each particle.
> This is part of an analysis scheme where I plan to isolate cells from a
> picture into a folder and then batch process this folder with another
> macro.

Have a look at the Catalogue_Particles macro in the Morphology collection.
It can create a stack of objects extracted from a binary image (one object per
slice).

Cheers,
G
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Michael Schmid
In reply to this post by BenTupper
Hi Ben,

just a short remark:
If you want to combine particles closer than a given distance, create  
a mask and dilate it. If you use the Process>Filters>Maximum for  
dilating, it won't be a square but a circular kernel.

For large distances, thresholding the distance map of the inverted  
mask will be faster than 'max'. Set the threshold range to 0...radius.

Michael
________________________________________________________________

On 17 Apr 2009, at 15:02, Ben Tupper wrote:

> In case you are interested, I want to determine the smallest  
> distance between particle perimeters - if two or more are close  
> enough then I want to consider them a single object (like a chain  
> of pearls).  I think this macro ...
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

BenTupper
Great ideas!  Thanks!


On Apr 17, 2009, at 9:44 AM, Michael Schmid wrote:

> Hi Ben,
>
> just a short remark:
> If you want to combine particles closer than a given distance,  
> create a mask and dilate it. If you use the Process>Filters>Maximum  
> for dilating, it won't be a square but a circular kernel.
>
> For large distances, thresholding the distance map of the inverted  
> mask will be faster than 'max'. Set the threshold range to 0...radius.
>
> Michael
> ________________________________________________________________
>
> On 17 Apr 2009, at 15:02, Ben Tupper wrote:
>
>> In case you are interested, I want to determine the smallest  
>> distance between particle perimeters - if two or more are close  
>> enough then I want to consider them a single object (like a chain  
>> of pearls).  I think this macro ...

Ben Tupper
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Fabrice Senger
In reply to this post by Gabriel Landini
Gabriel Landini a écrit :

> On Friday 17 April 2009, Senger Fabrice wrote:
>  
>> I have a picture with 10 cells in it.
>> I'm able to segment them.
>> Next for each cell I would create a new picture.
>> So I don't want to copy one specific particle, I would like to create
>> one image for each particle.
>> This is part of an analysis scheme where I plan to isolate cells from a
>> picture into a folder and then batch process this folder with another
>> macro.
>>    
>
> Have a look at the Catalogue_Particles macro in the Morphology collection.
> It can create a stack of objects extracted from a binary image (one object per
> slice).
>
> Cheers,
> G
>  
I tried this but did not succeeded yet as i get some error messages, but
i will try again.
Actually I wanted to adapt this code taken from :

// ROI Manager Stack Demo
//

  n = roiManager("count");
  for (i=0; i<n; i++) {
      roiManager("select", i);
      getStatistics(area, mean);
      setResult("Area",  i, area);
      setResult("Mean", i, mean);
  }
  updateResults();
  roiManager("deselect");


and instead of making measurements I would rather go for a duplicate
image command I tried different ways but it does not work yet, one of my
macros get stuck to the first ROI and another version only displays the
last particle...
To me the advantage of using the ROI manager is to vizualize the
selected particles and to have the opportunity to discard not relevant
particles.

Fabrice.

--
Senger Fabrice
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Gabriel Landini
On Friday 17 April 2009, Senger Fabrice wrote:
> I tried this but did not succeeded yet as i get some error messages, but
> i will try again.
> Actually I wanted to adapt this code taken from :

What error do you get?

G
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Michael Schmid
In reply to this post by Fabrice Senger
Hi Fabrice,

what about something like this:

  myID = getImageID();
  n = roiManager("count");
  for (i=0; i<n; i++) {
      selectImage(myID);
      roiManager("select", i);
      run("Duplicate...", "title=particle_"+i);
  }


Michael
________________________________________________________________

On 17 Apr 2009, at 17:06, Senger Fabrice wrote:

> Gabriel Landini a écrit :
>> On Friday 17 April 2009, Senger Fabrice wrote:
>>
>>> I have a picture with 10 cells in it.
>>> I'm able to segment them.
>>> Next for each cell I would create a new picture.
>>> So I don't want to copy one specific particle, I would like to  
>>> create
>>> one image for each particle.
>>> This is part of an analysis scheme where I plan to isolate cells  
>>> from a
>>> picture into a folder and then batch process this folder with  
>>> another
>>> macro.
>>>
>>
>> Have a look at the Catalogue_Particles macro in the Morphology  
>> collection.
>> It can create a stack of objects extracted from a binary image  
>> (one object per slice).
>>
>> Cheers,
>> G
>>
> I tried this but did not succeeded yet as i get some error  
> messages, but i will try again.
> Actually I wanted to adapt this code taken from :
>
> // ROI Manager Stack Demo
> //
>
>  n = roiManager("count");
>  for (i=0; i<n; i++) {
>      roiManager("select", i);
>      getStatistics(area, mean);
>      setResult("Area",  i, area);
>      setResult("Mean", i, mean);
>  }
>  updateResults();
>  roiManager("deselect");
>
>
> and instead of making measurements I would rather go for a  
> duplicate image command I tried different ways but it does not work  
> yet, one of my macros get stuck to the first ROI and another  
> version only displays the last particle...
> To me the advantage of using the ROI manager is to vizualize the  
> selected particles and to have the opportunity to discard not  
> relevant particles.
>
> Fabrice.
>
> --
> Senger Fabrice
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Gabriel Landini
In reply to this post by Fabrice Senger
I think that I found what error you might have encountered. This would happen
if you were using the built in Particle analyzer instead of the Particels8.
I uploaded a new version of the morphology plugins that fixes this.

http://www.dentistry.bham.ac.uk/landinig/software/morphology.zip

Let me know if that fixes it.
Cheers

G
Reply | Threaded
Open this post in threaded view
|

Re: Disjoint ROI selection using macro language

Fabrice Senger
In reply to this post by Michael Schmid
Michael Schmid a écrit :

> Hi Fabrice,
>
> what about something like this:
>
>  myID = getImageID();
>  n = roiManager("count");
>  for (i=0; i<n; i++) {
>      selectImage(myID);
>      roiManager("select", i);
>      run("Duplicate...", "title=particle_"+i);
>  }
>
>
> Michael
> ________________________________________________________________
>
> On 17 Apr 2009, at 17:06, Senger Fabrice wrote:
>
>> Gabriel Landini a écrit :
>>> On Friday 17 April 2009, Senger Fabrice wrote:
>>>
>>>> I have a picture with 10 cells in it.
>>>> I'm able to segment them.
>>>> Next for each cell I would create a new picture.
>>>> So I don't want to copy one specific particle, I would like to create
>>>> one image for each particle.
>>>> This is part of an analysis scheme where I plan to isolate cells
>>>> from a
>>>> picture into a folder and then batch process this folder with another
>>>> macro.
>>>>
>>>
>>> Have a look at the Catalogue_Particles macro in the Morphology
>>> collection.
>>> It can create a stack of objects extracted from a binary image (one
>>> object per slice).
>>>
>>> Cheers,
>>> G
>>>
>> I tried this but did not succeeded yet as i get some error messages,
>> but i will try again.
>> Actually I wanted to adapt this code taken from :
>>
>> // ROI Manager Stack Demo
>> //
>>
>>  n = roiManager("count");
>>  for (i=0; i<n; i++) {
>>      roiManager("select", i);
>>      getStatistics(area, mean);
>>      setResult("Area",  i, area);
>>      setResult("Mean", i, mean);
>>  }
>>  updateResults();
>>  roiManager("deselect");
>>
>>
>> and instead of making measurements I would rather go for a duplicate
>> image command I tried different ways but it does not work yet, one of
>> my macros get stuck to the first ROI and another version only
>> displays the last particle...
>> To me the advantage of using the ROI manager is to vizualize the
>> selected particles and to have the opportunity to discard not
>> relevant particles.
>>
>> Fabrice.
>>
>> --
>> Senger Fabrice
Hi Michael,

it works just great, my mistake was in taht simple line

run("Duplicate...", "title=particle_"+i);

where I tried title=particle_i

anyway,

thank you very much,

Fabrice.

I will try aswell Gabriel's suggestion...

--
Senger Fabrice