Question about xcp_d

Hi xcp_d experts,

Recently I want to use xcp_d to deal with my preprocessed rs fmri data after fmriprep preprocessing. Here are my commands:

fmriprep:v21.0.4
sudo docker run -ti --rm -v /home/ra/xx:/data:ro -v /home/ra/xx-derivatives:/out -v /home/ra/work:/work -v /home/freesurfer/license.txt:/opt/freesurfer/license.txt nipreps/fmriprep /data /out participant --participant-label 050 -w /work --cifti-output --use-aroma --dummy-scans 4 --output-spaces MNI152NLin2009cAsym fsnative

xcp_d v0.2.1
sudo docker run -it --rm -v /home/ra/xx-derivatives:/fmriprep:ro -v /tmp/wkdir:/work:rw -v /home/ra/test:/out:rw -v /home/freesurfer:/freesurfer:ro pennlinc/xcp_d:latest /fmriprep /out participant --participant-label 050 -w /work --despike --head_radius 40 --smoothing 6 -d 8 --cifti

Now I have the following questions:

  1. the outputs of xcp_d contain only cifti data rather than the expected nifti and cifti as the xcp_d Docs show, and when I delete ‘–cifti’ flag, error occurred:

Process Process-2:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/multiprocessing/process.py”, line 315, in _bootstrap
self.run()
File “/usr/local/miniconda/lib/python3.8/multiprocessing/process.py”, line 108, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/cli/run.py”, line 921, in build_workflow
retval[“workflow”] = init_xcpd_wf(
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/workflow/base.py”, line 161, in init_xcpd_wf
single_subj_wf = init_subject_wf(
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/workflow/base.py”, line 456, in init_subject_wf
bold_postproc_wf = postproc_wf_function(
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/workflow/bold.py”, line 174, in init_boldpostprocess_wf
raise Exception(f"Unable to determine TR of {bold_file}")
Exception: Unable to determine TR of /fmriprep/sub-050/ses-1/func/sub-050_ses-1_task-rest_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz

  1. sorry that I’ve never done surface-based fmri analysis before, if I want to preform some group analyses based on surface fmri next, would you please recommand some tools like fsl randomise?

  2. in fmriprep, the default FD threshold is 0.5mm and in xcp_d is 0.2 mm, will this affect the censoring process?

  3. my last question is that I am confused with ‘–bandpass_filter’ and ‘–motion-filter-type’. I think there is some overlap between the two and I just need to set the former, right?

Thank you in advance for the input!

Best regards,
Jun

Hello,

Is the TR specified in the accompanying JSON file?

FitLins would be a good next step to process CIFTI data.

XCP_D to my knowledge will not use motion outliers as defined by fMRIPrep, and instead recalculates them. You can change the XCP_D default outlier threshold if you would like with the -f flag.

These are two different things. The -bandpass_filter is for processing the BOLD time series. The -motion-filter-type corresponds to filtering of the FD values (due to respiratory effects).

Best,
Steven

EDIT:

I just saw that you have resting state data, in which case FitLins would not be appropriate. Without knowing more about your specific hypotheses it is hard to recommend a next step.

Hi Steven,

Thank you so much for solving my doubts and giving me advice. It’s clear to me now!

I think the TR is specified in the accompanying JSON file:

{
“RepetitionTime”: 2,
“SkullStripped”: false,
“SliceTimingCorrected”: true,
“StartTime”: 0.972,
“TaskName”: “rest”
}

Best,
Jun

Does the error persist when using a different working directory for running xcp_d on the volumetric data?

I changed the working directory, and this error still exists without ‘–cifti’ flag.

and error appeared when the ‘–cifti’ flag added:

Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py”, line 67, in run_node
result[“result”] = node.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 plot_svgx_wf.

Traceback:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py”, line 398, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/surfplotting.py”, line 131, in _run_interface
‘after_process’] = plot_svgx(
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/utils/plot.py”, line 478, in plot_svgx
raw_data = raw_data[dummyvols:]
TypeError: slice indices must be integers or None or have an index method

Just to make sure I understand, you now get the TypeError when you use --cifti, and the TR Exception when you don’t. Is that correct?

Can you try using pennlinc/xcp_d:unstable?

Thank you! I tried the pennlinc/xcp_d:unstable, and it works well in both case (the outputs look complete), but there is still TypeError with or without --cifti.

All tasks completed
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/cli/run.py”, line 557, in main
xcpd_wf.run(**plugin_settings)
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/workflows.py”, line 638, in run
runner.run(execgraph, updatehash=updatehash, config=self.config)
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/base.py”, line 212, in run
raise error from cause
RuntimeError: Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py”, line 67, in run_node
result[“result”] = node.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 plot_svgx_wf.

Traceback:
Traceback (most recent call last):
File “/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py”, line 398, in run
runtime = self._run_interface(runtime)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/surfplotting.py”, line 131, in _run_interface
‘after_process’] = plot_svgx(
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/utils/plot.py”, line 479, in plot_svgx
raw_data = raw_data[dummyvols:]
TypeError: slice indices must be integers or None or have an index method

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/miniconda/bin/xcp_d”, line 8, in
sys.exit(main())
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/cli/run.py”, line 647, in main
failed_reports = generate_reports(
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/report_core.py”, line 172, in generate_reports
LayoutBuilder(html_path=str(Path(output_dir)) + ‘/xcp_d/’,
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/layout_builder.py”, line 400, in init
self.run()
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/layout_builder.py”, line 506, in run
tasks_section = TasksSection(tasks=tasks_list, **kwargs)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/layout_builder.py”, line 255, in init
self.run(tasks)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/layout_builder.py”, line 362, in run
self.write_bold_gray_row(task_name)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/interfaces/layout_builder.py”, line 331, in write_bold_gray_row
task_file = find_one_file(self.img_path, pattern)
File “/usr/local/miniconda/lib/python3.8/site-packages/xcp_d/utils/filemanip.py”, line 684, in find_one_file
one_file = filelist[0]
IndexError: list index out of range

Hi Jun,

Thank you for testing that. I think I understand the problem now. I will look into fixing it today and hopefully we can push a patch release later today or tomorrow. I may ask you to test using a newer version of unstable once I have merged the fix, if that’s alright?

OK, with pleasure! :smiley:

@wenjun I’ve merged the fix. Could you pull the updated version of unstable and try it out on your data?

Thank you, Taylor! It works successfully now.

1 Like