openlifu.seg.skinseg

Tools to get a skin surface from an MRI.

Example workflow, starting from

  • an MRI volume vol_array, as a numpy array

  • an associated 4x4 affine transform, as a numpy array

  • a desired spherical coordinate system origin location inside the volume (e.g. the sonication target)

foreground_mask_array = compute_foreground_mask(vol_array) foreground_mask_vtk_image = vtk_img_from_array_and_affine(foreground_mask_array, affine) skin_mesh = create_closed_surface_from_labelmap(foreground_mask_vtk_image) skin_interpolator = spherical_interpolator_from_mesh(skin_mesh, origin)

Functions

affine_from_vtk_image_data(vtk_img)

Get a 4x4 affine matrix out of a vtkImageData, a partial reverse to vtk_img_from_array_and_affine

apply_affine_to_polydata(affine, polydata)

Apply an affine transform to a vtkPolyData.

compute_foreground_mask(vol_array[, ...])

Given a 3D image array, return a boolean mask representing the "foreground."

create_closed_surface_from_labelmap(...[, ...])

Create a surface mesh vtkPolyData from a binary labelmap vtkImageData.

spherical_interpolator_from_mesh(surface_mesh)

Create a spherical interpolator from a vtkPolyData.

take_largest_connected_component(mask)

Given a boolean image array (or any integer numpy array), return a mask of the largest connected component.

vtk_img_from_array_and_affine(vol_array, affine)

Convert a numpy (array, affine) pair into a vtkImageData.