Before using pydicom to read dicom files, everything is normal, but when reading a batch of data recently, an error will be reported
Read code
file = pydicom.read_file(filepath) data = file.pixel_array
The problem lies in the attribute of pixel_array, the error is reported as follows
OSError Traceback (most recent call last) c:\python35\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(dicom_dataset) 196 fio = io.BytesIO(pixel_data) --> 197 decompressed_image = Image.open(fio) 198 except IOError as e: c:\python35\lib\site-packages\PIL\Image.py in open(fp, mode) 2571 raise IOError("cannot identify image file %r" -> 2572 % (filename if filename else fp)) 2573 OSError: cannot identify image file <_io.BytesIO object at 0x000002418FC85CA8> During handling of the above exception, another exception occurred: NotImplementedError Traceback (most recent call last) <ipython-input-55-c00f3f09682d> in <module>() ----> 1 file.pixel_array c:\python35\lib\site-packages\pydicom\dataset.py in pixel_array(self) 899 The Pixel Data (7FE0,0010) as a NumPy ndarray. 900 """ --> 901 self.convert_pixel_data() 902 return self._pixel_array 903 c:\python35\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self) 845 ) 846 --> 847 raise last_exception 848 849 def decompress(self): c:\python35\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self) 813 try: 814 # Use the handler to get a 1D numpy array of the pixel data --> 815 arr = handler.get_pixeldata(self) 816 self._pixel_array = reshape_pixel_array(self, arr) 817 c:\python35\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(dicom_dataset) 197 decompressed_image = Image.open(fio) 198 except IOError as e: --> 199 raise NotImplementedError(e.strerror) 200 UncompressedPixelData.extend(decompressed_image.tobytes()) 201 except Exception: NotImplementedError: None
Solution:
this compression format can not be read with pydicom, using SimpleITK can solve
file = sitk.ReadImage (filepath) data = sitk.GetArrayFromImage (file)
Read More:
- How to Solve Chrome error: ERR_CACHE_READ_FAILURE
- [Solved] import mxnet Error: OSError: libcudart.so.8.0: cannot open shared object file: No such file or directory
- How to Solve Error: could not read ok from ADB Server.failed to start daemon error: cannot connect to daemon
- How to Solve Clickhouse restart error: Cannot obtain value of path from config file…
- How to Solve Error:cannot open source file “QtWidgets/QMainWindow”
- How to Solve dtd Error in MybatisGenerator.xml file
- How to Solve Svn upload so File Error
- How to Solve Spring MVC upload file error
- How to Solve Loadrunner Error: Failed to find .cfg file
- How to Solve Error: Heartbeating to master:7182 failed.
- How to Solve Hadoop Missing Hadoop.dll and winutils.exe file error
- Websocket: How to Fix Error Read Econnreset
- How to Solve ModuleNotFoundError: No module named ‘_bz2‘
- [Solved] Hbase …ERROR: Unable to read .tableinfo from file:/hbaseData/data/default/table1/xxxx
- How to Solve Fopen bus error
- Sqllineage Error: OSError: [Errno 99] Cannot assign requested address
- [Solved] HTML report error, httprunner 3. X HTML report error, oserror: [winerror 6] handle invalid (resolved)
- [Solve] DAAS Pubulish Error: Failed read-only file system
- How to Solve TypeError: type numpy.ndarray doesn‘t define __round__ method