FlowStudio — Extended Help (English)

Purpose of this document. This help explains how measurements are produced and the mathematics behind them, starting from the basics. It describes the commands and parameters you can use inside the application, without assuming prior knowledge.
Important. The numbers produced by FlowStudio depend strongly on video quality (focus, lighting stability, compression, frame rate, and subject framing). If you use results for research or clinical reporting, validate the workflow on known references and keep acquisition conditions consistent.

Table of contents


0) Architecture overview

FlowStudio is organized as a real-time processing pipeline: each incoming frame updates motion, per-cell signals, frequency maps, spectra, and the optional region (“blob”) oscillator. The UI configures parameters and visualizes outputs; the measurement chain itself is the same whether the source is a live camera or a video file.

0.1 Processing pipeline (from frames to numbers)

Source (Camera / Video file)
   ↓ frames @ FPS        →   dt = 1/FPS
Preprocess (optional: Blur / CLAHE)
   ↓
Optical Flow (frame t → t+1)                 [see §6]
   ↓
Reliability / Mask (photoErr, FB, gradient, MAD…)   [see §7]
   ↓
Grid reduction (cell aggregation + EMA smoothing + stability)   [see §8]
   ↓
Per-cell signal x[n] (magnitude / U / V) + optional decimation D  →  fs_eff = FPS/D   [see §9–§10]
   ↓
Rapid Oscillation Analyzer (band-pass + autocorr peak → f0, corr, rms, stable)         [see §10]
   ↓
Maps & Overlay (f0/corr/rms/stable → color overlay + debug maps)                       [see §11]
Entropy diagnostics (H(t), H_local map, Ṡ proxy)                                  [see §12]
   ↓
   ↓
Aggregation & decisions
   ├─ Spectrum / Waterfall (histogram over active cells)                               [see §13]
   ├─ Blob Oscillator (Hz(t), Coh(t) over stable cells)                                [see §11.2]
   └─ Baseline/Change detector → Event recorder → CSV exports / Before–After summary   [see §14–§18]

0.2 How the blocks connect in the UI

0.3 Resync vs Reset (what gets cleared)

0.4 Status bar, timecode and log


1) What FlowStudio measures

FlowStudio analyzes a stream of images (camera or video file) to measure tiny motion and, in particular, rapid oscillatory motion (e.g., tremor-like motion, vibration, micro-movements) within a selected region. The key idea is:

  1. Estimate a motion vector for many points of the image between consecutive frames (optical flow).
  2. Turn motion over time into a time signal per small area (cell).
  3. Estimate the dominant frequency of that signal using a short sliding window.
  4. Aggregate frequencies across the region to build a spectrum and detect changes/events.

FlowStudio outputs both visual information (overlay, vectors, maps, spectrum/waterfall) and numbers (statistics, events, Before/After summaries).

1.1 “Motion” in one sentence

Between frame t and frame t+1, FlowStudio estimates a displacement vector v(x,y) = (u, v) for each pixel (or a dense subset), meaning “this point moved by u pixels horizontally and v pixels vertically”.

1.2 “Oscillation” in one sentence

If a point moves back-and-forth periodically, its displacement magnitude (or one component) over time behaves like a wave. The frequency is “how many cycles per second” (Hz).


2) Video, time, sampling, units

2.1 Frames, FPS, and time step

A video is a sequence of frames. If the acquisition runs at FPS frames per second, then the time between frames is:

dt = 1 / FPS   (seconds)

Example: 200 FPS ⇒ dt = 0.005 s (5 ms).

2.2 Sampling and the Nyquist limit (why FPS matters)

If you want to measure an oscillation at frequency f, you must sample fast enough. A fundamental rule is the Nyquist limit: roughly, you need FPS > 2·f. In practice you want more than 2× (e.g., 5×–10×) for robust detection.

2.3 Pixel units and physical units (µm)

Most internal computations are in pixels per frame (px/frame). To convert to physical units, you provide a calibration:

um_per_px = micrometers represented by 1 pixel

Then speeds convert as:

speed_um_per_s = (speed_px_per_frame) * FPS * um_per_px

Note: If you do not know the calibration, you can still compare relative values across conditions, but you cannot report µm/s reliably.


3) Typical workflow

  1. Select the source: camera or video file.
  2. If using a camera: pick Select Camera and Camera Resolution; in Camera Settings try disabling auto-exposure/auto-gain to reduce flicker.
  3. Start analysis.
  4. Select ROI (optional but recommended): isolate the relevant area to reduce noise.
  5. Check focus and lighting: avoid blur, saturation, and flicker.
  6. Tune the main gates in the Main panel:
  7. Observe the spectrum/waterfall and the frequency maps to confirm the measured band makes sense.
  8. (Optional) Enable Session recording (SQLite) (File menu) to write the measurement session to a .sqlite database with per-frame QC metrics and (optionally) per-cell grid flow vectors. See §15.5.
  9. (Optional) Enable Event recorder to capture detected changes.
  10. (Optional) Clinical Before/After: record two segments, set calibration, generate report.
Tip. After large parameter changes, use Resync to clear history and restart the measurement chain.

4) Commands and shortcuts

4.1 Main commands

CommandMeaning
StartStart processing from the selected source (camera or file).
StopStop processing and release the source.
Open Video…Open a video file.
Open RecentReopen one of the last used video files (up to 16).
Restart VideoRestart playback/processing from the beginning of the current file.
Pause / ResumeFreeze/unfreeze processing. When resuming, the chain is resynchronized.
ResyncClear short-term history and restart internal timing (useful after ROI/seek changes).
ResetReset all internal states and counters (analysis, histograms, detector baselines).
Clear ROIDisable the ROI and return to full-frame processing.
Fit docksRestore the default panel arrangement.
Select Camera...Select the UVC/DirectShow camera device (Windows). Useful when multiple cameras are connected.
Camera Resolution...Select camera resolution/format. Prefer doing this before Start to stabilize FPS and quality (especially on USB2/USB3).
Camera Settings...Opens the system driver property pages (UVC/DirectShow, Windows). Often used to disable auto-exposure/auto-gain if available.
Video hardcopyRecords the whole window (menus + docks + status bar) to a video file. Useful for documenting sessions exactly as seen.
Session recording (SQLite)...Creates/updates a SQLite session file (.sqlite) with one row per processed frame (table frames) and one row per run/segment (table runs). Tip: enable recording and then Restart Video / Start camera for a clean take. [see §15.5]
Record grid flow (heavy)If enabled, also logs per-cell flow vectors (table grid_flow). This can grow fast and increase load: prefer a higher hop and/or a less dense grid.
Verify session DB integrity...Runs PRAGMA integrity_check plus basic statistics on a selected session file and prints results into the Log. Useful to confirm the recording is complete.
AI Request...Creates a bundle (report + structured data) for external evaluation: PDF/JSON/CSV/images. It doesn’t change analysis, it’s export-only.
HelpOpens this help.

4.2 View toggles

4.3 Keyboard shortcuts

Shortcuts are designed for fast tuning during live observation:


5) ROI (Region Of Interest)

An ROI is a rectangular sub-area of the image used for analysis. Everything (motion, frequency, spectrum) is computed only inside the ROI.

5.1 Why ROI matters

5.2 When to Resync

Changing ROI changes the geometry and the history buffers. After ROI changes (or after seeking in a file), use Resync to avoid mixing data from incompatible regions/time segments.


6) Motion estimation (Optical Flow Detector)

FlowStudio estimates motion between consecutive grayscale frames. The underlying model is the classical brightness constancy assumption: a point keeps approximately the same intensity as it moves.

6.1 The optical flow idea

Let I(x,y,t) be pixel intensity. If a point moves by (u,v) between frames:

I(x, y, t) ≈ I(x + u, y + v, t + dt)

An optical-flow algorithm finds (u,v) that best satisfies this constraint over neighborhoods and multiple scales. FlowStudio uses a dense, multi-scale method that is robust for small-to-medium motions.

6.2 Preprocessing (optional)

Before motion estimation, frames can be preprocessed to improve robustness:

Practical note. Avoid excessive preprocessing: if texture is destroyed, motion becomes ambiguous and confidence drops.

7) Confidence, mask and quality

Not all motion vectors are reliable. FlowStudio computes a mask and a confidence so that unreliable pixels/cells do not contribute to frequency estimates.

7.1 Diagnostic cues used for confidence

Several cues are combined; each has an intuitive interpretation:

  1. Photometric error: after warping frame 1 using the estimated flow, compare to frame 2.
    photoErr(x,y) = | I2(x,y) − warp(I1, flow12)(x,y) |
    Low error means the motion explains the intensity changes.
  2. Forward–backward consistency: estimate flow 1→2 and flow 2→1; a consistent motion should return near the start:
    fbErr ≈ | flow12(p) + flow21(p + flow12(p)) |
    Large fbErr indicates occlusions, blur, or wrong matches.
  3. Local deviation from neighborhood: compare a vector to the local median vector. If one pixel is very different from its neighbors, it is likely an outlier.
  4. Texture gate (gradient magnitude): if the image is flat (low gradient), motion is ill-defined. A minimum gradient threshold avoids “flow on noise”.
  5. Cell dispersion (MAD): within each cell, if motion vectors are too scattered, the cell is considered unstable. MAD = Median Absolute Deviation is a robust dispersion measure.

7.2 From cues to a mask

Each cue has a threshold (Tphoto, Tfb, Tdev, Tgrad, Tmad). A pixel passes the mask if it satisfies the enabled criteria. After building the mask, optional morphological cleanup removes isolated speckles.

7.3 Quality number (inlier ratio)

A simple global quality value is the fraction of pixels/cells that pass reliability checks. This is displayed in summaries as quality (%).


8) Grid reduction and stabilization

8.1 Why reduce to a grid?

Dense flow produces a vector per pixel. Frequency analysis per pixel would be too heavy and too noisy. FlowStudio therefore aggregates vectors inside square cells of size Cell size.

8.2 Cell aggregation (robust statistics)

Inside each cell, only masked (reliable) pixels are used. The cell vector is a robust estimate:

A cell becomes valid only if it has at least Min samples reliable pixels.

8.3 Temporal smoothing (EMA) and max-jump clamp

Cell vectors still fluctuate. A simple exponential moving average (EMA) smooths them:

v_smooth[t] = α · v_new[t] + (1 − α) · v_smooth[t−1]

Additionally, a max jump parameter limits unrealistic sudden changes: if |v_new − v_prev| is too large, the update is rejected or clamped.

8.4 Persistence (stability across frames)

For oscillation estimation, you want cells that keep a coherent motion signal over multiple frames. Persistence maintains a stable counter per cell: the counter increases when motion changes little (within epsilon) and drops when it becomes inconsistent or missing.


9) From motion to a signal

Once you have one vector per cell and per frame, you can convert it into a 1D time signal x[n]. FlowStudio offers three choices:

Why would you use a component instead of magnitude? A signed component preserves direction (back-and-forth becomes a clean oscillation around zero), while magnitude can “rectify” motion and introduce harmonics.


10) Rapid Oscillation Analyzer (frequency per cell)

This is the core frequency engine. For each cell, FlowStudio maintains a short history buffer and estimates the dominant oscillation frequency.

10.1 Effective sampling rate and decimation

If input FPS is high (e.g., 200 FPS), you can optionally decimate by a factor D: average D consecutive vectors to produce one sample. This reduces noise and decreases computational cost.

fs_eff = FPS / D

All frequency computations use fs_eff.

10.2 Simple band-pass filtering (1st order HP + LP)

Raw motion contains slow drift (posture, camera drift) and fast noise. FlowStudio uses a simple band-pass built from:

These are standard 1st-order filters in discrete time. Conceptually:

high-pass:   y[n] = a · ( y[n−1] + x[n] − x[n−1] )
low-pass:    y[n] = y[n−1] + b · ( x[n] − y[n−1] )

The cutoffs are in Hz and are interpreted using fs_eff.

10.3 Sliding window: N and Hop

Each cell keeps a circular buffer of length N samples. The time span covered is:

window_duration = N / fs_eff  (seconds)

The analyzer updates every Hop samples, so the update rate is approximately:

updates_per_second ≈ fs_eff / Hop

Small N gives fast reactions but poorer frequency resolution; larger N stabilizes estimation but reacts slower.

10.4 Autocorrelation-based frequency estimation

To find a periodicity, FlowStudio computes the normalized autocorrelation of the windowed signal. First remove the mean (so oscillations center at zero). Then, for each lag L:

corr(L) =  Σ_{i=0..M−1} x[i]·x[i+L]  /  sqrt( Σ x[i]^2 · Σ x[i+L]^2 )
where M = N − L

This is a correlation coefficient between the signal and a delayed copy. It lies roughly in [−1, +1]. FlowStudio uses the positive peak as a periodicity score.

10.5 Restricting the search to a frequency band

FlowStudio searches only within a frequency band [fMin, fMax]. Frequencies correspond to lags:

L ≈ fs_eff / f
lagMin = floor(fs_eff / fMax)
lagMax = ceil (fs_eff / fMin)

The analyzer picks the lag with maximum corr(L) inside [lagMin, lagMax].

10.6 RMS energy gate

Before trusting corr peaks, FlowStudio checks that the signal has enough energy:

RMS = sqrt( mean( x[i]^2 ) )

If RMS is below RMS thr, the cell is considered inactive (no meaningful oscillation).

10.7 Sub-lag interpolation (more precise frequency)

Lag is discrete, but true period might be between two lags. FlowStudio refines the best lag with a small parabolic interpolation using corr(L−1), corr(L), corr(L+1). Then the dominant frequency is:

f0 = fs_eff / lagFrac

10.8 Persistence of frequency (stable counter)

Even after gating, frequency can jump due to noise. FlowStudio keeps a per-cell stable counter: if |f0 − previous_f0| ≤ freqTol, the counter increases; otherwise it resets. This “stable” value is used as an additional reliability measure.


11) Maps: f0 / corr / rms / stable

After analyzing all cells, FlowStudio builds grid maps:

11.1 The overlay: color + transparency

The overlay is a visualization that blends:

Transparency (alpha) is computed from corr, rms and stable, with the main thresholds:

if corr < CorrThr or rms < RmsThr → alpha = 0

cc = (corr − CorrThr) / (1 − CorrThr)   clipped to [0,1]
rr = (rms  − RmsThr ) / (3·RmsThr)      clipped to [0,1]
ss = min(1, stable / stableNeed)

alpha = alphaBase · cc · rr · ss · AlphaBoost   clipped to [0,1]

Then the final view mixes B/W and color:

output = (1−alpha)·(BW·BWgain) + alpha·(COLOR·ColorGain)

This means “stronger, more periodic, more stable oscillations” become more visible and more saturated.


11.2 Blob Oscillator (region-level Hz + Coh)

Besides estimating a frequency per cell, FlowStudio can also estimate an equivalent oscillator for the whole ROI/blob: a single frequency trace Hz(t) plus a coherence number Coh(t) that tells how much the region behaves like “one oscillator” (high coherence) versus a mixture of unrelated phases/noise (low coherence).

Where to find it in the UI. The time plot is shown in the Oscillator Plot tab (docked together with Spectrum/Waterfall and Log). Debug images are in the F0 Map dock → sub-tab Oscillator (Amp/Phase/Contrib/Mask). To save CPU, the entire block is disabled when Enable blob oscillator (heavy) is unchecked.

11.2.1 Stable-cell selection (the same “stable-only” gates)

The Blob Oscillator uses only the cells that are already considered reliable by the Rapid Oscillation Analyzer. Let each cell i have: corri (periodicity), rmsi (energy), and stablei (persistence counter). Then the active set is:

S = { i | corr_i ≥ CorrThr  and  rms_i ≥ RmsThr  and  stable_i ≥ stableNeed }

If |S| is too small, the oscillator output is marked invalid for that update (no trustworthy region-level estimate).

11.2.2 From many cell signals to one region signal

For each cell in S, FlowStudio already maintains a short, band-pass filtered time signal xi[n] (the same filtering/decimation used by the per-cell analyzer; see Sections 10.1–10.3). The equivalent region signal is the average:

y[n] = (1 / |S|) · Σ_{i∈S} x_i[n]

Intuition: y[n] suppresses uncorrelated noise (averaging) and emphasizes motion that is common to many stable cells.

11.2.3 Dominant frequency of the region (FFT/DFT peak in a band)

On each update (every Hop samples), FlowStudio computes the discrete Fourier transform (DFT) of y[n] over the current window:

Y[k] = Σ_{n=0..N−1} y[n] · exp( −j · 2π · k · n / N )
f_k  = k · fs_eff / N

The peak bin is searched only inside the user band [fMin, fMax] (the same band used for per-cell f0):

kMin = ceil( fMin · N / fs_eff )
kMax = floor( fMax · N / fs_eff )
k*   = argmax_{k ∈ [kMin..kMax]} |Y[k]|
Hz   = f_{k*}
Amp  = |Y[k*]|            (relative amplitude)

Amp is a relative spectral magnitude for the region. If you need calibrated physical units, combine it with your px→µm calibration and FPS.

11.2.4 Coherence (Coh): how “single-oscillator” the region is

Once the region peak bin k* is known, each stable cell contributes a complex coefficient at that frequency:

X_i = Σ_{n=0..N−1} x_i[n] · exp( −j · 2π · k* · n / N )

Coherence is computed as a phase-alignment ratio (0..1):

Coh = | Σ_{i∈S} X_i |  /  Σ_{i∈S} |X_i|

11.2.5 Debug maps (optional, heavier)

If Compute debug maps is enabled, FlowStudio builds per-cell maps at the peak frequency k*:

11.2.6 Implementation note (FFT peak search vs Goertzel single-bin DFT)

The region peak search uses one FFT/DFT on the region signal y[n] to find the best bin k* inside [fMin, fMax]. After k* is known, the per-cell complex coefficients Xi at that single bin can be computed in two equivalent ways:

The single-bin DFT is exactly:

X_i(k*) = Σ_{n=0..N−1} x_i[n] · exp( −j · ω · n ),   with  ω = 2π · k* / N

The Goertzel recursion computes the same value using a second-order filter:

s[n] = x[n] + 2·cos(ω)·s[n−1] − s[n−2]     with s[−1]=s[−2]=0
X(k*) = s[N−1] − exp(−j·ω)·s[N−2]

In FlowStudio, the FFT on y[n] is used to pick k* (Hz). The same k* is then used to compute Coh and (optionally) the debug maps using the single-bin coefficients Xi. This gives the same mathematics as a full FFT, with lower CPU cost.

Practical tuning tips. If Hz looks unstable or Coh stays low, try: smaller ROI, increase CorrThr/RmsThr/stableNeed, or reduce the bandwidth [fMin, fMax]. Low coherence often means multiple oscillating sources inside the ROI or strong phase gradients.


12) Entropy (global H, spatial maps, and entropy-production proxy)

This panel adds a complementary family of measurements based on entropy, intended as a diagnostic of how concentrated or spread the oscillatory activity is in frequency and space. In FlowStudio, “entropy” is used in the Shannon sense (information entropy) applied to distributions built from the existing maps (f0, corr, rms, stable) and the frequency histogram.

Terminology. In signal processing, Shannon entropy increases when a distribution becomes more spread/unpredictable. In thermodynamics, entropy production is tied to dissipated power: Ṡ ≈ Pdiss/T. FlowStudio provides both:

12.1 Global entropy H(t) from the frequency histogram

At each update, FlowStudio already builds a frequency histogram by counting how many cells have a valid dominant frequency f0 (only cells that pass the same gates used for “valid oscillation”: band + CorrThr + RmsThr + StableNeed). Let the histogram have K bins and counts ck. Convert counts to probabilities:

p_k = c_k / Σ c_k
H   = − Σ p_k · log(p_k)          (Shannon entropy; base e)
H01 = H / log(K)                  (normalized to 0..1)
Interpretation tip. A rising H01 often indicates that the system is leaving a clean periodic regime and entering a regime with multiple modes, intermittent motion, impacts, or strong non-linearities. Conversely, a drop in H01 can indicate locking on a dominant mode.

12.2 Spatial entropy map Hlocal(x,y): how mixed the neighborhood is

While H(t) is a region-level summary, Hlocal(x,y) is a map. For each cell (x,y), FlowStudio looks at a square neighborhood of radius R (in grid cells) and builds a small histogram of f0 values inside the neighborhood, after quantizing them into K bins (same “bins” parameter). Then it computes the Shannon entropy (normalized 0..1) of that local distribution.

Formally, for a neighborhood N(x,y):

p_k(x,y) = count of cells in N(x,y) whose f0 falls in bin k  /  total valid cells in N(x,y)
H_local(x,y)  = − Σ p_k(x,y) · log(p_k(x,y))
H_local01(x,y)= H_local(x,y) / log(K)
Important. Hlocal is meaningful only where the neighborhood contains enough valid cells. If too few valid samples are available, the cell is marked as “no-data” (typically shown as black). To reduce “false entropy” from unreliable cells, keep Use Oscillation mask enabled.

12.3 Power proxy map and Ṡ(t) proxy

A thermodynamic entropy production rate would be:

Ṡ ≈ P_diss / T

However, from images alone you typically do not have direct access to calibrated dissipated power. FlowStudio therefore provides a proxy that correlates with “how much oscillatory activity is happening” and can be visualized as a map. A practical default is:

powerProxy(x,y) = rms(x,y)^2 · corr(x,y)     (only on valid/gated cells)
P_proxy(t)      = Σ powerProxy(x,y)
Sdot_proxy(t)   = powerScale · P_proxy(t) / T

Notes. rms is after band-pass filtering; corr is the autocorrelation peak score. The factor powerScale is a user scale to make the plot readable. If you have a calibrated mechanical model (mass, stiffness, damping) or a direct estimate of Pdiss, you can replace the proxy with the physical expression while keeping the same visualization.

12.4 UI parameters and performance

Performance. H(t) is light (one histogram per update). Hlocal(x,y) is heavier because it builds a neighborhood histogram per cell; keep it off unless needed, or use smaller R.

12.5 Exports

12.6 Common pitfalls and practical advice


12.5) Metric Space (metric-of-metrics)

Metric Space is a 3D view that turns the time evolution of many metrics (frequencies, entropy, quality, triggers, etc.) into a trajectory in space. Each point represents a time sample (one every Hop frames) and is colored by the selected scalar. The goal is not to “measure a new quantity”, but to see the system state at a glance: stable regimes, transitions, clusters, and Before/After differences.

12.5.1 Where points come from

FlowStudio builds a 16-dimensional feature vector (robust-normalized with median and MAD over a time window) including, among others:

That vector is then embedded into 3D:

Practical interpretation. If the trajectory stays as a compact cluster, the state is stable. If you see sharp jumps or branches, it is often a real change (motion, lighting, ROI change) or an event/trigger.

12.5.2 Key parameters (Controls → Metric Space)

ParameterWhat it doesPractical notes
EnableEnables trajectory generation.If off, the view stays unchanged.
Hop framesTemporal decimation: 1 point every N frames.Increase to reduce load (e.g. 3–10).
Window (sec)Window used for robust normalization and (if not frozen) PCA updates.Longer = steadier basis, less reactive.
EmbedPCA or LMDS.LMDS is more expensive; keep landmarks moderate.
Freeze basisLocks normalization + basis once enough history is collected.Recommended for comparisons and to avoid geometry “jumps”.
View mode3D curve or time-axis (z=t), rendered as line/points, ribbon, tube, or density.Ribbon/tube improve readability; density shows an “attractor”.
ColorColors points by Time, Peak Hz, Entropy H, Osc Hz, Quality, Global speed, Osc Coh.Great to see what changes along the trajectory.
Max pointsHistory cap (maximum kept points).Prevents unlimited growth in long sessions.
Landmarks (LMDS)Landmark count for LMDS.256 is often a good trade-off.
ResetClears trajectory and restarts.Use after changing source or conditions.

12.5.3 Viewer controls (mouse)

12.5.4 Density + Iso mode (3D signature)

In Density cloud mode, points are voxelized into a 3D grid (bins^3) and shown as a weighted cloud. The Iso overlay draws an iso-surface over the densest regions: it behaves like a 3D signature of the trajectory.

12.5.5 Export

Performance note. LMDS and Density/Iso are the heaviest modes. If you see slowdowns: (a) increase Hop frames, (b) reduce Max points or Density bins, (c) use PCA and/or freeze the basis.

13) Frequency histogram, spectrum and waterfall

12.1 From per-cell frequencies to a histogram

Each cell that passes gating contributes to a histogram bin. A bin represents a frequency, with a user-defined scale:

bin = round( f0 · scale )    (scale = bins per Hz)

Only frequencies inside [Hist fMin, Hist fMax] are accumulated.

12.2 Weighting modes

A cell can contribute a simple count (COUNT) or be weighted by reliability/strength:

Weighting helps emphasize strong, periodic oscillations and suppress weak/noisy ones.

12.3 Peak frequency

The peak bin (maximum histogram value) defines the “dominant frequency” for the current frame:

peakHz = peakBin / scale

12.4 Waterfall

The waterfall is a time–frequency display: each row is a histogram, and rows scroll with time. It helps you see whether the frequency is stable, drifting, or intermittent.


14) Baseline and frequency-change detector

The detector triggers events when the dominant frequency changes beyond normal variability. It maintains a baseline mean (mu) and variance (var) using an exponential moving average (EWMA).

13.1 EWMA baseline

mu[t]  = (1−α)·mu[t−1]  + α·f[t]
var[t] = (1−α)·var[t−1] + α·(f[t]−mu[t])^2
sigma  = sqrt(var)

A smaller α means “longer memory” (baseline changes slowly).

13.2 Dynamic threshold

A change is significant if:

|f − mu| > max( absHz, rel·mu, kSigma·sigma )

13.3 Consecutive and cooldown

13.4 Gating

Baseline and trigger are updated only when the frame contains enough valid oscillatory cells. This prevents the baseline from being “polluted” by idle/noisy frames.


15) Event recorder

When the detector triggers, the event recorder saves image sequences around the event:

At the trigger moment, it can also save a one-time snapshot of diagnostics: overlay, corr map, f0 map, and mask.

15.5) Session recording (SQLite)

In addition to event snapshots (Event recorder), FlowStudio can log a full measurement session into a SQLite database. The resulting .sqlite file contains per-frame QC metrics and, optionally, per-cell grid flow vectors.

15.5.1 Operational workflow

  1. Open File → Session recording (SQLite)... and choose a target .sqlite file. The action stays checked (recording is armed).
  2. (Optional) enable File → Record grid flow (heavy) if you also want to store per-cell vectors (grid_flow).
  3. For a clean take, use Restart Video (file) or Start (camera). On the first valid frame, FlowStudio automatically opens a new run.
  4. When finished, disable Session recording (SQLite)... (or stop the runtime): FlowStudio commits/checkpoints and closes the DB.
About WAL and file size. In WAL mode SQLite may create sidecar files name.sqlite-wal and name.sqlite-shm. During recording, the main .sqlite can stay relatively small: this is expected. On stop, FlowStudio runs a checkpoint to fold data back into the main file. If you need to copy a session while recording, copy -wal and -shm together with the .sqlite.

15.5.2 Database contents

TableContent
metaKey/value pairs: schema, version, creation time, meta_json (UI-provided JSON), source_meta_json (source information).
runsOne record per run/segment: start timestamps and source snapshot (fps, size, etc.).
framesOne row per frame with key QC metrics: peak/baseline Hz, quality, activity, fps, drops, luminance/blur/saturation, ROI, etc.
grid_flow(Optional) Sparse grid vectors: per frame (optionally subsampled by hop) stores (cx,cy,u,v,conf,stable).
eventsLightweight JSON events: run_start/run_end, roi_changed, and future markers.
Performance. Record grid flow (heavy) may generate a lot of rows (cells × frames). If you only need per-frame QC, keep it off. If you need it, consider: higher hop, larger cell size, or a smaller ROI.

15.5.3 Menu integrity check

To quickly confirm the file is valid and complete, use File → Verify session DB integrity...: FlowStudio runs PRAGMA integrity_check; and prints basic counters/ranges (runs/frames) into the Log.

15.5.4 Useful queries (DB Browser / sqlite3)

-- how many rows were written
SELECT COUNT(*) FROM frames;

-- frames per run
SELECT run_id, COUNT(*) AS n
FROM frames
GROUP BY run_id
ORDER BY run_id;

-- time range (UTC microseconds) for run 1
SELECT MIN(t_us), MAX(t_us) FROM frames WHERE run_id=1;

-- mean peak and mean quality (run 1)
SELECT AVG(peak_hz) AS peakHz_mean, AVG(quality01) AS q_mean
FROM frames
WHERE run_id=1;


16) CSV exports

15.1 Statistics CSV

Exports the last N samples of:

15.2 Spectra CSV (sparse)

Exports the last N histograms, but only non-zero bins: each output row includes time, frame index, activeCount, weightSum, bin index, Hz and count. This is efficient for large bin counts (e.g., 1024).


17) Sonata analysis

Sonata analysis is a “session summary” of spectral content. It uses the accumulated histogram history to find the most prominent frequencies over time.

16.1 Peak picking on the accumulated spectrum

Conceptually:

  1. Sum histograms over many frames to get an overall spectrum.
  2. Smooth the spectrum with a moving average (to reduce noise peaks).
  3. Find local maxima (candidate peaks).
  4. Select the top N peaks while enforcing a minimum frequency separation.

Parameters:


18) Clinical Before/After workflow and metrics

This workflow is designed to compare two short segments acquired under similar conditions (same ROI, same camera settings, same subject framing). It produces a concise summary, plus quality flags.

17.1 Procedure

  1. Set ROI and main gates (Corr thr, RMS thr, Cell size) and wait a few seconds until the spectrum stabilizes.
  2. Enter a Case label (free text).
  3. Enter the calibration Scale (um/px).
  4. Press Record BEFORE, record a representative segment, then Stop BEFORE.
  5. Press Record AFTER, record another segment, then Stop AFTER.
  6. Press Report to generate the summary (and optionally save/print it).

17.2 What is measured per frame

During recording, each processed frame contributes:

17.3 Conversions to user-facing units

Let FPS_seg be the measured FPS during the recorded segment. Pixel speeds are converted to µm/s by:

value_um_s = value_px_frame · FPS_seg · um_per_px

17.4 The core metrics (what they mean)

MetricMeaning
RMS speed (µm/s) Global motion speed is computed each frame as |globalMotion|. RMS speed is the root-mean-square of that per-frame speed, converted to µm/s. It represents overall motion intensity.
Drift (µm/min) Mean global speed converted to µm/min. It represents slow drift or sustained displacement.
Dominant frequency (Hz) Mean of peakHz across frames. Represents the typical oscillation frequency.
Frequency stability (Hz) Standard deviation of peakHz across frames. Lower means more stable frequency.
Peak amplitude (µm/s) Uses bestRms (px/frame) of the best cell, converted to µm/s. It is a proxy of oscillation amplitude/strength.
Peak/Band ratio peakToBand averaged across frames. Closer to 1 means “a single sharp frequency dominates”. Lower means “spread spectrum / mixed frequencies”.
Events/min How often the frequency-change detector triggered during the segment, normalized per minute.
Micro-activity (µm/s) Mean residual motion magnitude after removing global translation. It reflects “local micro-movement” inside the ROI rather than whole-ROI drift.
Active area (%) Fraction of residual samples whose magnitude exceeds a small threshold (~0.5 px/frame), averaged across frames, expressed in percent.
Quality (%) Average inlier ratio (reliable motion fraction) expressed in percent. Low quality means the measurement is likely unreliable.

17.5 Advanced tremor metrics

17.6 Advanced jerk-like events (severity/duration/duty cycle)

In addition to the main detector, FlowStudio characterizes “jerk-like” periods using global speed statistics: it tracks a running mean and standard deviation of speed, then opens an event when speed exceeds mean + 3·std, and closes it when speed stays below mean + 2·std for a few frames (hysteresis).

From these events it reports:

17.7 Validation metrics and quality flags

During recording, FlowStudio also measures:

A simple quality flag is produced:


19) Interpreting issues & troubleshooting

18.1 “I see motion vectors but frequency is 0 Hz”

18.2 “The spectrum is very noisy / too many peaks”

18.3 “Frequency jumps a lot”

18.4 “Quality is low”

18.5 Interpreting Coh (coherence) for the Blob Oscillator

Coh is designed as a phase-alignment metric:

Coh = | Σ_{i∈S} X_i |  /  Σ_{i∈S} |X_i|      (0..1)
Debug workflow for low Coh. First check the Mask and the count of active cells (|S|). Then look at Phase and Contrib to distinguish “two-lobe counterphase” from “random phase”. If Coh rises dramatically when you reduce ROI size, you likely had multiple oscillators in the ROI.

20) Glossary & acronyms

Acronym / termMeaning in FlowStudio
ROIRegion Of Interest: the rectangle where analysis runs (everything outside is ignored).
FPSFrames per second (sampling rate of the video stream).
dtTime step between frames: dt = 1/FPS.
NyquistSampling rule: the highest resolvable frequency is roughly FPS/2 (more margin is better in practice).
Optical flowFrame-to-frame displacement estimation; outputs a vector (u,v) per pixel or per region.
(u,v)Horizontal/vertical displacement components, typically in px/frame.
px/framePixels per frame: internal motion unit (before converting to physical units).
um_per_pxCalibration: micrometers per pixel (µm/px). Enables physical units (µm, µm/s).
Mask / inliersSet of reliable pixels/cells that pass confidence checks and therefore contribute to estimates.
photoErrPhotometric error after warping; low values mean the flow explains intensity changes well.
FB / fbErrForward–backward consistency error; large values signal occlusions/blur/mismatch.
MADMedian Absolute Deviation: robust dispersion measure used for cell stability/outlier rejection.
EMAExponential Moving Average: temporal smoothing of cell vectors/signals.
Decimation (D)Optional averaging of D consecutive frames/samples to reduce noise and CPU cost.
fs_effEffective sampling rate after decimation: fs_eff = FPS/D.
NWindow length (number of samples) used for frequency estimation.
HopUpdate step (in samples) between consecutive window analyses.
Band [fMin,fMax]Frequency search band (Hz) used by the analyzer and (optionally) other blocks.
HP / LPHigh-pass / low-pass filters used to form a simple band-pass (cutoffs: hpCut / lpCut).
RMSRoot Mean Square energy of the filtered signal (activity/energy gate).
Corr / corr(L)Normalized autocorrelation peak; “periodicity score” used as a gate and for alpha.
CorrThrCorrelation threshold: minimum periodicity score required to accept a cell.
f0Dominant frequency estimate per cell (Hz). 0 means “no valid frequency”.
stable / stableNeedPersistence counter and its threshold: how long a cell kept a consistent frequency.
Active cellsCells that pass corr/rms/stable gates in the current update and contribute to maps/histograms.
Spectrum / histogramDistribution of per-cell frequencies in the ROI (possibly weighted by corr/rms).
WaterfallTime history of spectra; useful to see drifts, bursts and band changes.
Blob oscillatorROI-level oscillator estimate: produces Hz(t) and Coh(t) over the stable-cell set.
Hz(t)Region dominant frequency trace (one value per update) from the blob oscillator.
CohCoherence (0..1): phase-alignment ratio across stable cells; high means “single-oscillator-like”.
DFT / FFTDiscrete Fourier Transform / Fast Fourier Transform used for peak search in spectra.
GoertzelEfficient single-bin DFT (often used when only one frequency bin is needed).
UVCUSB Video Class (standard USB camera interface on Windows).
BW gain / Color gain / Alpha boostVisualization gains that control background brightness, color saturation and overlay transparency strength.
quality (%)Overall inlier ratio (fraction of pixels/cells considered reliable), shown as a quick acquisition health indicator.

End of document.


Appendix A) UVC camera formats, pixel formats, and recording containers (MP4, AVI, …)

This appendix clarifies a common source of confusion: a camera output format (what the UVC device streams over USB) is not the same as a file format (what you save on disk). UVC cameras typically stream either:

When you save a recording, you usually choose a container (e.g., MP4 or AVI) and a codec (e.g., H.264 or MJPG). The application (through OpenCV / OS multimedia backends) encodes the incoming frames into that codec.

A.1 UVC: what comes out of the camera

UVC (USB Video Class) is a standard that allows cameras to expose video streams with a set of supported formats and frame sizes. Typical format families:

Practical choice. If USB bandwidth is not a problem and you care about fine motion, prefer uncompressed or lightly compressed formats. If you need very high resolution or high FPS over USB2, MJPG is often the only practical choice.

A.2 Pixel format ≠ codec (and why “YUV” can’t be “MP4”)

“YUV” (more precisely Y′CbCr) describes pixel organization (how luma/chroma samples are stored), not a file container. MP4 is a container that usually carries compressed video streams (e.g., H.264/H.265/AV1). You generally do not store raw YUY2 inside MP4. So the real chain is:

UVC camera outputs YUY2 (raw frames)   → application decodes to BGR/gray   → encoder compresses to H.264   → MP4 file

Or, if the camera outputs MJPG:

UVC camera outputs MJPG (compressed frames) → decoder to BGR/gray → (optional) re-encode → MP4/AVI file

A.3 Containers and codecs (typical combinations)

ContainerCommon codecsNotes
MP4H.264 (AVC), H.265 (HEVC), AV1Efficient; can introduce compression artifacts at low bitrate; often VFR pitfalls if not handled carefully.
AVIMJPG, XVID/DivX, uncompressedSimple and widely supported; good for MJPG recordings; file size can be large if uncompressed.
MKVH.264/H.265, VP9, AV1Flexible container; depends on the chosen backend/support.

The actual available codecs depend on the OS backend (Windows Media Foundation / DirectShow) and your OpenCV build.

A.4 Why formats matter for motion/oscillation measurements

A.5 Troubleshooting quick hints

Appendix B) Panels, dock widgets and layout (Qt)

FlowStudio follows the standard QMainWindow (Qt) model: one central view plus several dock widgets (dockable panels) around it. If you are not used to Qt, this appendix explains how to bring panels back, move and resize them.

B.1 Show / hide a panel

B.2 Move and dock

B.3 Tabs and splits

B.4 Resize areas

B.5 Restore the layout

B.6 Quick tips