Issue 150 in pydicom: _pixel_data_numpy in dataset does not respect Planar Configuration

22 views
Skip to first unread message

pyd...@googlecode.com

unread,
Jul 3, 2014, 11:15:40 AM7/3/14
to pydic...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Difficulty-Medium

New issue 150 by arothb...@4combinator.com: _pixel_data_numpy in dataset
does not respect Planar Configuration
http://code.google.com/p/pydicom/issues/detail?id=150

See: https://www.medicalconnections.co.uk/kb/Planar_configuration for a
definition of the field tag. It appears that the reshaping assumes that
Planar Configuration=1.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

pyd...@googlecode.com

unread,
Nov 2, 2014, 3:47:22 PM11/2/14
to pydic...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 150 by darcy...@gmail.com: _pixel_data_numpy in
dataset does not respect Planar Configuration
https://code.google.com/p/pydicom/issues/detail?id=150

Going through the issues list, coming back to this. Does anyone have
example files that illustrate type 0? It should be fixable with a numpy
rearrangement of the data, but it would be good to have examples to confirm
correct behaviour.

pyd...@googlecode.com

unread,
Nov 2, 2014, 3:53:52 PM11/2/14
to pydic...@googlegroups.com

Comment #2 on issue 150 by arothb...@4combinator.com: _pixel_data_numpy in
dataset does not respect Planar Configuration
https://code.google.com/p/pydicom/issues/detail?id=150

I think you can convert a file from one format to another using dcmdjpeg

planar configuration options:

+pa --planar-auto
automatically determine planar configuration
from SOP class and color space (default)

# If the compressed image is a color image, store in
color-by-plane
# planar configuration if required by the SOP class and
photometric
# interpretation. Hardcopy Color images are always stored
color-by-
# plane, and the revised Ultrasound image objects are stored
color-by-
# plane if the color model is YBR_FULL. Everything else is stored
# color-by-pixel.

+px --color-by-pixel
always store color-by-pixel

# If the compressed image is a color image, store in
color-by-pixel
# planar configuration.

+pl --color-by-plane
always store color-by-plane

# If the compressed image is a color image, store in
color-by-plane
# planar configuration.

pyd...@googlecode.com

unread,
Nov 5, 2014, 7:43:05 PM11/5/14
to pydic...@googlegroups.com

Comment #3 on issue 150 by agrothberg: _pixel_data_numpy in dataset does
I fixed the issue here:
https://github.com/cancan101/pydicom/commit/4113792397c3e26336cd864db8062905f069b553
for when PlanarConfiguration==0

pyd...@googlecode.com

unread,
Nov 8, 2014, 9:06:40 PM11/8/14
to pydic...@googlegroups.com
Updates:
Labels: -Priority-Medium Priority-High Milestone-Release1.0

Comment #4 on issue 150 by darcy...@gmail.com: _pixel_data_numpy in
dataset does not respect Planar Configuration
https://code.google.com/p/pydicom/issues/detail?id=150

I'm not familiar with color images, but after reading a bit, I agree that
the fix looks correct, but unfortunately it is a backwards-incompatible
change, because the order of indices of pixel_array is changed
(SamplesPerPixel is moved from first index to last index). As you mention,
that would be correct for PlanarConfiguration=1, but it seems that
PlanarConfiguration of 0 is the dicom default. Code out there might have
rearranged the order to compensate, so I'm thinking to introduce this in
pydicom 1.0, where there will be other backwards incompatible changes.
While we are at it, then, a couple of thoughts. The code should not assume
PlanarConfiguration is specified, so should check ('PlanarConfiguration' in
ds) before testing it (and set a local variable to 0 if not there). Also,
there should be the correct branching for PlanarConfiguration of 1 also.

pyd...@googlecode.com

unread,
Nov 9, 2014, 4:05:08 PM11/9/14
to pydic...@googlegroups.com

Comment #5 on issue 150 by agrothberg: _pixel_data_numpy in dataset does
Maybe I don't understand the backward comptabile argument, but what would
be wrong with something like:

if self.PlanarConfiguration==0:
arr = arr.reshape(self.NumberOfFrames, self.Rows, self.Columns,
self.SamplesPerPixel)
else:
arr = arr.reshape(self.SamplesPerPixel, self.NumberOfFrames, self.Rows,
self.Columns)

That should correctly handle both PlanarConfiguration==0 (the DICOM
default) and PlanarConfiguration==1.

I would be curious as to how current users are able to work around the
parsing issues when opening color files with PlanarConfiguration==0. I
solved the issue with the above linked patch.
Reply all
Reply to author
Forward
0 new messages