Skip to content

Commit c8c3cf9

Browse files
committed
FIX: Revert
1 parent 410b810 commit c8c3cf9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

nibabel/nicom/utils.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def find_private_section(dcm_data, group_no, creator):
1717
``tag``, ``VR``, ``value``
1818
group_no : int
1919
Group number in which to search
20-
creator : str or regex
21-
Name of section - e.g. b'SIEMENS CSA HEADER' - or regex to search for
20+
creator : str or bytes or regex
21+
Name of section - e.g. 'SIEMENS CSA HEADER' - or regex to search for
2222
section name. Regex used via ``creator.search(element_value)`` where
23-
``element_value`` is the decoded value of the data element.
23+
``element_value`` is the value of the data element.
2424
2525
Returns
2626
-------
@@ -29,7 +29,9 @@ def find_private_section(dcm_data, group_no, creator):
2929
"""
3030
if hasattr(creator, 'search'):
3131
match_func = creator.search
32-
else: # assume str
32+
else:
33+
if isinstance(creator, bytes):
34+
creator = creator.decode('latin-1')
3335
match_func = creator.__eq__
3436
# Group elements assumed ordered by tag (groupno, elno)
3537
for element in dcm_data.group_dataset(group_no):
@@ -39,6 +41,8 @@ def find_private_section(dcm_data, group_no, creator):
3941
if element.VR not in ('LO', 'OB'):
4042
continue
4143
val = element.value
44+
if isinstance(val, bytes):
45+
val = val.decode('latin-1')
4246
if match_func(val):
4347
return elno * 0x100
4448
return None

0 commit comments

Comments
 (0)