imagepy icon indicating copy to clipboard operation
imagepy copied to clipboard

I hava some errors when I load ImageJ RoiSet.zip

Open FengZhiheng opened this issue 6 years ago • 9 comments

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''

FengZhiheng avatar Oct 24 '19 08:10 FengZhiheng

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

BioinfoTongLI avatar Oct 30 '19 13:10 BioinfoTongLI

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.

FengZhiheng avatar Oct 31 '19 03:10 FengZhiheng

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.

BioinfoTongLI avatar Oct 31 '19 09:10 BioinfoTongLI

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.

FengZhiheng avatar Oct 31 '19 11:10 FengZhiheng

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?

BioinfoTongLI avatar Oct 31 '19 14:10 BioinfoTongLI

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 avatar Nov 03 '19 03:11 yxdragon

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

yxdragon avatar Nov 04 '19 04:11 yxdragon

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

BioinfoTongLI avatar Nov 04 '19 15:11 BioinfoTongLI

@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.

yxdragon avatar Nov 05 '19 03:11 yxdragon