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

NIFTI to BIDS conversion with multiple subjects in one session. #246

Open
JulianGaviriaL opened this issue Nov 7, 2024 · 6 comments
Open

Comments

@JulianGaviriaL
Copy link

What is missing in the following code line to convert NIFTI to BIDS with multiple subjects in one session?
D:\software\pyproj\proj_name>bidsmapper raw BIDS -n '*' -p nibabel2bids

OS: windows 10 pro
Python: 3.12.6
BIDSCOIN: 4.4.0

Folder structure:

image

output:
D:\software\pyproj\bidscoin\Lib\site-packages\bidscoin_init_.py:201: RuntimeWarning: Please report the following error to the developers:
db type could not be determined
warnings.warn(f"Please report the following error to the developers:\n{shelveerror}", RuntimeWarning)
INFO |
INFO | -------------- START BIDSmapper ------------
INFO | >>> bidsmapper sourcefolder=D:\software\pyproj\proj_name\raw bidsfolder=D:\software\pyproj\proj_name\BIDS bidsmap=bidsmap.yaml template=C:\Users\Julian.bidscoin\4.4.0\templates\bidsmap_dccn.yaml plugins=['nibabel2bids'] subprefix='' sesprefix=None store=False force=False
INFO | No bidsmap file found: D:\software\pyproj\proj_name\BIDS\code\bidscoin\bidsmap.yaml
INFO | Reading: C:\Users\Julian.bidscoin\4.4.0\templates\bidsmap_dccn.yaml
INFO | Adding default bidsmap options from the nibabel2bids plugin
INFO | Checking the bidsmap run-items:
SUCCESS | All datatypes and options in the template bidsmap are valid
WARNING | No subjects found in: D:\software\pyproj\proj_name\raw''
*
INFO | Opening the bidseditor
INFO |
INFO | Checking the bidsmap run-items:
INFO |
INFO | bids-validator 1.14.7.post0 test results (* = in .bidsignore):
SUCCESS | All generated bidsnames are BIDS-valid

@marcelzwiers
Copy link
Collaborator

marcelzwiers commented Nov 7, 2024

Mhhh, it seems okay to me. We always have a prefix in the center where I work, so your use case is less well-tested. I do test it (see here), but apparently, not well enough. I assume that in your raw -> anat, etc folder you have .nii.gz files?

@marcelzwiers
Copy link
Collaborator

marcelzwiers commented Nov 7, 2024

Perhaps it helps if you also specify an empty ses-prefix, i.e. -m ""?

@JulianGaviriaL
Copy link
Author

Thanks marcel for replying:

Yes, I have .nii.gz files in the "raw -> anat", "raw -> func" folders.

Trials 1 and 2 yielded the following error message:

