macronucleus / Chromagnon

Image correction software for chromatic shifts in fluorescence microscopic images
GNU General Public License v2.0
21 stars 5 forks source link

'MultiTiffReader' object has no attribute 'dtype' #14

Closed carandraug closed 5 years ago

carandraug commented 5 years ago

Our users are unable to open tif files, only dv. Here's the traceback

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/PriCommon/listbox.py", line 365, in OnDropFiles
    self.list.addFiles(filenames)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/PriCommon/listbox.py", line 250, in addFiles
    self.addFile(fn)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/PriCommon/listbox.py", line 273, in addFile
    imgio_dialog(e, self)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/PriCommon/listbox.py", line 266, in addFile
    h = self.load_func(fn)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/chromagnon.py", line 229, in _load_func
    h = imgio.Reader(fn)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/__init__.py", line 35, in Reader
    return _switch(fn, read=True, *args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/__init__.py", line 97, in _switch
    return klasses['tif'](fn, *args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/multitifIO.py", line 30, in __init__
    generalIO.GeneralReader.__init__(self, fn)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/generalIO.py", line 34, in __init__
    self.openFile()
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/multitifIO.py", line 39, in openFile
    self.readHeader()
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/multitifIO.py", line 112, in readHeader
    self.setDim(p.imagewidth, p.imagelength, nz, nt, nw, s.dtype, waves, imgSeq)
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/generalIO.py", line 149, in setDim
    self.organize()
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/generalIO.py", line 161, in organize
    self.setSecSize()
  File "/usr/local/lib/python2.7/dist-packages/Chromagnon/imgio/generalIO.py", line 174, in setSecSize
    self._secByteSize = int(N.nbytes[self.dtype] * npxls) + self._secExtraByteSize
AttributeError: 'MultiTiffReader' object has no attribute 'dtype'
carandraug commented 5 years ago

We're running Chromagnon on python 2.7 in Debian stable (stretch) with javabridge 1.0.18, tifffile 0.15.1, python-bioformats 1.5.2, numpy 1.12, and scipy 0.18.

macronucleus commented 5 years ago

I am sorry for the problem to read tif files.

Would you try the latest version (v0.66) which is currently available only as the source distribution? Although I believe I have fixed the problem, please post new error messages if this version also fails to read the tif files.

carandraug commented 5 years ago

Reading a tif file now fails with:

Traceback (most recent call last):
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/chromagnon.py", line 111, in <lambda>
    self.refAddButton = G.makeButton(self, box, lambda ev:self.OnChooseImgFiles(ev,'ref'), title='Reference files', tip='', enable=True)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/chromagnon.py", line 314, in OnChooseImgFiles
    ll.addFiles(fns)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/PriCommon/listbox.py", line 252, in addFiles
    self.addFile(fn)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/PriCommon/listbox.py", line 275, in addFile
    imgio_dialog(e, self)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/PriCommon/listbox.py", line 268, in addFile
    h = self.load_func(fn)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/chromagnon.py", line 235, in _load_func
    return listbox.imgio_dialog(e, self)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/chromagnon.py", line 233, in _load_func
    h = imgio.Reader(fn)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/imgio/__init__.py", line 35, in Reader
    return _switch(fn, read=True, *args, **kwds)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/imgio/__init__.py", line 97, in _switch
    return klasses['tif'](fn, *args, **kwds)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/imgio/multitifIO.py", line 30, in __init__
    generalIO.GeneralReader.__init__(self, fn)
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/imgio/generalIO.py", line 34, in __init__
    self.openFile()
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/imgio/multitifIO.py", line 39, in openFile
    self.readHeader()
  File "/home/carandraug/.local/lib/python2.7/site-packages/Chromagnon/imgio/multitifIO.py", line 111, in readHeader
    raise ValueError('data type not found')
ValueError: data type not found

Adding @halidi to the issue since it's she who's actually been having the problem.

macronucleus commented 5 years ago

Thank you for your feedback. The new version of Chromagnon (v0.67) reads your tiff file by BioFormats, that may work for the time being (only the source code distribution is available now). However, this workaround should slow down reading tiff files compared to the native python codes,

If you are willing to help us, it would be great if you could share the file. You can crop a small region of background image since all I need is the metadata of your file.

carandraug commented 5 years ago

If you are willing to help us, it would be great if you could share the file.

Sure, that should be no problem. What email address should we send the file?

@halidi : Nadia, could you please send the tif file to @macronucleus (I guess via Oxfile)?

macronucleus commented 5 years ago

Great!

Would you send your file using this link? https://fexcc.nict.go.jp/user/~th/ac3btc52v5kpgg2gamtjgsja4s password: pU2Hs3KChA

The link is valid until 2019/01/09 23:59. Thank you so much.

nadiahalidi commented 5 years ago

Just done so. Thanks so much.

macronucleus commented 5 years ago

Thank you for sharing your file. By examining your file, I found that some older versions of numpy (1.12) used different dtype than later versions of numpy (boolean evaluation of dtype was False in the older versions of numpy). I fixed my code to be compatible with older versions of numpy (please get the source distribution of Chromagnon v0.68). Alternatively you can just update numpy to 1.13.3-1.15.0, which I have tested successfully with older Chromagnon.

macronucleus commented 5 years ago

Please use Chromagnon v0.69. I found v0.68 was broken to read other file formats.

carandraug commented 5 years ago

We have tried version 0.69 and can confirm that this issue is now fixed. Thank you.