QSIRecon Custom Atlas and Response Functions

Hello,
My team has been using QSIPrep and now we’re moving on to QSIRecon. I’ve been able to successfully process a subject with QSIRecon, but before I continue with more subjects my team has a couple of questions that we can’t seem to find the answer to on the documentation page.

  1. How exactly do we use a custom atlas? I saw the section for it on the documentation page, but it’s still not exactly clear to me how we can use a custom atlas (say from Freesurfer). Also, the link in that section does not seem to work.

  2. Is there a way to use our own response functions? My team is interested in creating average response functions from a set of controls and then using those response functions for our entire set of subjects. Is this possible?

  3. Is there a workflow that generates FA and ADC/MD maps?

Thank you for all your help!

Best,
Sofie

Hi @scchung,

Documentation is here: Built-In Reconstruction Workflows — qsirecon 1.2.1.dev4+g9c2ed9aa5 documentation. You have to make a BIDS valid atlas (i.e. following BEP038), pass in the folder containing your atlas as a --datasets, then add the name of your atlas as an argument for --atlases

No, not at the moment, but you can use QSIRecon just for response function generating step and then average after. (see next posts)

Several. DIPY DKI uses the tensor component of a kurtosis model (multishell compatible). DSI Studio GQI uses an ordinary least squares and TORTOISE uses a weighted linear least squares approach. You may consider only using b-values less than some cut off such as 1200 unless using the multishell DKI. You can see an example of all approaches being combined here: qsirecon/qsirecon/data/pipelines/abcd_recon.yaml at main · PennLINC/qsirecon · GitHub.

Best,
Steven

Just to follow up on @Steven’s post: technically QSIRecon expects atlases to follow an older version of the BEP. BIDS has since merged the BEP with some changes, so QSIRecon expects something that isn’t actually BIDS-compliant.

Here is an example tree from a test:

/path
├── atlas-carpet
│   ├── atlas-carpet_space-MNI152NLin2009cAsym_dseg.json
│   ├── atlas-carpet_space-MNI152NLin2009cAsym_dseg.tsv
│   └── atlas-carpet_space-MNI152NLin2009cAsym_res-01_dseg.nii.gz
└── dataset_description.json

In the dataset_description.json, you should have DatasetType set to atlas. Since, in that example, the atlas dataset is located at /path and the name of the atlas (from atlas-<label>) is carpet, you could pass that in as --datasets carpet=/path --atlases carpet.

We plan to overhaul atlas organization to match BIDS in the near future, but we don’t have a timeline for it yet.

We did add the ability to ingress custom response functions not that long ago. You could run QSIRecon to generate the subject-wise response functions, then average them with your own code, and then incorporate those into a new pipeline.

This is a very new addition so we don’t have any good documentation on it. We do have a pair of pipelines set up for testing that you could use as a template:

The first pipeline estimates the response functions:

The second one uses averaged response functions stored in --recon-spec-aux-files with the names wm.txt, gm.txt, and csf.txt:

@tsalo @Steven Thank you for the quick response! Could I have more clarification with the custom atlas. Here is what I think I would need to do:
Say I wanted to use the Desikan killiany atlas.

  1. From Freesurfer/sub-01/mri/ would I do mri_convert aparc+aseg.mgz aparc+aseg.nii.gz
  2. Use antsApplyTransforms to register to MNI152NLin2009cAsym space (Where is this transform? The link in Custom Datasets doesn’t seem to work. Is it one of the transforms that QSIPrep outputs in the anat folder)
  3. Reorient to LPS
3dresample -orient LPS \
-inset aparc+aseg_MNI.nii.gz \
-prefix aparc+aseg_MNI_LPS.nii.gz
  1. sform zeroed-out
fslorient -deleteorient aparc+aseg_MNI_LPS.nii.gz
  1. Create atlas-Desikan_dseg.tsv
  2. Put everything in the atlas-BIDS format and create dataset_description.json

Best,
Sofie

Hi @scchung,

To clarify, you want subject specific atlases? You might be better off your matrices outside of QSIRecon in that case.

You’ll get a ACPC-to-MNI transform in the QSIPrep anat folder. But that won’t work directly because your FreeSurfer outputs will be in native T1w space. You can register your freesurfer brain with the MNI template in templateflow.

Best,
Steven

For reference, something like this is used to register freesurfer to ACPC space, and you can replace that ACPC space target with the MNI template. Then apply the resulting xfm to your segmentation. But are you sure you want to use the DK atlas? That’s a very coarse atlas.

## We can use the software in the QSIPrep container to run the commands below
run_qsiprep_cmd="singularity exec --containall -e -B ${bids},${workdir} ${qsiprep_IMG}" # Alias for easy invocation of QSIPrep container

# Convert from FreeSurfer .mgz file format to NIFTI
${run_qsiprep_cmd} mrconvert -strides -1,-2,3 \
    ${SUBJECTS_DIR}/${subject}/mri/brain.mgz ${workdir}/${subject}/fs_brain.nii

# Register FreeSurfer brain to QSIPrep T1w
${run_qsiprep_cmd} antsRegistration --collapse-output-transforms 1 \
    --dimensionality 3 --float 0 \
    --initial-moving-transform [ ${bids}/derivatives/qsiprep/${subject}/anat/${subject}_desc-preproc_T1w.nii, ${workdir}/${subject}/fs_brain.nii, 1 ] \
    --initialize-transforms-per-stage 0 --interpolation BSpline \
    --output [ ${workdir}/${subject}/transform, ${workdir}/${subject}/transform_Warped.nii.gz ] \
    --transform Rigid[ 0.1 ] \
    --metric Mattes[ ${bids}/derivatives/qsiprep/${subject}/anat/${subject}_desc-preproc_T1w.nii, ${workdir}/${subject}/fs_brain.nii, 1, 32, Random, 0.25 ] \
    --convergence [ 1000x500x250x100, 1e-06, 10 ] \
    --smoothing-sigmas 3.0x2.0x1.0x0.0mm --shrink-factors 8x4x2x1 \
    --use-histogram-matching 0 \
    --masks [ ${bids}/derivatives/qsiprep/${subject}/anat/${subject}_desc-brain_mask.nii.gz, NULL ] \
    --winsorize-image-intensities [ 0.002, 0.998 ] \
    --write-composite-transform 0

@Steven Thank you! I did the registration and transformation and now I have the subject’s Freesurfer atlas in MNI152NLin2009cAsym space. How do I continue with the QSIRecon pipeline such that I can extract the MRtrix3 connectomes based on the Freesurfer atlas?

Hi @scchung,

@tsalo answered you above for that.

Best,
Steven