XCP-D offline use, issue with atlases

Hello :slight_smile:

I am trying to run xcp_d on a high performance computer that does not have access to internet.

I have specified in the script network none, yet it is still trying to access the internet to obtain some atlases (I suspect).

I have uploaded atlases generated when running xcp_d via Docker that is saved in derivatives/sourcedata/atlases. But I believe that the xcptmp working directory requires its own set of atlases. I have seen that for each participant it tries to run that it generates these atlases per participant working directory, so I am not too sure where to save atlases like: tpl-MNI152NLin2009cAsym_res-01_desc-carpet_dseg.nii.gz

Would I just download the atlases from the AtlasPack available on GitHub and store them in derivatives/sourcedata/atlases?

Command used:

#!/bin/bash
#PBS -P vn67
#PBS -q normal
#PBS -l ncpus=8
#PBS -l mem=16GB
#PBS -l walltime=08:00:00
#PBS -l wd
#PBS -m abe
#PBS -l storage=scratch/vn67+gdata/vn67

module load singularity


IMG=/g/data/vn67/et0688/xcp_d-26.0.2.simg

FMRIPREP=/scratch/vn67/et0688/MPATHY_MRI/MPATHY/fmriprep/prep_derivatives
OUT=/scratch/vn67/et0688/MPATHY_MRI/MPATHY/xcp_d/derivatives
WORK=/scratch/vn67/et0688/MPATHY_MRI/MPATHY/xcptmp/work

mkdir -p ${WORK}

# Extract subject ID from job name 
SUBJECT=$PBS_JOBNAME
#echo "Running fmriprep for subject: ${subject}"

echo "Running XCP-D for subject ${SUBJECT}"

singularity exec --cleanenv --network none \
  -B ${FMRIPREP}:/fmriprep:ro \
  -B ${OUT}:/out:rw \
  -B ${WORK}:/work:rw \
  -B /scratch/vn67/et0688/MPATHY_MRI/MPATHY/xcp_d/prep_derivatives/freesurfer:/freesurfer:ro \
  -B /scratch/vn67/et0688/MPATHY_MRI/MPATHY/fmriprep/Ref_Files/freesurfer.txt:/license.txt:ro \
  ${IMG} \
  xcp_d /fmriprep /out participant \
  -w /work \
  --participant-label ${SUBJECT} \
  --mode none \
  --task-id restingstate \
  --input-type fmriprep \
  --file-format nifti \
  --despike \
  --head-radius 50 \
  --smoothing 6 \
  -f 0.3 \
  --nuisance-regressors 36P \
  --motion-filter-type none \
  --output-type censored \
  --warp-surfaces-native2std n \
  --min-coverage 0.5 \
  --fs-license-file /license.txt \
  --abcc-qc n \
  --linc-qc n \
  --combine-runs n \
  --create-matrices all \
  --output-run-wise-correlations n

Version:

xcp_d-26.0.2

Environment (Docker, Singularity / Apptainer, custom installation):

Singularity

Data formatted according to a validatable standard? Please provide the output of the validator:

BIDS


