Hi all,
I want to use init_ bold_ surf_ wf function of fmriprep20.1.1, but there are the following errors, and I have installed FreeSurfer.
/usr/local/python3/bin/python3.8 /home/yxx/fmriprep-20.1.1/fmriprep-20.1.1/fmriprep/workflows/bold/resampleboldSurf.py
200826-10:28:16,490 nipype.workflow INFO:
Workflow bold_surf_wftest settings: ['check', 'execution', 'logging', 'monitoring']
200826-10:28:16,503 nipype.workflow INFO:
Running serially.
200826-10:28:16,503 nipype.workflow INFO:
[Node] Setting-up "bold_surf_wftest.rename_src" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/rename_src".
200826-10:28:16,506 nipype.workflow INFO:
[Node] Running "rename_src" ("nipype.interfaces.utility.base.Rename")
200826-10:28:16,619 nipype.workflow INFO:
[Node] Finished "bold_surf_wftest.rename_src".
200826-10:28:16,620 nipype.workflow INFO:
[Node] Setting-up "bold_surf_wftest.targets" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/targets".
200826-10:28:16,623 nipype.workflow INFO:
[Node] Running "targets" ("nipype.interfaces.utility.wrappers.Function")
200826-10:28:16,629 nipype.workflow INFO:
[Node] Finished "bold_surf_wftest.targets".
200826-10:28:16,629 nipype.workflow INFO:
[Node] Setting-up "bold_surf_wftest.get_fsnative" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/get_fsnative".
200826-10:28:16,632 nipype.workflow INFO:
[Node] Running "get_fsnative" ("nipype.interfaces.io.FreeSurferSource")
200826-10:28:16,673 nipype.workflow INFO:
[Node] Finished "bold_surf_wftest.get_fsnative".
200826-10:28:16,673 nipype.workflow INFO:
[Node] Setting-up "bold_surf_wftest.itk2lta" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/itk2lta".
200826-10:28:16,680 nipype.workflow INFO:
[Node] Running "itk2lta" ("nipype.interfaces.utility.wrappers.Function")
200826-10:28:17,465 nipype.workflow INFO:
[Node] Finished "bold_surf_wftest.itk2lta".
200826-10:28:17,465 nipype.workflow INFO:
[Node] Setting-up "bold_surf_wftest.sampler" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler".
200826-10:28:17,483 nipype.workflow INFO:
[Node] Setting-up "_sampler0" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler/mapflow/_sampler0".
200826-10:28:17,491 nipype.workflow INFO:
[Node] Running "_sampler0" ("nipype.interfaces.freesurfer.utils.SampleToSurface"), a CommandLine Interface with command:
mri_vol2surf --cortex --hemi lh --interp trilinear --o /home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler/mapflow/_sampler0/lh.fsaverage5.gii --srcsubject sub-50004 --reg /home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/itk2lta/out.lta --projfrac-avg 0.000 1.000 0.200 --mov /home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/rename_src/fsaverage5.nii.gz --trgsubject fsaverage5
200826-10:28:17,497 nipype.workflow WARNING:
Storing result file without outputs
200826-10:28:17,497 nipype.workflow WARNING:
[Node] Error on "_sampler0" (/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler/mapflow/_sampler0)
200826-10:28:17,522 nipype.workflow INFO:
[Node] Setting-up "_sampler1" in "/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler/mapflow/_sampler1".
200826-10:28:17,530 nipype.workflow INFO:
[Node] Running "_sampler1" ("nipype.interfaces.freesurfer.utils.SampleToSurface"), a CommandLine Interface with command:
mri_vol2surf --cortex --hemi rh --interp trilinear --o /home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler/mapflow/_sampler1/rh.fsaverage5.gii --srcsubject sub-50004 --reg /home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/itk2lta/out.lta --projfrac-avg 0.000 1.000 0.200 --mov /home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/rename_src/fsaverage5.nii.gz --trgsubject fsaverage5
200826-10:28:17,533 nipype.workflow WARNING:
Storing result file without outputs
200826-10:28:17,534 nipype.workflow WARNING:
[Node] Error on "_sampler1" (/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler/mapflow/_sampler1)
200826-10:28:17,535 nipype.workflow WARNING:
Storing result file without outputs
200826-10:28:17,535 nipype.workflow WARNING:
[Node] Error on "bold_surf_wftest.sampler" (/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/bold_surf_wftest/_target_fsaverage5/sampler)
200826-10:28:17,536 nipype.workflow ERROR:
Node sampler.a0 failed to run on host yxx-virtual-machine.
200826-10:28:17,536 nipype.workflow ERROR:
Saving crash info to /home/yxx/fmriprep-20.1.1/fmriprep-20.1.1/fmriprep/workflows/bold/crash-20200826-102817-root-sampler.a0-d72a11f1-4b38-497d-940f-e72ebfaa7363.pklz
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/plugins/linear.py", line 46, in run
node.run(updatehash=updatehash)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
result = self._run_interface(execute=True)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 1381, in _run_interface
result = self._collate_results(
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 1294, in _collate_results
raise Exception(
Exception: Subnodes of node: sampler failed:
Subnode 0 failed
Error: Traceback (most recent call last):
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/utils.py", line 94, in nodelist_runner
result = node.run(updatehash=updatehash)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
result = self._run_interface(execute=True)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
return self._run_command(execute)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
result = self._interface.run(cwd=outdir)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/interfaces/freesurfer/base.py", line 149, in run
return super(FSCommand, self).run(**inputs)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run
runtime = self._run_interface(runtime)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 778, in _run_interface
raise IOError(
OSError: No command "mri_vol2surf" found on host yxx-virtual-machine. Please check that the corresponding package is installed.
Subnode 1 failed
Error: Traceback (most recent call last):
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/utils.py", line 94, in nodelist_runner
result = node.run(updatehash=updatehash)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 516, in run
result = self._run_interface(execute=True)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 635, in _run_interface
return self._run_command(execute)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 741, in _run_command
result = self._interface.run(cwd=outdir)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/interfaces/freesurfer/base.py", line 149, in run
return super(FSCommand, self).run(**inputs)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run
runtime = self._run_interface(runtime)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 778, in _run_interface
raise IOError(
OSError: No command "mri_vol2surf" found on host yxx-virtual-machine. Please check that the corresponding package is installed.
200826-10:28:17,537 nipype.workflow INFO:
***********************************
200826-10:28:17,538 nipype.workflow ERROR:
could not run node: bold_surf_wftest.sampler.a0
200826-10:28:17,538 nipype.workflow INFO:
crashfile: /home/yxx/fmriprep-20.1.1/fmriprep-20.1.1/fmriprep/workflows/bold/crash-20200826-102817-root-sampler.a0-d72a11f1-4b38-497d-940f-e72ebfaa7363.pklz
200826-10:28:17,538 nipype.workflow INFO:
***********************************
Traceback (most recent call last):
File "/home/yxx/fmriprep-20.1.1/fmriprep-20.1.1/fmriprep/workflows/bold/resampleboldSurf.py", line 166, in <module>
workflow.run()
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/engine/workflows.py", line 632, in run
runner.run(execgraph, updatehash=updatehash, config=self.config)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/plugins/linear.py", line 70, in run
report_nodes_not_run(notrun)
File "/usr/local/python3/lib/python3.8/site-packages/nipype/pipeline/plugins/tools.py", line 97, in report_nodes_not_run
raise RuntimeError(
RuntimeError: Workflow did not execute cleanly. Check log for details
Process finished with exit code 1
But I can run the mri_vol2surf command on the terminal.FreeSurfer has been successfully installed,Here is the code I used from fmeiprep 20.1.1
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
Resampling workflows
++++++++++++++++++++
.. autofunction:: init_bold_surf_wf
.. autofunction:: init_bold_std_trans_wf
.. autofunction:: init_bold_preproc_trans_wf
"""
import pysnooper
from nipype.interfaces.io import FreeSurferSource
from nipype.pipeline import engine as pe
from nipype.interfaces import utility as niu, freesurfer as fs
from pathlib import Path
from pathlib import Path
from niworkflows.interfaces.bids import DerivativesDataSink
from niworkflows.interfaces.utility import KeySelect
DEFAULT_MEMORY_MIN_GB = 0.01
mem_gb=0.1
surface_spaces=['fsaverage5']
medial_surface_nan=False
# """
# Sample functional images to FreeSurfer surfaces.
#
# For each vertex, the cortical ribbon is sampled at six points (spaced 20% of thickness apart)
# and averaged.
# Outputs are in GIFTI format.
#
# Workflow Graph
# .. workflow::
# :graph2use: colored
# :simple_form: yes
#
# from fmriprep.workflows.bold import init_bold_surf_wf
# wf = init_bold_surf_wf(mem_gb=0.1,
# surface_spaces=['fsnative', 'fsaverage5'],
# medial_surface_nan=False)
#
# Parameters
# ----------
# surface_spaces : :obj:`list`
# List of FreeSurfer surface-spaces (either ``fsaverage{3,4,5,6,}`` or ``fsnative``)
# the functional images are to be resampled to.
# For ``fsnative``, images will be resampled to the individual subject's
# native surface.
# medial_surface_nan : :obj:`bool`
# Replace medial wall values with NaNs on functional GIFTI files
#
# Inputs
# ------
# source_file
# Motion-corrected BOLD series in T1 space
# subjects_dir
# FreeSurfer SUBJECTS_DIR
# subject_id
# FreeSurfer subject ID
# t1w2fsnative_xfm
# LTA-style affine matrix translating from T1w to FreeSurfer-conformed subject space
#
# Outputs
# -------
# surfaces
# BOLD series, resampled to FreeSurfer surfaces
#
# """
from niworkflows.engine.workflows import LiterateWorkflow as Workflow
from niworkflows.interfaces.surf import GiftiSetAnatomicalStructure, Path2BIDS
workflow = Workflow(name='bold_surf_wf',base_dir='/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func')
workflow.__desc__ = """\
The BOLD time-series were resampled onto the following surfaces from nipype.interfaces.io import FreeSurferSource
(FreeSurfer reconstruction nomenclature):
{out_spaces}.
""".format(out_spaces=', '.join(['*%s*' % s for s in surface_spaces]))
inputnode = pe.Node(
niu.IdentityInterface(fields=['source_file', 'subject_id', 'subjects_dir',
't1w2fsnative_xfm']),
name='inputnode')
inputnode.inputs.t1w2fsnative_xfm='/home/yxx/betascap_50004/derivatives/fmriprep/sub-50004/func/t1w2fsnative/t1w2fsnative_xfm/out.lta'
inputnode.inputs.source_file='/home/yxx/betascap_50004/BIDS/sub-50004/func/sub-50004_task-rest_bold_space-T1w_preproc.nii.gz'
inputnode.inputs.subject_id='sub-50004'
inputnode.inputs.subjects_dir='/home/yxx/betascap_50004/derivatives/freesurfer'
itersource = pe.Node(niu.IdentityInterface(fields=['target']), name='itersource')
itersource.iterables = [('target', surface_spaces)]
get_fsnative = pe.Node(FreeSurferSource(), name='get_fsnative',
run_without_submitting=True)
def select_target(subject_id, space):
"""Get the target subject ID, given a source subject ID and a target space."""
return subject_id if space == 'fsnative' else space
targets = pe.Node(niu.Function(function=select_target), name='targets',
run_without_submitting=True, mem_gb=DEFAULT_MEMORY_MIN_GB)
# Rename the source file to the output space to simplify naming later
rename_src = pe.Node(niu.Rename(format_string='%(subject)s', keep_ext=True),
name='rename_src', run_without_submitting=True,
mem_gb=DEFAULT_MEMORY_MIN_GB)
def _itk2lta(in_file, src_file, dst_file):
import nitransforms as nt
from pathlib import Path
out_file = Path("out.lta").absolute()
nt.linear.load(
in_file,
fmt="fs" if in_file.endswith(".lta") else "itk",
reference=src_file).to_filename(
out_file, moving=dst_file, fmt="fs")
return str(out_file)
itk2lta = pe.Node(niu.Function(function=_itk2lta), name="itk2lta",
run_without_submitting=True)
sampler = pe.MapNode(
fs.SampleToSurface(
cortex_mask=True,
interp_method='trilinear',
out_type='gii',
override_reg_subj=True,
sampling_method='average',
sampling_range=(0, 1, 0.2),
sampling_units='frac',
),
iterfield=['hemi'], name='sampler', mem_gb=mem_gb * 3)
sampler.inputs.hemi = ['lh', 'rh']
update_metadata = pe.MapNode(GiftiSetAnatomicalStructure(), iterfield=['in_file'],
name='update_metadata', mem_gb=DEFAULT_MEMORY_MIN_GB)
outputnode = pe.JoinNode(niu.IdentityInterface(fields=['surfaces', 'target']),
joinsource='itersource', name='outputnode')
workflow.connect([
(inputnode, get_fsnative, [('subject_id', 'subject_id'),
('subjects_dir', 'subjects_dir')]),
(inputnode, targets, [('subject_id', 'subject_id')]),
(inputnode, rename_src, [('source_file', 'in_file')]),
(inputnode, itk2lta, [('source_file', 'src_file'),
('t1w2fsnative_xfm', 'in_file')]),
(get_fsnative, itk2lta, [('T1', 'dst_file')]),
(inputnode, sampler, [('subjects_dir', 'subjects_dir'),
('subject_id', 'subject_id')]),
(itersource, targets, [('target', 'space')]),
(itersource, rename_src, [('target', 'subject')]),
(itk2lta, sampler, [('out', 'reg_file')]),
(targets, sampler, [('out', 'target_subject')]),
(rename_src, sampler, [('out_file', 'source_file')]),
(sampler, update_metadata, [('out_file', 'in_file')]),
(update_metadata, outputnode, [('out_file', 'surfaces')]),
(itersource, outputnode, [('target', 'target')]),
])
workflow.run()
I don’t know how to correct such a mistake,I am looking forward to your reply!