Watch a capture folder, stack every new sub-exposure as it lands, and see a cumulative image build in real time — with on-the-fly calibration, star alignment, quality-weighted σ-clipping rejection, per-filter mono-to-colour composition, star-trail mode, live metrics, an SNR-goal estimate and a culling folder for bad frames. The stack is linear; only the preview is stretched. The during-session companion to the batch Stacking Suite.
The core incremental update, applied per pixel for every good frame x with frame weight w, where W is the sum of the weights kept at that pixel:
During the bootstrap every valid pixel is kept; afterwards a pixel more than kσ from the running mean is left out of that update entirely (§12.10). Everything happens on linear data — the statistical stretch is applied to the preview only.
The window is a vertical stack: a top row of controls, a status line showing where files come from and go to, a toolbar (zoom, Auto Stretch, SNR Region, help and the Settings wrench), the Show Metrics button, the large live-preview area, brightness/contrast sliders, and the Open … ▶ buttons at the bottom (§10). The metrics window (§8) is a separate window that belongs to Live Stacking: it stays in front of it and closes with it. A dynamic Mode label (“Weighted Average, bootstrap n/B” / “Weighted σ-Clipping Average” / “Star-Trail” / per-filter variants), a Status label and the SNR line (§8.1) at the very bottom narrate what's happening.
Frames are loaded, calibrated, measured and aligned in separate worker processes and stacked on a background thread, so the window stays usable while frames are processed: you can pan, zoom, move the sliders, open the metrics or export the current stack at any time. When you start on a folder that already holds frames, several are prepared at once.
The preview is a true QGraphicsView, so pan with click-drag and zoom with the toolbar. The dialog is non-modal — you can leave it running and keep working in SASpro.
Click Select Folder… and pick the directory your capture software writes to. Live Stacking recurses into subfolders, so if your capture program organizes by filter or session into subdirectories, it still works.
By default every supported file type in the folder is scanned:
| Category | Extensions |
|---|---|
| FITS | .fit, .fits |
| TIFF & XISF | .tif, .tiff, .xisf |
| Camera RAW | .cr2, .cr3, .nef, .arw, .dng, .raf, .orf, .rw2, .pef |
| Everyday | .png, .jpg, .jpeg |
If your capture program writes preview JPGs, autostretch TIFFs, debug thumbnails or other derived files alongside the real subs, tick Ignore non-FITS files in Settings (§9) — the scanner then limits itself to *.fit and *.fits only, which is also what you want for most dedicated astro cameras.
Capture software writes a file in chunks and often holds the handle open for a moment after the last byte lands. Reading it half-written would be a disaster. Live Stacking's file-readiness probe handles this:
The watch loop polls every 1.5 s. A re-entrancy guard prevents overlapping scans if a frame takes longer than one tick to process.
Live Stacking supports a single master dark, a single master flat, and a per-filter flat dictionary for mono-to-colour sessions.
FILTER header if present, otherwise by its filename stem. Stored as a dictionary keyed on the filter letter (H, O, S, R, G, B, L). The badge then lists the loaded filter names.During processing (§12.3), per-filter flats take precedence over the global master flat when the incoming frame's FILTER header matches a key. Masters are automatically shape-coerced to match each incoming frame: a mono master applied to a colour frame broadcasts to all three channels; a colour master applied to a mono frame is collapsed to its channel mean. This means you can load a mono dark and still have it correctly subtract from debayered RGB frames.
Click Select Cull Folder… to pick a destination for rejected frames (frames that fail the thresholds in §7 or can't be aligned). When set, flagged frames are moved there with shutil.move; when not set, they're simply logged in the status line and skipped. The folder is created on first use if it doesn't exist.
Four run buttons sit at the right of the top row:
The Frames counter and Total Exp label (format HH:MM:SS) in the status row tick up with each accepted frame; exposure is accumulated from the FITS EXPOSURE or EXPTIME header, or from the RAW file's metadata.
Live Stacking has three top-level modes, two of them toggled by checkboxes next to the run buttons.
With both checkboxes off, Live Stacking runs a two-phase integration on linear data. The first Bootstrap frames (default 24) are averaged without rejection while per-pixel statistics build up; then the stack switches to σ-clipping at Clip threshold σ (default 3.5). At the switch, a satellite, plane or cosmic ray that landed in one of the bootstrap frames is taken back out of the stack (§12.9), so the first frames get the same protection as the rest. Each frame counts in proportion to its quality weight (§7). The Mode label narrates the transition.
Tick Mono → Color Stacking to bucket incoming mono frames by their FILTER header into separate per-filter stacks and composite them live into an RGB preview according to a Narrowband Mapping (§6). Each filter stack is its own linear stack with its own bootstrap, normalization and statistics. The composite is rebuilt from scratch each new frame, so adding a late OIII frame updates the whole preview immediately.
Mono-to-colour mode works entirely from the FILTER header — frames with no FILTER are not routed to any channel. OSC frames with a BAYERPAT header are still debayered and stacked as colour, bypassing the mono buckets.
Tick ★★ Star-Trail Mode ★★ to replace the running-mean pipeline with an elementwise per-pixel maximum accumulator. No alignment is performed and no clipping is applied; each frame is calibrated, debayered if needed, stretched to target_median = 0.3, and then combined with the current stack as:
— the classic star-trail blend, where every bright pixel wins. Enabling Star-Trail disables Mono→Color (they're mutually exclusive).
When Mono→Color is on, the Narrowband Mapping setting controls how per-filter stacks are composited into the live RGB preview. Change it any time in Settings (§9) — the next preview refresh uses the new mapping.
SASpro recognises these FILTER values (case-insensitive, with common synonyms):
| Key | Matches |
|---|---|
| H | H, Ha, HAlpha, H-Alpha |
| O | O, O3, OIII |
| S | S, S2, SII |
| R | R, Red, Rd |
| G | G, Green, Grn |
| B | B, Blue, Bl |
| L | L, Lum, Lumi, Luminance |
Natural (default) — auto-selects the composite based on what's loaded:
SHO, HSO, OSH, SOH, HOS, OHS — direct three-letter mappings. The letters assign to R, G, B in order:
R = SII, G = Hα, B = OIII — the classic Hubble palette.R = Hα, G = SII, B = OIII.R = OIII, G = SII, B = Hα.R = SII, G = OIII, B = Hα.R = Hα, G = OIII, B = SII.R = OIII, G = Hα, B = SII.Missing channels in a direct mapping default to zero, so an SHO composition with only Hα and OIII loaded shows up red-less until the first SII frame lands.
Every frame is measured for star quality (§12.7) after calibration, before it is combined into the stack. Two things can keep a frame out:
| Threshold | Default | Meaning |
|---|---|---|
| Max FWHM | 15.0 px | Reject frames with median star FWHM above this. Catches heavy defocus and bad seeing spikes. |
| Max Eccentricity | 0.9 | Reject frames with median eccentricity above this. Catches tracking slips, wind gusts, cable snags. |
| Min Star Count | 5 | Reject frames with fewer detected stars than this. Catches clouds, satellite streaks saturating detection, and dome lights. |
The defaults are deliberately loose: they catch disasters, not ordinary frames. Everything else is handled by frame weights. With Weight frames by quality on (the default), each frame counts in proportion to the same “Balanced” score the Stacking Suite uses:
with N★ the star count, e the eccentricity, b the frame's median sky level, and F̃/F the stack's median FWHM over this frame's FWHM (clamped to ×⅓…×3). A frame shot through thin cloud still adds its photons, just less of them. The status line shows each frame's weight relative to the stack's median weight.
Flagged frames appear as red dots on the live metrics plots, and the status line says why. If a cull folder is set, the file is moved there; otherwise the status line notes it and continues. The frame counter and exposure accumulator don't tick up for culled frames — what you see in Frames: N is the integrated count only.
Click Show Metrics to open a separate 3×2 scatter window that updates per frame:
Dots are stacked frames; a red × is a culled frame (on the first three plots only). In Mono→Color each filter is its own series in its own colour, named in the legend on the FWHM plot (Ha pink, OIII cyan, SII amber, R red, G green, B blue, L grey), and the frame numbers count each filter's frames, so all filters build up side by side from frame 1 and line up vertically on every plot. A single stack is plotted in blue. Everything stays plotted for the whole session so you can see when and why conditions changed. The window is independent of the main dialog — close it any time without stopping the stack; reopen with Show Metrics.
Click SNR Region in the toolbar and drag a box over the faint signal you care about — the outer arm, the IFN, the faint shell. Clear Region removes it. From then on the yellow SNR line under the preview reads, for example:
The estimate starts after 3 frames. In Mono→Color mode the line reports on the filter of the latest frame.
Click the orange wrench button in the zoom toolbar to open the combined Live Stack & Culling settings dialog. All values persist across sessions via QSettings under the LiveStack/ key.
| Setting | Default | Range | Effect |
|---|---|---|---|
| Switch to μ–σ clipping after | 24 | 1 – 100 | Bootstrap frame count. Frames up to this count are averaged without rejection, then the stack switches to σ-clipping. Applies to stacks started after the change. |
| Clip threshold | 3.5 | 0.1 – 10.0 | σ rejection multiplier (§12.10). Lower = more aggressive rejection. |
| Max FWHM (px) | 15.0 | 0.1 – 50.0 | Culling threshold on median star FWHM. |
| Max Eccentricity | 0.9 | 0.0 – 1.0 | Culling threshold on median star eccentricity. |
| Min Star Count | 5 | 0 – 5000 | Culling threshold on detected star count. |
| Acquisition Delay | 3.0 s | 0.0 – 60.0 s | File stability window. Size+mtime must stay unchanged for this long before a file is considered writeable-complete. |
| Stars to detect | 100 | 10 – 2000 | How many stars star detection aims for. The detection threshold is found from this on each stack's first good frame and then held for that stack (§12.7). Applies after Reset. |
| Ignore non-FITS files | off | — | When on, only *.fit/*.fits are picked up. Use when the capture app writes derived files beside the raw subs. |
| Weight frames by quality | on | — | Each frame counts in proportion to its quality score (§7). Off = every stacked frame counts equally. |
| SNR goal (per pixel) | 10 | 1 – 1000 | Target for the frames-to-go estimate in the SNR region (§8.1). |
| Narrowband Mapping | Natural | — | Composition rule for Mono→Color (§6). |
| Debayer | the Stacking Suite's (RCD) | RCD, Edge-aware, AHD, VNG, Bilinear | Demosaic for OSC / Bayer frames (§12.4). Until you change it here, it follows the Stacking Suite's Debayer setting. Applies to frames stacked after the change. |
The Open … ▶ buttons below the preview open the current result. You can use them at any time, also while frames are still arriving; each opens a new 32-bit document named LiveStack_<YYYYMMDD_HHMMSS>_<N>f, where N is the integrated frame count.
LiveStack_Ha_…, LiveStack_OIII_… and so on, for your own channel combination.NCOMBINE, EXPTIME (mean per frame), TOTALEXP and, for a single filter, FILTER. A composite counts the frames and exposure of all its filters.With Auto Stretch on (the default), the preview is the linear stack put through SASpro's statistical stretch to a median of 0.3 (unlinked per channel for colour; in Mono→Color each filter is stretched on its own before the composite). Turn Auto Stretch off in the toolbar to see the linear stack as it is, which is mostly dark: use it to check for clipping or a gradient. The choice is remembered. Auto Stretch and the brightness and contrast sliders affect the preview only; the stack itself is never stretched. Both sliders are pivoted at 0.3:
with c the contrast slider (10–1000 mapped to 0.1–10.0) and b the brightness slider (-100–100 mapped to -1.0–+1.0). The result is clipped to [0, 1] for display.
The streaming pipeline, in order of each frame's processing.
The scanner runs on its own thread (a QThread), pausing 1.5 s between scans. Each scan, the folder is reglobbed recursively against the current extension set, candidate paths are normalised (case-insensitive, absolute, platform-normalised slashes), and those not yet in the processed set are tested for readiness. Each path accumulates a probe record:
size and mtime from os.stat, refreshed each cycle.since — the last cycle where either size or mtime changed; the file is only ready once now - since ≥ FILE_STABLE_SECS.penalty_until — a cool-down timestamp. On a PermissionError or OSError during the final 1-byte read probe, the penalty is set to now + 10 s so repeated hammering doesn't make matters worse.fails — a counter incremented on every exception during process_frame. After three failures the file is permanently marked processed so it stops blocking the queue, and its name goes to the status line.Worker processes. Each ready frame is handed to a pool of worker processes (up to three, a quarter of the CPU threads; fewer when memory is short for the frame size), started when you first press Process or Monitor and kept until the window closes. A worker loads the frame, calibrates and debayers it, measures its stars, applies the cull thresholds, normalizes it and aligns it (§12.2–12.7), and returns the aligned frame with its measurements. Separate processes matter because SEP and parts of the alignment hold Python's interpreter lock while they run: on a thread in SASpro's own process they would freeze the window for seconds per frame. The masters and the reference frame reach the workers as temporary .npy files written once, which are deleted when the window closes.
Frames are stacked in file order whatever order the workers finish in, so the result is the same as stacking them one by one. The session's first frame is prepared on its own, because it becomes the alignment reference for every later frame. A frame prepared before its filter's stack had normalization levels is normalized to its own levels and moved to the stack's with one more per-channel gain when it is stacked (the normalization is a gain after the floor, so this is exact).
When worker processes can't start (SASpro's start-up check of the Python environment failed, or a worker died), frames are prepared on the background thread with the same code, and the status line says so. Star-Trail mode always runs on the thread.
The background thread never touches the window. Each finished frame is handed to the window as a result (labels, the metrics point and the preview image) through a queued Qt signal. The background thread is the only writer of the stacks and writes them under a lock that export, the preview and the SNR readout also take, so an export never sees a half-updated stack. Reset and a Mono→Color switch advance a generation counter, and a frame that was in flight under the old one is discarded instead of being added.
Every file goes through SASpro's shared load_image, which returns the pixel array, a FITS-style header, bit depth and a mono flag. XISF, TIFF, FITS, PNG, JPG and camera RAW all land in the same code path.
For camera RAW, load_image returns the linear Bayer mosaic (black level removed, scaled to [0, 1]) with exposure and camera details from the RAW metadata. Live Stacking reads the 2×2 pattern for exactly that mosaic from LibRaw and debayers it like a FITS frame (§12.4), so darks and flats are applied to the mosaic before demosaicing. Fujifilm X-Trans sensors can't use the Bayer debayer, so those frames use LibRaw's linear demosaic, without dark or flat (as in the Stacking Suite). A RAW whose sensor data can't be read and only offers its embedded JPEG preview is skipped, because that preview isn't linear.
Calibration is a two-step process applied once per frame after loading:
Dark subtraction is a plain NumPy subtraction in float32. Flat division is dispatched through apply_flat_division_numba, a JIT-compiled helper shared with the Stacking Suite. The flat used is the per-filter flat F_k when (a) Mono→Color is active, (b) the frame's FILTER header matches a key in the per-filter dictionary; otherwise the global master flat is used.
Shape coercion is automatic:
(H, W, 1) so it broadcasts across the three channels.Up-front shape compatibility between the master dark and master flat themselves is checked at load time, so you can't mix a 3D dark with a 2D flat without noticing.
If a frame is marked mono by the loader but its header carries a BAYERPAT (or it's a Bayer RAW, §12.2), Live Stacking debayers it with debayer_fits_fast (SASpro's shared vectorised debayerer, same one the Stacking Suite uses) after calibration and before the alignment stage, with the method chosen under Debayer in Settings: RCD (ratio-corrected, noise-robust; keeps faint colour without speckling dim areas, the default), AHD, VNG, Edge-aware or Bilinear. These are the Stacking Suite's methods except Strict CFA, which only prepares CFA drizzle. Supports RGGB, GRBG, GBRG and BGGR patterns. X-Trans RAW always uses LibRaw's demosaic (§12.2).
The first stacked frame becomes reference_image_2d — a 2D intensity plane used as the alignment reference for the rest of the session (reset clears it, so a new reference is picked on the next good frame after a Reset). Every subsequent frame is reduced to a 2D plane (channel mean for colour, or the mono plane in Mono→Color), aligned to the reference via Astroalign's star-triangle matching, and the resulting 2×3 affine transform:
is applied to the full image with SASpro's ring-free Lanczos warp. Pixels the warp brings in from outside the frame are 0.0, which means no data: they never enter the stack. If Astroalign can't find a transform (too few stars, catastrophic defocus, clouds), the frame is culled and the status line says so.
Each frame is matched to its stack's reference linearly, per channel, with the Stacking Suite's per-channel normalization. For channel c, with mc the frame's minimum and Lc its median above that minimum:
where Tc is the same level measured on the stack's first frame. That is an offset and a gain — no curve — so the stack stays linear and colour ratios survive. No-data pixels (0.0) stay no-data.
Per-frame star metrics use the settings of SASpro's measure_stars_sep, run on a statistically stretched copy of the calibrated frame, exactly as Blink measures (the copy is for measuring only; the stack stays linear), which wraps SEP (Barbary 2016; the Python port of Bertin & Arnouts' Source Extractor). The call uses:
sep.Background() with default mesh parameters.deblend_nthresh = 32.Extraction goes through SASpro's sep_tiled.waterfall_extract and extract_auto, shared with the Stacking Suite and Mosaic Master: a dense field is extracted in overlapping horizontal strips, each object kept by the strip that owns its centroid, which gives the same catalogue as one call, faster.
The background, noise, minimum area and median aggregation are those of SASpro's Blink tool, so the numbers are close to Blink's on the same subs. They match Blink's exactly only when the held threshold is Blink's 7 σ; at a higher threshold only brighter stars are measured, which reads a slightly larger median FWHM.
The stack keeps, per pixel, the weighted running mean μ, the sum of kept weights W and the weighted sum of squared deviations S. Their frame-to-frame variance gives the noise of one stacked pixel directly:
Because it comes from how each pixel varies between frames, the target's own structure is never counted as noise. In the SNR region:
with sky the median of the valid pixels in a 50×50 background box. The box is found with Background Neutralization's Find Background search (the darkest of 10×10 tile medians, a downhill walk to the local minimum, then a refinement of the box position), at least 100 px from the edges. No-data pixels (0.0, such as warp borders) are raised to the image maximum for the search, so the box never lands on them. The box is found once per stack, the first time the SNR is computed, and then kept, so the SNR series isn't moved by a sample that wanders from frame to frame; Reset finds a new one. If no box can be found the sky falls back to the median of the darkest 10% of 64×64-pixel block medians. For sky-limited frames SNR grows as √Neff, so reaching a goal G from the current SNR needs
converted to frames with the stack's effective weight per frame. To check the √N assumption, the stack's pixel-to-pixel noise is measured after each frame as 1.4826×MAD of horizontal first differences over a central crop, divided by √2 (smooth structure hardly moves a first difference). Its slope against Neff on a log–log scale is fitted over the recent half of the session. (The plot shows frame numbers so the filters line up; with quality weights Neff is a little below the frame count, and the fit uses Neff because that is what the noise actually follows.) A pattern that stays in the same place on every frame doesn't average down, so with σ2 = σp2 + σr2/N the slope drifts from −0.5 toward 0; above −0.25 the pattern holds at least half the noise and the warning appears.
Frames 1 through B (the bootstrap frame count) are accumulated without rejection: there isn't yet enough history to tell an outlier from a normal pixel. No frame is kept in memory for this. Instead, each pixel remembers its brightest bootstrap sample and that sample's weight. When frame B arrives, that sample is removed from the statistics with the reverse update:
and wherever m − μ' exceeds the critical value against the remaining frames (at least 3 of them), the pixel keeps μ', S', W'. Testing the brightest of B samples with σ estimated from the others is a multiple comparison, so the critical value is the larger of kσ' and a Bonferroni-corrected Student-t bound that removes a sample from about 1 pixel in 1000 on pure noise: about 4.9σ' at the default B = 24, 8.2σ' at B = 8. A satellite trail, plane or cosmic ray in one of the first frames sits far above that and is taken out, just as it would be later; fainter bootstrap outliers stay. The status line reports the fraction of pixels where this happened. The Mode label then switches to Weighted σ-Clipping Average. In Mono→Color mode every filter has its own bootstrap.
For each frame after the bootstrap, a pixel is kept only if
with k = Clip threshold. A rejected pixel is simply left out of that frame's update — it changes neither the mean, the variance nor W. Kept pixels update the weighted statistics in place (West 1979):
Pixels with fewer than two samples are never rejected. Because rejected samples never enter S, the kept samples form a normal distribution truncated at ±kσ, whose variance is smaller by c(k) = 1 − 2kφ(k) / (2Φ(k) − 1) (0.973 at k = 3). The variance is divided by that factor, in proportion to the weight stacked while clipping, so rejection doesn't tighten on itself and the SNR readout isn't optimistic. The status line shows the percentage of pixels rejected from each frame. Memory is three float32 images per stack (plus two more during the bootstrap), regardless of how many frames are integrated; updates run in bands of rows to keep temporary arrays small.
Each incoming mono frame whose FILTER key is recognized (§6) goes into its own linear stack with its own frame counter, normalization levels, bootstrap and statistics. For the preview, each filter stack is stretched on its own (or left linear with Auto Stretch off) and the RGB composite is rebuilt after every new frame using the current mapping. The linear composite export applies the same mapping to the unstretched stacks. For the Natural mode, the branch decision is made at composite time, not at frame-ingestion time, so adding the first SII frame to an already-running HOO session automatically promotes the composite to the SII palette on the next refresh.
For direct 3-letter mappings (SHO, HSO, …), missing filter stacks default to zeros in that channel, so a partial dataset simply shows the available channels and the missing one as black. If an invalid mapping string is somehow set, the composite falls back to Natural and the mapping is reset.
Star-trail mode replaces alignment, normalization, measurement, culling and integration with a direct per-pixel maximum of stretched frames:
Each frame is still calibrated and debayered as usual and still stretched to target_median = 0.3 — stars across the frames may have different brightnesses but the max accumulator always keeps the brightest sample at each pixel. No alignment is performed (that's the whole point — tracking off, let the stars sweep), no metrics are collected and no culling is done. The frame counter still ticks and the exposure accumulator still accumulates, so you can see how long you've been building the trail.
Every pipeline stage is bracketed by _should_stop() checks so Stop is responsive mid-frame. Exceptions during process_frame are caught and reflected to the status line without crashing the dialog; the file's fail counter in the probe record is incremented and a 10 s penalty window is set. After three failures the file is marked permanently processed so the queue drains past it; this is the right call for e.g. a half-written file the capture app aborted and left behind.
QApplication.processEvents() is called at key points through the pipeline so the UI stays responsive during long frames (large debayer, big affine warp). The dialog connects to QApplication.aboutToQuit to call stop_live() at app shutdown, so you never leave a polling timer running past exit.