http://imagej.273.s1.nabble.com/Disjoint-ROI-selection-using-macro-language-tp3692854p3692855.html
(... same as yours)
> 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%)