Image-Py / imagepy

Image process framework based on plugin like imagej, it is esay to glue with scipy.ndimage, scikit-image, opencv, simpleitk, mayavi...and any libraries based on numpy
http://imagepy.org
BSD 4-Clause "Original" or "Old" License
1.29k stars 330 forks source link

I hava some errors when I load ImageJ RoiSet.zip #71

Open FengZhiheng opened 4 years ago

FengZhiheng commented 4 years ago

image

error information is

'self.run(para) File "C:\Users\XXX\Desktop\ImagePy-64\ImagePy\programs\lib\site-packages\imagepy\menus\File\Import\roi_plg.py", line 30, in run img[polygon(ls[i]['y'], ls[i]['x'], img.shape)] = int(i) KeyError: 'y''

BioinfoTongLI commented 4 years ago

Hi, @FengZhiheng, Thank you for filing the issue. It seems that some features such as "x" and "y" are not saved when you save the roiset in ij. Can you maybe send an example of your RoiSet.zip? Tong

FengZhiheng commented 4 years ago

Hi, @FengZhiheng, Thank you for filing the issue. It seems that some features such as "x" and "y" are not saved when you save the roiset in ij. Can you maybe send an example of your RoiSet.zip? Tong

Ok! It's very kind of you for helping me out.

BioinfoTongLI commented 4 years ago

I successfully opened the RoiSet.zip you sent to me. Is it the same one that caused the error? It seems that the one you sent to me has no problem.

FengZhiheng commented 4 years ago

RoiSet1.zip Please try this one. This one can cause the error I met a few days ago. I used Fiji ROI manager and saves this ROI.zip file.

BioinfoTongLI commented 4 years ago

Ok, I confirm it's a glitch. By default, imagepy takes the xy coordinates to draw a polygon. However, IJ sometimes save the bounding box instead of the coordinates. @yxdragon , is there a way to draw a polygon with bounding box?

yxdragon commented 4 years ago

just using slice to fill bounding box, such as img[top:bot, left:right] = lab. the trouble is, bounding boxes may cross with each other, but for the labled image, one pixel just has one value.

yxdragon commented 4 years ago

I saw the roi file is a collection of oval object like this: {'type': 'oval', 'left': 154, 'top': 115, 'width': 39, 'height': 38, 'name': '0134-0173', 'position': 0} It is not a polygon object, so we need draw it by skimage.draw.ellipse

rs, cs = ellipse(top+height/2, left+width/2, height/2, width/2) img[rs, cs] = lab

BioinfoTongLI commented 4 years ago

https://github.com/Image-Py/imagepy/pull/72#issue-336336231 PR created for a quick-fix @FengZhiheng

yxdragon commented 4 years ago

@FengZhiheng merged, have a try. @BioinfoTongLI ellipse method need a shape parameter to cut the rs, cs out of image to make sure that img[rs, cs] is safe.