# khchenlab/split-fish architecture

> Architecture diagram of the GitHub repository khchenlab/split-fish, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khchenlab/split-fish
- Repository: https://github.com/khchenlab/split-fish

## Overview

This repository is a multiplexed-FISH image-analysis toolkit. Its principal workflow parses multi-FOV microscope data, loads codebook/FPKM metadata, preprocesses and registers images, decodes gene spots, and produces coordinate/count outputs and QC plots. Separate tools stitch analyzed FOVs and spots, then visualize them; the repository also includes probe-design and manuscript-figure capabilities. The graph follows documented workflow and SOURCE INDEX references; unsampled implementation details and unverified call paths are omitted.

Main entry points: [`MainScript.py`](https://github.com/khchenlab/split-fish/blob/master/MainScript.py) (Analysis Runner), [`stitchMstClasses.py`](https://github.com/khchenlab/split-fish/blob/master/stitchMstClasses.py) (Mosaic Stitching), [`spotViewer.py`](https://github.com/khchenlab/split-fish/blob/master/spotViewer.py) (Spot Viewer), [`utils/writeClasses.py`](https://github.com/khchenlab/split-fish/blob/master/utils/writeClasses.py) (HDF5 Read Write)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Image Analysis"]
  node_main["Analysis Runner<br/>[MainScript.py]"]
  node_preprocess["Registration And Filtering"]
  node_registration["Registration Math"]
  node_frequency["Frequency Filter<br/>[frequencyFilter.py]"]
  node_correction["Image Correction"]
  node_fieldmask["Field Mask Generation"]
  node_decode["Pixel Decoder<br/>[decodeFunctions.py]"]
end

subgraph group_data["Data Handling"]
  node_parser["Image Parser<br/>[filesClasses.py]"]
  node_grid["FOV Grid"]
  node_genes["Gene Metadata<br/>[geneData.py]"]
  node_images["Image State<br/>[imageData.py]"]
  node_storage["HDF5 Read Write<br/>[writeClasses.py]"]
end

subgraph group_results["Results And QC"]
  node_normalize["Count Normalization"]
  node_plotcounts["Counts And QC"]
end

subgraph group_tools["Visualization And Extensions"]
  node_stitch["Mosaic Stitching"]
  node_viewer["Spot Viewer<br/>[spotViewer.py]"]
  node_probe["Probe Design"]
  node_figures["Paper Figures"]
end

node_user(("Researcher"))

node_user -->|"runs analysis"| node_main
node_main -->|"parses images"| node_parser
node_main -->|"builds FOV grid"| node_grid
node_main -->|"loads codebook"| node_genes
node_main -->|"processes images"| node_images
node_main -->|"preprocesses"| node_preprocess
node_preprocess -->|"estimates shifts"| node_registration
node_main -->|"uses filtering"| node_frequency
node_main -->|"corrects images"| node_correction
node_correction -->|"uses field masks"| node_fieldmask
node_main -->|"decodes pixels"| node_decode
node_main -->|"normalizes counts"| node_normalize
node_main -->|"generates QC"| node_plotcounts
node_main -->|"writes outputs"| node_storage
node_user -->|"runs stitching"| node_stitch
node_stitch -->|"parses image files"| node_parser
node_stitch -->|"uses FOV layout"| node_grid
node_stitch -->|"registers mosaic"| node_registration
node_stitch -->|"writes stitched data"| node_storage
node_user -->|"opens results"| node_viewer
node_viewer -->|"reads spot files"| node_storage
node_viewer -.->|"views stitched output"| node_stitch
node_user -->|"designs probes"| node_probe
node_user -->|"generates figures"| node_figures
node_figures -->|"uses count plots"| node_plotcounts

click node_main "https://github.com/khchenlab/split-fish/blob/master/MainScript.py"
click node_parser "https://github.com/khchenlab/split-fish/blob/master/fileparsing/filesClasses.py"
click node_grid "https://github.com/khchenlab/split-fish/blob/master/fileparsing/fovGridFunctions.py"
click node_genes "https://github.com/khchenlab/split-fish/blob/master/data_objects/geneData.py"
click node_images "https://github.com/khchenlab/split-fish/blob/master/data_objects/imageData.py"
click node_preprocess "https://github.com/khchenlab/split-fish/blob/master/processing/processFunctions.py"
click node_registration "https://github.com/khchenlab/split-fish/blob/master/utils/registrationFunctions.py"
click node_frequency "https://github.com/khchenlab/split-fish/blob/master/utils/frequencyFilter.py"
click node_correction "https://github.com/khchenlab/split-fish/blob/master/processing/correctionFunctions.py"
click node_fieldmask "https://github.com/khchenlab/split-fish/blob/master/fieldCorrMaskGenerator.py"
click node_decode "https://github.com/khchenlab/split-fish/blob/master/processing/decodeFunctions.py"
click node_normalize "https://github.com/khchenlab/split-fish/blob/master/processing/globalNormalizationFunctions.py"
click node_plotcounts "https://github.com/khchenlab/split-fish/blob/master/processing/plotCountsFunctions.py"
click node_stitch "https://github.com/khchenlab/split-fish/blob/master/stitchMstClasses.py"
click node_viewer "https://github.com/khchenlab/split-fish/blob/master/spotViewer.py"
click node_probe "https://github.com/khchenlab/split-fish/tree/master/probedesign"
click node_figures "https://github.com/khchenlab/split-fish/tree/master/splitFISH_manuscript_figures"
click node_storage "https://github.com/khchenlab/split-fish/blob/master/utils/writeClasses.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_preprocess,node_registration,node_frequency,node_correction,node_fieldmask,node_decode toneBlue
class node_parser,node_grid,node_genes,node_images,node_storage toneAmber
class node_normalize,node_plotcounts toneMint
class node_stitch,node_viewer,node_probe,node_figures toneRose
class node_user toneIndigo
```

## Components

### Image Analysis

- [Analysis Runner](https://github.com/khchenlab/split-fish/blob/master/MainScript.py): `MainScript.py`
- [Registration And Filtering](https://github.com/khchenlab/split-fish/blob/master/processing/processFunctions.py): `processing/processFunctions.py`
- [Registration Math](https://github.com/khchenlab/split-fish/blob/master/utils/registrationFunctions.py): `utils/registrationFunctions.py`
- [Frequency Filter](https://github.com/khchenlab/split-fish/blob/master/utils/frequencyFilter.py): `utils/frequencyFilter.py`
- [Image Correction](https://github.com/khchenlab/split-fish/blob/master/processing/correctionFunctions.py): `processing/correctionFunctions.py`
- [Field Mask Generation](https://github.com/khchenlab/split-fish/blob/master/fieldCorrMaskGenerator.py): `fieldCorrMaskGenerator.py`
- [Pixel Decoder](https://github.com/khchenlab/split-fish/blob/master/processing/decodeFunctions.py): `processing/decodeFunctions.py`

### Data Handling

- [Image Parser](https://github.com/khchenlab/split-fish/blob/master/fileparsing/filesClasses.py): `fileparsing/filesClasses.py`
- [FOV Grid](https://github.com/khchenlab/split-fish/blob/master/fileparsing/fovGridFunctions.py): `fileparsing/fovGridFunctions.py`
- [Gene Metadata](https://github.com/khchenlab/split-fish/blob/master/data_objects/geneData.py): `data_objects/geneData.py`
- [Image State](https://github.com/khchenlab/split-fish/blob/master/data_objects/imageData.py): `data_objects/imageData.py`
- [HDF5 Read Write](https://github.com/khchenlab/split-fish/blob/master/utils/writeClasses.py): `utils/writeClasses.py`

### Results And QC

- [Count Normalization](https://github.com/khchenlab/split-fish/blob/master/processing/globalNormalizationFunctions.py): `processing/globalNormalizationFunctions.py`
- [Counts And QC](https://github.com/khchenlab/split-fish/blob/master/processing/plotCountsFunctions.py): `processing/plotCountsFunctions.py`

### Visualization And Extensions

- [Mosaic Stitching](https://github.com/khchenlab/split-fish/blob/master/stitchMstClasses.py): `stitchMstClasses.py`
- [Spot Viewer](https://github.com/khchenlab/split-fish/blob/master/spotViewer.py): `spotViewer.py`
- [Probe Design](https://github.com/khchenlab/split-fish/tree/master/probedesign): `probedesign`
- [Paper Figures](https://github.com/khchenlab/split-fish/tree/master/splitFISH_manuscript_figures): `splitFISH_manuscript_figures`

### Other components

- **Researcher**

## Connections

- Researcher → Analysis Runner: runs analysis (evidence: `README.md`)
- Analysis Runner → Image Parser: parses images (evidence: `MainScript.py`)
- Analysis Runner → FOV Grid: builds FOV grid (evidence: `MainScript.py`)
- Analysis Runner → Gene Metadata: loads codebook (evidence: `MainScript.py`)
- Analysis Runner → Image State: processes images (evidence: `MainScript.py`)
- Analysis Runner → Registration And Filtering: preprocesses (evidence: `MainScript.py`)
- Registration And Filtering → Registration Math: estimates shifts (evidence: `processing/processFunctions.py`)
- Analysis Runner → Frequency Filter: uses filtering (evidence: `MainScript.py`)
- Analysis Runner → Image Correction: corrects images (evidence: `MainScript.py`)
- Image Correction → Field Mask Generation: uses field masks (evidence: `processing/correctionFunctions.py`)
- Analysis Runner → Pixel Decoder: decodes pixels (evidence: `MainScript.py`)
- Analysis Runner → Count Normalization: normalizes counts (evidence: `MainScript.py`)
- Analysis Runner → Counts And QC: generates QC (evidence: `MainScript.py`)
- Analysis Runner → HDF5 Read Write: writes outputs (evidence: `MainScript.py`)
- Researcher → Mosaic Stitching: runs stitching (evidence: `README.md`)
- Mosaic Stitching → Image Parser: parses image files (evidence: `stitchMstClasses.py`)
- Mosaic Stitching → FOV Grid: uses FOV layout (evidence: `stitchMstClasses.py`)
- Mosaic Stitching → Registration Math: registers mosaic (evidence: `stitchMstClasses.py`)
- Mosaic Stitching → HDF5 Read Write: writes stitched data (evidence: `stitchMstClasses.py`)
- Researcher → Spot Viewer: opens results (evidence: `README.md`)
- Spot Viewer → HDF5 Read Write: reads spot files (evidence: `spotViewer.py`)
- Spot Viewer → Mosaic Stitching: views stitched output (evidence: `README.md`)
- Researcher → Probe Design: designs probes (evidence: `README.md`)
- Researcher → Paper Figures: generates figures (evidence: `README.md`)
- Paper Figures → Counts And QC: uses count plots (evidence: `splitFISH_manuscript_figures/figure_shared_functions.py`)
