@@ -914,7 +914,7 @@ def convert(items, symlink=True, converter=None,
914
914
# save acquisition time information if it's BIDS
915
915
# at this point we still have acquisition date
916
916
if is_bids :
917
- save_scans_key (items , outname_bids_files )
917
+ save_scans_key (item , outname_bids_files )
918
918
# Fix up and unify BIDS files
919
919
tuneup_bids_json_files (outname_bids_files )
920
920
# we should provide specific handling for fmap,
@@ -967,8 +967,8 @@ def get_formatted_scans_key_row(item):
967
967
mw = ds .wrapper_from_data (dcm .read_file (dcm_fn , stop_before_pixels = True ))
968
968
# we need to store filenames and acquisition times
969
969
# 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 ]
972
972
td = time + date
973
973
acq_time = datetime .strptime (td , '%H%M%S%Y%m%d' ).isoformat ()
974
974
# add random string
@@ -1024,27 +1024,27 @@ def _find_subj_ses(f_name):
1024
1024
return res .get ('subj' ), res .get ('ses' , None )
1025
1025
1026
1026
1027
- def save_scans_key (items , outname_bids_files ):
1027
+ def save_scans_key (item , bids_files ):
1028
1028
"""
1029
1029
Parameters
1030
1030
----------
1031
1031
items:
1032
- outname_bids_files:
1032
+ bids_files: str or list
1033
1033
1034
1034
Returns
1035
1035
-------
1036
1036
1037
1037
"""
1038
1038
rows = dict ()
1039
+ assert bids_files , "we do expect some files since it was called"
1039
1040
# we will need to deduce subject and session from the bids_filename
1040
1041
# and if there is a conflict, we would just blow since this function
1041
1042
# should be invoked only on a result of a single item conversion as far
1042
1043
# as I see it, so should have the same subject/session
1043
1044
subj , ses = None , None
1044
-
1045
- for item , outname_bids_file in zip (items , outname_bids_files ):
1045
+ for bids_file in bids_files :
1046
1046
# get filenames
1047
- f_name = '/' .join (outname_bids_file .split ('/' )[- 2 :])
1047
+ f_name = '/' .join (bids_file .split ('/' )[- 2 :])
1048
1048
f_name = f_name .replace ('json' , 'nii.gz' )
1049
1049
rows [f_name ] = get_formatted_scans_key_row (item )
1050
1050
subj_ , ses_ = _find_subj_ses (f_name )
@@ -1061,7 +1061,7 @@ def save_scans_key(items, outname_bids_files):
1061
1061
)
1062
1062
ses = ses_
1063
1063
# where should we store it?
1064
- output_dir = dirname (dirname (outname_bids_file ))
1064
+ output_dir = dirname (dirname (bids_file ))
1065
1065
# save
1066
1066
ses = '_ses-%s' % ses if ses else ''
1067
1067
add_rows_to_scans_keys_file (
0 commit comments