qsiprep.interfaces.surf module

Handling surfaces

class qsiprep.interfaces.surf.NormalizeSurf(from_file=None, resource_monitor=None, **inputs)[source]

Bases: SimpleInterface

Normalizes a FreeSurfer-generated GIFTI image

FreeSurfer includes an offset to the center of the brain volume that is not respected by all software packages. Normalization involves adding this offset to the coordinates of all vertices, and zeroing out that offset, to ensure consistent behavior across software packages. In particular, this normalization is consistent with the Human Connectome Project pipeline (see AlgorithmSurfaceApplyAffine and FreeSurfer2CaretConvertAndRegisterNonlinear), although the the HCP may not zero out the offset.

GIFTI files with midthickness/graymid in the name are also updated to include the following metadata entries:

{
    AnatomicalStructureSecondary: MidThickness,
    GeometricType: Anatomical
}

This interface is intended to be applied uniformly to GIFTI surface files generated from the ?h.white/?h.smoothwm and ?h.pial surfaces, as well as externally-generated ?h.midthickness/?h.graymid files. In principle, this should apply safely to any other surface, although it is less relevant to surfaces that don’t describe an anatomical structure.

Mandatory Inputs:

in_file (a pathlike object or string representing an existing file) – Freesurfer-generated GIFTI file.

Optional Inputs:

transform_file (a pathlike object or string representing an existing file) – FSL or LTA affine transform file.

Outputs:

out_file (a pathlike object or string representing a file) – Output file with re-centered GIFTI coordinates.

qsiprep.interfaces.surf.load_transform(fname)[source]

Load affine transform from file

Parameters:

fname (str or None) – Filename of an LTA or FSL-style MAT transform file. If None, return an identity transform

Returns:

affine

Return type:

(4, 4) numpy.ndarray

qsiprep.interfaces.surf.normalize_surfs(in_file, transform_file, newpath=None)[source]

Re-center GIFTI coordinates to fit align to native T1 space

For midthickness surfaces, add MidThickness metadata

Coordinate update based on: https://github.com/Washington-University/workbench/blob/1b79e56/src/Algorithms/AlgorithmSurfaceApplyAffine.cxx#L73-L91 and https://github.com/Washington-University/Pipelines/blob/ae69b9a/PostFreeSurfer/scripts/FreeSurfer2CaretConvertAndRegisterNonlinear.sh#L147