Multiple tasks with multiple fmaps

Hello,

Here is the data structure of a single subject in the dataset in this dir (/.../bids_alldata/sub-pp031/ses-01/).

-sub-pp001

--ses-01

---anat

sub-pp001_ses-01_inv-1_MP2RAGE.json

sub-pp001_ses-01_inv-1_MP2RAGE.nii.gz

sub-pp001_ses-01_inv-2_MP2RAGE.json

sub-pp001_ses-01_inv-2_MP2RAGE.nii.gz

sub-pp001_ses-01_T1w.json

sub-pp001_ses-01_T1w.nii.gz

---func

sub-pp001_ses-01_task-A_run-001_bold.json.json

sub-pp001_ses-01_task-A_run-001_bold.json.nii.gz

sub-pp001_ses-01_task-A_run-002_bold.json.json

sub-pp001_ses-01_task-A_run-002_bold.json.nii.gz

sub-pp001_ses-01_task-A_run-003_bold.json.json

sub-pp001_ses-01_task-A_run-003_bold.json.nii.gz

sub-pp001_ses-01_task-B_run-001_bold.json.json

sub-pp001_ses-01_task-B_run-001_bold.json.nii.gz

sub-pp001_ses-01_task-B_run-001_events.tsv

sub-pp001_ses-01_task-C_run-001_bold.json.json

sub-pp001_ses-01_task-C_run-001_bold.json.nii.gz

sub-pp001_ses-01_task-C_run-002_bold.json.json

sub-pp001_ses-01_task-C_run-002_bold.json.nii.gz

sub-pp001_ses-01_task-C_run-003_bold.json.json

sub-pp001_ses-01_task-C_run-003_bold.json.nii.gz

sub-pp001_ses-01_task-C_run-004_bold.json.json

sub-pp001_ses-01_task-C_run-004_bold.json.nii.gz

sub-pp001_ses-01_task-D_run-001_bold.json.json

sub-pp001_ses-01_task-D_run-001_bold.json.nii.gz

sub-pp001_ses-01_task-D_run-002_bold.json.json

sub-pp001_ses-01_task-D_run-002_bold.json.nii.gz

sub-pp001_ses-01_task-D_run-003_bold.json.json

sub-pp001_ses-01_task-D_run-003_bold.json.nii.gz

sub-pp001_ses-01_task-D_run-004_bold.json.json

sub-pp001_ses-01_task-D_run-004_bold.json.nii.gz

sub-pp001_ses-01_task-rest_run-001_bold.json

sub-pp001_ses-01_task-rest_run-001_bold.nii.gz

sub-pp001_ses-01_task-rest_run-001_events.tsv

---fmap

sub-pp001_ses-01_fid-alpha_magnitude1.json

sub-pp001_ses-01_fid-alpha_magnitude1.nii.gz

sub-pp001_ses-01_fid-alpha_magnitude2.json

sub-pp001_ses-01_fid-alpha_magnitude2.nii.gz

sub-pp001_ses-01_ fid-alpha_phasediff.json

sub-pp001_ses-01_ fid-alpha_phasediff.nii.gz

sub-pp001_ses-01_fid-beta_magnitude1.json

sub-pp001_ses-01_fid-beta_magnitude1.nii.gz

sub-pp001_ses-01_fid-beta_magnitude2.json

sub-pp001_ses-01_fid-beta_magnitude2.nii.gz

sub-pp001_ses-01_ fid-beta_phasediff.json

sub-pp001_ses-01_ fid-beta_phasediff.nii.gz

sub-pp001_ses-01_fid-gamma_magnitude1.json

sub-pp001_ses-01_fid-gamma_magnitude1.nii.gz

sub-pp001_ses-01_fid-gamma_magnitude2.json

sub-pp001_ses-01_fid-gamma_magnitude2.nii.gz

sub-pp001_ses-01_ fid-gamma_phasediff.json

sub-pp001_ses-01_ fid-gamma_phasediff.nii.gz

---dwi

I want to preprocess only task-D using fmriprep. The fmap that corresponds to the task-D is the fid-gamma.

Additionally, I want the output to be saved in the following structure, since other tasks are being preprocessed via another preprocessing pipeline:

/.../bids_alldata/derivatives/sub-pp001/func/fmriprep
/.../bids_alldata/derivatives/sub-pp00/anat/fmriprep
/.../bids_alldata/derivatives/sub-pp00/figures/fmriprep
/.../bids_alldata/derivatives/sub-pp00/log/fmriprep

Could you please let me know how I can specify these features in the command line?

Thank you in advance and best.
Sevil.

Hi @svl and welcome to Neurostars!

You can use a BIDS filter file. See more about that here.

As long as the IntendedFor field in the fieldmap JSONs are specified correctly, they will be associated only with the BOLD files they are intended for. You do not have to worry about unrelated fieldmaps being in the directory.

That is not possible via the command line, you would have to do that reorganization yourself after the fact.

Best,
Steven

Hi,

I am not sure that fid- is part of the BIDS specification.

You can do that with the [-t TASK_ID] argument in the FMRIPREP call.

You can specify this relationship in two ways in your dataset:

  • with the IndendedFor: metadata field specified in the JSON file of your fieldmap data
  • With the B0FieldIdentifier / B0FieldSource pairs of metadata fields.

Explanation:
https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#expressing-the-mr-protocol-intent-for-fieldmaps

This is not the normal behavior of FMRIPREP. The general behavior is to save the data in a specific FOLDER that you define in the command line. Inside FOLDER, the data is saved in the following form:

.
├── dataset_description.json
├── desc-aparcaseg_dseg.tsv
├── desc-aseg_dseg.tsv
├── group
│   └── dataset_description.json
├── logs
│   ├── CITATION.bib
│   ├── CITATION.html
│   ├── CITATION.md
│   └── CITATION.tex
├── sourcedata
│   └── freesurfer
├── sub-SUB
│   ├── anat
│   ├── figures
│   ├── fmap
│   ├── func
│   └── log
├── sub-SUB.html

Hi @Steven hi @jsein

Thank you for your input.

I checked the IntendedFor field, fmap_gamma was correctly assigned to the task_D.

So I started the pre-processing :slight_smile:

Best,
Sevil.

1 Like

Hi again @jsein,

As you mentioned, the fid- in fmaps naming caused an error during the bids validation. So I had to add the flag of --skip-bids-validation to the FMRIPREP call.
Does the IndendedFor: option still work to find the desired fmap?

Thank you in advance and best,
Sevil.

Hi @svl ,

You could rename the files if you wanted to be BIDS-compatible.
Otherwise I think that it should work with --skip-bids-validation if that is the only error you get.

Hi

I had to change the naming of the fmaps as follows, since I didn’t want to use the --skip-bids-validation flag. As far as I understand it should also apply the field map correction by default if the data is in BIDs. The preprocessing finished without error, however in the logs I see that Susceptibility distortion correction: None. Could you please let me know how I should approach this to run the fieldmap correction as well.

sub-pp001_ses-01_acq-alpha_magnitude1.json
sub-pp001_ses-01_acq-alpha_magnitude1.nii.gz
sub-pp001_ses-01_acq-alpha_magnitude2.json
sub-pp001_ses-01_acq-alpha_magnitude2.nii.gz
sub-pp001_ses-01_ acq-alpha_phasediff.json
sub-pp001_ses-01_ acq-alpha_phasediff.nii.gz
sub-pp001_ses-01_acq-beta_magnitude1.json
sub-pp001_ses-01_acq-beta_magnitude1.nii.gz
sub-pp001_ses-01_acq-beta_magnitude2.json
sub-pp001_ses-01_acq-beta_magnitude2.nii.gz
sub-pp001_ses-01_ acq-beta_phasediff.json
sub-pp001_ses-01_ acq-beta_phasediff.nii.gz
sub-pp001_ses-01_acq-gamma_magnitude1.json
sub-pp001_ses-01_acq-gamma_magnitude1.nii.gz
sub-pp001_ses-01_acq-gamma_magnitude2.json
sub-pp001_ses-01_acq-gamma_magnitude2.nii.gz
sub-pp001_ses-01_ acq-gamma_phasediff.json
sub-pp001_ses-01_ acq-gamma_phasediff.nii.gz

Best,
Sevil.

How are you associated your fieldmaps to your BOLD files? Can you provide an example of a phasediff.json and the output of the tree command on this subject’s raw data directory?

Best,
Steven

This is the output of tree command:

?????? ses-01
    ?????? anat
    ?? ? ? ?????? sub-pp001_ses-01_inv-1_MP2RAGE.json
    ?? ? ? ?????? sub-pp001_ses-01_inv-1_MP2RAGE.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_inv-2_MP2RAGE.json
    ?? ? ? ?????? sub-pp001_ses-01_inv-2_MP2RAGE.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_T1w.json
    ?? ? ? ?????? sub-pp001_ses-01_T1w.nii.gz
    ?????? dwi
    ?? ? ? ?????? sub-pp001_ses-01_dwi.bval
    ?? ? ? ?????? sub-pp001_ses-01_dwi.bvec
    ?? ? ? ?????? sub-pp001_ses-01_dwi.json
    ?? ? ? ?????? sub-pp001_ses-01_dwi.nii.gz
    ?????? fmap
    ?? ? ? ?????? sub-pp001_ses-01_acq-alpha_magnitude1.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-alpha_magnitude1.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-alpha_magnitude2.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-alpha_magnitude2.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-alpha_phasediff.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-alpha_phasediff.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-beta_magnitude1.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-beta_magnitude1.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-beta_magnitude2.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-beta_magnitude2.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-beta_phasediff.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-beta_phasediff.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-gamma_magnitude1.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-gamma_magnitude1.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-gamma_magnitude2.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-gamma_magnitude2.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_acq-gamma_phasediff.json
    ?? ? ? ?????? sub-pp001_ses-01_acq-gamma_phasediff.nii.gz
    ?????? func
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-001_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-001_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-001_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-002_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-002_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-002_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-003_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-003_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-aliceloc_run-003_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-catloc_run-001_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-catloc_run-001_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-catloc_run-001_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-001_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-001_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-001_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-002_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-002_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-002_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-003_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-003_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-003_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-004_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-004_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-music_run-004_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-rest_run-001_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-rest_run-001_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-rest_run-001_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-001_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-001_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-001_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-002_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-002_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-002_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-003_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-003_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-003_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-004_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-004_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-004_events.tsv
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-005_bold.json
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-005_bold.nii.gz
    ?? ? ? ?????? sub-pp001_ses-01_task-spatial_run-005_events.tsv
    ?????? sub-pp001_ses-01_scans.tsv

5 directories, 71 files

and this is the sub-pp001_ses-01_acq-gamma_phasediff.json:

