Background Subtraction

Quadrant Folding estimates and removes diffuse background scattering from the quadrant-folded image. Several algorithms from the CCP13 FibreFix suite are available, along with 2D convex hull and white top-hat methods. Methods can be used alone, combined across radius (inner/outer merge), or chosen automatically using a quantitative loss score.

For the algorithmic details of each method, see How it works — Apply Background Subtraction. This page documents the current GUI workflow (Results tab and Background Subtraction Settings dialog).

Introduction

Muscle diffraction patterns carry a diffuse background whose structure varies with radius and angle. The choice of subtraction method therefore depends on what you need from the analysis—display, peak fitting, or downstream normalization—and on which part of the pattern matters most.

In principle, background should be removed consistently across the entire folded image. In practice, no single algorithm performs equally well at all radii: some methods preserve low-angle equatorial features while others handle the high-angle region more reliably. 2D Convexhull is currently the strongest option for revealing equatorial structure near the beam. At larger radii, where meridional layer lines dominate, White-top-hats and Smoothed-Gaussian typically give cleaner results; Automated Processing can search among these methods and select parameters using the compound loss metric.

To obtain plausible background removal over the full pattern today, use Manual Setting | Transition, which fits an inner method at small radii and an outer method at large radii, then merges the two estimates at a Transition Radius. A future release will add dedicated equator-streak fitting followed by general background removal on top of that estimate.

For time-resolved (TDI) normalization, you may instead fix one method and parameter set and apply it uniformly to every frame in a sequence. The summary csv file will contain the integrated background sum between rmin and rmax for each frame.

See Examples for more details.

Where to find the controls

Background subtraction is configured from two places in the Results tab:

  1. Background Subtraction panel (collapsible section on the right) — quick access to mode, method parameters, apply buttons, and current configuration summary.

  2. Advanced Configuration — opens the Background Subtraction Settings dialog for R-min/R-max, image processing, automated optimization, evaluation metrics, saved configurations, and batch processing.

A link at the top of the dialog points back to this documentation.

Processing options

Use the Options dropdown in the Results tab to choose how background is applied:

Option

Description

Manual Setting | One Method

A single subtraction method on the full pattern (inner region). Method and parameters are set in the panel; click Apply Selected Subtraction Settings to reprocess.

Manual Setting | Transition

One method for radii below the transition radius (inner) and another for radii above (outer). Results are merged using Transition Radius and Transition Delta. 2D Convexhull is not available for the outer method.

Automated Processing

Parameter search and/or selection from saved configurations using the compound loss metric. Use Apply Default Optimization on the current image, then tune settings in Advanced Configuration.

Manual controls are shown in the Results panel. Apply Default Optimization and Advanced Configuration are shown only when Automated Processing is selected.

Manual Setting | One Method

  1. Subtraction Method — Select the background subtraction method to use.

  2. Method-specific parameters — Set the method-specific parameters.

  3. Apply Selected Subtraction Settings — Click to apply the selected subtraction settings.

Set the method and parameters to use for the background subtraction.

Manual Setting | Transition

  1. Inner background — Method and parameters for radii inside the transition region (e.g. 2D Convexhull).

  2. Outer background — Separate method and parameters for larger radii (e.g. Smoothed-Gaussian).

  3. Transition Radius — Radius where inner and outer estimates are blended.

  4. Transition Delta — Width of the linear blend zone.

  5. Show Transition Radius and Delta — Overlay transition circles on the folded image.

Set the transition radius just outside the M3 meridional peak when possible.

Automated Processing

Apply Default Optimization runs this search with default methods on the current image and can add a Default Optimization entry to the configuration table to be applied to subsequent images. Advanced Configuration allows to adjust the settings for the optimization and add additional configurations to the configuration table.

Subtraction methods and parameters

Six methods are available (plus None). Visible parameters depend on the selected method.

Circularly-symmetric

  • Pixel Range (min–max %): lowest-intensity pixels averaged per radial bin (e.g. 0–25% = lowest quarter).

  • Radial Bin (pixels)

  • Smoothing factor (spline smoothing)

2D Convexhull

  • Step Degree (angular bin size for radial histograms)

  • R-min (and R-max when set)

Roving Window

  • Window Size (X, Y) and Window Separation (X, Y)

  • Pixel Range (%)

  • Smoothing factor and Tension factor

White-top-hats

  • Top-hat Disk Size

Smoothed-Gaussian

  • Gaussian FWHM

  • Number of Cycles

Smoothed-BoxCar

  • Box Car Size (X, Y)

  • Number of Cycles

Default optimization searches White-top-hats and Smoothed-Gaussian unless you change the method list.

Automated processing details

When Automated Processing is active and optimization runs:

  1. For each selected method, the program searches parameter space using the configured step schedule and iteration limit.

  2. The optimization processes tunes each parameter in the selected method one at a time in the order of their importance.

  3. Candidates are scored with the compound loss; search can stop early when loss drops below Early Stop Loss Threshold.

  4. The best method/parameter set is written to Current Configuration and used for the result image.

Apply Default Optimization runs this search with default methods on the current image and can add a Default Optimization entry to the configuration table.

For batch runs with Choose best configuration for images automatically, optimization is not repeated per image; each saved configuration is evaluated once and the lowest-loss configuration is applied.

Examples

Example 1: High Angle Features with Automated Processing - Intact Mouse Skeletal Muscle - Faint pattern & faint background

The default weights are used for the optimization.

-

Example 2: Whole Pattern Background Subtraction with Transition - 2D Convexhull for Inner and Smoothed Gaussian for Outer - Skinned Pig Cardiac Muscle - High intensity background

This example shows the use of transition mode to remove background on the whole pattern. This is preferable for visualization of patterns where the equatorial features are important. The transition radius and delta are shown in yellow and red.

-

Headless mode

Background subtraction parameters can be set in qfsettings.json. Important keys include bgsub, bgsub_out, transition_radius, transition_delta, fixed_rmin, fixed_rmax, method-specific fields (fwhm, cycles, win_size_x, win_sep_x, etc.), and bg_options (0 = one method, 1 = transition, 2 = automated). For automated batch behavior, also pass saved configurations and flags such as choose_configurations_auto as produced by saving settings from the GUI (File → Save current settings).

See How to use — Headless Mode for the general headless workflow.