diff --git a/bidscoin/bids.py b/bidscoin/bids.py index 7e7e27d0..ed248999 100644 --- a/bidscoin/bids.py +++ b/bidscoin/bids.py @@ -2204,7 +2204,7 @@ def get_bidsvalue(bidsfile: Union[str, Path], bidskey: str, newvalue: str='') -> """ # Check input - if not bidskey and newvalue: + if not bidsfile or (not bidskey and newvalue): return bidsfile # No fallback bidspath = Path(bidsfile).parent diff --git a/bidscoin/plugins/dcm2niix2bids.py b/bidscoin/plugins/dcm2niix2bids.py index 58f6be85..58785d8f 100644 --- a/bidscoin/plugins/dcm2niix2bids.py +++ b/bidscoin/plugins/dcm2niix2bids.py @@ -511,14 +511,14 @@ def bidscoiner_plugin(session: Path, bidsmap: BidsMap, bidsses: Path) -> Union[N typeguess, targetguess = metadata.get('BidsGuess') or ['', ''] # BidsGuess: [datatype, filename] LOGGER.bcdebug(f"BidsGuess: [{typeguess}, {targetguess}]") if typeguess and run.datatype != typeguess: - LOGGER.warning(f"The datatype of {target.relative_to(bidsfolder)} does not match with the datatype suggested by dcm2niix: {typeguess}") + LOGGER.warning(f"The datatype of {target.relative_to(bidsses)} does not match with the datatype guessed by dcm2niix: {typeguess}") elif targetguess and run.bids['suffix'] != bids.get_bidsvalue(targetguess, 'suffix'): - LOGGER.warning(f"The suffix of {target.relative_to(bidsfolder)} does not match with the suffix suggested by dcm2niix: {targetguess}") + LOGGER.warning(f"The suffix of {target.relative_to(bidsses)} does not match with the suffix guessed by dcm2niix: {targetguess}") for entity in ('part', 'inv', 'echo', 'dir'): targetvalue = bids.get_bidsvalue(target, entity) guessvalue = bids.get_bidsvalue(targetguess, entity) - if targetvalue and targetvalue != guessvalue: - LOGGER.warning(f"The '{entity}_{targetvalue}' value in {target.relative_to(bidsfolder)} does not match with the '{entity}_{guessvalue}' value suggested by dcm2niix: {targetguess}") + if targetvalue and guessvalue and targetvalue != guessvalue: + LOGGER.warning(f"The '{entity}_{targetvalue}' value in {target.relative_to(bidsses)} does not match with the '{entity}_{guessvalue}' value guessed by dcm2niix: {targetguess}") # Write the scans_table to disk LOGGER.verbose(f"Writing acquisition time data to: {scans_tsv}")