-Some polygon ROIs are read in correctly.
-For some polygon ROIs, all x coordinates have a large negative offset (ca -60.000), while the y is correct
-With the freehand ROIs, I observed all four cases: correct ROIs, large negative offsets in x while y is ok, the reverse, and both x and y with large negative offsets.
I also found out that the following function from another github user works correctly on the same ROI file: https://github.com/tdsmith/ijroi
I attach my ROI file, a screenshot of the correct ROIs in Image J and the incorrectly read-in ROIs plotted in python.
0 x [2104, 2302, 2573, 2729, 2833]
y [6647, 6605, 6428, 6251, 6167]
1 x [4709, 4063, 3875, 3844, 3646]
y [5073, 4751, 4615, 4417, 4313]
2 x [5605, 6032, 6345, 6522, 6741]
y [5521, 5834, 6032, 6188, 6428]
3 x [5188, 5199, 5167, 5240, 5334]
y [4928, 4844, 4761, 4709, 4709]
4 x [4844, 4678, 4553, 4553, 4542]
y [9126, 8897, 8720, 8616, 8397]
5 x [-57316, -57128, -57087, -57149, -57285]
y [4230, 4323, 4177, 4042, 4021]
6 x [-59066, -59108, -59108, -59108, -59108]
y [3334, 3365, 3386, 3396, 3406]
7 x [1583, 1541, 1531, 1521, 1510]
y [3907, 3907, 3907, 3907, 3907]
8 x [2062, 2104, 2115, 2115, 2135]
y [-57649, -57670, -57681, -57691, -57733]
9 x [-57431, -57472, -57493, -57504, -57514]
y [-57076, -57087, -57128, -57139, -57149]
import original_read_roi
import matplotlib.pyplot as plt
import numpy as np
a = original_read_roi.read_roi_zip('hajdu_20180205_0_RBPMS_referenceROIs_day2_nozoom.zip')
for i,k in enumerate(list(a.keys())):
plt.plot(np.array(a[k]['x']),-(np.array(a[k]['y'])),label=str(i))
print(i,'x',a[k]['x'][:5],'\n y',a[k]['y'][:5])
plt.title('all rois')
plt.legend(loc=6)
plt.show()
plt.figure(figsize=(10,10))
for i,k in enumerate(list(a.keys())):
if a[k]['type']=='polygon':
plt.plot(a[k]['x'],-(np.array(a[k]['y'])))
plt.title('polygon rois, uncorrected')
plt.show()
#
plt.figure(figsize=(10,10))
for i,k in enumerate(list(a.keys())):
if a[k]['type']=='polygon':
if a[k]['name']=='00005-04172-08334':
plt.plot(np.array(a[k]['x'])+65307,-(np.array(a[k]['y'])),label='corrected outlier (added 65307 to y coordinate)')
else:
plt.plot(a[k]['x'],-(np.array(a[k]['y'])))
plt.title('polygon rois, corrected')
plt.legend()
plt.show()
for i,k in enumerate(list(a.keys())):
if a[k]['type']=='freehand':
plt.plot(np.array(a[k]['x']),-(np.array(a[k]['y'])),label=str(i))
plt.title('only freehand rois')
plt.legend()
plt.show()