From 396903e2c134b35d37c40214adf37bafb7706b82 Mon Sep 17 00:00:00 2001 From: Marcel Zwiers Date: Fri, 27 Sep 2024 13:02:52 +0200 Subject: [PATCH] Add a dcm2niix "BidsGuess" check for the datatype and filename entities --- bidscoin/plugins/dcm2niix2bids.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bidscoin/plugins/dcm2niix2bids.py b/bidscoin/plugins/dcm2niix2bids.py index 5c99e2c5..99482e16 100644 --- a/bidscoin/plugins/dcm2niix2bids.py +++ b/bidscoin/plugins/dcm2niix2bids.py @@ -507,6 +507,15 @@ def bidscoiner_plugin(session: Path, bidsmap: BidsMap, bidsses: Path) -> Union[N acq_time = 'n/a' scans_table.loc[target.relative_to(bidsses).as_posix(), 'acq_time'] = acq_time + # Check if the target output aligns with dcm2niix's "BidsGuess" datatype and filename entities + typeguess, targetguess = metadata.get('BidsGuess') or ['', ''] # BidsGuess: [datatype, filename] + if typeguess and run.datatype != typeguess: + LOGGER.warning(f"The datatype of {run} does not match with the datatype suggested by dcm2niix: {typeguess}") + elif targetguess and run.bids.get('suffix') != bids.get_bidsvalue(targetguess, 'suffix'): + LOGGER.warning(f"The suffix of {run} does not match with the suffix suggested by dcm2niix: {targetguess}") + if targetguess and run.bids.get('dir') and run.bids.get('dir') != bids.get_bidsvalue(targetguess, 'dir'): + LOGGER.warning(f"The (phase-encoding) 'dir' value in {run} does not match with the 'dir' value suggested by dcm2niix: {targetguess}") + # Write the scans_table to disk LOGGER.verbose(f"Writing acquisition time data to: {scans_tsv}") scans_table.sort_values(by=['acq_time','filename'], inplace=True)