Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add only existing jsonfiles to jsonfiles and make it set #215

Merged

Conversation

dzemanov
Copy link

@dzemanov dzemanov commented Jan 5, 2024

Sometimes is the return code of running dcm2niix success even though no nii files, therefore no json files were produced. This means that jsonfiles will need to remove <outfolder/bidsname.json> as it doesn't exist.

This code changes jsonfiles to set and only adds jsonfiles if they exist, meaning no need of removing nonexistent jsonfiles.
Maybe continue can be added not only for if return code is not success, but also if no nii files are produced?

@@ -308,6 +308,8 @@ def bidscoiner_plugin(session: Path, bidsmap: dict, bidsses: Path) -> Union[None
if bcoin.run_command(command):
if not list(outfolder.glob(f"{bidsname}.*nii*")): continue

jsonfiles.update(outfolder.glob(f"{bidsname}.json")) # add existing created json files: bidsname.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should also be added right after the physio2tsv conversion above (i.e. after line 295)

@marcelzwiers
Copy link
Collaborator

Thanks, I have never come across this myself, but it looks like a clean solution. And I agree, set() is indeed a much better datatype to use here :-)

@marcelzwiers marcelzwiers merged commit 55b1302 into Donders-Institute:master Jan 11, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants