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

The convert_bids_to_nnUNetV2.py script is not compatible with datatypes other than anat #43

Closed
rohanbanerjee opened this issue Feb 14, 2024 · 3 comments · Fixed by #44
Closed
Assignees

Comments

@rohanbanerjee
Copy link
Contributor

Description:

I am using the convert_bids_to_nnUNetV2.py script for an fMRI dataset and script is running into the following error:
contrast bold for subject <subject-name> does not exist this contrast is ignored for all my subjects.

Why is this happening?
The script assumes that the the datatype used from conversion from `bids` to the `nnUNet` is `anat`. The below lines of code assume that the data type is `anat`:

if is_ses:
subject_image_file = os.path.join(root, subject, session, 'anat', f"{subject}_{session}_{contrast}.nii.gz")
subject_label_file = os.path.join(root, 'derivatives', 'labels', subject, session, 'anat',
f"{subject}_{session}_{contrast}_{label_suffix}.nii.gz")
sub_name = re.match(r'^([^_]+_[^_]+)', Path(subject_image_file).name).group(1)
else:
subject_image_file = os.path.join(root, subject, 'anat', f"{subject}_{contrast}.nii.gz")
subject_label_file = os.path.join(root, 'derivatives', 'labels', subject, 'anat',
f"{subject}_{contrast}_{label_suffix}.nii.gz")
sub_name = re.match(r'^([^_]+)', Path(subject_image_file).name).group(1)

The files name of subjects in general for anat data type is {subject}_{contrast}.nii.gz which is also used/hard-coded in the above lines. When I use the func data type (which is the data type of my dataset), it starts throwing the error because of two reasons:

  1. The code is not able to read the new data type func
  2. The naming convention of fMRI data is generally like -- {subject}_{task-name}_{contrast}.nii.gz

Attaching screenshot from the BIDS dataset for naming convention reference:

Screenshot 2024-02-14 at 4 57 31 PM

Solution:

  1. Add a flag --data-type so that the use can mention the type of dataset. The most used ones (afaik) are anat, func and dwi
  2. Remove the hard-coded naming structure and make it more dynamic as per the data type. But I also would be fine with keeping It hard-coded since it makes sure that the dataset actually uses the BIDS file naming convention.
@rohanbanerjee rohanbanerjee self-assigned this Feb 14, 2024
@valosekj
Copy link
Member

Good catch! Indeed, anat is now hardcoded.

Add a flag --data-type so that the use can mention the type of dataset. The most used ones (afaik) are anat, func and dwi

Sounds good! The default can be anat. List of choices then [anat, func and dwi], or we can keep it "open" for any datatype specified by the user.

@rohanbanerjee
Copy link
Contributor Author

Sounds good! The default can be anat. List of choices then [anat, func and dwi], or we can keep it "open" for any datatype specified by the user.

I've kept it open for now. Generally the anat and dwi would have similar naming conventions but func would have a task-name in between subject-name and contrast. The PR #44 solves this.

@naga-karthik
Copy link
Member

Thanks for opening the issue, @rohanbanerjee ! Agree with making it more dynamic to accept other data types

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 a pull request may close this issue.

3 participants