@@ -17,10 +17,10 @@ def find_private_section(dcm_data, group_no, creator):
17
17
``tag``, ``VR``, ``value``
18
18
group_no : int
19
19
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
22
22
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.
24
24
25
25
Returns
26
26
-------
@@ -29,7 +29,9 @@ def find_private_section(dcm_data, group_no, creator):
29
29
"""
30
30
if hasattr (creator , 'search' ):
31
31
match_func = creator .search
32
- else : # assume str
32
+ else :
33
+ if isinstance (creator , bytes ):
34
+ creator = creator .decode ('latin-1' )
33
35
match_func = creator .__eq__
34
36
# Group elements assumed ordered by tag (groupno, elno)
35
37
for element in dcm_data .group_dataset (group_no ):
@@ -39,6 +41,8 @@ def find_private_section(dcm_data, group_no, creator):
39
41
if element .VR not in ('LO' , 'OB' ):
40
42
continue
41
43
val = element .value
44
+ if isinstance (val , bytes ):
45
+ val = val .decode ('latin-1' )
42
46
if match_func (val ):
43
47
return elno * 0x100
44
48
return None
0 commit comments