Relevant log outputs (up to 20 lines):

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/.pixi/envs/xcp-d/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/app/.pixi/envs/xcp-d/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/cli/workflow.py", line 94, in build_workflow
    retval['workflow'] = init_xcpd_wf()
                         ^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/base.py", line 81, in init_xcpd_wf
    single_subject_wf = init_single_subject_wf(subject_id, anat_session, func_sessions)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/base.py", line 579, in init_single_subject_wf
    postprocess_bold_wf = init_postprocess_bold_wf(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/bold/nifti.py", line 325, in init_postprocess_nifti_wf
    qc_report_wf = init_qc_report_wf(
                   ^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/bold/plotting.py", line 236, in init_qc_report_wf
    get_template(
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/templateflow/client.py", line 249, in get
    _s3_get(self.cache.config, filepath)
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/templateflow/client.py", line 387, in _s3_get
    r = requests.get(url, stream=True, timeout=config.timeout)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/adapters.py", line 677, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='templateflow.s3.amazonaws.com', port=443): Max retries exceeded with url: /tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-carpet_dseg.nii.gz (Caused by NewConnectionError("HTTPSConnection(host='templateflow.s3.amazonaws.com', port=443): Failed to establish a new connection: [Errno 101] Network is unreachable"))

Thank you!! :slight_smile:


Hi @etow6030,

In this case, it is using Templateflow standard space files. You can clone the templateflow repo directly ( TemplateFlow · GitHub ), use datalad get to retrieve only the files they need (I think it is the T1w and brain mask of whatever MNI space your fmri are in), and then set the TEMPLATEFLOW_HOME environment variable in your singularity run command (with the --envflag) to wherever you cloned it.

EDIT: you would just need to download tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-01_desc-carpet_dseg.nii.gz as indicated in the error.

Best,

Steven

Hi Steven,

Thank you so much for the prompt reply.

I have now done this, but for some reason xcp_d is trying to access the internet still - despite the fact that tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz exists in the templateflow directory.

Script:

singularity exec --cleanenv --network none
-B ${OUT}:/out:rw
-B ${WORK}:/work:rw
-B /scratch/vn67/et0688/MPATHY_MRI/MPATHY/xcp_d/prep_derivatives:/fmriprep:ro
-B /scratch/vn67/et0688/MPATHY_MRI/MPATHY/fmriprep/Ref_Files/freesurfer.txt:/license.txt:ro
-B /g/data/vn67/templateflow:/templateflow:ro
–env TEMPLATEFLOW_HOME=/templateflow
${IMG}
xcp_d /fmriprep /out participant
-w /work
–participant-label 1115539
–mode none
–task-id restingstate
–input-type fmriprep
–file-format nifti
–despike
–head-radius 50
–smoothing 6
-f 0.3
–nuisance-regressors 36P
–motion-filter-type none
–output-type censored
–warp-surfaces-native2std n
–min-coverage 0.5
–fs-license-file /license.txt
–abcc-qc n
–linc-qc n
–combine-runs n
–create-matrices all
–output-run-wise-correlations n

And the error output:

Traceback (most recent call last):
File “/app/.pixi/envs/xcp-d/lib/python3.12/multiprocessing/process.py”, line 314, in _bootstrap
self.run()
File “/app/.pixi/envs/xcp-d/lib/python3.12/multiprocessing/process.py”, line 108, in run
self._target(*self._args, **self._kwargs)
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/cli/workflow.py”, line 94, in build_workflow
retval[‘workflow’] = init_xcpd_wf()
^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/base.py”, line 81, in init_xcpd_wf
single_subject_wf = init_single_subject_wf(subject_id, anat_session, func_sessions)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/base.py”, line 579, in init_single_subject_wf
postprocess_bold_wf = init_postprocess_bold_wf(
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/bold/nifti.py”, line 325, in init_postprocess_nifti_wf
qc_report_wf = init_qc_report_wf(
^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/xcp_d/workflows/bold/plotting.py”, line 125, in init_qc_report_wf
get_template(
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/templateflow/client.py”, line 249, in get
_s3_get(self.cache.config, filepath)
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/templateflow/client.py”, line 387, in _s3_get
r = requests.get(url, stream=True, timeout=config.timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/api.py”, line 73, in get
return request(“get”, url, params=params, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/api.py”, line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/sessions.py”, line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/sessions.py”, line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/app/.pixi/envs/xcp-d/lib/python3.12/site-packages/requests/adapters.py”, line 677, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘``templateflow.s3.amazonaws.com``’, port=443): Max retries exceeded with url: /tpl-MNI152NLin2009cAsym/tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz (Caused by NewConnectionError(“HTTPSConnection(host=‘``templateflow.s3.amazonaws.com``’, port=443): Failed to establish a new connection: [Errno 101] Network is unreachable”))

And I have triple checked that that file exists in my templateflow directory:

[et0688@gadi-login-08 tpl-MNI152NLin2009cAsym]$ pwd
/g/data/vn67/templateflow/tpl-MNI152NLin2009cAsym
[et0688@gadi-login-08 tpl-MNI152NLin2009cAsym]$ ls tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz
tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz

So I am not too sure why:

a) xcp_d does not recognise templateflow b) it is still trying to access the internet despite the --network noneflag

Thanks :slight_smile:

Hi @etow6030 ,

You can see now the error references a different file. Have you used datalad get to actually download the file? (That is, it’s not just an empty symlink?)

Best,

Steven

Hi Steven,

I had initially attempted to download the entire template flow using:

datalad install -r ///templateflow

But for anyone that runs into the same issue ! For whatever reason certain individual files were remaining as empty symlinks. I had to recursively run an interactive job on the HPC and individually download whichever templates that were flagged as unavailable. It now it working :slight_smile:

Thank you again for your help !!!

1 Like