Skip to content
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

roi utils zero division fix #278

Merged
merged 1 commit into from
Feb 23, 2021
Merged

Conversation

will-moore
Copy link
Member

This fixes an error I saw on outreach server during today's training (see below).

To test:

  • Draw a horizontal line on an image and save
  • Select the Image and run Analysis Scripts > Plot_Profile

Should run without an error and generate a csv file.

Traceback (most recent call last):
  File "./script", line 305, in <module>
    run_script()
  File "./script", line 293, in run_script
    file_anns, message = process_images(conn, script_params)
  File "./script", line 224, in process_images
    conn, script_params, image, polylines, line_width, f)
  File "./script", line 65, in process_polylines
    the_z, the_c, the_t)
  File "/opt/omero/server/venv3/lib64/python3.6/site-packages/omero/util/roi_handling_utils.py", line 54, in get_line_data
    rads = math.atan(old_div(float(line_x),line_y))
  File "/opt/omero/server/venv3/lib64/python3.6/site-packages/past/utils/__init__.py", line 95, in old_div
    return a / b
ZeroDivisionError: float division by zero

@will-moore will-moore changed the title Use atan2() to avoid zero division roi utils zero division fix Feb 19, 2021
@jburel
Copy link
Member

jburel commented Feb 19, 2021

I drew a line on https://outreach.openmicroscopy.org/webclient/?show=image-9539 (trainer-1)
but I did not get an error when running the script

@will-moore
Copy link
Member Author

@jburel I realise that the error I got from image: https://outreach.openmicroscopy.org/webclient/?show=image-11110 was actually due to the PolyLine, since we try to calculate the Plot Profile for each section in a PolyLine, and there are horizontal lines within that PolyLine. So, you will see the error with this image.

When you try to draw a "horizontal" line in iviewer, it's almost impossible since it doesn't snap to integer pixel values. The Y coordinates of the lines you drew are shown in the iviewer as "72.0" but are actually saved as:

"Y1": 71.95605468749991,
"Y2": 72.03339843749991

I used a script to add horizontal line to that image https://outreach.openmicroscopy.org/webclient/?show=image-9539 so that you will see the error with that image now.

@jburel
Copy link
Member

jburel commented Feb 19, 2021

I managed to reproduce the error against outreach now

@will-moore
Copy link
Member Author

Tests added in ome/openmicroscopy#6264

Copy link
Member

@joshmoore joshmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change LGTM. I checked omero-py and omero-web for other uses of atan+old_div and didn't find any.

@jburel
Copy link
Member

jburel commented Feb 23, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants