Skip to content

Commit 7ad4751

Browse files
committed
Use a relative path in scans.tsv
1 parent 87fa35a commit 7ad4751

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

bidscoin/bidscoiner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ def coin_dicom(session: str, bidsmap: dict, bidsfolder: str, personals: dict, su
223223
with open(jsonfile, 'r') as json_fid:
224224
data = json.load(json_fid)
225225
acq_time = dateutil.parser.parse(data['AcquisitionTime'])
226-
scans_table.loc[jsonfile.replace(bidsses+os.sep,''), 'acq_time'] = '1900-01-01T' + acq_time.strftime('%H:%M:%S') # Somehow .strip(bidsses) instead of replace(bidsses,'') does not work properly
226+
niipath = glob.glob(os.path.splitext(jsonfile)[0] + '.nii*')[0] # Find the corresponding nifti file (there should be only one, let's not make assumptions about the .gz extension)
227+
niipath = niipath.replace(bidsses+os.sep,'') # Use a relative path. Somehow .strip(bidsses) instead of replace(bidsses,'') does not work properly
228+
scans_table.loc[niipath, 'acq_time'] = '1900-01-01T' + acq_time.strftime('%H:%M:%S')
227229

228230
# Write the scans_table to disk
229231
bids.printlog('Writing acquisition time data to: ' + scans_tsv, LOG)

0 commit comments

Comments
 (0)