cpp-lln-lab / bidspm

an SPM centric BIDS app
https://bidspm.readthedocs.io/en/latest/general_information.html
GNU General Public License v3.0
7 stars 14 forks source link

subject level analysis using smoothAROMAnonaggr files #1035

Closed Rageve closed 1 year ago

Rageve commented 1 year ago

Dear Remi,

I am currently doing the first-level analysis with the smoothAROMAnonaggr processed by fmriprep. The copying to the preproc_dir .../outputs/derivatives/bidspm-preproc worked fine. Now I have for each subject and session

sub-0736/ses-V0/func 
sub-0736_ses-V0_task-food_run-1_desc-confounds_timeseries.json
sub-0736_ses-V0_task-food_run-1_desc-confounds_timeseries.tsv
sub-0736_ses-V0_task-food_run-1_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.json
sub-0736_ses-V0_task-food_run-1_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii

and the same for run-2

To select the correct files I created the following structure

bids_filter_file = struct('bold', struct('modality', 'func', ...
                                           'suffix', 'bold', ...
                                           'desc', {'smoothAROMAnonaggr'}));

path settings:

bids_dir = '/server/fo2-17/data/NASAL_2018/DAGen_Bromo/BIDS/Tuebingen/inputs/rawdata';
models_dir = '/server/fo2-17/data/NASAL_2018/DAGen_Bromo/BIDS/Tuebingen';
output_dir = '/server/fo2-17/data/NASAL_2018/DAGen_Bromo/BIDS/Tuebingen/outputs/derivatives';

model_file = fullfile(models_dir, 'models', 'model-foodspm_firstlevel_small_smdl.json');

then I tried to run the code

for i=1:length(Dir_Participants)

subject_label = Dir_Participants(i);

bidspm(bids_dir, output_dir, 'subject', ...
         'participant_label',subject_label, ...
         'action', 'stats', ...
         'preproc_dir', preproc_dir, ...
         'bids_filter_file', bids_filter_file, ...
         'verbosity', 3, ...
         'task', {'food'}, ...
         'model_file', model_file, ...
         'options', struct([]), ...
         'skip_validation', true);
end
Indexing subject: sub-0736 [....]

[13:16:22] bidspm - INFO                getData
WILL WORK ON SUBJECTS
    - 0736

[13:16:22] bidspm - INFO                printWorkflowName
WORKFLOW: SUBJECT LEVEL GLM

[13:16:22] bidspm - INFO                bidsFFX

 PROCESSING NODE: run_level

[13:16:22] bidspm - INFO                printProcessingSubject
PROCESSING SUBJECT No.: 1 SUBJECT LABEL : 0736

[13:16:22] bidspm - DEBUG               printBatchName
 BUILDING JOB: specify subject level fmri model
Warning: Non-existent field "SliceTiming" for metadata.

and later comes the error

No repetition time found for filter:

    - desc: {preproc}
    - extension: {.nii.*}
    - modality: {func}
    - prefix: {}
    - space: {MNI152NLin6Asym}
    - sub: {^0736$}
    - suffix: {bold}
    - task: {food}
    - target: {RepetitionTime}

Notwithstanding the code produces for each subject an empty folder in bidspm-stats task-food_space-MNI152NLin6Asym_FWHM-6

It seems to me that the code does not accept another desc flag. The .json files contains the following:

{
  "DelayTime": 0.09499999999999997,
  "RepetitionTime": 1.18,
  "SliceTimingCorrected": true,
  "StartTime": 0.542,
  "TaskName": "food"
}

Any idea how to run the code?

error_2023-05-31T13-16.zip

github-actions[bot] commented 1 year ago

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

Remi-Gau commented 1 year ago

you are correct in your diagnostic: the bids filter seems to not be working.

let me check

Remi-Gau commented 1 year ago

OK I hard coded this here:

https://github.com/cpp-lln-lab/bidspm/blob/0c5309733f6c10abe7f43b566957174c3c2a203b/src/bids/fileFilterForBold.m#L34

It should be reading the value from the BIDS filter file and if no value is found then it should fall back on using preproc.

Should be an easy fix.

Remi-Gau commented 1 year ago

Actually @Rageve I think the problem might be somewhere else:

https://github.com/cpp-lln-lab/bidspm/blob/0c5309733f6c10abe7f43b566957174c3c2a203b/src/batches/stats/setBatchSubjectLevelGLMSpec.m#L51

I think if you comment the line I linked to above, it should work for fmriprep dataset like in your case.

I may still need to fix things for datasets preprocessed with bidspm but that is a different story.

Can you check if commenting this line fixes that issue?

Rageve commented 1 year ago

Unfortunately, there is another desc flag error (smth6)

No bold file found in:
    /server/fo2-17/data/NASAL_2018/DAGen_Bromo/BIDS/Tuebingen/outputs/derivatives/bidspm-preproc
for query

    - modality: {func}
    - task: {food}
    - desc: {smth6}
    - space: {MNI152NLin6Asym}
Remi-Gau commented 1 year ago

OK the error is different so that I still count that as relative progress... 😛 Just kidding.

OK I need to find a way to make it easier for me to test this.

Remi-Gau commented 1 year ago

OK seems that most fmriprep datasets from openneuro contain some aroma data. Should be easier to get those.

Rageve commented 1 year ago

Hey Remi,

It's been over a month now and I would like to kindly ask if you have found time to use the smootharoma data as input for the first level analysis (instead of the default smth6 files)?

Remi-Gau commented 1 year ago

Hey @Rageve

sorry it took so long and thanks for pushing me on this

I cleared my schedule to work on this today

I am managed to make it work with one of the demos in #1036

The demo would look something like this: https://github.com/cpp-lln-lab/bidspm/blob/91813dc93f00ab91a96135f31fa46eb20a24cc31/demos/openneuro/ds000001_aroma_run.m

And the associated model file that specifies the input file must be "description" "AROMA" looks like this: https://github.com/cpp-lln-lab/bidspm/blob/91813dc93f00ab91a96135f31fa46eb20a24cc31/demos/openneuro/models/model-balloonanalogrisktaskAroma_smdl.json

maybe you can try it from this branch: https://github.com/Remi-Gau/bidspm/tree/fix-filter_desc_aroma

Remi-Gau commented 1 year ago

if the tests pass I will merge and we can tackle any other issues after that: there are still some warnings but at least it runs the GLM and computes the contrasts for subject level

Remi-Gau commented 1 year ago

Ok the tests pass. So I am closing this for now. Reopen it or open another issue if this does not work. There are still a few things I want to check on this so I will also open separate issues.