-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image_to_html always fails to find pixelSize #436
Comments
@Tom-TBT I tried to reproduce the issue using the following example code: from omero.gateway import BlitzGateway
with BlitzGateway(
host='localhost', username=<username>, passwd=<password>) as conn:
conn.connect()
conn.SERVICE_OPTS['omero.group']='-1'
i=conn.getObject('Image',185001)
print(i.getPixelSizeX())
print(i.getPixelSizeX(units="MICROMETER")) All OMERO.py versions between 5.13.0 and 5.19.5 produced the following output:
Older versions failed to connect due to SSL issues. Matching your code history review, it looks like this has been the behavior of the API for the last decade. Do you have more specifics on which version of OMERO.py would have been returning the Length object by default? Or is the issue not about the |
Hi @sbesson, thank you for the thorough testing.
I was wrong, nothing changed then. As you say it's just about I checked in the history of commit in the PR and the last commit introduced the error, that was not shown in the screenshots above. thus getting a Adding back
def image_to_html(image):
import base64
try:
pixsizeX = '{:.3f}'.format(image.getPixelSizeX())
pixsizeY = '{:.3f}'.format(image.getPixelSizeY())
pixsizeZ = '{:.3f}'.format(image.getPixelSizeZ())
UnitX = image.getPixelSizeX(units=True).getUnit()
UnitY = image.getPixelSizeY(units=True).getUnit()
UnitZ = image.getPixelSizeZ(units=True).getUnit()
except:
pixsizeX, pixsizeY, pixsizeZ = 'na', 'na', 'na'
UnitX, UnitY, UnitZ = 'na', 'na', 'na' |
An example of the issue from image.sc
https://forum.image.sc/t/fetch-and-save-ome-tiff-from-omero-to-local-directory-with-metadata/105507/3
It seems to me that something changed about
image.getPixelSizeX()
(and Y and Z)With older versions of omero-py I was used to get this output:
but it now only returns a float, so
0.16249999999999787
in this case.What happens with
image_to_html
is that it tries to get the unit of the value from the returned pixel size. But since we get a float, it throws an error. The error is caught and the output defaults to(na, na, an)
It's still possible to get the old output by specifying the pixel units:
image.getPixelSizeX(units="MICROMETER")
.In the case of
image_to_html
, it would thus need to find the most appropriate unit to express the pixel size with as few 0s as possible.I had a look with git blame to https://github.com/ome/omero-py/blame/master/src/omero/gateway/__init__.py#L9997 and https://github.com/ome/omero-py/blame/master/src/omero/gateway/__init__.py#L292 but everything is 10yo.
I don't know what happened in between.
@jo-mueller
The text was updated successfully, but these errors were encountered: