Skip to content

Commit

Permalink
Fix dcm2niix "BidsGuess" entity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Sep 27, 2024
1 parent 4db3e38 commit f5d17e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions bidscoin/plugins/dcm2niix2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit f5d17e9

Please sign in to comment.