How mzarowka/hsitools works
Based on our analysis of the file tree and README, the HSItools project is an R package designed for processing and visualizing hyperspectral core scanning data. It provides both a programmatic API and an interactive Shiny app interface for users to process raw hyperspectral images, extract spectral data, apply normalization and filtering operations, and finally generate visualizations (such as RGB composites).
Main Components
• User Interface (Shiny App):
• Represented by files like R/app.R and R/simpleShiny.R.
• This component handles interactive sessions and lets users set analysis parameters.
• Data Ingestion & Preprocessing:
• Functions in R/data.R, R/app_helpers.R, and related files handle reading raw hyperspectral data (evidenced by directories like inst/extdata and data-raw).
• Steps for preparing the core image (e.g., prepare_core()).
• Processing & Analysis Pipeline:
• Consists of modules for spectral extraction (R/extractors.R), spectral calculations (R/spectral_calculations.R), normalization (R/normalization.R), filtering (R/filters.R), and other processing tasks.
• These components form the core computation engine, transforming raw data to reflectance values and computed indices.
• Visualization & Output:
• Files like R/plotting.R and various plotting functions (e.g., plot_raster_rgb, plot_profile_spectral_profile.Rd) generate outputs.
• This component outputs final images, plots, and, in some cases, dataset exports.
• Documentation & Deployment:
• Documentation is detailed in the man folder (i.e., Rd files), vignettes, and the README.
• There are also CI/CD workflows using GitHub Actions (under .github/workflows) which indicate automated builds and checks.
• Utilities & Helper Modules:
• Other utility files under R/utils.R and workflow.R contain helper functions that support the main processing pipeline.
Relationships and Data Flow
• The data flows into the preprocessing module (prepare_core), and then through a series of processing functions (spectral calculations, filtering, normalization).
• Processed data is passed to visualization functions that generate output plots or files (RGB previews, reflectance images).
• Supporting helper functions and utilities streamline this data flow.
• A CI/CD pipeline oversees testing and package building, tying the codebase to deployment practices.
Architectural Patterns and Design Principles
• Modular Design: Clear separation of concerns is evident by splitting UI, processing, and visualization into distinct R scripts.
• Functional Pipeline: The project utilizes a functional programming style where data is passed through a series of transformation steps (e.g., core → prepare_core → stretch_raster_full → plot_raster_rgb).
• Extensibility and Reusability: The package’s structure (with numerous helper functions and clearly documented methods) facilitates easy extension for additional spectral processing methods.
• Integration with R-based tools: Leveraging R’s package ecosystem with CI/CD workflows (via GitHub Actions) and a Shiny interface demonstrates an integration of analysis and interactivity.
Technologies, Frameworks, and Libraries
• R Language: The core platform.
• Shiny: For creating the web-based interactive UI.
• Package Management: Integration with tools like pak for package installation.
• GitHub Actions: CI/CD for ongoing integration and checking (as indicated by YAML workflows).
• Other R libraries: Likely libraries for raster data handling and plotting (though not explicitly detailed, by function names they are likely used).