color_mesh: Takes a density vector mapped to standardized coordinates and...

View source: R/BoneDensityFunctions.R

color_meshR Documentation

Takes a density vector mapped to standardized coordinates and maps it to a surface mesh for visualization.

Description

Takes a density vector mapped to standardized coordinates and maps it to a surface mesh for visualization.

Usage

color_mesh(
  surface_mesh,
  template_pts,
  density_vector,
  maxi = NULL,
  mini = NULL,
  export_path,
  color_sel
)

Arguments

surface_mesh

Mesh object

template_pts

Matrix

density_vector

Vector

maxi

Numeric

mini

Numeric

export_path

Character

color_sel

String

Value

mesh3d object with added color dimension

Author(s)

Scott Telfer scott.telfer@gmail.com

Examples


  # Download CT scan
  url <- "https://github.com/Telfer/BoneDensityMapping/releases/download/v1.0.1/test_CT_hip.nii.gz"
  scan_filepath <- tempfile(fileext = ".nii.gz")
  download.file(url, scan_filepath, mode = "wb")
  nifti <- import_scan(scan_filepath)
  url2 <- "https://github.com/Telfer/BoneDensityMapping/releases/download/v1.0.2/test_CT_femur.stl"
  bone_filepath <- tempfile(fileext = ".stl")
  download.file(url2, bone_filepath, mode = "wb")
  surface_mesh <- import_mesh(bone_filepath)
  landmark_path <- system.file("extdata", "test_femur.mrk.json",
                               package = "BoneDensityMapping")
  landmarks <- import_lmks(landmark_path)
  mapped_coords <- surface_points_template(surface_mesh, landmarks,
                                           no_surface_sliders = 1000)
  dens <- voxel_point_intersect(mapped_coords, nifti,
                                ct_eqn = "linear",
                                ct_params = c(68.4, 1.106))
  colored_mesh <- color_mesh(surface_mesh, mapped_coords, dens)


BoneDensityMapping documentation built on Aug. 8, 2025, 6:46 p.m.