color_mapping: maps numeric values to a color

View source: R/BoneDensityFunctions.R

color_mappingR Documentation

maps numeric values to a color

Description

maps numeric values to a color

Usage

color_mapping(x, maxi, mini, color_sel)

Arguments

x

Vector.

maxi

Numeric. Maximum value. Defaults to maximum value in vector. Can be useful to set this manually if there are outliers in the scan data

mini

Numeric. Minimum value. Defaults to minimum value in vector. Can be useful to set this manually if there are outliers in the scan data

color_sel

Vector. Colors to use for map. Defaults to a scale of "grey", "blue", "green", "yellow", "orange", "red", "pink".

Value

Vector of hex color values same length as x

Author(s)

Scott Telfer scott.telfer@gmail.com

Examples


  # Download CT scan
  url <- "https://github.com/Telfer/BoneDensityMapping/releases/download/v1.0.2/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)
  mat_peak <- voxel_point_intersect(surface_mesh, nifti, ct_eqn = "linear",
                                    ct_params = c(68.4, 1.106),)
  colors <- color_mapping(mat_peak)


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