# orlyliba/oct_reconstruction_and_spectral_analysis architecture

> Architecture diagram of the GitHub repository orlyliba/oct_reconstruction_and_spectral_analysis, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/orlyliba/oct_reconstruction_and_spectral_analysis
- Repository: https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis

## Overview

Step 1: Identify the Main Components
- Data Input and Acquisition:
– The project is built to work with raw interferograms from Thorlabs OCT systems (e.g., Ganymede HR and Telesto).
– Include a “Data Input” component that represents the interferogram files and calibration files (like Chirp files mentioned in the README).

- Parameter & Configuration Setup:
– Parameter files (such as reconstructParams.m, spectralParamsV3_2D.m, spectralParamsV3_3D.m) allow users to configure system-specific variables.
– A “Parameter Setup” component that feeds into the reconstruction and analysis processes.

- Reconstruction Engine:
– The core functionality is contained in files like runReconstruct.m and runSpectralV3.m. This module is responsible for applying dispersion compensation and reconstructing OCT images.

- Spectral Analysis Module:
– This part covers spectral contrast, spectral-depth compensation, and speckle variance computations. Modules are partly integrated in the core routines (runSpectralV3.m) and functions (e.g., calcSpectral2.m, calcSpectral4.m) located within the “functions” directory.

- ROI & Statistical Analysis:
– The ROI_analysis folder contains a suite of scripts for further processing and extracting regions of interest from the OCT data.
– Include a component labeled “ROI Analysis & Statistical Processing” that indicates step-by-step operations like ROI creation and statistical analysis (e.g., createROIdata.m, getROIavg.m, statAnalysis_SEM.m, etc.).

- Visualization & Display:
– The display_functions directory contains tools for creating and exporting images (e.g., creation of Tiff stacks, PNG B-Scans, surface display functions).
– A “Display/Visualization Module” should be illustrated that receives processed data and converts it into visual representations (including colormap functions and stitching tools).

- Utility & Supporting Libraries:
– The “functions” directory houses several supportive functions for tasks like data reading, scaling, dispersion calculation, and file/folder management.
– The “xml_io_tools” directory provides XML read/write capabilities for parameter files or metadata.
– Also include “lymph_functions” (for specialized analysis possibly integrated with OCT imaging for lymphatic-related studies).

Step 2: Define Relationships and Data Flow
- That both “Reconstruction Engine” and “Spectral Analysis Module” output results to the “Display/Visualization Module” for creating final visual outputs.
- Finally, illustrate that “Utility & Supporting Libraries” interact with almost all main modules, providing elasticity and careful management of lower-level functions and I/O operations (including XML processing).

Step 3: Highlight Architectural Patterns & Technologies
- That the project uses a modular design structure. Each directory corresponds to a specific module or function—reconstruction, analysis, ROI, display, and supporting utilities.
- That the design leverages MATLAB scripting and function files extensively. Libraries for colormaps and image processing (e.g., mat2im, pmkmp, real2rgb) are important for the visualization aspect.
- Mention that the system design follows clear input-process-output phases (i.e., from raw data ingestion to parameter-based reconstruction, followed by spectral analysis, ROI processing, and visualization).
- Depending on the complexity, you might represent external dependencies like the underlying OCT hardware (Thorlabs systems) as an external block feeding data into the system.

- Use clear labels for each component, for instance:
- External inputs such as raw OCT data and external calibration/chirp files, marking how these feed into the Parameter Setup before proceeding to subsequent processing stages.

– The sequential flow of data processing.
– The modularity of various MATLAB components working together.
– How preprocessing, reconstruction, and spectral analysis map distinctly to separate modules.
– The ROI analysis and visualization functionality, which are crucial for interpreting and analyzing the OCT images.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Data Acquisition (Raw Interferograms)"]:::data
    B["Parameter & Calibration Setup"]:::param
    C["OCT Reconstruction Engine"]:::reconstruction
    D["Spectral Analysis Module"]:::spectral
    E["ROI & Statistical Analysis"]:::roi
    F["Display/Visualization Module"]:::display
    G["Utility & Supporting Libraries"]:::utility

    A -->|"feeds"| B
    B -->|"configures"| C
    B -->|"configures"| D
    C -->|"providesRawData"| D
    C -->|"outputsData"| E
    D -->|"outputsAnalysis"| E
    C -->|"visualOutputs"| F
    D -->|"visualOutputs"| F

    G --> B
    G --> C
    G --> D
    G --> E
    G --> F

    click A "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/functions/Chirp_Ganymede.mat"
    click A "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/functions/Chirp_Telesto.mat"
    click B "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/reconstructParams.m"
    click B "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/spectralParamsV3_2D.m"
    click B "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/spectralParamsV3_3D.m"
    click C "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/runReconstruct.m"
    click D "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/runSpectralV3.m"
    click D "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/functions/calcSpectral2.m"
    click D "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/functions/calcSpectral4.m"
    click D "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/blob/master/functions/spectralAnalysis4.m"
    click E "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/tree/master/ROI_analysis"
    click F "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/tree/master/display_functions"
    click G "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/tree/master/functions"
    click G "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/tree/master/xml_io_tools"
    click G "https://github.com/orlyliba/oct_reconstruction_and_spectral_analysis/tree/master/lymph_functions"

    classDef data fill:#f9d6d5,stroke:#333,stroke-width:2px;
    classDef param fill:#d5f9d6,stroke:#333,stroke-width:2px;
    classDef reconstruction fill:#d6e6f9,stroke:#333,stroke-width:2px;
    classDef spectral fill:#f9eed6,stroke:#333,stroke-width:2px;
    classDef roi fill:#ead6f9,stroke:#333,stroke-width:2px;
    classDef display fill:#d6f9f7,stroke:#333,stroke-width:2px;
    classDef utility fill:#f9d6f3,stroke:#333,stroke-width:2px;
```
