Hi Christophe,

the issue is not limited to Roi.setProperty; it seems to be a more fundamental thing:

In the Roi Manager's "Show All" mode, if I select a roi of the RoiManager and drag it with the mouse, it affects the roi of the RoiManager.

If "Show All is off, and I select a roi of the RoiManager and drag it with the mouse, this only affects the roi currently seen, but the roi stored in the roiManager remains unchanged.

This means that after selecting a roi in the RoiManager, the roi in the RoiManager's list becomes active (and susceptible to modifications) if "Show All" is on. But it creates a copy of that roi and makes this the active roi if "Show All" is off. To me, this is not really intuitive.

The code responsible for this is in RoiManager.java lines 738... ("Show all" on) and 743... ("Show all" off).


I don't understand why the "Show all" state should make a difference for whether selecting a roi in the RoiManager creates a copy of the roi or allows the user to modify the roi as it is in the RoiManager.

So what would be a good solution?

For the API (and macro), in principle one could have two different slice selection functions, one that creates a copy and one that keeps the Roi in the RoiManager.

But which behavior should we have for the GUI?
If one selects a roi from the RoiManager's list, should it create a copy (so that the roi in the RoiManager remains unaffected by any modification of the roi) or should modifications by the user affect the roi in the RoiManager's list? I see arguments for both: Sometimes one may want to modify a roi in the RoiManager's list, sometimes one wants to have the RoiManager's rois protected against accidental modifications.

In principle, one could also have an option for selecting the behavior, but I fear that the average user won't have a look at the RoiManager's options. (There is already a "restore centered" option; probably only very few users are aware of this.)


Best,

Michael
________________________________________________________________

On 09.01.25 15:05, Christophe Leterrier wrote:
Hi,

I have a problem with setting custom ROI properties in a macro. If I store
a ROI in the ROI manager, then assign it properties while the "Show All"
checkbox is unchecked, the properties are properly assigned to the ROI.

If I do the same thing with the "Show All" checkbox unchecked, the
properties are not assigned to the ROI.

To test, run the following code:

run("AuPbSn 40");

roiManager("Show All");
makeRectangle(122, 76, 181, 141);
roiManager("add");
roiManager("select",0);
Roi.setProperty("P1", "" + 1);
Roi.setProperty("P2", "Cat" + 1);

roiManager("Show None");
makeRectangle(510, 214, 53, 133);
roiManager("add");
roiManager("select",1);
Roi.setProperty("P1", "" + 2);
Roi.setProperty("P2", "Cat" + 2);

After that, if you select the first ROI in the ROI manager and click on the
"Properties" button of the ROI manager, in the dialog you will get a "List
Properties (2)" checkbox in the dialog. If you select the second ROI, you
will only get a "No properties" message under the "List coordinates"
checkbox.

What is strange is that if I try to recall the properties of the second ROI
in the macro itself using "ROi.getProperty", the properties are there and I
can retrieve them. But if I save the two ROIs as a zip ROI set, open it
again, and try to retrieve the properties of the second ROI, they are gone.

Thank you for your help,

Christophe

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

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

Reply via email to