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

an integer is required (got type str) #1

Closed MichalZG closed 7 years ago

MichalZG commented 7 years ago

Hi,

I try to use your module but I got a error:

In [39]: read_roi_zip('11692a_x40_06_nuclei.tif.zip')

TypeError                                 Traceback (most recent call last)
<ipython-input-39-8b081d0c8add> in <module>()
----> 1 read_roi_zip('11692a_x40_06_nuclei.tif.zip')

/home/pi/Programs/anaconda2/envs/bioformats/lib/python2.7/site-packages/read_roi/_read_roi.pyc in read_roi_zip(zip_path)
    304     zf = zipfile.ZipFile(zip_path)
    305     for n in zf.namelist():
--> 306         rois.update(read_roi_file(zf.open(n)))
    307     return rois

/home/pi/Programs/anaconda2/envs/bioformats/lib/python2.7/site-packages/read_roi/_read_roi.pyc in read_roi_file(fpath)
    124 
    125     magic = get_byte(data, list(range(4)))
--> 126     magic = "".join([chr(c) for c in magic])
    127 
    128     # TODO: raise error if magic != 'Iout'

TypeError: an integer is required

11692a_x40_06_nuclei.tif.zip

The roi file was created by ImageJ, can you give me some hint where is the problem?

hadim commented 7 years ago

Your roi file works well on my machine. What Python version do you use ? Did you get the last read_roi version ?

MichalZG commented 7 years ago

Ok I checked and on python=3.5 everything work well. Error occurs if in environment is only python 2.7. Now I see there is Python > 2.7 and > 3.4 not OR:)

Thanks!

hadim commented 7 years ago

I only use Python 3.4 and above. I will change the README to reflect that. Any chance for you to use Python 3 ?

MichalZG commented 7 years ago

Any chance for you to use Python 3 ?

yes of course, there is no problem:)

hadim commented 7 years ago

Thank you.

cxrodgers commented 7 years ago

If anyone else is trying to make it work with Python 2, you just need to add the line: data = map(ord, data) in the function read_roi_file. https://github.com/cxrodgers/read-roi/commit/4418cfe834a2d2973fda43294420d0689d4a88c0