From c2637d3844d3ce4d1affa453d8cefc74a9269f1d Mon Sep 17 00:00:00 2001 From: Marcel Zwiers Date: Wed, 22 May 2024 17:19:41 +0200 Subject: [PATCH] Add the runindex underscore only if there is a runindex (Github Issue #198) --- bidscoin/bids.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bidscoin/bids.py b/bidscoin/bids.py index 91932bc4..0ecd3d27 100644 --- a/bidscoin/bids.py +++ b/bidscoin/bids.py @@ -2214,7 +2214,8 @@ def addmetadata(bidsses: Path) -> None: limitmatches(fmap, matches, limits, niifiles, scans_table) # In the b0fieldtags, replace the limits with fieldmap runindex - newb0fieldtag = b0fieldtag.replace(':'+limits, '_'+get_bidsvalue(fmap,'run')) + runindex = get_bidsvalue(fmap, 'run') + newb0fieldtag = b0fieldtag.replace(':'+limits, '_'+runindex if runindex else '') for niifile in niifiles: metafile = (bidsses/niifile).with_suffix('').with_suffix('.json') LOGGER.bcdebug(f"Updating the b0fieldtag ({b0fieldtag} -> {newb0fieldtag}) for: {metafile}")