#868229 NotImplementedError: Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array #868229
- Package:
- python3-nibabel
- Source:
- nibabel
- Submitter:
- Mathieu Malaterre
- Date:
- 2021-12-22 22:15:03 UTC
- Severity:
- normal
There is something a bit odd with DICOM plugin, here is what I get:
% nib-dicomfs -v -v -v -v /tmp/raw /tmp/foo
...
matched: (<bound method _Series.nifti_size of <nibabel.dft._Series
object at 0x7f4b11e4a910>>, <bound method _Series.as_nifti of
<nibabel.dft._Series object at 0x7f4b11e4a910>>)
open /1.3.12.2.1107.5.2.30.26321.30000017030713461021800000007/20170307_122808.515000/3/3.nii
path:/1.3.12.2.1107.5.2.30.26321.30000017030713461021800000007/20170307_122808.515000/3/3.nii
part:1.3.12.2.1107.5.2.30.26321.30000017030713461021800000007
path:/1.3.12.2.1107.5.2.30.26321.30000017030713461021800000007/20170307_122808.515000/3/3.nii
part:20170307_122808.515000
path:/1.3.12.2.1107.5.2.30.26321.30000017030713461021800000007/20170307_122808.515000/3/3.nii
part:3
path:/1.3.12.2.1107.5.2.30.26321.30000017030713461021800000007/20170307_122808.515000/3/3.nii
part:3.nii
return
reading 1/13
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/fuse.py", line 362, in __call__
return apply(self.func, args, kw)
File "/usr/lib/python2.7/dist-packages/fuse.py", line 778, in wrap
res = fun(*a, **kw)
File "/usr/bin/nib-dicomfs", line 156, in open
self.fhs[i] = matched_path[1]()
File "/usr/lib/python2.7/dist-packages/nibabel/dft.py", line 173, in as_nifti
data[i, :, :] = d.pixel_array
File "/usr/lib/python2.7/dist-packages/dicom/dataset.py", line 417,
in pixel_array
return self._get_pixel_array()
File "/usr/lib/python2.7/dist-packages/dicom/dataset.py", line 399,
in _get_pixel_array
raise NotImplementedError("Pixel Data is compressed in a format
pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does
not yet handle. Cannot return array
getattr /
return root
However input is simply:
$ gdcminfo /tmp/raw
filename: /tmp/raw/MR0001.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0005.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0010.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0008.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0006.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0009.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0012.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0003.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0007.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0013.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0002.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0011.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
filename: /tmp/raw/MR0004.dcm
MediaStorage is 1.2.840.10008.5.1.4.1.1.4 [MR Image Storage]
TransferSyntax is 1.2.840.10008.1.2.1 [Explicit VR Little Endian]
NumberOfDimensions: 2
Dimensions: (1024,1024,1)
SamplesPerPixel :1
BitsAllocated :16
BitsStored :12
HighBit :11
PixelRepresentation:0
ScalarType found :UINT16
PhotometricInterpretation: MONOCHROME2
PlanarConfiguration: 0
TransferSyntax: 1.2.840.10008.1.2.1
Origin: (-969.322,-995.593,55.9534)
Spacing: (1.875,1.875,2.5)
DirectionCosines: (1,0,0,0,1,0)
Rescale Intercept/Slope: (0,1)
Orientation Label: AXIAL
before anything: could you share this input file publicly by any chance? (if not) could you try with current upstream master of nibabel which progressed forward quite a bit without a release: 2.1.0-370-gf5dec180 and also -- what version of python-dicom you have? I guess 0.9.9... (that is where exception comes from). upstream also progressed quite forward without a release v0.9.9-448-g5b4d0f3 https://github.com/darcymason/pydicom/ but probably it is just that indeed some rare JPEG2000 or smth like that was used to compress the data, which pydicom doesn't handle. I wish pydicom provided a bit more informative exception though ;)
Hi, Well I could reproduce with the very first file I took from gdcmData. So this is easy. Step: $ cd /tmp $ wget "https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw" $ mkdir bug $ gdcmconv --raw SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm* bug/raw.dcm $ nib-dicomfs /tmp/bug /tmp/demo In another shell: $ find /tmp/demo/ Cheers
Great -- thanks! but seems to work for me just fine
so -- first tried with most recent devel of nibabel and pydicom -- worked...
(see below II.). Then tried with the ones installed -- also worked (I.)
(welp is my command you could find at http://git.onerussian.com/?p=etc/bash.git;a=blob;f=.bash/bashrc/30_aliases_sh;h=28fa4ad215839110953f598becbbbd586ff8edb0;hb=HEAD#l1009
if interested)
I.
$> which nib-dicomfs
/usr/bin/nib-dicomfs
2 27593.....................................:Thu 13 Jul 2017 11:29:48 AM EDT:.
hopa:/tmp
$> welp nibabel
PATH : /usr/lib/python2.7/dist-packages/nibabel/__init__.pyc
SRC PATH : /usr/lib/python2.7/dist-packages/nibabel/__init__.py
VERSION : 2.1.0
__version__: '2.1.0'
PACKAGE : python-nibabel
ii python-nibabel 2.1.0-1 all Python bindings to various neuroimaging data formats
python-nibabel:
Installed: 2.1.0-1
Candidate: 2.1.0-1
Version table:
*** 2.1.0-1 600
100 http://http.debian.net/debian stretch/main amd64 Packages
100 http://http.debian.net/debian stretch/main i386 Packages
600 http://http.debian.net/debian sid/main amd64 Packages
600 http://http.debian.net/debian sid/main i386 Packages
100 /var/lib/dpkg/status
2.1.0-1~nd90+1 500
500 http://neuro.debian.net/debian stretch/main amd64 Packages
500 http://neuro.debian.net/debian stretch/main i386 Packages
2 27594.....................................:Thu 13 Jul 2017 11:29:54 AM EDT:.
hopa:/tmp
$> welp dicom
PATH : /usr/lib/python2.7/dist-packages/dicom/__init__.pyc
SRC PATH : /usr/lib/python2.7/dist-packages/dicom/__init__.py
VERSION : Not found
__version__: '0.9.9'
PACKAGE : python-dicom
ii python-dicom 0.9.9-2 all DICOM medical file reading and writing (Python 2)
python-dicom:
Installed: 0.9.9-2
Candidate: 0.9.9-2
Version table:
*** 0.9.9-2 600
100 http://http.debian.net/debian stretch/main amd64 Packages
100 http://http.debian.net/debian stretch/main i386 Packages
600 http://http.debian.net/debian sid/main amd64 Packages
600 http://http.debian.net/debian sid/main i386 Packages
100 /var/lib/dpkg/status
0.9.9-1~nd80+1+nd90+1 500
500 http://neuro.debian.net/debian stretch/main amd64 Packages
500 http://neuro.debian.net/debian stretch/main i386 Packages
2 27595.....................................:Thu 13 Jul 2017 11:29:58 AM EDT:.
hopa:/tmp
$> nib-dicomfs /tmp/bug /tmp/demo &
[1] 8114
2 27596 [1].....................................:Thu 13 Jul 2017 11:30:04 AM EDT:.
hopa:/tmp
$> find /tmp/demo
/tmp/demo
/tmp/demo/xxxx^xxxxxxx^R
/tmp/demo/xxxx^xxxxxxx^R/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.png
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.nii
II.
$> virtualenv --system-site-packages test-dicom
Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/test-dicom/bin/python2
Also creating executable in /tmp/test-dicom/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
2 27576.....................................:Thu 13 Jul 2017 11:25:43 AM EDT:.
hopa:/tmp
$> source test-dicom/bin/activate
(test-dicom) 2 27577.....................................:Thu 13 Jul 2017 11:25:48 AM EDT:.
hopa:/tmp
$> pip install --upgrade git+https://github.com/darcymason/pydicom/
Collecting git+https://github.com/darcymason/pydicom/
Cloning https://github.com/darcymason/pydicom/ to ./pip-_KHMlx-build
Installing collected packages: pydicom
Found existing installation: pydicom 0.9.9
Not uninstalling pydicom at /usr/lib/python2.7/dist-packages, outside environment /tmp/test-dicom
Running setup.py install for pydicom ... done
Successfully installed pydicom-1.0.0a1
(test-dicom) 2 27578.....................................:Thu 13 Jul 2017 11:26:03 AM EDT:.
hopa:/tmp
$> pip install --upgrade git+https://github.com/nipy/nibabel
Collecting git+https://github.com/nipy/nibabel
Cloning https://github.com/nipy/nibabel to ./pip-90D2wS-build
Installing collected packages: nibabel
Found existing installation: nibabel 2.1.0
Not uninstalling nibabel at /usr/lib/python2.7/dist-packages, outside environment /tmp/test-dicom
Running setup.py install for nibabel ... done
Successfully installed nibabel-2.2.0.dev0
pip install --upgrade git+https://github.com/nipy/nibabel 10.36s user 2.28s system 22% cpu 56.005 total
(test-dicom) 2 27579.....................................:Thu 13 Jul 2017 11:27:10 AM EDT:.
hopa:/tmp
$> wget "https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw"
--2017-07-13 11:27:23-- https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net)|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/dicom]
Saving to: ‘SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw’
SIEMENS_MOSAIC_12Bit [ <=> ] 128.31K --.-KB/s in 0.1s
2017-07-13 11:27:23 (879 KB/s) - ‘SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw’ saved [131390]
(test-dicom) 2 27580.....................................:Thu 13 Jul 2017 11:27:24 AM EDT:.
hopa:/tmp
$> mkdir bug
(test-dicom) 2 27581.....................................:Thu 13 Jul 2017 11:27:28 AM EDT:.
hopa:/tmp
$> gdcmconv --raw SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm* bug/raw.dcm
(test-dicom) 2 27582.....................................:Thu 13 Jul 2017 11:27:35 AM EDT:.
hopa:/tmp
$> nib-dicomfs /tmp/bug /tmp/demo
fuse: bad mount point `/tmp/demo': No such file or directory
(test-dicom) 2 27583 ->1.....................................:Thu 13 Jul 2017 11:27:45 AM EDT:.
hopa:/tmp
$> mkdir demo
(test-dicom) 2 27584.....................................:Thu 13 Jul 2017 11:27:53 AM EDT:.
hopa:/tmp
$> nib-dicomfs /tmp/bug /tmp/demo
----
$> find /tmp/demo
/tmp/demo
/tmp/demo/xxxx^xxxxxxx^R
/tmp/demo/xxxx^xxxxxxx^R/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.png
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.nii
$ cd /tmp
$ wget "https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw"
$ mkdir bug1
$ gdcmconv --raw SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm* bug1/raw.dcm
$ nib-dicomfs /tmp/bug1 /tmp/demo
$ find /tmp/demo
At this point output should be clean. Now let's try again with an
intermediate step:
$ sudo umount /tmp/demo
$ mkdir bug2
$ cp ~/buggy.dcm bug2/jpeg.dcm
$ nib-dicomfs /tmp/bug2 /tmp/demo
$ find /tmp/demo
At this point it is expected to get a funky output since it is
explitely mentionned that JPEG is not supported. But now that we have
made nib-dicomfs failed at least once, let's try original steps again:
$ sudo umount /tmp/demo
$ nib-dicomfs /tmp/bug1 /tmp/demo
$ find /tmp/demo
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/fuse.py", line 362, in __call__
return apply(self.func, args, kw)
File "/usr/bin/nib-dicomfs", line 141, in getattr
st.st_size = matched_path[0]()
File "/usr/lib/python2.7/dist-packages/nibabel/dft.py", line 156, in png_size
return len(self.as_png(index=index, scale_to_slice=scale_to_slice))
File "/usr/lib/python2.7/dist-packages/nibabel/dft.py", line 137, in as_png
data = d.pixel_array.copy()
File "/usr/lib/python2.7/dist-packages/dicom/dataset.py", line 417,
in pixel_array
return self._get_pixel_array()
File "/usr/lib/python2.7/dist-packages/dicom/dataset.py", line 399,
in _get_pixel_array
raise NotImplementedError("Pixel Data is compressed in a format
pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does
not yet handle. Cannot return array
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/fuse.py", line 362, in __call__
return apply(self.func, args, kw)
File "/usr/bin/nib-dicomfs", line 141, in getattr
st.st_size = matched_path[0]()
File "/usr/lib/python2.7/dist-packages/nibabel/dft.py", line 156, in png_size
return len(self.as_png(index=index, scale_to_slice=scale_to_slice))
File "/usr/lib/python2.7/dist-packages/nibabel/dft.py", line 137, in as_png
data = d.pixel_array.copy()
File "/usr/lib/python2.7/dist-packages/dicom/dataset.py", line 417,
in pixel_array
return self._get_pixel_array()
File "/usr/lib/python2.7/dist-packages/dicom/dataset.py", line 399,
in _get_pixel_array
raise NotImplementedError("Pixel Data is compressed in a format
pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does
not yet handle. Cannot return array
Let me try to find an example of dataset that I can share.
The original SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm reproduce the symptoms perfectly. Let me know if you can reproduce it now with the complete steps.
sorry... could you please provide a complete tiny "script" since in the above list of steps I just see cp ~/buggy.dcm bug2/jpeg.dcm and I see no way to get buggy.dcm and you did say that it worked fine on that downloaded SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm*
What I tried to say is: $ cp SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm ~/buggy.dcm does reproduce the symptoms (you'll see the error on your end). Let me know if this still does not make sense, and I'll try to write a tiny script otherwise.
someone needs to write it one way or another and I would appreciate if you do it ;) trying to undig myself from TODOs here
% cat tiny.sh #!/bin/sh -x pushd /tmp wget -O buggy.dcm "https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw" mkdir bug1 mkdir bug2 mkdir demo cp buggy.dcm bug1 gdcmconv --raw buggy.dcm bug2/raw.dcm nib-dicomfs /tmp/bug1 /tmp/demo & sleep 5 find /tmp/demo sudo umount /tmp/demo nib-dicomfs /tmp/bug2 /tmp/demo & sleep 5 find /tmp/demo popd Thanks
could rerun it)
$> cat tiny.sh
#!/bin/bash -x
pushd /tmp
rm -rf buggy.dcm bug1 bug2 demo
wget -O buggy.dcm "https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw"
mkdir bug1
mkdir bug2
mkdir demo
cp buggy.dcm bug1
gdcmconv --raw buggy.dcm bug2/raw.dcm
nib-dicomfs /tmp/bug1 /tmp/demo &
sleep 5
find /tmp/demo
sudo umount /tmp/demo
nib-dicomfs /tmp/bug2 /tmp/demo &
sleep 5
find /tmp/demo
sudo umount /tmp/demo
popd
$> ./tiny.sh
+ pushd /tmp
/tmp ~/trash
+ rm -rf buggy.dcm bug1 bug2 demo
+ wget -O buggy.dcm 'https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw'
--2017-07-17 11:34:51-- https://sourceforge.net/p/gdcm/gdcmdata/ci/master/tree/SIEMENS_MOSAIC_12BitsStored-16BitsJPEG.dcm?format=raw
Resolving sourceforge.net (sourceforge.net)... 216.34.181.60
Connecting to sourceforge.net (sourceforge.net)|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/dicom]
Saving to: ‘buggy.dcm’
buggy.dcm [ <=> ] 128.31K --.-KB/s in 0.06s
2017-07-17 11:34:52 (2.14 MB/s) - ‘buggy.dcm’ saved [131390]
+ mkdir bug1
+ mkdir bug2
+ mkdir demo
+ cp buggy.dcm bug1
+ gdcmconv --raw buggy.dcm bug2/raw.dcm
+ sleep 5
+ nib-dicomfs /tmp/bug1 /tmp/demo
+ find /tmp/demo
/tmp/demo
/tmp/demo/xxxx^xxxxxxx^R
/tmp/demo/xxxx^xxxxxxx^R/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.png
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.nii
+ sudo umount /tmp/demo
+ sleep 5
+ nib-dicomfs /tmp/bug2 /tmp/demo
+ find /tmp/demo
/tmp/demo
/tmp/demo/xxxx^xxxxxxx^R
/tmp/demo/xxxx^xxxxxxx^R/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/INFO
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.png
/tmp/demo/xxxx^xxxxxxx^R/20080807_101152/18/18.nii
+ sudo umount /tmp/demo
+ popd
~/trash
hopa:~/trash
$> welp dicom
PATH : /usr/lib/python2.7/dist-packages/dicom/__init__.pyc
SRC PATH : /usr/lib/python2.7/dist-packages/dicom/__init__.py
VERSION : Not found
__version__: '0.9.9'
PACKAGE : python-dicom
ii python-dicom 0.9.9-2 all DICOM medical file reading and writing (Python 2)
python-dicom:
Installed: 0.9.9-2
Candidate: 0.9.9-2
Version table:
*** 0.9.9-2 600
100 http://http.debian.net/debian stretch/main amd64 Packages
100 http://http.debian.net/debian stretch/main i386 Packages
600 http://http.debian.net/debian sid/main amd64 Packages
600 http://http.debian.net/debian sid/main i386 Packages
100 /var/lib/dpkg/status
0.9.9-1~nd80+1+nd90+1 500
500 http://neuro.debian.net/debian stretch/main amd64 Packages
500 http://neuro.debian.net/debian stretch/main i386 Packages
$> welp nibabel
PATH : /usr/lib/python2.7/dist-packages/nibabel/__init__.pyc
SRC PATH : /usr/lib/python2.7/dist-packages/nibabel/__init__.py
VERSION : 2.1.0
__version__: '2.1.0'
PACKAGE : python-nibabel
ii python-nibabel 2.1.0-1 all Python bindings to various neuroimaging data formats
python-nibabel:
Installed: 2.1.0-1
Candidate: 2.1.0-1
Version table:
*** 2.1.0-1 600
100 http://http.debian.net/debian stretch/main amd64 Packages
100 http://http.debian.net/debian stretch/main i386 Packages
600 http://http.debian.net/debian sid/main amd64 Packages
600 http://http.debian.net/debian sid/main i386 Packages
100 /var/lib/dpkg/status
2.1.0-1~nd90+1 500
500 http://neuro.debian.net/debian stretch/main amd64 Packages
500 http://neuro.debian.net/debian stretch/main i386 Packages
Hi,
I tried the suggested test script but I think there is another even
more deep problem which seems to be a broken Python3-port:
+ nib-dicomfs /tmp/bug1 /tmp/demo
Traceback (most recent call last):
File "/usr/bin/nib-dicomfs", line 33, in <module>
sys.exit(load_entry_point('nibabel==3.2.1', 'console_scripts', 'nib-dicomfs')())
File "/usr/lib/python3/dist-packages/nibabel/cmdline/dicomfs.py", line 232, in main
dicom_path=files[0].decode(encoding)
AttributeError: 'str' object has no attribute 'decode'
Kind regards
Andreas.
Hi Andreas, Andreas Tille, on 2021-12-19: That looks definitely related to python3 port. The 'str' type is expected to always be encoded utf-8, so it is not possible to decode an from any other encodings anymore. Quick and easy (and also probably deemed wrong) option would be to assume utf-8 and just strip the decoding step. A more correct option would be to work with 'bytes' type which can be decoded from more arbitrary streams using its 'decode' method; from the quick glimpse I had in the corresponding file, I didn't get a precise idea how to implement that unfortunately. In hope this helps anyway,