Skip to content

Commit

Permalink
Use python string split()
Browse files Browse the repository at this point in the history
  • Loading branch information
jbwexler authored May 14, 2024
1 parent 8f84304 commit 232c036
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wbhiutils/parse_dicom_hdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# Parse a dicom header and return the pi-id and sub-id
def parse_pi_sub(dcm_hdr, site):
if site == 'ucsb':
pi_id, sub_id = re.split('^', dcm_hdr["PatientName"])[:2]
pi_id, sub_id = dcm_hdr["PatientName"].split('^')[:2]
elif site == 'uci':
pi_id = re.split('[^0-9a-zA-Z]', dcm_hdr["PatientName"])[0]
sub_id = re.split('[^0-9a-zA-Z]', dcm_hdr["PatientID"])[0]
elif site == 'ucb':
pi_id = re.split(' ', dcm_hdr["StudyDescription"])[0]
sub_id = dcm_hdr["PatientName"]
else:
pi_id, sub_id = re.split('^', dcm_hdr["PatientName"])[:2]
pi_id, sub_id = dcm_hdr["PatientName"].split('^')[:2]

return pi_id, sub_id

0 comments on commit 232c036

Please sign in to comment.