vol2surf
- subcortexmesh.vol2surf.vol2surf(inputdir: str | Path, outputdir: str | Path, dilate_erode: bool = True, roilabel: str | Sequence[str] = ['left-cerebellum-cortex', 'right-cerebellum-cortex', 'left-pallidum', 'right-pallidum', 'left-putamen', 'right-putamen', 'left-thalamus', 'right-thalamus', 'left-amygdala', 'right-amygdala', 'left-hippocampus', 'right-hippocampus', 'left-accumbens-area', 'right-accumbens-area', 'left-caudate', 'right-caudate', 'left-ventraldc', 'right-ventraldc', 'brain-stem'], smoothing: int = 15, plot_volnext2surf: bool = False, overwrite: bool = True, silent: bool = False)[source]
Converting subcortical volumes to surface meshes
This function function converts the separate volumes outputted by subseg_getvol, using the discrete marching cube method. This includes pre-conversion dilation/erosion of the volume and smoothing of the surface (both can be disabled) to ensure meshes are not too coarse and noisy. Note that the dilation/smootinh process was applied to the meshes used as the standard space in mesh_metrics().
An optional argument can be provided to visualise the volume and its rendered mesh (plot_volnext2surf), with an interactive slider, in order to check the quality of the rendering of every mesh.
Parallel processes: to avoid conflicts, subjects will be skipped if a “isrunning” tmp file exists to mark them as currently processing. The tmp file is removed at the end or replaced if 1 hour old. If a process has been interrupted, remove the tmp manually to rerun a subject before the 1 hour (its path is printed when flagged).
- Parameters:
inputdir (str, Path) – The sub_volumes/ directory where the subcortical volumes were outputted (using subseg_getvol()).
outputdir (str, Path) – The path where subcortical meshes will be saved (creates the “sub_surfaces” directory inside the path).
roilabel (str, Sequence) – The name(s) of the region(s)-of-interest to be computed as strings. Default is all subcortices across all segmentation templates: ‘left-cerebellum-cortex’, ‘right-cerebellum-cortex’, ‘left-pallidum’, ‘right-pallidum’, ‘left-putamen’, ‘right-putamen’, ‘left-thalamus’, ‘right-thalamus’,’left-amygdala’, ‘right-amygdala’, ‘left-hippocampus’, ‘right-hippocampus’, ‘left-accumbens-area’,’right-accumbens-area’,’left-caudate’, ‘right-caudate’, ‘left-ventraldc’, ‘right-ventraldc’, and ‘brain-stem’.
dilate_erode (bool) – Uses vtkImageDilateErode3D to slightly erode and dilate the volume before conversion, which helps unify sparse voxels and produce smooth vertices. Default is True.
smoothing (int) – The number of iterations of the smoothing procedure (0 will apply no smoothing). The settings are otherwise those of VTK’s SmoothDiscreteMarchingCubes. Default is 15.
plot_volnext2surf (bool) – Whether to plot the volume and the surface together and check for their correspondance. Default is False.
overwrite (bool) – Whether files are to be overwritten or skipped if already in outputdir. Default is True.
silent (bool) – Whether messages about the process are to be printed. Default is False.