--- title: "Cubert Camera Data Workflow" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Cubert Camera Data Workflow} %\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 ) ``` ```{r setup} library(hyperspectR) ``` ## Overview This vignette demonstrates the package's ENVI and calibration interfaces using synthetic data. Device support tests use fixtures and SDK mocks; real camera sessions remain an external validation requirement. Read wavelength, FWHM, processing mode and acquisition settings from each recording. Do not infer them from a model name or this demonstration's defaults. ## Step 1: Reading ENVI Data After exporting from CUVIS Export to ENVI format: ```{r eval=FALSE} # Read the ENVI header + binary pair cube <- hs_read_envi("path/to/measurement.hdr") # Or use the auto-detect reader cube <- hs_read_cube("path/to/measurement.hdr") ``` For this vignette we use synthetic data: ```{r} cube <- hs_simulate_cube(rows = 30, cols = 30, seed = 42) print(cube) ``` ## Step 2: Calibration Apply dark current subtraction and white reference normalization: ```{r} # Simulate dark and white references dark_data <- array(0.02, dim(cube$data)) white_data <- array(0.95, dim(cube$data)) dark <- hsi_cube(dark_data, cube$wavelengths) white <- hsi_cube(white_data, cube$wavelengths) # Demonstrate the calibration arithmetic (these references are synthetic) calibrated <- hs_calibrate(cube, dark, white) range(calibrated$data) ``` ## Step 3: Preprocessing Apply spectral smoothing to reduce noise: ```{r} smoothed <- hs_smooth(calibrated, window = 5, poly = 2) hs_plot_spectra(smoothed, pixels = "mean", show_sd = TRUE) ``` ## Step 4: Computing Indices ```{r fig.width=10, fig.height=4} hs_plot_clinical(smoothed, indices = c("sto2", "npi", "thi")) ``` ## Step 5: Saving Results ```{r eval=FALSE} # Save processed cube hs_write_envi(smoothed, "path/to/processed_cube") # Export index map as PNG sto2 <- hs_sto2(smoothed) hs_export_png(sto2, "path/to/sto2_map.png") ```