ivadomed / utilities

Repository containing utility scripts for handling various aspects in a DL model training pipeline
MIT License
8 stars 0 forks source link

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

Closed rohanbanerjee closed 8 months ago

rohanbanerjee commented 8 months ago

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`: https://github.com/ivadomed/utilities/blob/e9cbfd8413d3529f38a995f1d639512056bb2bf1/dataset_conversion/convert_bids_to_nnUNetV2.py#L85-L94 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.
valosekj commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

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