{
  "AcquisitionDuration": 129.37,
  "AcquisitionMatrixPE": 92,
  "AcquisitionNumber": 1,
  "AcquisitionTime": "12:37:4.775000",
  "BaseResolution": 92,
  "BodyPartExamined": "BRAIN",
  "CoilCombinationMethod": "Sum of Squares",
  "CoilString": "HeadNeck_64",
  "ConversionSoftware": "dcm2niix",
  "ConversionSoftwareVersion": "v1.0.20220720",
  "DeviceSerialNumber": "66054",
  "DwellTime": 9.1e-06,
  "EchoNumber": 2,
  "EchoTime": 0.00738,
  "EchoTime1": 0.00492,
  "EchoTime2": 0.00738,
  "FlipAngle": 60,
  "HeudiconvVersion": "0.11.6",
  "ImageOrientationPatientDICOM": [
    1,
    -4.06921e-08,
    9.99171e-07,
    -4.902e-12,
    0.999172,
    0.040697
  ],
  "ImageType": [
    "ORIGINAL",
    "PRIMARY",
    "P",
    "NONE",
    "PHASE"
  ],
  "ImageTypeText": [
    "ORIGINAL",
    "PRIMARY",
    "P",
    "DIS2D"
  ],
  "ImagingFrequency": 123.226,
  "InPlanePhaseEncodingDirectionDICOM": "ROW",
  "InstitutionAddress": "Chemin des Mines 9,Geneve,District,CH,1211",
  "InstitutionName": "Fondation Campus Biotech Geneva",
  "IntendedFor": [
    "bids::sub-pp001/ses-01/func/sub-pp001_ses-01_task-rest_run-001_bold.nii.gz",
    "bids::sub-pp001/ses-01/func/sub-pp001_ses-01_task-spatial_run-001_bold.nii.gz",
    "bids::sub-pp001/ses-01/func/sub-pp001_ses-01_task-spatial_run-002_bold.nii.gz",
    "bids::sub-pp001/ses-01/func/sub-pp001_ses-01_task-spatial_run-003_bold.nii.gz",
    "bids::sub-pp001/ses-01/func/sub-pp001_ses-01_task-spatial_run-004_bold.nii.gz",
    "bids::sub-pp001/ses-01/func/sub-pp001_ses-01_task-spatial_run-005_bold.nii.gz"
  ],
  "MRAcquisitionType": "2D",
  "MTState": false,
  "MagneticFieldStrength": 3,
  "Manufacturer": "Siemens",
  "ManufacturersModelName": "MAGNETOM Prisma",
  "MatrixCoilMode": "SENSE",
  "Modality": "MR",
  "NonlinearGradientCorrection": true,
  "PartialFourier": 1,
  "PatientPosition": "HFS",
  "PercentPhaseFOV": 100,
  "PercentSampling": 100,
  "PhaseEncodingDirection": "i",
  "PhaseResolution": 1,
  "PixelBandwidth": 597,
  "ProcedureStepDescription": "N.Golestani Al_Ir",
  "ProtocolName": "fmap_fid-gamma",
  "PulseSequenceDetails": "%SiemensSeq%\\gre_field_mapping",
  "PulseSequenceName": "*fm2d2r",
  "ReceiveCoilActiveElements": "HC1-6",
  "ReceiveCoilName": "HeadNeck_64",
  "ReconMatrixPE": 92,
  "RepetitionTime": 0.707,
  "ScanningSequence": "GR",
  "SequenceVariant": "SP",
  "SeriesDescription": "fmap_fid-gamma",
  "SeriesNumber": 54,
  "ShimSetting": [
    -1290,
    -11675,
    6281,
    383,
    253,
    11,
    -93,
    91
  ],
  "SliceThickness": 2,
  "SliceTiming": [
    0.355,
    0,
    0.3625,
    0.01,
    0.3725,
    0.02,
    0.3825,
    0.03,
    0.3925,
    0.04,
    0.4025,
    0.05,
    0.4125,
    0.06,
    0.4225,
    0.07,
    0.4325,
    0.08,
    0.4425,
    0.09,
    0.4525,
    0.1,
    0.4625,
    0.1075,
    0.4725,
    0.1175,
    0.4825,
    0.1275,
    0.49,
    0.1375,
    0.5,
    0.1475,
    0.51,
    0.1575,
    0.52,
    0.1675,
    0.53,
    0.1775,
    0.54,
    0.1875,
    0.55,
    0.1975,
    0.56,
    0.2075,
    0.57,
    0.2175,
    0.58,
    0.2275,
    0.59,
    0.235,
    0.6,
    0.245,
    0.61,
    0.255,
    0.62,
    0.265,
    0.6275,
    0.275,
    0.6375,
    0.285,
    0.6475,
    0.295,
    0.6575,
    0.305,
    0.6675,
    0.315,
    0.6775,
    0.325,
    0.6875,
    0.335,
    0.6975,
    0.345
  ],
  "SoftwareVersions": "syngo MR XA30",
  "SpacingBetweenSlices": 2,
  "StationName": "AWP66054",
  "TxRefAmp": 222.601
}

Best,
Sevil.

Remove this from all of your intended for lists. fMRIPrep does not yet support BIDS URI. So each one should begin with the ses- folder.

Best,
Steven

Hi,

I have applied the changes as you suggested. The four tasks (catloc, music, aliceloc and spatial) were preprocced. I am attaching screenshots of the SDC results of the two tasks, as you can see in the images there are artifacts. Could please let me know why this is happening?
This is the command I used:

fmriprep-docker "${bids_dir}" "${output_dir}" \
        participant \
        --participant-label "${subject}" \
        --fs-license-file /usr/local/freesurfer/license.txt \
        --fs-no-reconall \
        --output-space MNI152NLin2009cAsym:res-2 \
        --task-id "${task_name}" \
        --work-dir "${working_dir}"

Best,
Sevil.


Hi @svl,

What version of fMRIPrep are you using? A lot of users are experiencing some issues with SDC at the moment.

Also,

this flag is not recommended (See here). Try running without it to use the full FreeSurfer functionality.

Best,
Steven

Hi @Steven,

Thank you! I used fMRIPrep version: 23.1.2.
I will try with FreeSurfer.

Best,
Sevil.

Hi,

I would like to report back regarding the recent unusual susceptibility distortion correction issue, with expanding brain to non-brain voxels.

I tried masking the magnitude images but there was no improvement in the results.

Based on the recommendation by @Marcel_Zwiers, here. I masked the phasediff image. I didn’t use the BIDScoin pipeline. I basically multiplied the phase-diff image with a masked-eroded magnitude image which I am also sharing with you. And the results look much better. I have used fMRIPrep version: 23.1.3.

Best,
Sevil.


1 Like