Skip to content

Commit

Permalink
Unwrap pydicom DICOM tag values.
Browse files Browse the repository at this point in the history
  • Loading branch information
FredLoney committed Feb 20, 2015
1 parent a94512e commit 50ae2b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions History.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
This history lists major release themes. See the GitHub commits
for change details.

2.2.2 / 2015-02-19
------------------
* Unwrap pydicom DICOM tag values.

2.2.1 / 2015-02-17
------------------
* Add eddicom utility.
Expand Down
2 changes: 1 addition & 1 deletion qidicom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This qidicom module contains utilities to read and edit DICOM files.
"""

__version__ = '2.2.1'
__version__ = '2.2.2'
"""
The one-based major.minor.patch version based on the
`Fast and Loose Versioning <https://gist.github.com/FredLoney/6d946112e0b0f2fc4b57>`_
Expand Down
12 changes: 11 additions & 1 deletion qidicom/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@ def group_by(tag, *files):
for ds in reader.iter_dicom_headers(*files):
# Ignore subtraction images.
if not 'SUB' in ds.ImageType:
series_dict[getattr(ds, tag)].append(ds.filename)
# The dictionary key is the string form of the DICOM tag value
# rather than the tag value itself to work around the following
# pydicom bug:
# * Serializing a pydicom tag value with Python 2.x results in
# the following error:
# TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled
# The work-around is to unwrap the tag value.
value = getattr(ds, tag)
# Unwrap the value as either an integer or a string.
key = int(value) if isinstance(value, int) else str(value)
series_dict[key].append(ds.filename)

return series_dict

Expand Down

0 comments on commit 50ae2b2

Please sign in to comment.