Skip to content

Commit f5e8c68

Browse files
committed
Use StudyDate to resolve PatientAgeDerived for the latest XA DICOM versions (GitHub issue #267)
1 parent 02f7791 commit f5e8c68

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bidscoin/plugins/dcm2niix2bids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_attribute(self, dataformat: Union[DataFormat, str], sourcefile: Path, at
107107
# Parse custom "DICOM" tags
108108
if attribute == 'PatientAgeDerived':
109109
try:
110-
acqdate = datetime.strptime(get_dicomfield('AcquisitionDate', sourcefile) or get_dicomfield('AcquisitionDateTime', sourcefile), '%Y%m%d')
110+
acqdate = datetime.strptime(get_dicomfield('AcquisitionDate', sourcefile) or get_dicomfield('StudyDate', sourcefile), '%Y%m%d')
111111
birthdate = datetime.strptime(get_dicomfield('PatientBirthDate', sourcefile), '%Y%m%d')
112112
return (acqdate - birthdate).days / 365.25
113113
except Exception as dateerror:
@@ -490,7 +490,7 @@ def bidscoiner(self, session: Path, bidsmap: BidsMap, bidsses: Path) -> None:
490490
if not ignore:
491491
acq_time = ''
492492
if dataformat == 'DICOM':
493-
acq_time = f"{run.datasource.attribute('AcquisitionDate')}T{run.datasource.attribute('AcquisitionTime')}"
493+
acq_time = f"{run.datasource.attribute('AcquisitionDateTime')}" or f"{run.datasource.attribute('AcquisitionDate')}T{run.datasource.attribute('AcquisitionTime')}"
494494
elif dataformat == 'PAR':
495495
acq_time = run.datasource.attribute('exam_date')
496496
if not acq_time or acq_time == 'T':

0 commit comments

Comments
 (0)