Skip to content

Commit 26fe77c

Browse files
committed
BF+RF: save_scans_key should get a single item to be applied to all related bids files, use ContentTime not SeriesTime
1 parent 8715102 commit 26fe77c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

bin/heudiconv

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def convert(items, symlink=True, converter=None,
914914
# save acquisition time information if it's BIDS
915915
# at this point we still have acquisition date
916916
if is_bids:
917-
save_scans_key(items, outname_bids_files)
917+
save_scans_key(item, outname_bids_files)
918918
# Fix up and unify BIDS files
919919
tuneup_bids_json_files(outname_bids_files)
920920
# we should provide specific handling for fmap,
@@ -967,8 +967,8 @@ def get_formatted_scans_key_row(item):
967967
mw = ds.wrapper_from_data(dcm.read_file(dcm_fn, stop_before_pixels=True))
968968
# we need to store filenames and acquisition times
969969
# parse date and time and get it into isoformat
970-
date = mw.dcm_data.SeriesDate
971-
time = mw.dcm_data.SeriesTime.split('.')[0]
970+
date = mw.dcm_data.ContentDate
971+
time = mw.dcm_data.ContentTime.split('.')[0]
972972
td = time + date
973973
acq_time = datetime.strptime(td, '%H%M%S%Y%m%d').isoformat()
974974
# add random string
@@ -1024,27 +1024,27 @@ def _find_subj_ses(f_name):
10241024
return res.get('subj'), res.get('ses', None)
10251025

10261026

1027-
def save_scans_key(items, outname_bids_files):
1027+
def save_scans_key(item, bids_files):
10281028
"""
10291029
Parameters
10301030
----------
10311031
items:
1032-
outname_bids_files:
1032+
bids_files: str or list
10331033
10341034
Returns
10351035
-------
10361036
10371037
"""
10381038
rows = dict()
1039+
assert bids_files, "we do expect some files since it was called"
10391040
# we will need to deduce subject and session from the bids_filename
10401041
# and if there is a conflict, we would just blow since this function
10411042
# should be invoked only on a result of a single item conversion as far
10421043
# as I see it, so should have the same subject/session
10431044
subj, ses = None, None
1044-
1045-
for item, outname_bids_file in zip(items, outname_bids_files):
1045+
for bids_file in bids_files:
10461046
# get filenames
1047-
f_name = '/'.join(outname_bids_file.split('/')[-2:])
1047+
f_name = '/'.join(bids_file.split('/')[-2:])
10481048
f_name = f_name.replace('json', 'nii.gz')
10491049
rows[f_name] = get_formatted_scans_key_row(item)
10501050
subj_, ses_ = _find_subj_ses(f_name)
@@ -1061,7 +1061,7 @@ def save_scans_key(items, outname_bids_files):
10611061
)
10621062
ses = ses_
10631063
# where should we store it?
1064-
output_dir = dirname(dirname(outname_bids_file))
1064+
output_dir = dirname(dirname(bids_file))
10651065
# save
10661066
ses = '_ses-%s' % ses if ses else ''
10671067
add_rows_to_scans_keys_file(

0 commit comments

Comments
 (0)