QSIPrep problem about custom atlas:

I am trying to use a custom atlas to calculate connectivity.
I have already resampled my atlas to the LPS+ and same FOV as described in the [documentation]
(Reconstruction — qsiprep version documentation).

However, I don’t understand why and how to zero-out the sform. Is it necessary, and how do I do it? (I have checked the Neurostar and github, but didn’t found a clear answer.)

Now, I am trying to replicate the qform and sform of the QSIPrep atlas template using below code. However, I am still not sure if it is correct.

The QSIPrep atals:
filename aal116MNI_lps_mni.nii.gz

My code:

import nibabel as nib
qsi_atlas = '/mnt/workdir/DCM/Docs/Reference/qsirecon_atlases/aal116MNI_lps_mni.nii.gz'
qsi_atlas_img = nib.load(qsi_atlas)
sform = qsi_atlas_img.header.get_sform()
sform_code = qsi_atlas_img.header._structarr['sform_code']
print(sform)
print(sform_code)

my_atlas = r'/mnt/workdir/DCM/Docs/Mask/DMN/DMN_atlas/DMN_atlas_lps.nii.gz'
dmn_img = nib.load(my_atlas)
print(dmn_img.header.get_sform())
qform = dmn_img.header.get_qform()
print(qform)

# zero_out the sform
dmn_img.header.set_sform(sform, int(sform_code))
dmn_img.header.set_qform(qform, int(1))
dmn_img.to_filename('/mnt/workdir/DCM/Docs/Mask/DMN/DMN_atlas/DMN_atlas_lps_zero-

After this, I got the sform and qform in my atlas as below:

Now, my QSIPrep procedure have been stuck at the step “tck_sift2” for 20h. The log shows: “230830-11:25:20,267 nipype.workflow INFO: [Node] Finished “tck_sift2”, elapsed time 476.22031s.”

As far as I know, after “tck_sift2”, QSIPrep should proceed to calculate the connectome. Could this issue be related to my atlas?

It’s not necessary to zero out the sform, your custom parcellation should be good!

If qsiprep ever gets stuck on a step for this long, it’s likely that something crashed earlier in the pipeline. What was your command?

@mattcieslak This is my command, here you are:

qsiprep-docker /mnt/workdir/DCM/BIDS /mnt/workdir/DCM/BIDS/derivatives/qsiprep participant 
--participant_label 202 203 204 205  --output-resolution 2
--recon_input /mnt/workdir/DCM/BIDS/derivatives/qsiprep 
--recon_spec mrtrix_multishell_msmt_ACT-hsvs 
--fs-license-file /mnt/data/license.txt 
--freesurfer-input /mnt/workdir/DCM/BIDS/derivatives/freesurfer 
-w /mnt/workdir/DCM/working 
--custom_atlases /mnt/workdir/DCM/Docs/Reference/qsirecon_atlases 
--nthreads 100 
--gpus all

This is my atlas directory:
The “atlas_config.json” and “DMN_atlas_lps.nii.gz” both in the directory:


I found a crash file. The content in this file is :

Node: qsirecon_wf.sub-070_mrtrix_multishell_msmt_hsvs.sub_070_dir_PA_space_T1w_desc_preproc_recon_wf.qsirecon_anat_wf.get_atlases
Working directory: /scratch/qsirecon_wf/sub-070_mrtrix_multishell_msmt_hsvs/sub_070_dir_PA_space_T1w_desc_preproc_recon_wf/qsirecon_anat_wf/get_atlases

Node inputs:

atlas_names = [‘schaefer100’, ‘schaefer200’, ‘schaefer400’, ‘brainnetome246’, ‘aicha384’, ‘gordon333’, ‘aal116’]
forward_transform = /out/qsiprep/sub-070/anat/sub-070_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5
reference_image = /out/qsiprep/sub-070/dwi/sub-070_dir-PA_space-T1w_desc-preproc_dwi.nii.gz
space = T1w

Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py”, line 344, in _send_procs_to_workers
self.procs[jobid].run(updatehash=updatehash)
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py”, line 527, in run
result = self._run_interface(execute=True)
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py”, line 645, in _run_interface
return self._run_command(execute)
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py”, line 771, in _run_command
raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node get_atlases.

Traceback:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py”, line 397, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/interfaces/utils.py”, line 46, in _run_interface
atlas_configs = get_atlases(atlas_names)
File “/usr/local/miniconda/lib/python3.8/site-packages/qsiprep/utils/atlases.py”, line 26, in get_atlases
raise Exception(“Atlas %s not found in atlas_config.json” % atlas_name)
Exception: Atlas schaefer200 not found in atlas_config.json

Maybe I know the reason for this. To aceelated the speed of reconstruction, I remove the default atlas from the atlas_config.json. But the QSIPrep read the atlas name from the pipeline json file. It still only contains the default atlas but not my custom atlas.
So, to fulfill my requirement, I also need change the pipeline json file as the input of QSIPrep command?

Hi @YukunQu,

Yes, please make your own recon spec json that is a copy of the json file (https://github.com/PennLINC/qsiprep/blob/master/qsiprep/data/pipelines/mrtrix_multishell_msmt_ACT-hsvs.json) but with your atlas in the atlases field. Then pass that modified json into the —recon-spec argument.

Best,
Steven

1 Like