trial 1:
(bidscoin) D:\software\pyproj\proj_name>bidsmapper raw BIDS -n '*' -m '*' -p nibabel2bids
trial 2:
((bidscoin) D:\software\pyproj\proj_name>bidsmapper raw BIDS -n '*' -m"" -p nibabel2bids

db type could not be determined
warnings.warn(f"Please report the following error to the developers:\n{shelveerror}", RuntimeWarning)
INFO |
INFO | -------------- START BIDSmapper ------------
INFO | >>> bidsmapper sourcefolder=D:\software\pyproj\proj_name\raw bidsfolder=D:\software\pyproj\proj_name\BIDS bidsmap=bidsmap.yaml template=C:\Users\Julian.bidscoin\4.4.0\templates\bidsmap_dccn.yaml plugins=['nibabel2bids'] subprefix='' sesprefix='' store=False force=False
INFO | Reading: D:\software\pyproj\proj_name\BIDS\code\bidscoin\bidsmap.yaml
INFO | Checking the bidsmap run-items:
INFO | Reading: C:\Users\Julian.bidscoin\4.4.0\templates\bidsmap_dccn.yaml
INFO | Adding default bidsmap options from the nibabel2bids plugin
INFO | Checking the bidsmap run-items:
SUCCESS | All datatypes and options in the template bidsmap are valid
WARNING | No subjects found in: D:\software\pyproj\proj_name\raw''
INFO | Opening the bidseditor
INFO | -------------- FINISHED! -------------------

Trial 3: Adding the "s" prefix to the subjects folders.

Step1:
(bidscoin) D:\software\pyproj\proj_name>bidsmapper raw BIDS -n "s"
It did not recognize the subjects in the nibabel window:
image

However, the data is well read in the "data browser" window:
image

Step2. I saved a template (bidsmap.yaml) with the nibabel2bids plugin. I ran again the editor with the nibabel2bids plugin:
It now reads the .nii files only from the first subject in "the nibabel mapping" window.
image

However, the second subject seems recognized. see console lines:

(bidscoin) D:\software\pyproj\proj_name>bidsmapper raw BIDS -n "s"
D:\software\pyproj\bidscoin\Lib\site-packages\bidscoin_init_.py:201: RuntimeWarning: Please report the following error to the developers:
db type could not be determined
warnings.warn(f"Please report the following error to the developers:\n{shelveerror}", RuntimeWarning)
INFO |
INFO | -------------- START BIDSmapper ------------
INFO | >>> bidsmapper sourcefolder=D:\software\pyproj\proj_name\raw bidsfolder=D:\software\pyproj\proj_name\BIDS bidsmap=bidsmap.yaml template=C:\Users\Julian.bidscoin\4.4.0\templates\bidsmap_dccn.yaml plugins=[] subprefix=s sesprefix=None store=False force=False
INFO | Reading: D:\software\pyproj\proj_name\BIDS\code\bidscoin\bidsmap.yaml
INFO | Checking the bidsmap run-items:
INFO | Reading: C:\Users\Julian.bidscoin\4.4.0\templates\bidsmap_dccn.yaml
INFO | Checking the bidsmap run-items:
SUCCESS | All datatypes and options in the template bidsmap are valid
WARNING | Could not update the bidsmap session label expression: <filepath:/raw/s.*?/ses-(.*?)/>
WARNING | Could not update the bidsmap session label expression: <filepath:/raw/s.*?/ses-(.*?)/>
WARNING | Could not update the bidsmap session label expression: <filepath:/raw/s.*?/ses-(.*?)/>
WARNING | Could not update the bidsmap session label expression: <filepath:/raw/s.*?/ses-(.*?)/>
WARNING | Could not update the bidsmap session label expression: <filepath:/raw/s.*?/ses-(.*?)/>
WARNING | Could not update the bidsmap session label expression: <filepath:/raw/s.*?/ses-(.*?)/>
INFO | Mapping: D:\software\pyproj\proj_name\raw\s100101\anat (subject 1/2)
VERBOSE | Executing plugin: nibabel2bids -> D:\software\pyproj\proj_name\raw\s100101\anat
0%| | 0/2 [00:00<?, ?subject/s]D:\software\pyproj\bidscoin\Lib\site-packages\bidscoin_init_.py:201: RuntimeWarning: Please report the following error to the developers:
db type could not be determined
warnings.warn(f"Please report the following error to the developers:\n{shelveerror}", RuntimeWarning)
INFO | Discovered sample: [Nibabel] D:\software\pyproj\proj_name\raw\s100101\anat\100101_1_T1.nii.gz
INFO | Mapping: D:\software\pyproj\proj_name\raw\s100101\func (subject 1/2)
VERBOSE | Executing plugin: nibabel2bids -> D:\software\pyproj\proj_name\raw\s100101\func
INFO | Discovered sample: [Nibabel] D:\software\pyproj\proj_name\raw\s100101\func\100101_1_rs.nii.gz
INFO | Mapping: D:\software\pyproj\proj_name\raw\s110520\anat (subject 2/2)
VERBOSE | Executing plugin: nibabel2bids -> D:\software\pyproj\proj_name\raw\s110520\anat
INFO | Mapping: D:\software\pyproj\proj_name\raw\s110520\func (subject 2/2)
VERBOSE | Executing plugin: nibabel2bids -> D:\software\pyproj\proj_name\raw\s110520\func
INFO | Opening the bidseditor
WARNING | Required "task" value is missing (func/*_bold -> D:\software\pyproj\proj_name\raw\s100101\func\100101_1_rs.nii.gz)
INFO | Checking the bidsmap run-items:
SUCCESS | All run-items in the bidsmap are valid
INFO | Saving bidsmap in: D:\software\pyproj\proj_name\BIDS\code\bidscoin\bidsmap.yaml

@marcelzwiers
Copy link
Collaborator

marcelzwiers commented Nov 15, 2024

Sorry for my slow response, but in your last email you are showing two different windows, i.e. in the first there is no Nibabel mappings tab, but in the second (where you are showing the file browser) there is. So I'm not sure what is going on, but my guess is that by re-running the bidsmapper you got it to work, right? Your question about the second subject is nothing to be worried about, in fact it is a feature: in BIDScoin you only specify the mapping per unique datatype, not per subject (which can become incredibly long)

Unfortunately, I cannot be of much assistance because I'll be away for the coming three weeks....

@marcelzwiers
Copy link
Collaborator

As for your update warning, you can use the --no-update flag to avoid that

@marcelzwiers
Copy link
Collaborator

Hi, I'm back from my holidays, how's the progress on this issue?

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

No branches or pull requests

2 participants