Remi-Gau / bids-app_rsHRF

Resting state HRF estimation from BOLD-fMRI signal
http://bids-apps.neuroimaging.io/rsHRF/
MIT License
1 stars 0 forks source link

Expected input is actually not a BIDS dataset #2

Open Remi-Gau opened 3 years ago

Remi-Gau commented 3 years ago

Expected is actually not a BIDS dataset

Documented in this issue: https://github.com/Remi-Gau/bids-app_rsHRF/issues/2


The following does not work does work because the package expects files ending with a preproc.nii and not *preproc_bold.nii

input_dir=../../derivatives/fmriprep
output_dir=../../derivatives/rsHRF

input_dir=/home/remi/gin/olfaction_blind/derivatives/fmriprep
output_dir=/home/remi/gin/olfaction_blind/derivatives/rsHRF

mkdir $output_dir

docker run -ti --rm \
-v $input_dir:/input_dir:ro \
-v $output_dir:/results \
bids/rshrf  --bids_dir input_dir \
            --output_dir results \
            --analysis_level participant \
            --brainmask \
            --estimation canon2dd \
            --participant_label blnd01

This gives the following error

rsHRF: error: There are no files of type *preproc.nii / *preproc.nii.gz Please make sure to have at least one file of the above type in the BIDS specification

I suspect the error is due to the fact that the BIDS app actually expect data that does in fact NOT conform to the BIDS specifications.

BIDS files have the general format:

sub-<label>_entity1-<label>_entity2-<label>[...]_suffix.ext

The general form for BIDS derivatives data is described here: https://bids-specification.readthedocs.io/en/stable/05-derivatives/02-common-data-types.html#preprocessed-or-cleaned-data

<pipeline_name>/
    sub-<participant_label>/
        <datatype>/
            <source_entities>[_space-<space>][_desc-<label>]_<suffix>.<ext>

Which means that preprocessed bold data should have the suffix bold and not the preproc one that rsHRF expects. Something like this:

sub-01/func/sub-01_task-rest_desc-preproc_bold.nii.gz
sub-01/func/sub-01_task-rest_desc-preproc_bold.json

Another issue is that rsHRF expects the task label to be rest. This is indeed the "suggested" label by the BIDs specification and makes for a good default but resting state dataset can technically have any task label.

Those should be fixed to make the app work on most valid derivatives BIDS datasets. I suspect it would also be preferable to have the following as defaults:

Bot issues could be tested on the ds002790 dataset from open neuro that should be accessible from openeuro with datalad.

datalad clone ///
cd datasets.datalad.org/
datalad install openneuro datalad
install openneuro/ds002790
cd openneuro/ds002790
# get rest data first subject
datalad get /derivatives/fmriprep/sub-0001/func/sub-0001*task-restingstate_acq-seq*\*

Additonally when processing a BIDS data set, it would be preferable to generate a dataset_description.json that helps track the provenance of the of the input.

See here for more details: https://bids-specification.readthedocs.io/en/stable/03-modality-agnostic-files.html#derived-dataset-and-pipeline-description


Finally, one little extra: it could be nice when dealing with BIDS dataset to make sure that the input data is a derivatives dataset (this information should be included in the DatasetType of the dataset_description.json of a dataset): the reason for this is to prevent users from running rsHRF on data that has not been minimally preprocessed (i.e realigned).

NigelCol commented 3 years ago

Response to issues documented in #2

Expected input is actually not a BIDS dataset

The code was adjusted so that it expects preprocessed bold input data conform to the BIDS specifications (https://github.com/BIDS-Apps/rsHRF/commit/a31fae6dbf40b6730e85582b9888a5275c10b123)

Generation of dataset_description.json file

The rsHRF with --bids_dir now generates a dataset_description.json file as suggested (https://github.com/BIDS-Apps/rsHRF/commit/16cfeb789cdd037c5a5177b9929df6fda9239f86).

In addition there are now several checks implemented for the dataset_description.json file (https://github.com/BIDS-Apps/rsHRF/commit/735b5fcaa13c357d6b9429360b379aad4a3a6f3e):

Filter BIDS-data for input into rsHRF toolbox

Based on the suggestion to allow users the freedom of giving any task label for BIDS input, we added an additional argument to the toolbox named --bids_filter_file (https://github.com/BIDS-Apps/rsHRF/commit/5f2863176e2f725ada9155680c2288e423df66ee).

This gives users more flexibility to filter the BIDS-data inputted in the rsHRF BIDS-app.

This arguments expects a filepath to a .JSON file that describes a custom BIDS filter for selecting input with PyBIDS, with the syntax {<query>: {<entity>: <filter>, ...}, .... }

Queries can be defined for bold and/or mask in the .JSON file which allows the user to filter the BIDS-data to its individual needs.

For example :

{
    'bold': {
     'datatype': 'func',
     'task' : 'restingstate',
     'desc': 'preproc',
     'surffix': 'bold',
      'extension': 'nii.gz'
      },
        'mask': {
     'datatype': 'func',
     'task': 'restingstate',     
     'desc': 'brain',
     'suffix': 'mask',
     'extension': 'nii.gz'
     } 
}

These queries will filter the bold and mask data according to the defined entities . The mask query will only have an effect when the --brainmask argument is defined.

rsHRF-BIDS app uses the following queries, by default :

   'bold' : {'datatype':' func', 'suffix': 'bold', 'extension': 'nii.gz', 'desc': 'preproc', 'task': 'rest'}
   'mask' : {'datatype': 'func', 'suffix': 'mask', 'extension': 'nii.gz', 'desc': 'brain', 'task': 'rest'}

Only modification of these queries will have any effect. You may filter on any entity defined in the PyBIDS config file and derivatives file

This means that the BIDS-App by default checks for bold or mask data that has the following entities :

 bold : sub-<label>/func/sub<label>-task_rest-desc_preproc_bold.nii.gz
 mask : sub-<label>/func/sub<label>-task_rest-desc_brain_mask.nii.gz

Changing of these default entities and/or filtering by non-default entities (e.g. 'space'), can be done by defining the queries of bold and/ or mask defined in a .JSON file using the -bids_filter_file.