hadim / read-roi

Read ROI files .zip or .roi generated with ImageJ.
BSD 3-Clause "New" or "Revised" License
51 stars 22 forks source link

Implement counters for multi-point rois #8

Closed fabiansvara closed 5 years ago

fabiansvara commented 5 years ago

This fork implements the "counters" for multi-point ROIs, i.e. it allows you to load the z coordinates of the points, which is quite important when working with 3D microscopy data.

The code had to be unfortunately restructured a bit to mirror the logic in the Java implementation at https://imagej.nih.gov/ij/developer/source/ij/io/RoiDecoder.java.html while still staying as close as possible to it. Note how, in RoiDecoder.java, control breaks out of the big switch statement (line 220) at line 297. Because Python has no switch / break and no way to jump out of nested ifs, the python implementation had a bug where point ROIs would incorrectly be assigned the default "freeroi" type. (The same bug would also occur for freehand type, see break at line 314).

Long story short, I wrapped the code that would be the switch body in Java in a python function extract_basic_roi_data() so that return can be used as a replacement for switch / break.

hadim commented 5 years ago

Thank you!