Learn R Programming

BoneDensityMapping (version 0.1.4)

color_mapping: maps numeric values to a color

Description

maps numeric values to a color

Usage

color_mapping(x, maxi, mini, color_sel)

Value

Vector of hex color values same length as x

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".

Author

Scott Telfer scott.telfer@gmail.com

Examples

Run this code
# \donttest{
  # 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)
# }

Run the code above in your browser using DataLab