Skip to content

Commit e96a246

Browse files
committed
ENH: bids - make ContentDate/Time optional for _scans file
1 parent 14a5a33 commit e96a246

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

heudiconv/bids.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,14 @@ def get_formatted_scans_key_row(item):
293293
force=True))
294294
# we need to store filenames and acquisition times
295295
# parse date and time and get it into isoformat
296-
date = mw.dcm_data.ContentDate
297-
time = mw.dcm_data.ContentTime.split('.')[0]
298-
td = time + date
299-
acq_time = datetime.strptime(td, '%H%M%S%Y%m%d').isoformat()
296+
try:
297+
date = mw.dcm_data.ContentDate
298+
time = mw.dcm_data.ContentTime.split('.')[0]
299+
td = time + date
300+
acq_time = datetime.strptime(td, '%H%M%S%Y%m%d').isoformat()
301+
except AttributeError as exc:
302+
lgr.warning("Failed to get date/time for the content: %s", str(exc))
303+
acq_time = None
300304
# add random string
301305
randstr = ''.join(map(chr, sample(k=8, population=range(33, 127))))
302306
try:

0 commit comments

Comments
 (0)