http://imagej.273.s1.nabble.com/Disjoint-ROI-selection-using-macro-language-tp3692854p3692868.html
> 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