N-back task fMRI with fMRIPrep

Hello, I am preprocesing my task-fMRI data of two time points but I have some thoughts:

  1. I have decided to preprocess my task-fMRI data with fMRIPrep, but I am not sure about which outputs I should add to the folder. Should I include the document with the events of the task in the folder (i.e., sub-101_ses-1_task-nback_events)? I mean, does fMRIPrep use that document, or is it needed for the next steps? These are the different images that I have for each time and participant in the functional folder now:

* sub-101_ses-1_task-nback_bold
* sub-101_ses-1_task-nback_bold.nii
* sub-101_ses-1_task-nback_sbref
* sub-101_ses-1_task-nback_sbref.nii.gz
  1. In case I need to add it or not, which document do I need for the n-back task? Additionally, do you have any recommendations for creating that document? Currently, I have documents from each participant and time, but I couldn’t find any examples for know what I need:

I_101_AVERAGE_Nback_Results

I_101_Nback_results

I_101_Nback1_Onset
image

I_101_Nback2_Onset
image

Thanks so much,
Beatriz

Hi @Beatriz,

The events.tsv file should go in the func folder with the other images you provided, but it is not used by fMRIPrep. It can, however, be parsed by Fitlins and Nilearn to run GLMs after preprocessing.

Neither of the documents you have are BIDS-valid events files. The second one, however, is closer to BIDS valid. Events files are explained here: Task events - Brain Imaging Data Structure v1.9.0. And you can see an example here: https://github.com/bids-standard/bids-examples/blob/eff47f104210a142a71abd058417fc91a82ba95a/synthetic/task-nback_events.tsv#L4

  • onset: time in seconds of event/block onset

  • duration: duration in seconds of event/block

  • trial type: kind of task (e.g., 0-back, 1-back, whatever description is helpful)

You don’t need to specify weight (often times you set this when running the GLM)

Best,
Steven

Hello Steven, thank you so much for your response. It was really useful.

Following, you can see the BIDS-valid event file that I created with the second document that I showed you, but I still have a thought. As you can see, I have some blank spaces in the duration on my document because of the rest time when the participant is reading the instructions (We have n-back 1 and n-back 2). Should I remove it? Can it cause some errors in my analysis?

Thank you so much,

Regards,

Beatriz

Hi @Beatriz,

It might depend on the software you use. I think it would be safer to delete them and only include rows for events your are interested in modeling.

Best,
Steven

Thank you so much, Steven.

We are going to use FSL for the first-level analyses and group analyses.

Despite you mentioning that the events.tsv file is not used by fMRIPrep, I realized that in my output (after running fMRIPrep), I don’t have the regressors document (as shown in this example: fMRIPrep Tutorial #5: Running the 1st-level Analysis — Andy's Brain Book 1.0 documentation - sub-08_task-flanker_run-1_desc-confounds_regressors.tsv). Instead, I have a file named sub-101_ses-1_task-nback_desc-confounds_timeseries with different columns.

Shall I add something more to my script for run fmriprep?

#!/bin/bash

  #User inputs:
  bids_root_dir=/home/jovyan/neurodesktop-storage/Agueda/BIDS/derivatives/fmripreptask_tsv
  output_directory=${bids_root_dir}/derivatives
  #work_dir=/home/jovyan/neurodesktop-storage/Agueda/work
  nthreads=4
  mem=20 #gb 
  participant_labels=("sub-101" "sub-103")  # List of participant labels
  #participant_labels='sub-103'  # List of participant labels

  #Begin:

  #Convert virtual memory from gb to mb
  mem=`echo "${mem//[!0-9]/}"` #remove gb at end
  mem_mb=`echo $(((mem*1000)-5000))` #reduce some memory for buffer space during pre-processing


  #export TEMPLATEFLOW_HOME=$HOME/.cache/templateflow
  #export FS_LICENSE=${bids_root_dir}/license.txt

  #Run fmriprep

for subj in "${participant_labels[@]}"; do
    fmriprep ${bids_root_dir} ${bids_root_dir}/derivatives \
      participant \
      --participant-label $subj \
      --skip-bids-validation \
      --md-only-boilerplate \
      --fs-license-file ${bids_root_dir}/license.txt \
      --output-spaces MNI152NLin2009cAsym:res-2 \
      --nthreads $nthreads \
      --stop-on-first-crash \
      --mem_mb $mem_mb \
      #-w ${work_dir}
done

echo "Thank God! you went without errors in fMRIPrep!"

On the other hand, I have a doubt about why it is not necessary to include the corrects and errors in my events document for the different trials. At what point are they added?

Thanks so much.

Hi @Beatriz,

The name changed in more recent versions of fMRIPrep

Softwares such as Nilearn and Fitlins can automatically use those when making GLMs. You might find this article helpful, even if some of the information is outdated: Analysis of task-based functional MRI data preprocessed with fMRIPrep | Nature Protocols

I recommend using containers (e.g., Docker or Singularity/Apptainer) for running fMRIPrep

Best,
Steven