Donders-Institute / bidscoin

BIDScoin converts your source-level neuroimaging data to BIDS
https://bidscoin.readthedocs.io
GNU General Public License v3.0
130 stars 35 forks source link

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

Open JulianGaviriaL opened 2 weeks ago

JulianGaviriaL commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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

JulianGaviriaL commented 2 weeks ago

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 commented 1 week ago

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 future: 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 commented 1 week ago

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