--- title: "Getting Started with hyperspectR" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Started with hyperspectR} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- [![R-CMD-check](https://github.com/CTTIR/hyperspectR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/CTTIR/hyperspectR/actions/workflows/R-CMD-check.yaml) [![pkgdown](https://github.com/CTTIR/hyperspectR/actions/workflows/pkgdown.yaml/badge.svg)](https://cttir.github.io/hyperspectR/) [![CRAN status](https://www.r-pkg.org/badges/version/hyperspectR)](https://CRAN.R-project.org/package=hyperspectR) [![Codecov test coverage](https://codecov.io/gh/CTTIR/hyperspectR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/CTTIR/hyperspectR?branch=main) [![CRAN downloads](https://cranlogs.r-pkg.org/badges/hyperspectR)](https://cran.r-project.org/package=hyperspectR) [![CRAN downloads total](https://cranlogs.r-pkg.org/badges/grand-total/hyperspectR)](https://cran.r-project.org/package=hyperspectR) [![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 5 ) ``` ## Installation ```{r eval=FALSE} # Install from GitHub # install.packages("remotes") remotes::install_github("cttir/hyperspectR") ``` ## Loading the Package ```{r setup} library(hyperspectR) ``` ## Creating and Inspecting a Cube hyperspectR provides synthetic data generators for testing and demonstration. `hs_example_cube()` creates a 30x30 pixel tissue scene with 61 spectral bands spanning 430-910 nm: ```{r} cube <- hs_example_cube() print(cube) ``` Check the dimensions: ```{r} dim(cube) ``` The summary provides per-band statistics: ```{r} s <- summary(cube) s$wavelength_range s$data_range ``` ## Subsetting You can subset cubes spatially and spectrally while preserving the class: ```{r} sub <- cube[1:15, 1:15, 1:30] dim(sub) ``` ## Visualization ### RGB Composite ```{r} ggplot2::autoplot(cube, type = "rgb") ``` ### Single Band Image ```{r} hs_plot_image(cube, wavelength = 550) ``` ### Mean Spectrum ```{r} hs_plot_spectra(cube, pixels = "mean", show_sd = TRUE) ``` ## Computing Tissue Indices The package provides a research hemoglobin fraction estimate and dimensionless band ratios. These outputs are not validated clinical measurements: ```{r} sto2 <- hs_sto2(cube) hs_plot_index(sto2, title = "Fitted Hb fraction (%)", palette = "sto2") ``` ### Clinical Panel Display ```{r fig.width=10, fig.height=4} hs_plot_clinical(cube, indices = c("sto2", "npi", "thi")) ``` ## Interactive Exploration Launch the Shiny app for interactive analysis: ```{r eval=FALSE} hs_run_app(cube) ``` ## Next Steps - Read real data with `hs_read_envi()` or `hs_read_cube()` - Preprocess with `hs_smooth()`, `hs_snv()`, `hs_msc()` - Perform PCA with `hs_pca()` or MNF with `hs_mnf()` - Classify with `hs_sam()` or fit chromophores with `hs_beer_lambert()` # Citation To cite hyperspectR in publications, please use: ```bibtex @Manual{, title = {hyperspectR: Hyperspectral Imaging Analysis for Biomedical Applications}, author = {R. Heller and V. Forstmeier}, year = {2026}, note = {R package version 0.1.0}, url = {https://github.com/cttir/hyperspectR}, } ```