# flatironinstitute/normcorre architecture

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

- Interactive diagram: https://gitdiagram.com/flatironinstitute/normcorre
- Repository: https://github.com/flatironinstitute/normcorre

## Overview

NoRMCorre is a MATLAB package for online piecewise-rigid motion correction of 2D and 3D calcium-imaging data. The documented workflow accepts an in-memory or file-backed dataset, options, and optionally an initial template; it estimates patch translations, refines them into a smooth motion field, corrects frames, and can update the template online. Batch processing, 1p preprocessing, the MotionCorrection object, and quality metrics are separate documented capabilities. Source excerpts were unavailable, so relationships below rely on the README; implementation details beyond those statements are not inferred.

Main entry points: [`normcorre.m`](https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m) (Online correction), [`NoRMCorreSetParms.m`](https://github.com/flatironinstitute/normcorre/blob/master/NoRMCorreSetParms.m) (Correction options), [`normcorre_batch.m`](https://github.com/flatironinstitute/normcorre/blob/master/normcorre_batch.m) (Batch processing), [`demo_1p.m`](https://github.com/flatironinstitute/normcorre/blob/master/demo_1p.m) (1p preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Correction workflow"]
  node_core["Online correction<br/>[normcorre.m]"]
  node_patches["Overlapping patches<br/>[construct_grid.m]"]
  node_registration["Patch registration"]
  node_field["Motion-field refinement"]
  node_correction["Frame correction<br/>[apply_shifts.m]"]
  node_template["Online template<br/>[normcorre.m]"]
  node_result["Registered data<br/>[normcorre.m]"]
end

subgraph group_configuration["Configuration"]
  node_options["Correction options"]
end

subgraph group_interfaces["User interfaces"]
  node_batch["Batch processing<br/>[normcorre_batch.m]"]
  node_onep["1p preprocessing<br/>[demo_1p.m]"]
  node_class["MotionCorrection object<br/>[MotionCorrection.m]"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["Motion metrics<br/>[motion_metrics.m]"]
end

node_user(("User"))
node_dataset["Imaging dataset"]

node_user -->|"runs correction"| node_core
node_dataset -->|"provides input"| node_core
node_options -->|"configures"| node_core
node_user -->|"sets parameters"| node_options
node_core -->|"splits into patches"| node_patches
node_core -->|"estimates shifts"| node_registration
node_core -->|"refines shifts"| node_field
node_core -->|"applies motion field"| node_correction
node_core -->|"updates template"| node_template
node_core -->|"produces"| node_result
node_user -->|"runs batches"| node_batch
node_batch -->|"processes mini-batches"| node_core
node_user -->|"runs 1p workflow"| node_onep
node_onep -->|"uses filtered data"| node_core
node_user -->|"uses object API"| node_class
node_class -->|"performs correction"| node_result
node_user -->|"evaluates output"| node_metrics
node_result -->|"provides registered frames"| node_metrics

click node_options "https://github.com/flatironinstitute/normcorre/blob/master/NoRMCorreSetParms.m"
click node_core "https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m"
click node_patches "https://github.com/flatironinstitute/normcorre/blob/master/construct_grid.m"
click node_registration "https://github.com/flatironinstitute/normcorre/blob/master/dftregistration_min_max.m"
click node_field "https://github.com/flatironinstitute/normcorre/blob/master/construct_weights.m"
click node_correction "https://github.com/flatironinstitute/normcorre/blob/master/apply_shifts.m"
click node_template "https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m"
click node_batch "https://github.com/flatironinstitute/normcorre/blob/master/normcorre_batch.m"
click node_onep "https://github.com/flatironinstitute/normcorre/blob/master/demo_1p.m"
click node_class "https://github.com/flatironinstitute/normcorre/blob/master/%40MotionCorrection/MotionCorrection.m"
click node_metrics "https://github.com/flatironinstitute/normcorre/blob/master/motion_metrics.m"
click node_result "https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m"

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_core,node_patches,node_registration,node_field,node_correction,node_template,node_result,node_user toneBlue
class node_options toneAmber
class node_batch,node_onep,node_class toneMint
class node_metrics toneRose
class node_dataset toneIndigo
```

## Components

### Correction workflow

- [Online correction](https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m): `normcorre.m`
- [Overlapping patches](https://github.com/flatironinstitute/normcorre/blob/master/construct_grid.m): `construct_grid.m`
- [Patch registration](https://github.com/flatironinstitute/normcorre/blob/master/dftregistration_min_max.m): `dftregistration_min_max.m`
- [Motion-field refinement](https://github.com/flatironinstitute/normcorre/blob/master/construct_weights.m): `construct_weights.m`
- [Frame correction](https://github.com/flatironinstitute/normcorre/blob/master/apply_shifts.m): `apply_shifts.m`
- [Online template](https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m): `normcorre.m`
- [Registered data](https://github.com/flatironinstitute/normcorre/blob/master/normcorre.m): `normcorre.m`

### Configuration

- [Correction options](https://github.com/flatironinstitute/normcorre/blob/master/NoRMCorreSetParms.m): `NoRMCorreSetParms.m`

### User interfaces

- [Batch processing](https://github.com/flatironinstitute/normcorre/blob/master/normcorre_batch.m): `normcorre_batch.m`
- [1p preprocessing](https://github.com/flatironinstitute/normcorre/blob/master/demo_1p.m): `demo_1p.m`
- [MotionCorrection object](https://github.com/flatironinstitute/normcorre/blob/master/%40MotionCorrection/MotionCorrection.m): `@MotionCorrection/MotionCorrection.m`

### Evaluation

- [Motion metrics](https://github.com/flatironinstitute/normcorre/blob/master/motion_metrics.m): `motion_metrics.m`

### Other components

- **User**
- **Imaging dataset**

## Connections

- User → Online correction: runs correction (evidence: `README.md`)
- Imaging dataset → Online correction: provides input (evidence: `README.md`)
- Correction options → Online correction: configures (evidence: `README.md`)
- User → Correction options: sets parameters (evidence: `README.md`)
- Online correction → Overlapping patches: splits into patches (evidence: `README.md`)
- Online correction → Patch registration: estimates shifts (evidence: `README.md`)
- Online correction → Motion-field refinement: refines shifts (evidence: `README.md`)
- Online correction → Frame correction: applies motion field (evidence: `README.md`)
- Online correction → Online template: updates template (evidence: `README.md`)
- Online correction → Registered data: produces (evidence: `README.md`)
- User → Batch processing: runs batches (evidence: `README.md`)
- Batch processing → Online correction: processes mini-batches (evidence: `README.md`)
- User → 1p preprocessing: runs 1p workflow (evidence: `README.md`)
- 1p preprocessing → Online correction: uses filtered data (evidence: `README.md`)
- User → MotionCorrection object: uses object API (evidence: `README.md`)
- MotionCorrection object → Registered data: performs correction (evidence: `README.md`)
- User → Motion metrics: evaluates output (evidence: `README.md`)
- Registered data → Motion metrics: provides registered frames (evidence: `README.md`)
