How to add costum atlas to QSIprep reconstruction?

Hello!

I would like to add a custom atlas to the reconstruction of structural connectivity. I managed to do this with docker, but now need to run singularity. However I get an error, in that it seems it can’t find the atlases I’m using. I’m wondering if this is the correct way to do it?

singularity run --cleanenv \
    -B /data/bids/:/datax:ro,/data/bids/derivatives/:/out,/data/bids/files/license.txt,/data/bids/files/:/atlas/qsirecon_atlases \
    /data/images/qsiprep-0.19.1.sif \
    /datax /out -w /out/work participant \
    --recon-only --recon_spec /atlas/qsirecon_atlases/pipeline.json \
    --recon_input /data/bids/derivatives/qsiprep \
    --fs-license-file /data_x/files/license.txt \
    --n_cpus 15 --skip_bids_validation 

Kind regards,

Hi @AlteredCarbon, and welcome to neurostars!

It would help to see (1) the error (2) the contents of /data/bids/files/ (3) the recon pipeline config.

Best,
Steven

Thank you!

The content of /data/bids/files/ is:
atlas_config.json
license.txt
Schaefer2018_1000Parcels_17Networks_MNI152_1mm.nii.gz
SchaeferTian416_MNI_1mm.nii.gz
coords.tsv
pipeline.json

The recon pipeline config is:

{
    "name": "dsistudio_pipeline",
    "space": "T1w",
    "atlases": ["SchaeferTian416", "Schaefer1000"],
    "nodes": [
      {
        "name": "dsistudio_gqi",
        "software": "DSI Studio",
        "action": "reconstruction",
        "input": "qsiprep",
        "output_suffix": "gqi",
        "parameters": {"method": "gqi"}
      },
      {
        "name": "scalar_export",
        "software": "DSI Studio",
        "action": "export",
        "input": "dsistudio_gqi",
        "output_suffix": "gqiscalar"
      },
      {
        "name": "tractography",
        "software": "DSI Studio",
        "action": "tractography",
        "input": "dsistudio_gqi",
        "parameters": {
          "turning_angle": 35,
          "smoothing": 0.0,
          "step_size": 1.0,
          "min_length": 30,
          "max_length": 250,
          "seed_plan": 0,
          "interpolation": 0,
          "initial_dir": 2,
          "fiber_count": 5000000
        }
      },
      {
        "name": "streamline_connectivity",
        "software": "DSI Studio",
        "action": "connectivity",
        "input": "tractography",
        "output_suffix": "gqinetwork",
        "parameters": {
          "connectivity_value": "ncount,gfa",
          "connectivity_type": "pass,end"
        }
      }
    ]
  }

And the error from the crash file is:

Node: qsirecon_wf.sub-BI02450_dsistudio_pipeline.sub_BI02450_ses_20230328_space_T1w_desc_preproc_anat_wf.get_atlases
Working directory: /out/work/qsirecon_wf/sub-BI02450_dsistudio_pipeline/sub_BI02450_ses_20230328_space_T1w_desc_preproc_anat_wf/get_atlases

Node inputs:

atlas_names = ['SchaeferTian416', 'Schaefer1000']
forward_transform = /data/bids/derivatives/qsiprep/sub-BI02450/anat/sub-BI02450_from-MNI152NLin2009cAsym_to-T1w_mode-image_xfm.h5
reference_image = /data/bids/derivatives/qsiprep/sub-BI02450/ses-20230328/dwi/sub-BI02450_ses-20230328_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 22, in get_atlases
	    atlas_config = json.load(f)
	  File "/usr/local/miniconda/lib/python3.8/json/__init__.py", line 293, in load
	    return loads(fp.read(),
	  File "/usr/local/miniconda/lib/python3.8/json/__init__.py", line 357, in loads
	    return _default_decoder.decode(s)
	  File "/usr/local/miniconda/lib/python3.8/json/decoder.py", line 337, in decode
	    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
	  File "/usr/local/miniconda/lib/python3.8/json/decoder.py", line 355, in raw_decode
	    raise JSONDecodeError("Expecting value", s, err.value) from None
	json.decoder.JSONDecodeError: Expecting value: line 1846 column 2 (char 20935)

The atlas_config.json contains:

  {
    "SchaeferTian416": {
      "file": "SchaeferTian416_MNI_1mm.nii.gz",
      "node_ids": [
        1, 2, ... 416
      ],
      "node_names": [
  	"node1", "node2", ...
       
      ]
    },
    "Schaefer1000": {
      "file": "Schaefer2018_1000Parcels_17Networks_MNI152_1mm.nii.gz",
      "node_ids": [
  	1, 2, ... 1000
        ],
      "node_names": [
  	"node1", "node2", ...
  	
      ] 
    }
  }

Hi @AlteredCarbon,

What are the contents of atlas_config.json? Also, your recon_spec is using schaefer400, which is not included in your /data/bids/files/ collection.

Best,
Steven

Thank you @Steven. I’ve edited my previous reply, and added the info on atlas_config.json.

Hi @AlteredCarbon,

According to the error, perhaps there’s a formatting error in the atlas config json. Run the full contents through https://jsonlint.com/ to confirm.

Best,
Steven