File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 23
23
from deid .utils import parse_value , read_json
24
24
25
25
here = os .path .dirname (os .path .abspath (__file__ ))
26
-
26
+ parentheses_hex_tag_format = re .compile (r"\(([0-9A-Fa-f]{4}),([0-9A-Fa-f]{4})\)" )
27
+ bare_hex_tag_format = re .compile (r"[0-9A-Fa-f]{8}" )
27
28
28
29
class DicomParser :
29
30
"""
@@ -461,13 +462,11 @@ def parse_tag_string(tag_string):
461
462
4. A tag name (e.g., "PatientID"), rather than a number.
462
463
"""
463
464
if tag_string .startswith ("(" ):
464
- pattern = re .compile (r"\(([0-9A-Fa-f]{4}),([0-9A-Fa-f]{4})\)" )
465
- result = pattern .match (tag_string )
465
+ result = parentheses_hex_tag_format .match (tag_string )
466
466
return int (f"0x{ result .group (1 )} { result .group (2 )} " , base = 16 )
467
467
else :
468
468
try :
469
- unannotated_hex_tag = re .compile (r"[0-9A-Fa-f]{8}" )
470
- if unannotated_hex_tag .match (tag_string ):
469
+ if bare_hex_tag_format .match (tag_string ):
471
470
return int (f"0x{ tag_string } " , base = 16 )
472
471
else :
473
472
return int (tag_string )
You can’t perform that action at this time.
0 commit comments