Coder Social home page Coder Social logo

Comments (7)

rossant avatar rossant commented on May 1, 2024

I also have a DICOM dir with multiple sequences that cannot be read:

Reading DICOM (examining files): 235/235 files (100.0%)
  Found 5 correct series.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/cyrille/git/imageio/imageio/core/functions.py", line 419, in mvolread
    for im in reader:
  File "/home/cyrille/git/imageio/imageio/core/format.py", line 372, in iter_data
    i, n = 0, self.get_length()
  File "/home/cyrille/git/imageio/imageio/core/format.py", line 317, in get_length
    return self._get_length()
  File "/home/cyrille/git/imageio/imageio/plugins/dicom.py", line 133, in _get_length
    self._data = dcm.get_numpy_array()
  File "/home/cyrille/git/imageio/imageio/plugins/_dicom.py", line 382, in get_numpy_array
    value = self._read_undefined_length_value()
  File "/home/cyrille/git/imageio/imageio/plugins/_dicom.py", line 275, in _read_undefined_length_value
    raise EOFError("End of file reached before sequence "
EOFError: End of file reached before sequence delimiter found.

otherwise, any ideas on how to just extract a single series?

from imageio.

almarklein avatar almarklein commented on May 1, 2024

Sorry, not really. PyDicom might do it if you're lucky. Any chance for me to get my hands on that data? Or can you have a look?

A first simple check could be to check what file it chokes on. If this is some kind of meta file, we might be able to fix it by detecting that and skipping it. If it is a real file with data, we should make the plugin able to read it.

from imageio.

rossant avatar rossant commented on May 1, 2024

pydicom didn't work because the file was compressed. I managed to uncompress it with gdcm --raw and then imageio worked.

from imageio.

almarklein avatar almarklein commented on May 1, 2024

Ok, good. Do you know how we can detect that, so we can give a more appropriate error?

from imageio.

ivoflipse avatar ivoflipse commented on May 1, 2024

I just ran into the same problem using pydicom and had hoped that imageio would have been able to read the data (alas it did not).

pydicom returns a helpful error saying which UID wasn't supported:
RuntimeError: The simple dicom reader can only read files with uncompressed image data (not u'1.2.840.10008.1.2.4.90')
Which according to this page is a JPEG 2000 Image Compression (Lossless Only).

I reckon it would be easier to have the plugin add pydicom as an optional dependency to imageio or have people pass along a pydicom object, from which you can ask whatever you want.

In the end I ended up opening it with GDCM, but I'd rather not depend on that. So any hints on what would need to happen to make similar functionality available in imageio?

from imageio.

almarklein avatar almarklein commented on May 1, 2024

Firstly, the dicom plugin needs better error reporting on this.

The dicom plugin in imageio was made standalone because at the time of writing pydicom was not available in py3k. It actually uses almost the same code. The extra code in pydicom is for 95% or so aimed at reading all the fancy tags, and for writing dicom files. At some point imageio would need a solution to allow reading more/all tags from the data though.

The problem with JPEG 2000 is that (afaik) there is no way to decode it from pure Python. There are libs/programs that can, so we might look into a solution like "please install X to read JPEG 2000" files, where X can be GDCM, DCMTK, or maybe even libjpeg.

from imageio.

almarklein avatar almarklein commented on May 1, 2024

@rossant i suspect that the issue that you saw was due to a bug where the reader tried to read a specific JPEG format.

@ivoflipse the error message is now a bit more clear

I added primitive funtionality to try to recover the dcmtkdjpeg executable (from Office dcmtk) and use it to convert the image on the fly. This is something that should probably extended in the future, but this is a start.

For the record, the original issue of not being able to load multi-page images still stands, AFAIK.

from imageio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.