Skip to content

Commit

Permalink
Minor bugfixes and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelzwiers committed Sep 27, 2024
1 parent 637deb9 commit 983f6cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bidscoin/bidsapps/echocombine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def echocombine(bidsfolder: str, pattern: str, participant: list, output: str, algorithm: str, weights: list, force: bool=False):
"""
:param bidsdir: The bids-directory with the (multi-echo) subject data
:param bidsfolder: The bids-directory with the (multi-echo) subject data
:param pattern: Globlike recursive search pattern (relative to the subject/session folder) to select the first echo of the images that need to be combined, e.g. '*task-*echo-1*'
:param participant: List of sub-# identifiers to be processed (the sub-prefix can be left out). If not specified then all participants will be processed
:param output: Determines where the output is saved. It can be the name of a BIDS datatype folder, such as 'func', or of the derivatives folder, i.e. 'derivatives'. If output = [the name of the input datatype folder] then the original echo images are replaced by one combined image. If output is left empty then the combined image is saved in the input datatype folder and the original echo images are moved to the {unknowndatatype} folder
Expand Down
2 changes: 1 addition & 1 deletion bidscoin/bidscoiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def bidscoiner(sourcefolder: str, bidsfolder: str, participant: list=(), force:
# Create the job arguments and add it to the batch
bidsfolder_tmp = bidsfolder/'HPC_work'/f"bids_{subid}" # NB: f"bids_{subid}" is used later, don't change
bidsfolder_tmp.mkdir(parents=True, exist_ok=True)
jt.args = [rawfolder, bidsfolder_tmp, '-p', subject.name, '-b', bidsmapfile] + (['-f'] if force else [])
jt.args = [rawfolder, bidsfolder_tmp, '-p', subject.name, '-b', bidsmap.filepath] + (['-f'] if force else [])
jt.jobName = f"bidscoiner_{subject.name}"
jt.outputPath = f"{os.getenv('HOSTNAME')}:{bidsfolder_tmp}/{jt.jobName}.out"
jobids.append(pbatch.runJob(jt))
Expand Down
23 changes: 12 additions & 11 deletions bidscoin/plugins/dcm2niix2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,18 @@ def bidscoiner_plugin(session: Path, bidsmap: BidsMap, bidsses: Path) -> Union[N
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]
LOGGER.bcdebug(f"BidsGuess: [{typeguess}, {targetguess}]")
if typeguess and run.datatype != 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(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 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}")
if not ignore:
typeguess, targetguess = metadata.get('BidsGuess') or ['', ''] # BidsGuess: [datatype, filename]
LOGGER.bcdebug(f"BidsGuess: [{typeguess}, {targetguess}]")
if typeguess and run.datatype != typeguess:
LOGGER.info(f"The datatype of {target.relative_to(bidsses)} does not match with the datatype guessed by dcm2niix: {typeguess}")
elif targetguess and bids.get_bidsvalue(target, 'suffix') != bids.get_bidsvalue(targetguess, 'suffix'):
LOGGER.info(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 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 983f6cb

Please sign in to comment.