Comments (7)
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.
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.
pydicom didn't work because the file was compressed. I managed to uncompress it with gdcm --raw
and then imageio worked.
from imageio.
Ok, good. Do you know how we can detect that, so we can give a more appropriate error?
from imageio.
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.
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.
@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)
- super slow video reads HOT 6
- imageio v2.33.0 requieres Pillow>=9.1.0 for GIFs HOT 1
- Trouble using freeimage plugin on MacOS arm64 HOT 2
- 2.33.1: pytest is failing in 5 units HOT 1
- [Question] What tonemapping method does the imageio library use when reading HDR images? HOT 2
- title of the gif got stacked together HOT 2
- UnicodeDecodeError if metadata is not UTF-8 encoded (pyav plugin) HOT 3
- [request] more color/palette control on GIF writing HOT 3
- Transition from v2 ffmpeg read/write to v3 pyav read/write: quality, batching HOT 7
- AttributeError: 'SeekableFileObject' object has no attribute 'readline' HOT 2
- Find out what kwargs are available for each function
- Only partial DICOM layers loading in Google Colab using imageio.volread HOT 6
- How to suppress FFMPEG warning for BluRay files? HOT 1
- How to add a pause between loops of a GIF? HOT 1
- Wrong time unit in documentation of pillow_legacy
- support read gzip data in .nrrd file HOT 2
- can I get frame image filename in imiter when using ffmpeg plugin?
- Test failures with NumPy 2.0.0rc1 HOT 2
- Please make it possible to run tests against `test_images` without Internet access HOT 12
- Unable to write colored gifs with pyav HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imageio.