Closed pwalczysko closed 1 year ago
I'll do some testing - I can see problem 2 happening if fill color is completely unset on the origin ROI (in which case we'll probably have to have some sane default), but fill and stroke color should have been transferred.
I've just tested with a few ROIs and stroke/fill color were transfered correctly. I wonder if what you're seeing is a consequence of caveat number 7 from our previous repo README:
OMERO does some strange setting with channel = -1 for ROIs sometimes (for RGB images, I think). ome-types hates that, so we set those values to 0.
I don't know exactly how to fix this here - it would either require ome-types
to accept channel = -1
for an ROI, or some clever way of bypassing that.
(FWIW, I did see this issue pop up in some unrelated testing and I think #15 also fixes it)
I have a new occurrence of this issue with 0.3.1 release
omero transfer unpack dataset-to-plate.tar
...
Plate:42505
Other imported objects:
Fileset:43258
==> Summary
139 files uploaded, 1 fileset, 1 plate created, 16 images imported, 0 errors in 0:01:28.948
Matching source and destination images...
Creating and linking OMERO objects...
id='ROI:501662' annotation_ref=[] description=None name=None union=[Ellipse(
id='Shape:590991',
text='117.00000',
the_c=0,
the_t=0,
the_z=0,
radius_x=6.9782385,
radius_y=6.9782385,
x=1951.8583,
y=382.31174,
)]
None
Traceback (most recent call last):
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/bin/omero", line 8, in <module>
sys.exit(main())
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero/main.py", line 126, in main
rv = omero.cli.argv()
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero/cli.py", line 1787, in argv
cli.invoke(args[1:])
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero/cli.py", line 1225, in invoke
stop = self.onecmd(line, previous_args)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero/cli.py", line 1302, in onecmd
self.execute(line, previous_args)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero/cli.py", line 1384, in execute
args.func(args)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero_cli_transfer.py", line 125, in _wrapper
return func(self, *args, **kwargs)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero_cli_transfer.py", line 195, in unpack
self.__unpack(args)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/omero_cli_transfer.py", line 347, in __unpack
hash, folder, self.metadata)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/generate_omero_objects.py", line 404, in populate_omero
create_rois(ome.rois, ome.images, img_map, conn)
File "/Users/pwalczysko/opt/anaconda3/envs/cli-transfer/lib/python3.7/site-packages/generate_omero_objects.py", line 270, in create_rois
fill_color=fill_color, stroke_color=stroke_color)
UnboundLocalError: local variable 'fill_color' referenced before assignment
Maybe it is a variation - feel free to move the comment or tell me to do so - the ROIs got imported okay, but the error occcurred as above.
I think the main issue here is that ezomero Shape
s (which we're using to create ROIs) don't have fill_color
, stroke_color
and stroke_width
themselves, and they just use whatever is set at the ROI level. Meanwhile, omero-cli-transfer
looks for those parameters at the Shape
s, and adds those parameters to them in the metadata/XML file. For now, I will probably implement defaults in case they are not set at ROI level (maybe look at the first Shape
and use that), but doing this "right" will probably require some rewriting on the ezomero side as well. I'll open an issue there.
PR #37 implements a partial fix for this - if the first Shape
in an ROI
has these attributes we use them, otherwise we default to (0,0,0,0)
. A full fix requires a new ezomero version.
Release 0.3.2 includes the latest PR. Let me know if it works as intended!
Release 0.3.2 includes the latest PR. Let me know if it works as intended!
Thank you.
With 0.3.2
it works without error, but it seems that I am getting more ROIs in the resulting plate image than in the original. The original has 184
, the one after unpack
has 357
- there are some masks, which did not get duplicated, but the point ROIs did get somehow duplicated (there are two point ROIs on top of each other for each cell now). I will have a look on a creation of a simpler example with just couple of ROIs.
Release 0.3.2 includes the latest PR. Let me know if it works as intended!
Thank you. With
0.3.2
it works without error, but it seems that I am getting more ROIs in the resulting plate image than in the original. The original has184
, the one afterunpack
has357
- there are some masks, which did not get duplicated, but the point ROIs did get somehow duplicated (there are two point ROIs on top of each other for each cell now). I will have a look on a creation of a simpler example with just couple of ROIs.
I cannot repeat the doubling problem if there are only point ROIs on the image (i.e. no masks). In such case, the number of ROIs after unpack
is matching the original, just that the ROIs after unpack have no color of the stroke it seems (selectable, but invisible stroke, which is possibly expected after your fix?).
Any idea why the presence of masks should be important for the doubling bug ?
I think I hit an unrelated issue as well when testing this, see https://github.com/ome/omero-cli-transfer/issues/12#issuecomment-1387326768
what exactly do you mean by "masks" here? What kind of masks? Can you send an example?
Hi Erick, I mean a mask in OMERO, something like in https://forum.image.sc/t/prepping-and-including-roi-masks/48750/8 - you can see in that post how these are displayed in OMERO.iviewer. I have a mask on an image (mask is a type of RoI in OMERO) and some other ROIs (polygons). If this is the case, then it seems to me that the pack
command is not doing the correct thing. I have two examples, in one,
pack
- if the mask is deleted, and the pack
is unleashed on the image with the remaining 2 polygons, then all works as expected (i.e. the unpack
is executed, resulting in an image with 2 polygons in OMERO)The problem is the size of both those examples, one is a plate, and one is a large image.
I will ponder about how to create a smallish example for you.
thanks, Petr - we don't use OMERO masks at all, so I don't really have an easy way to generate a quick example for testing. The color/strokewidth issue needed some more work, but my current dev branch sorts that out (and the plate repeat import issue). As soon as I can check (and solve) this duplication problem I'll push a new release.
thanks, Petr - we don't use OMERO masks at all, so I don't really have an easy way to generate a quick example for testing. The color/strokewidth issue needed some more work, but my current dev branch sorts that out (and the plate repeat import issue). As soon as I can check (and solve) this duplication problem I'll push a new release.
Hi Erick, so tried to create a simple image example with masks for you, which succeeded. What did not succeed is to force any tools, such as OMERO.downloader
do export that image with the mask.
So the only way I see to give you something to reproduce is:
pack
that image, and unpack
-> Observe that you have only 4 ROIs, the mask is missing[1] - script for mask creation
I'll give it a try - thanks! I'll say that right now this looks like it's behaving as intended, we do not have Masks implemented. It's something we can discuss for the future, but I'd expect only 4 ROIs in this case. Is this not causing the duplication issue you've seen before?
Is this not causing the duplication issue you've seen before?
Not with this simple example, I actually have 2 issues, a duplication one, and a loss of all ROIs
is another. Will consult about how to get that to you maybe...
So, with regards to the duplication issue, we debugged it with @will-moore a bit and think we have a culprit
. The issue is as follows
omero-cli-transfer
pack
and unpack
the imagesunpacked
images have now 3 ROIs - 1 original polygon, 1 original Text ROI, 1 new polygon.This is because the pack
and unpack
workflow added the ROI which was in OMERO, but also the import imported the ROIs which were already in the original file.
How to solve:
There would be couple of suggestions, such as deleting the ROIs coming from the original file right after the import step of the unpack
command, then only add the new ROIs which were transferred from OMERO during pack
. But there might be other ways to go about this.
Sorry about the masks, this was a complete Red Herring, I was just confused by my own testing file which had ROIs from original file some of which were masks... - so a new issue, without masks involvement now :)
Alright - this makes a lot of sense actually. I think deleting file ROIs after import is probably the best choice here; it respects the user changes in ROIs on the source side and should provide the one-to-one correspondence we're striving for with this library. Thanks for the investigation, once again!
Sorry to add to this pile, but actually I think it belongs to here:
I think that the fill color is not being transferred at all, in fact, my new ROIs after unpack
have no fill at all, although the original ones had nice fill from QuPath, see e.g. https://omero-guides.readthedocs.io/en/latest/qupath/docs/qupath.html - is it expected ? Certainly, the colors of the ROIs in this case signifies the Annotation type, and it would make sense to preserve it - sorry if it was already discussed and rejected or implicitly discussed and not grasped by me :)
This should be fixed on the next release - it's already on my personal dev branch and working as intended!
0.3.3 should fix both issues here.
0.3.3 should fix both issues here.
Re: Preserving of color: the stroke color seems preserved, but the fill color is ignored.
Original:
After transfer:
Re: Plate with an image with ROIs in original file: This works as intended. The ROIs are not doubled, and the masks are ignored. It seems that there is a nice output for the masks now
...
populating well 8269
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
not a supported ROI type
populating well 8268
populating well 8267
populating well 8266
To be continued...
is there anything notable about the fillColors on the source and destination (different alpha values, etc)? is this an ROI with multiple shapes?
is there anything notable about the fillColors on the source and destination (different alpha values, etc)?
Not on the first look, except for what you see on the screenshot - the fill on the destination image is white, the one on the source is purpleish.
is this an ROI with multiple shapes?
No, single shape.
@erickmartins Sorry, I think that in fact cli-transfer
is doing the right thing. I have opened the transferred images in the Old inbuilt OMERO.web viewer, and the fills were transferred as expected. It is just the OMERO.iviewer which gives following discrepancy:
rgb(160, 90, 160) #this should be as it is like that on the original image (even in iviewer)
rgba(160, 90, 160, 0)
#this is what you can see on the transferred image, kind of "forced" by iviewer, indeed, when I try to draw a new ROI on an RGB image in iviewer, using the color picker UI only (ie. not typing into the text value box from which I copied the values here), then it insists on the rgba(x, y, z, 0)
type of motive - this motive then results in empty fill, which is shown as white in the color picker box
Any ideas @will-moore ?
this is something I am unclear on from the OME model side (and maybe @will-moore can clarify): using fillColor.as_rgb_tuple()
can return a tuple with 3 or 4 values, with the fourth value being alpha/transparency. If there are only 3 values, should I assume the fourth to be 0? 1? 255? I think for strokeColor
I assume 1
for fully opaque; is fillColor
the same?
I don't know about as_rgb_tuple()
but I would assume if there's only 3 values then alpha is 1
.
alright, I'll make sure fillColor
uses that as well
as of #42 fillColor
assumes alpha to be 1 in case it's not there.
How does the transfer of the ROI settings such as color of the stroke or fill work ?
I have encountered 2 problems: