Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freesurfer reconall outputs missing #3667

Open
JailanOweda opened this issue Aug 28, 2024 · 1 comment
Open

freesurfer reconall outputs missing #3667

JailanOweda opened this issue Aug 28, 2024 · 1 comment

Comments

@JailanOweda
Copy link

In the freesurfer interface when using the reconall function, not all files generated in the cache_directory are listed as possible outputs that you can use as inputs for the next node (e.g. copy them to the derivatives directory using datasink).
E.g. none of the files in the scripts directory are listed.

@effigies
Copy link
Member

Yes, the FreeSurfer interface assumes you're looking for imaging outputs. To add outputs, patch here:

nipype/nipype/interfaces/io.py

Lines 1634 to 1840 in 2e36f69

class FSSourceOutputSpec(TraitedSpec):
T1 = File(exists=True, desc="Intensity normalized whole-head volume", loc="mri")
aseg = File(
exists=True,
loc="mri",
desc="Volumetric map of regions from automatic segmentation",
)
brain = File(exists=True, desc="Intensity normalized brain-only volume", loc="mri")
brainmask = File(exists=True, desc="Skull-stripped (brain-only) volume", loc="mri")
filled = File(exists=True, desc="Subcortical mass volume", loc="mri")
norm = File(exists=True, desc="Normalized skull-stripped volume", loc="mri")
nu = File(exists=True, desc="Non-uniformity corrected whole-head volume", loc="mri")
orig = File(exists=True, desc="Base image conformed to Freesurfer space", loc="mri")
rawavg = File(
exists=True, desc="Volume formed by averaging input images", loc="mri"
)
ribbon = OutputMultiPath(
File(exists=True),
desc="Volumetric maps of cortical ribbons",
loc="mri",
altkey="*ribbon",
)
wm = File(exists=True, desc="Segmented white-matter volume", loc="mri")
wmparc = File(
exists=True,
loc="mri",
desc="Aparc parcellation projected into subcortical white matter",
)
curv = OutputMultiPath(
File(exists=True), desc="Maps of surface curvature", loc="surf"
)
avg_curv = OutputMultiPath(
File(exists=True),
desc="Average atlas curvature, sampled to subject",
loc="surf",
)
inflated = OutputMultiPath(
File(exists=True), desc="Inflated surface meshes", loc="surf"
)
pial = OutputMultiPath(
File(exists=True), desc="Gray matter/pia matter surface meshes", loc="surf"
)
area_pial = OutputMultiPath(
File(exists=True),
desc="Mean area of triangles each vertex on the pial surface is "
"associated with",
loc="surf",
altkey="area.pial",
)
curv_pial = OutputMultiPath(
File(exists=True),
desc="Curvature of pial surface",
loc="surf",
altkey="curv.pial",
)
smoothwm = OutputMultiPath(
File(exists=True), loc="surf", desc="Smoothed original surface meshes"
)
sphere = OutputMultiPath(
File(exists=True), desc="Spherical surface meshes", loc="surf"
)
sulc = OutputMultiPath(
File(exists=True), desc="Surface maps of sulcal depth", loc="surf"
)
thickness = OutputMultiPath(
File(exists=True), loc="surf", desc="Surface maps of cortical thickness"
)
volume = OutputMultiPath(
File(exists=True), desc="Surface maps of cortical volume", loc="surf"
)
white = OutputMultiPath(
File(exists=True), desc="White/gray matter surface meshes", loc="surf"
)
jacobian_white = OutputMultiPath(
File(exists=True),
desc="Distortion required to register to spherical atlas",
loc="surf",
)
graymid = OutputMultiPath(
File(exists=True),
desc="Graymid/midthickness surface meshes",
loc="surf",
altkey=["graymid", "midthickness"],
)
label = OutputMultiPath(
File(exists=True),
desc="Volume and surface label files",
loc="label",
altkey="*label",
)
annot = OutputMultiPath(
File(exists=True), desc="Surface annotation files", loc="label", altkey="*annot"
)
aparc_aseg = OutputMultiPath(
File(exists=True),
loc="mri",
altkey="aparc*aseg",
desc="Aparc parcellation projected into aseg volume",
)
sphere_reg = OutputMultiPath(
File(exists=True),
loc="surf",
altkey="sphere.reg",
desc="Spherical registration file",
)
aseg_stats = OutputMultiPath(
File(exists=True),
loc="stats",
altkey="aseg",
desc="Automated segmentation statistics file",
)
wmparc_stats = OutputMultiPath(
File(exists=True),
loc="stats",
altkey="wmparc",
desc="White matter parcellation statistics file",
)
aparc_stats = OutputMultiPath(
File(exists=True),
loc="stats",
altkey="aparc",
desc="Aparc parcellation statistics files",
)
BA_stats = OutputMultiPath(
File(exists=True),
loc="stats",
altkey="BA",
desc="Brodmann Area statistics files",
)
aparc_a2009s_stats = OutputMultiPath(
File(exists=True),
loc="stats",
altkey="aparc.a2009s",
desc="Aparc a2009s parcellation statistics files",
)
curv_stats = OutputMultiPath(
File(exists=True), loc="stats", altkey="curv", desc="Curvature statistics files"
)
entorhinal_exvivo_stats = OutputMultiPath(
File(exists=True),
loc="stats",
altkey="entorhinal_exvivo",
desc="Entorhinal exvivo statistics files",
)
class FreeSurferSource(IOBase):
"""Generates freesurfer subject info from their directories.
Examples
--------
>>> from nipype.interfaces.io import FreeSurferSource
>>> fs = FreeSurferSource()
>>> #fs.inputs.subjects_dir = '.'
>>> fs.inputs.subject_id = 'PWS04'
>>> res = fs.run() # doctest: +SKIP
>>> fs.inputs.hemi = 'lh'
>>> res = fs.run() # doctest: +SKIP
"""
input_spec = FSSourceInputSpec
output_spec = FSSourceOutputSpec
_always_run = True
_additional_metadata = ["loc", "altkey"]
def _get_files(self, path, key, dirval, altkey=None):
globsuffix = ""
if dirval == "mri":
globsuffix = ".mgz"
elif dirval == "stats":
globsuffix = ".stats"
globprefix = ""
if dirval in ("surf", "label", "stats"):
if self.inputs.hemi != "both":
globprefix = self.inputs.hemi + "."
else:
globprefix = "?h."
if key in ("aseg_stats", "wmparc_stats"):
globprefix = ""
elif key == "ribbon":
if self.inputs.hemi != "both":
globprefix = self.inputs.hemi + "."
else:
globprefix = "*"
keys = ensure_list(altkey) if altkey else [key]
globfmt = os.path.join(path, dirval, f"{globprefix}{{}}{globsuffix}")
return [
os.path.abspath(f) for key in keys for f in glob.glob(globfmt.format(key))
]
def _list_outputs(self):
subjects_dir = self.inputs.subjects_dir
subject_path = os.path.join(subjects_dir, self.inputs.subject_id)
output_traits = self._outputs()
outputs = output_traits.get()
for k in list(outputs.keys()):
val = self._get_files(
subject_path,
k,
output_traits.traits()[k].loc,
output_traits.traits()[k].altkey,
)
if val:
outputs[k] = simplify_list(val)
return outputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants