API Reference
Symbols are accessed via fully-qualified submodule paths (the package does not re-export names into its top-level namespace); using ScatteringTransforms: ScatteringTransforms as ST, then e.g. ST.ScatteringCore.ScatteringTransform(...).
ScatteringTransforms.ScatteringTransforms — Module
ScatteringTransforms.jl — Native Julia implementation of wavelet scattering transformsSurfaces: 1D signals, 2D and 3D gridded fields, scattered planar points (NUFFT), and the sphere — both on a structured grid and at scattered points. Each has a monogenic variant; the gridded ones also have a localized (Mallat) field output and a multi-resolution second order. The spherical and scattered paths run dependency-free by default, with fast paths supplied by extensions.
Quick Start
Names live in submodules and are reached by their full path; alias the package for brevity.
using ScatteringTransforms: ScatteringTransforms as ST
# 1D scattering (N = signal length, J = number of octaves)
signal = randn(1024)
st = ST.ScatteringCore.ScatteringTransform(1024, 8; Q=1, max_order=2)
coeffs = st(signal)
# 2D planar scattering (N = image size, J = scales, L = orientations)
image = randn(256, 256)
st2d = ST.ScatteringCore.ScatteringTransform((256, 256), 4; L=8, max_order=2)
coeffs2d = st2d(image)References
- Mallat (2012): Group invariant scattering. Comm. Pure Appl. Math.
- Bruna & Mallat (2013): Invariant Scattering Convolution Networks. IEEE PAMI.
- Cheng & Ménard (2021): How to quantify fields or textures? A guide to the scattering transform.
Grid-support matrix
Planar (Cartesian) and spherical scattering, on uniform/structured and nonuniform/scattered sampling:
| domain | uniform / structured | nonuniform / scattered |
|---|---|---|
| Cartesian | ScatteringTransform{D} (FFT/direct sum; GPU via GPUBackend) | scattered_planar_scattering (exact direct NUDFT; NonuniformFFTs or FINUFFT fast path) |
| Sphere (S²) | structured_spherical_scattering (exact direct SHT; FastSphericalHarmonics fast path) | spherical_scattering (exact direct SHT; NUFSHT fast path) |
Every cell has an in-core, dependency-free default (direct summation), with an optional fast path selected by the transform keyword, which takes a SpectralBackends.jl tag. DirectSumSpectralBackend is the in-core default everywhere; the fast paths are FFTSpectralBackend (FFTW) on a grid, FlowTransformBindings.jl's NonuniformFFTsBackend() or FINUFFTBackend() for scattered points, NUFSHTSpectralBackend (NUFSHT) for the scattered sphere, and FSHTSpectralBackend (FastSphericalHarmonics) for the structured sphere. AutoSpectralBackend (the default) picks the fast path if its extension is loaded, else the direct sum — so nothing requires an external library. Naming a backend explicitly is honoured exactly: if its extension is absent it throws.
Monogenic variants support gridded Cartesian fields and both spherical samplings. spherical_monogenic_components accepts scattered and structured spherical transforms.
Transforms
All transform objects subtype ScatteringCore.AbstractScatteringTransform and are callable as st(field). Both Cartesian families carry spatial rank as ScatteringTransform{D,…} and MonogenicScatteringTransform{D,…}. D = 1, 2, 3 selects a signal, image or volume.
ScatteringTransforms.ScatteringCore.AbstractScatteringTransform — Type
AbstractScatteringTransformPrepared scattering transform whose call st(field) returns scattering coefficients.
ScatteringTransforms.ScatteringCore.ScatteringTransform — Type
ScatteringTransform{D}
ScatteringTransform([T=Float64,] dims, J; kwargs...)Regular Cartesian scattering transform with D spatial axes, a wavelet bank and reusable buffers. The rank of the dims tuple selects the 1D, 2D or 3D wavelet builder; an integer selects 1D.
ScatteringTransforms.Scattering1D.scattering_transform! — Function
scattering_transform!(coeffs, st, signal; execution = SerialBackend()) -> coeffs′Fill coeffs.S1/coeffs.S2 and return the coefficients with S0 set by Coefficients.update_S0, which allocates a new container only when S0 is a scalar.
execution is where the cascade runs: SerialBackend in this task; ThreadedBackend (OhMyThreads extension) runs the first-order wavelet groups as parallel tasks after one serial input transform.
ScatteringTransforms.Scattering2D.scattering_transform2d! — Function
scattering_transform2d!(coeffs, st, image; execution = SerialBackend()) -> coeffs′Fill coeffs.S1/coeffs.S2 and return the coefficients with S0 set by Coefficients.update_S0.
execution is where the cascade runs: SerialBackend in this task; ThreadedBackend (OhMyThreads extension) runs the first-order wavelet groups as parallel tasks.
ScatteringTransforms.Scattering3D.scattering_transform3d! — Function
scattering_transform3d!(coeffs, st, volume; execution = SerialBackend()) -> coeffsIn-place 3D volumetric scattering transform; fills coeffs (a scales×orientations container) and returns it with S0 updated. execution is as for Scattering2D.scattering_transform2d!.
ScatteringTransforms.ScatteringCore.scattering — Function
scattering(st, x) -> coefficient containerThe coefficients of st(x), computed without mutation so the forward map can be differentiated (as synthesize does) and takes any element type, such as ForwardDiff.Dual.
Every intermediate comes from the non-mutating Plans.forward_transform and Plans.inverse_transform and broadcasts, so each call allocates; st(x) is the in-place forward pass. Methods are defined for the 1D, 2D and 3D transforms.
ScatteringTransforms.scattered_planar_scattering — Function
scattered_planar_scattering([T=Float64,] x, y, ms, J; period, origin=(0, 0), L=8, max_order=2,
transform=SpectralBackends.AutoSpectralBackend(),
analysis=Plans.WeightedAdjoint(), weights=nothing, tol=nothing,
maxiter=100, rtol=Plans.default_solver_rtol(T, transform, tol), damp=0,
ntrans=1, nthreads=0, filters=StoredFilters(), oversampling=J)
scattered_planar_scattering([T,] grid, ms, J; kwargs...)Build a 2D planar scattering transform for a scalar field sampled at scattered points (x, y). A nonuniform DFT analyses the samples onto a uniform Fourier mode grid of size ms = (m1, m2), and the cascade of the gridded ScatteringCore.ScatteringTransform{2}, with its oriented Morlet bank and oversampling, runs on that grid: each coefficient is the domain mean of a modulus of the field the analysis recovers. Apply it to a length-M vector of samples.
period is the length of the domain the points sample along each axis and origin its lower corner (a number for both axes, or a 2-tuple): mode k has wavelength period/k, so the wavelets' physical scales are those of the domain, and point sets drawn from one domain share them. Points 0:m-1 with period = m are the nodes of the length-m DFT. With FlowGeometries loaded, a 2-D Cartesian FlowGeometries.Grids grid stands in for the points: its active cells are the points, its periodic axes supply their periods, bounded axes their extents plus the coarsest wavelet width, the lowest cell centre supplies the origin, and cell measures supply default weights.
transform names the nonuniform transform: SpectralBackends.DirectSumSpectralBackend is the in-core, dependency-free exact NUDFT (always available, O(M·prod(ms))); FlowTransformBindings.NonuniformFFTsBackend() and FlowTransformBindings.FINUFFTBackend() select a nonuniform-FFT library (using NonuniformFFTs / using FINUFFT); and SpectralBackends.AutoSpectralBackend (the default) takes NonuniformFFTs when it is loaded, FINUFFT when only it is, and the direct sum otherwise. analysis=Plans.WeightedAdjoint() takes the adjoint weighted by weights, the quadrature of each Fourier coefficient's domain integral: exact on the nodes of the DFT, an estimate elsewhere. analysis=Plans.LeastSquares() fits the band-limited coefficients by least squares (slower, for irregular sampling). weights (length M, normalized to sum to 1) are uniform by default; S0 is the mean of the analysed field. tol is the NUFFT tolerance (ignored by the exact direct sum). ntrans = B builds a transform that runs B fields per call through one execution per cascade step (see scattering_batch). filters = FilterBanks.ComputedFilters() evaluates the wavelets on demand.
The solve is LSMR (FlowTransformBindings.lsmr!), which costs one type-2 and one type-1 per iteration and keeps both ‖b - Af‖ and ‖A†(b - Af)‖ monotone, so stopping at maxiter returns the best iterate reached. rtol targets ‖A†(b - Af)‖ ≤ rtol ‖A†b‖ and defaults to the accuracy of the transform under it: sqrt(eps(T)) for the exact direct sum and at least 10·tol for a fast library, whose type-1 and type-2 are adjoints only to its own tolerance (Plans.default_solver_rtol). damp is a Tikhonov λ minimising ‖Af - b‖² + λ²‖f‖², 0 by default; with prod(ms) > M the problem is underdetermined, construction warns, and LSMR returns the minimum-norm solution unless a λ is given.
The Krylov process terminates within prod(ms) steps, and maxiter caps it earlier. A truncated solve returns the best iterate reached but is reproducible only to the accuracy of the transform under it: a multi-threaded NUFFT accumulates its spreading in a run-dependent order, which an unconverged solve amplifies by about cond(A)². Raise maxiter until the solve converges for an answer independent of the thread count, or set nthreads = 1 for bitwise-identical repeats.
nthreads is the fast library's own thread count, honoured by every copy of the plan, including the per-task copies a threaded backend builds. 0 (the default) takes Threads.nthreads() on a serial backend and gives each per-task copy one thread. 1 keeps the library single-threaded everywhere, and its plan executes without allocating; a multi-threaded FFTW plan runs its parallel loop on Julia tasks.
ScatteringTransforms.spherical_scattering — Function
spherical_scattering(pts_theta, pts_phi, lmax, J; max_order=2,
transform=SpectralBackends.AutoSpectralBackend(), analysis=Plans.LeastSquares(),
rtol=SphericalCore.default_rtol(transform), maxiter=500, weights=nothing,
ntrans=1, nufft=SpectralBackends.AutoSpectralBackend(), grid_lmax=2lmax)Build a spherical scattering transform for a scalar field at scattered points (θ, φ) on S², using smooth difference-of-Gaussians band-pass wavelets. transform names the spherical-harmonic transform: SpectralBackends.DirectSumSpectralBackend is the in-core, dependency-free exact least-squares transform (always available, O(M·(lmax+1)²)); SpectralBackends.NUFSHTSpectralBackend uses the NUFSHT fast path (needs using NUFSHT); SpectralBackends.AutoSpectralBackend (the default) picks NUFSHT if its extension is loaded, else the direct transform. Accurate analysis needs the sampling to resolve the band limit, i.e. roughly M ≳ (lmax+1)² well-distributed points.
The samples are analysed once, onto the harmonics of degree ≤ lmax. Every band, modulus, mean and second analysis after that runs on the Gauss–Legendre grid of band limit grid_lmax (SphericalCore.gauss_legendre_grid): each coefficient is the spherical mean of a modulus of the field the analysis recovers, and S0 is that field's mean. A modulus is not band limited, and the grid's analysis of it onto degree ≤ lmax is exact for its content up to degree 2grid_lmax + 1 − lmax.
analysis = Plans.LeastSquares() fits by LSMR, configured by rtol and maxiter, and returns its best iterate at a stopping limit. Plans.WeightedAdjoint() takes the adjoint weighted by weights: the expansion of a degree-lmax field where the weights integrate the product of two degree-lmax harmonics exactly, and an approximation elsewhere. weights (length M, normalized to sum to 1) are the quadrature of that adjoint and the weights of the fit, uniform by default. ntrans = B builds a plan that transforms B co-located fields per call. nufft names the NUFFT library NUFSHT runs on; the in-core plan runs none and accepts only an Auto nufft.
ScatteringTransforms.structured_spherical_scattering — Function
structured_spherical_scattering([T=Float64,] lmax, J; max_order=2,
transform=SpectralBackends.AutoSpectralBackend(),
band_headroom=nothing, rtol=1e-8, maxiter=500)Build a spherical scattering transform for a scalar field sampled on the structured equiangular grid (Nθ = lmax+1 colatitudes, Nφ = 2lmax+1 longitudes), using the same smooth difference-of-Gaussians band-pass wavelets as spherical_scattering. Apply it to a (Nθ, Nφ) grid of samples; obtain the grid points with structured_sphere_points. transform names the spherical-harmonic transform: SpectralBackends.DirectSumSpectralBackend (in-core, dependency-free), or SpectralBackends.FSHTSpectralBackend (the fast exact SHT, needs using FastSphericalHarmonics); SpectralBackends.AutoSpectralBackend picks the fast path if its extension is loaded, else the direct SHT.
On a backend that can narrow its band limit (FastSphericalHarmonics), a finite band_headroom synthesises band j at band limit band_headroom·ℓ_j, discarding the tail SphericalCore.band_lmax describes; the default nothing runs the full-band-limit cascade bit for bit. rtol and maxiter configure the in-core plan's analysis solve.
ScatteringTransforms.structured_sphere_points — Function
structured_sphere_points(lmax) -> (Θ, Φ)Colatitudes Θ (length lmax+1) and longitudes Φ (length 2lmax+1) of the equiangular structured grid used by structured_spherical_scattering; sample a field as [f(θ, φ) for θ in Θ, φ in Φ]. In-core (no dependency); matches FastSphericalHarmonics.sph_points.
Reconstruction & synthesis
ScatteringTransforms.Inverse.ReconstructionWorkspace — Type
ReconstructionWorkspace(st)Scratch for the linear wavelet inverse and for phase retrieval: the complex wavelet coefficient fields (nw of them), the low-pass field, a spectrum accumulator, and the bank's Littlewood–Paley sum frame. Every filter's Fourier response is real, so the dual filters are ψ̂_λ/A and φ̂/A.
ScatteringTransforms.Inverse.wavelet_transform! — Function
wavelet_transform(st, x) -> (; wavelet, lowpass)
wavelet_transform!(ws, st, x) -> (; wavelet, lowpass)The linear (pre-modulus) wavelet layer underlying the scattering transform: the complex wavelet coefficient fields wavelet[λ] = x ⋆ ψ_λ and the low-pass field lowpass = x ⋆ φ, which together determine x exactly (see iwavelet!). The ! form returns arrays owned by ws.
ScatteringTransforms.Inverse.iwavelet! — Function
iwavelet(st, wavelet, lowpass) -> x
iwavelet(st, wt) -> x
iwavelet!(ws, st, wavelet, lowpass) -> xInverse of wavelet_transform! for a real field by the canonical dual frame, x = Re F⁻¹[(φ̂·Ŷ + Σ_λ ψ̂_λ·Ŵ_λ) / A] with A the bank's Littlewood–Paley sum: the real part takes C(k) to (C(k) + conj C(−k))/2, which turns C = (φ̂² + Σ_λ ψ̂_λ²)·x̂ into A·x̂. Returns the reconstructed real field; iwavelet(st, wavelet_transform(st, x)) ≈ x to rounding.
ScatteringTransforms.Inverse.reconstruct_phase — Function
reconstruct_phase(st, moduli; iters=200, init=nothing, seed_lowpass=nothing) -> xPhase retrieval from the first-order moduli moduli[λ] = |x ⋆ ψ_λ| (the real fields the scattering transform averages), via Gerchberg–Saxton alternating projections:
- take the linear wavelet transform of the current estimate;
- re-impose the target magnitudes on each band-pass channel (keeping the recovered phase);
- reconstruct with the exact frame inverse
iwavelet!; repeat.
The low-pass channel carries no magnitude target, so it is taken from the current estimate each iteration (or from seed_lowpass if supplied). The reconstruction is determined only up to a global sign/phase. init (defaults to a random field matched in energy to the moduli) seeds the estimate; pass one for reproducibility. Returns the real reconstructed field, on the array type of the transform's filters. The loop reuses one workspace.
ScatteringTransforms.synthesize — Function
synthesize(st, target; backend, init=nothing, iters=500, lr=0.05, loss=scattering_loss) -> (; field, losses)Reconstruct a field whose scattering coefficients match target by gradient descent (Bruna & Mallat microcanonical synthesis): starting from init (random by default), minimize loss(scattering(st, x̂), target) with Adam. target may be a precomputed coefficient container or a field (its coefficients are taken first). The gradient is obtained through DifferentiationInterface, so backend is any ADTypes backend. The modulus discards local phase, so the result is a sample with matching statistics and the original is not recovered. Requires using DifferentiationInterface and an AD backend package.
With Enzyme, pass AutoEnzyme(; mode = Enzyme.set_runtime_activity(Enzyme.Reverse)): the cascade's closures capture constant filters alongside the active input, which Enzyme's static activity analysis cannot separate, and a plain AutoEnzyme() raises EnzymeRuntimeActivityError.
ScatteringTransforms.scattering_loss — Function
scattering_loss(c, target) -> RealDefault synthesize objective: the normalized squared error between the coefficient container c and the target, summed over the first- and (when present) second-order coefficients, ‖S₁(c)−S₁(t)‖² + ‖S₂(c)−S₂(t)‖² divided by the target energy. Differentiable in c, so it composes with scattering(st, ·) under autodiff.
Monogenic (Riesz) scattering
ScatteringTransforms.Monogenic.MonogenicScatteringTransform — Type
MonogenicScatteringTransform{D}Monogenic scattering transform on a D-dimensional grid: an isotropic MonogenicFilterBank, the scattering path tree (strictly-increasing scale), a spectral plan, and the periodized MonogenicWorkspace the cascade runs in.
D is the number of spatial axes in dims.
ScatteringTransforms.Monogenic.MonogenicFilterBank — Type
MonogenicFilterBank{D,T,A,W,R,MV}Isotropic band-pass wavelets wavelets (one per scale/sub-octave), the D scale-free Riesz multipliers riesz, and the Gaussian low-pass averaging. The wavelets and the low-pass are real functions of |k|; only the Riesz multipliers are complex.
ScatteringTransforms.Monogenic.ComputedMonogenicFilterBank — Type
ComputedMonogenicFilterBank{D,T,A,R,MV,PV}The monogenic bank with its radial band-passes evaluated on demand into one scratch array, as in FilterBanks.ComputedFilterBank2D. The D Riesz multipliers are stored.
ScatteringTransforms.Monogenic.MonogenicWorkspace — Type
MonogenicWorkspace{T,D}The periodized cascade plus what the monogenic amplitude needs on top of it: one real accumulator per resolution, and the Riesz-weighted band-passes R_d ψ_j periodized to each parent resolution.
Each R_d ψ_j is stored as the periodization of the product, which differs from the product of the periodized factors. Level 1 stores none: the two full-resolution filters fuse in ScatteringCore.periodize_mul2!.
ScatteringTransforms.Monogenic.build_monogenic_bank — Function
build_monogenic_bank([T=Float64,] dims::NTuple{D,Int}, J; Q=1) -> MonogenicFilterBankBuild a D-dimensional isotropic Morlet-style monogenic filter bank: J octaves × Q sub-octaves of radial band-pass wavelets whose radial profile is Filters.Morlet1D's (center frequency ξ_j = ξ₀·2^{-j/Q}, adjacent wavelets crossing at √½ of their peak), the Riesz multipliers, and Filters.gaussian_lowpass!. The band-pass and its Riesz components carry 2|ψ̂_j|² per frequency, so the wavelets are scaled by c = lp_scale_1d(Q)/2, which puts 2c² Σ_j g(|k|·2^{j/Q})² (g the radial profile) at a maximum of 1 over the bank continued over every scale.
ScatteringTransforms.Monogenic.riesz_multipliers — Function
riesz_multipliers(dims, ::Type{T}=Float64) -> NTuple{D, Array{Complex{T},D}}The D Riesz-transform frequency multipliers R_d(k) = -i k_d/|k| over a grid of size dims, with R_d(0) = 0. On an even axis d the Nyquist bin holds k_d = ±½ at once, and there R_d is the mean of its two values, 0, so a real field's Riesz components are real. Scale-free, so one set serves every wavelet scale; Σ_d |R_d(k)|² = 1 off the DC bin and the Nyquist planes.
ScatteringTransforms.Monogenic.monogenic_amplitude — Function
monogenic_amplitude(m0, riesz_components) -> AMonogenic amplitude A = √(m₀² + Σ_d m_d²) from the band-pass field m0 and the tuple/vector of Riesz component fields. Broadcast, so it is CPU/GPU/autodiff-generic.
ScatteringTransforms.Monogenic.monogenic_components — Function
monogenic_components(st, x, j) -> (; bandpass, riesz, amplitude, phase)The monogenic decomposition of a real field x band-passed by isotropic wavelet j (1-based): the band-pass field bandpass = x ⋆ ψ_j, the D Riesz component fields riesz, the monogenic amplitude √(bandpass² + Σ|riesz|²), and the local monogenic phase = atan(‖riesz‖, bandpass). The Riesz vector's direction gives the local orientation (e.g. atan(riesz[2], riesz[1]) in 2D).
ScatteringTransforms.Monogenic.monogenic_scattering! — Function
monogenic_scattering!(coeffs, st, x) -> coeffsWrite the averaged monogenic coefficients of x into coeffs.
ScatteringTransforms.spherical_monogenic_scattering — Function
spherical_monogenic_scattering(pts_theta, pts_phi, lmax, J; max_order=2,
transform=SpectralBackends.AutoSpectralBackend(), analysis=Plans.LeastSquares(),
rtol=SphericalCore.default_rtol(transform), maxiter=500,
weights=nothing, nufft=SpectralBackends.AutoSpectralBackend(),
grid_lmax=2lmax)Build a monogenic spherical scattering transform for a scalar field at scattered points (θ, φ) on S². The nonlinearity is the spherical monogenic amplitude A_j = √(U⁰_j² + |U^R_j|²), where U⁰_j is the difference-of-Gaussians band-pass and U^R_j is the spin-1 Riesz field R = ð∘(−Δ_S)^{-1/2}. The Riesz energy |U^R_j|² = |∇_S g_j|² (with g_j = (−Δ_S)^{-1/2} U⁰_j) is synthesised exactly from g_j's coefficients (SphericalCore.sphere_riesz_energy!). The cascade runs on the Gauss–Legendre grid and the keywords are as in spherical_scattering.
ScatteringTransforms.spherical_monogenic_components — Function
spherical_monogenic_components(st, field, j) -> (; bandpass, riesz, amplitude, phase, orientation)Pointwise spherical monogenic decomposition of field band-passed at scale j — the S² analogue of the planar monogenic_components. Returns the band-pass field bandpass = U⁰_j, the spin-1 Riesz tangent vector riesz = (u_θ, u_φ) (U^R_j = ð∘(−Δ_S)^{-1/2} U⁰_j), the monogenic amplitude √(U⁰² + ‖U^R‖²), the phase = atan(‖U^R‖, U⁰), and the local orientation = atan(u_φ, u_θ) of the Riesz vector. st is a scattered or structured spherical monogenic transform. With the in-core direct SH plan (dependency-free) the Riesz field is synthesized as the surface gradient of g = (−Δ_S)^{-1/2}U⁰; with a NUFSHT-backed plan it uses spin-weighted synthesis — the two agree to solver accuracy.
ScatteringTransforms.structured_spherical_monogenic_scattering — Function
structured_spherical_monogenic_scattering([T=Float64,] lmax, J; max_order=2,
transform=SpectralBackends.AutoSpectralBackend(),
rtol=1e-8, maxiter=500)Structured-grid counterpart of spherical_monogenic_scattering. transform names the SH transform as in structured_spherical_scattering (dependency-free direct SHT by default, fast exact SHT with using FastSphericalHarmonics).
Localized (Mallat) field
ScatteringTransforms.ScatteringFields.scattering_field — Function
scattering_field(st, x; subsample) -> ScatteringField{1,2,3}DLocalized (Mallat) scattering transform: returns the per-path low-passed, subsampled fields. Methods are added by the per-dimension transform modules.
ScatteringTransforms.ScatteringFields.scattering_field! — Function
scattering_field!(field, st, x) -> fieldIn-place localized scattering transform into a pre-allocated ScatteringField.
ScatteringTransforms.ScatteringFields.ScatteringField1D — Type
ScatteringField1D{T,A,Tree,WS}Localized 1D scattering field. data is (M, npaths); column p is the localized field of path p at the subsampled resolution M = N ÷ s. ws is the Cascade.FieldWorkspace that fills it.
ScatteringTransforms.ScatteringFields.ScatteringField2D — Type
ScatteringField2D{T,A,Tree,WS}Localized 2D scattering field. data is (My, Mx, npaths); slice [:, :, p] is the localized field of path p at subsampled resolution (My, Mx) = (Ny, Nx) ÷ s.
ScatteringTransforms.ScatteringFields.ScatteringField3D — Type
ScatteringField3DLocalized volumetric scattering with data shaped (Mz, My, Mx, npaths).
ScatteringTransforms.ScatteringFields.path_field — Function
path_field(sf, p) -> viewView of path p's localized field, with the transform's spatial rank.
ScatteringTransforms.ScatteringFields.subsample_factor — Function
subsample_factor(sf) -> IntThe decimation factor s applied to produce the field resolution.
Coefficients & reductions
ScatteringTransforms.Coefficients.ScatteringCoefficients1D — Type
ScatteringCoefficients1D{T,V,M,S0}Immutable container for 1D scattering coefficients. S0 is either a scalar, which update_S0 replaces by returning a new container, or a 1-element array, which it writes in place.
Type Parameters
T: Element typeV: 1D array typeM: 2D array typeS0: S0 storage type (T for scalar, AbstractVector{T} for mutable)
ScatteringTransforms.Coefficients.ScatteringCoefficients2D — Type
ScatteringCoefficients2D{T,V,M,S0}Immutable container for scales × orientations scattering coefficients (2D, 3D and scattered planar). S0 is a scalar or a 1-element array, as in ScatteringCoefficients1D.
ScatteringTransforms.Coefficients.zeroth_order — Function
zeroth_order(c) -> NumberThe zeroth-order coefficient S0, the field mean, which is complex for a complex field.
ScatteringTransforms.Coefficients.first_order — Function
first_order(c) -> AbstractVectorExtract the first-order (S1) scattering coefficients.
ScatteringTransforms.Coefficients.second_order — Function
second_order(c) -> AbstractMatrixExtract the second-order (S2) scattering coefficients.
ScatteringTransforms.Coefficients.flatten1d — Function
flatten1d(coeffs::ScatteringCoefficients1D) -> AbstractVectorFlatten to [S0; S1; S2 upper triangle], keeping only the S2 entries with j2 > j1, in an array of element type flat_eltype.
ScatteringTransforms.Coefficients.flatten2d — Function
flatten2d(coeffs::ScatteringCoefficients2D) -> AbstractVectorFlatten to [S0; S1; S2 upper triangle], as flatten1d does.
ScatteringTransforms.Coefficients.flatten1d! — Function
flatten1d!(out, c) -> outZero-allocation flatten into a pre-allocated vector of length flatten_length(c).
ScatteringTransforms.Coefficients.flatten2d! — Function
flatten2d!(out, c) -> outZero-allocation flatten into a pre-allocated vector of length flatten_length(c).
ScatteringTransforms.Coefficients.flatten_length — Function
flatten_length(c) -> IntLength of the flattened coefficient vector [S0; S1; vec(S2 upper triangle)].
ScatteringTransforms.Coefficients.flat_length — Function
flat_length(n) -> Int
flat_row_s0() -> Int
flat_row_s1(j, n) -> Int
flat_row_s2(j1, j2, n) -> IntRow layout of the flattened coefficient vector [S0; S1; vec(S2 upper triangle)] for n wavelets, as produced by flatten1d!/flatten2d!. The S2 rows are present, zero, for coefficients that hold no S2.
The batched paths write flattened columns through these accessors, so they must match the order the flatten*! loops write.
ScatteringTransforms.Coefficients.flat_eltype — Function
flat_eltype(c) -> TypeElement type a flattened column of c needs.
S1 and S2 are moduli and stay real whatever the input is, but S0 is the field mean and is complex for a complex field, so the flat layout is as wide as the two together.
ScatteringTransforms.Coefficients.update_S0 — Function
update_S0(c, val) -> c′The coefficients c with S0 = val. A 1-element-array S0 is written in place and c returned; a scalar S0 gives a new container sharing c's S1 and S2.
ScatteringTransforms.Scattering2D.compute_shape_sparsity — Function
compute_shape_sparsity(S1, S2, meta) -> (; sparsity, shape)Reduced second-order descriptors (in the spirit of the reduced wavelet scattering transform, Allys et al. 2019; Cheng & Ménard 2021), as J × J matrices over scale pairs (j1, j2) with j2 > j1:
sparsity(s₂₁): the orientation-averaged ratio⟨S₂ / S₁⟩— how much energy cascades from scalej1to the coarser scalej2(large for sparse/intermittent fields).shape(s₂₂): the anisotropy of the cascade — the normalized second angular harmonic⟨S₂ · cos(2 Δθ)⟩ / ⟨S₂⟩over orientation pairs, whereΔθ = θ₂ − θ₁. It is≈ 0for statistically isotropic fields and departs from zero when the field has oriented structure.
ScatteringTransforms.Reductions.normalized_coefficients — Function
normalized_coefficients(c) -> (; S0, s1, s2)Amplitude-normalized coefficients: s1[j] = S1[j]/S0 and s2[j1,j2] = S2[j1,j2]/S1[j1] (zero where S1[j1] == 0).
ScatteringTransforms.Reductions.log_coefficients — Function
log_coefficients(c; pad=eps) -> (; S0, logS1, logS2)Log-coefficients log(S1 + pad), log(S2 + pad) (the small pad keeps structural zeros finite). Useful to gaussianize the heavy-tailed coefficients of intermittent fields.
flat_length's docstring also covers the row accessors flat_row_s0, flat_row_s1 and flat_row_s2, which are the layout flatten1d!, flatten2d! and the batched paths all walk.
Batching & backends
Where a transform runs is chosen with a backend from ComputationalBackends.jl — SerialBackend, ThreadedBackend, GPUBackend, DistributedBackend, MPIBackend, AutoBackend — passed as execution= to scattering_batch and scattering_batch!; the gridded scattering_transform! entries take SerialBackend or ThreadedBackend the same way. Which spectral algorithm it uses is chosen with a SpectralBackends.jl tag passed as transform= at construction. Each is honoured exactly: naming a backend whose extension is not loaded throws.
ScatteringTransforms.scattering_batch — Function
scattering_batch(st::ScatteringCore.ScatteringTransform{1}, X; execution = SerialBackend()) -> MatrixApply a 1D scattering transform to a batch of signals X of size (N, B) (signals as columns), returning a (flatten_length, B) matrix whose column b is flatten1d(st(X[:, b])). The plan, the workspace and one coefficient container are reused across the batch. execution is where the batch runs, as in scattering_batch!.
scattering_batch(st::ScatteringCore.ScatteringTransform{2}, X; execution = SerialBackend()) -> MatrixApply a 2D scattering transform to a batch of images X of size (Ny, Nx, B), returning a (flatten_length, B) matrix whose column b is flatten2d(st(X[:, :, b])). Plan and workspace are reused across the batch. execution is as in scattering_batch!.
scattering_batch(st::ScatteringCore.ScatteringTransform{3}, X; execution = SerialBackend()) -> MatrixApply a 3D scattering transform to a batch of volumes X of size (Nz, Ny, Nx, B), returning a (flatten_length, B) matrix. Plan and workspace are reused across the batch. execution is as in scattering_batch!.
scattering_batch(st::ScatteredPlanar.ScatteredPlanarScatteringTransform, X; execution = SerialBackend())
-> Matrix or (; coefficients, fit)Transform every slice of X against one transform, returning a (flatten_length, B) matrix. X is (M, B), where M is the plan's point count. A transform built with ntrans = W > 1 runs the columns W at a time, through one execution per cascade step for each group, the last group padded with zero columns. Under analysis = Plans.LeastSquares() the matrix comes with fit, one FlowTransformBindings.SolverResult per field. execution is as in scattering_batch!.
scattering_batch(st::SphericalCore.SphericalScatteringTransform, X; execution = SerialBackend())
-> Matrix or (; coefficients, fit)
scattering_batch(st::SphericalCore.SphericalMonogenicScatteringTransform, X; execution = SerialBackend())
-> Matrix or (; coefficients, fit)Transform a stack of B fields sampled by the same spherical plan — X of size (field_size…, B), so (M, B) for a scattered point set and (nθ, nφ, B) on a structured grid. A plan whose analysis is a least-squares fit gives the matrix with fit, one FlowTransformBindings.SolverResult per field. execution is as in scattering_batch!.
Rows follow Coefficients.flat_length. Scales are finest-first and second-order pairs satisfy j2 > j1, with row flat_row_s2(j1, j2, J).
ScatteringTransforms.scattering_batch! — Function
scattering_batch!(out, st, X; execution = SerialBackend(), workspace = nothing) -> out or (; coefficients, fit)In-place counterpart of scattering_batch: write the flattened coefficients of each slice of X into the preallocated (flatten_length, B) matrix out. A transform whose analysis of its samples is a least-squares fit returns (; coefficients = out, fit), fit[b] field b's FlowTransformBindings.SolverResult as its single call reports it.
execution is where the batch runs: SerialBackend in this task, ThreadedBackend and GPUBackend through their extensions (OhMyThreads; KernelAbstractions, for the gridded transforms), and AutoBackend as Execution.resolve_backend resolves it. DistributedBackend and MPIBackend gather a new matrix, so they run through scattering_batch alone. A backend whose extension is not loaded throws.
On SerialBackend a gridded transform runs one slice at a time against its own single-slice plan, which on a CPU keeps each slice's working set in cache. Passing a batch_workspace runs the whole stack through one batched plan (Batched.batch_cascade!), as the GPU extension does.
ScatteringTransforms.batch_coeffs — Function
batch_coeffs(st, T, S0T = T) -> coefficient containerA coefficient container for st whose S0 is a 1-element array, so a loop over a batch writes every field in place.
T is the element type of S1/S2, which are moduli; S0T is that of S0, the field mean, which is complex for a complex field.
ScatteringTransforms.flat_rows — Function
flat_rows(st) -> IntRows a flattened coefficient column of st occupies — the height of scattering_batch's output.
ScatteringTransforms.batch_workspace — Function
batch_workspace(st, B; transform = nothing, fft_nthreads = 1, kwargs...) -> Batched.BatchWorkspaceBuild the batched workspace for transform st at batch size B: a spectral plan over the whole (spatial…, B) stack plus the scratch Batched.batch_cascade! runs in, on the array type of st's own buffers. Build it once and pass it as workspace to scattering_batch! for every stack of B slices.
The stack's plan is of the kind st.plan is (Plans.plan_like), so a device-resident st gets a device workspace; a SpectralBackends tag as transform builds a host plan of that kind. fft_nthreads is the FFT library's own thread count, fixed in the plan; leave it at 1 when the batch or wavelet axis is already threaded. kwargs go to the plan builder.
ScatteringTransforms.Batched.BatchWorkspace — Type
BatchWorkspaceA spectral batch workspace with real-input staging and a full-resolution input spectrum.
ScatteringTransforms.Batched.SpectralBatchWorkspace — Type
SpectralBatchWorkspace{T,D}Periodized cascade buffers and per-field reductions for a stack of spectra.
red has shape (1…, B); invN[l] normalizes the mean at resolution l.
ScatteringTransforms.Batched.batch_cascade! — Function
batch_cascade!(out, ws, X) -> outWrite the flattened scattering coefficients of every slice of X into the columns of out, which has Coefficients.flat_length(n) rows in the layout flatten1d!/flatten2d! produce. A complex X needs complex columns, for its complex S0.
The batched form of Cascade.cascade!, with each mean replaced by a per-slice reduction and each decimation tuple extended by a 1 for the stack axis.
ScatteringTransforms.close_transform! — Function
close_transform!(st) -> nothingPlans.close_plan! every spectral plan st owns. st must not be in use by any task, and is not usable after.
The periodized cascade
Each wavelet's output is produced directly on the grid its band needs, decimated by r = 2^max(j-oversampling, 0) per axis. Exact at oversampling ≥ J, which reproduces the undecimated cascade bit for bit; below that it trades accuracy for speed.
ScatteringTransforms.Cascade.decimation — Function
decimation(N, scale, α) -> NTuple{D,Int}Per-axis decimation for a wavelet of octave scale: 2^max(scale-α, 0), reduced on each axis to the largest power of two that divides N[d]. The clamp only reduces decimation, so any N is accepted at no cost in accuracy.
ScatteringTransforms.Cascade.PeriodizedWorkspace — Type
PeriodizedWorkspace{T,D}Everything the cascade runs in: one working array and one spectrum array per live decimation, the spectral plan at each of those sizes, and the filters periodized to each resolution they are applied at.
Everything per-resolution is a vector indexed by level, with level[j] the level of wavelet j and level 1 the full grid. out[l] === work[l] when the plan inverts in place. spec[l] is empty except at levels that are a parent, where it holds Û₁ across that wavelet's children. D is the spatial rank of the resolutions; a batched workspace's arrays carry a trailing stack axis on top of it. means is a DeviceMeans on a device-resident workspace and nothing otherwise.
ScatteringTransforms.Cascade.DeviceMeans — Type
DeviceMeans{R,V,M,H}The per-path sums of a single-field cascade on device arrays, accumulated on the device so that the cascade synchronises with the host once, after its last path: red is a (1, …, 1) reduction target, s1 holds one sum per wavelet and s2 one per (j1, j2) pair, and invlen[j] is one over the size of the grid wavelet j is produced on, which turns a sum into a mean.
ScatteringTransforms.Cascade.gather_means! — Function
gather_means!(S1, S2, means) -> nothingThe sums a cascade kept on the device, as means in the host arrays S1 and S2; nothing to do without means.
ScatteringTransforms.Cascade.build — Function
build(fb, groups, dims, T, α, plan) -> PeriodizedWorkspacegroups is the cascade work list (j1, children, pathids); it determines which resolutions are live and which (wavelet, resolution) filter pairs are ever applied, so nothing unused is built. plan is the transform's full-grid plan and serves as level 1; the coarser levels are planned with its spectral backend.
ScatteringTransforms.Cascade.cascade! — Function
cascade!(S1, S2, ws, fb, groups, xfft) -> (S1, S2)Both scattering orders in one grouped pass, each convolution produced directly on the grid its wavelet's band needs.
Order 1 multiplies by the full-resolution filter and periodizes the product. Order 2 multiplies Û₁ by ψ_{j₂} periodized to the parent's grid, then periodizes the product onto the child's; r₂ ≥ r₁, since admissibility makes the child strictly coarser.
ScatteringTransforms.Cascade.group! — Function
group!(S1, S2, ws, fb, g, xfft) -> nothingOne first-order wavelet and all of its children. Group j1 writes only S1[j1] and S2[j1, :], so tasks may run distinct groups concurrently, each with its own task_copy of the workspace. The caller clears S2.
ScatteringTransforms.Cascade.scattering_values — Function
scattering_values(st, x) -> (S0, S1, S2)The same periodized cascade as cascade!, written with allocating transforms and broadcasts so that reverse-mode backends can differentiate it. Dimension-generic; the per-dimension scattering methods wrap the result in their coefficient container.
It must compute the same function as st(x), decimation included: synthesize differentiates this to match coefficients read from st(x).
ScatteringTransforms.Cascade.task_copy — Function
task_copy(ws, fb) -> ws′A workspace usable concurrently with ws: fresh buffers and task-local plans, sharing the read-only periodized filters. Every task that runs group! needs its own.
fb is the bank the copy runs against. For a computed bank it must be the task's own FilterBanks.task_bank, whose scratch the copy's level-1 filters alias.
ScatteringTransforms.Cascade.with_plans — Function
with_plans(f, ws) -> ws′ws with every plan replaced by f(plan), sharing all buffers and filters, for instrumenting or retargeting a cascade's transforms. f must preserve Plans.inplace_inverse, since the out/work aliasing follows it.
ScatteringTransforms.Cascade.FieldWorkspace — Type
FieldWorkspace{T,D}The periodized cascade plus what the localized transform S_p = (|U_p| ⋆ φ_J) ↓ s needs on top of it: φ_J periodized to every level a modulus is produced at, and one buffer and plan at the output resolution.
Its cascade is built with alias_out = false and decimates no wavelet past s (see field_oversampling), so every path is produced at or above the output resolution. At the default s = 2^(J-1) the cap changes nothing.
ScatteringTransforms.Cascade.build_field — Function
build_field(fb, groups, dims, T, α, s, φ; alloc, makeplan) -> FieldWorkspaceWorkspace for the localized transform at output subsample factor s. φ is the full-resolution low-pass.
ScatteringTransforms.Cascade.field_workspace — Function
field_workspace(st, subsample) -> FieldWorkspaceThe localized-field workspace for transform st at output factor subsample.
st must have fields filter_bank, groups, dims, plan, buffer_input and pw. Buffers take buffer_input's array type and plans plan's kind, so a device-resident transform gets a device-resident workspace.
ScatteringTransforms.Cascade.field_oversampling — Function
field_oversampling(fb, α, s) -> IntThe smallest oversampling at least α under which no wavelet decimates past s.
r = 2^max(j-α, 0) ≤ s = 2^q iff α ≥ j - q, so raising α to maxscale - q caps every resolution at the output grid without changing the dyadic family any wavelet lands on.
ScatteringTransforms.Cascade.localize! — Function
localize!(dst, fw, spec, level) -> dstdst = real(ifft(spec ⋅ φ̂) ↓ (rout/r)), where spec is the spectrum of a modulus living at level. The product is periodized onto the output grid, so the inverse runs at output size.
ScatteringTransforms.Cascade.field_group! — Function
field_group!(data, fw, fb, g, xfft, p1_first) -> nothingOne first-order wavelet and all of its children, written as localized fields into data's trailing path axis. The order-1 path id is p1_first + j1 - 1; the children's come from the group.
ScatteringTransforms.Cascade.field_cascade! — Function
field_cascade!(data, fw, fb, groups, xfft, root, p1_first) -> dataEvery path's localized field. root is the order-0 path id, p1_first the first order-1 id.
ScatteringTransforms.ScatteringCore.periodize_mul! — Function
periodize_mul!(dst, src, filt, r) -> dst
periodize!(dst, src, r) -> dstdst[k] = (1/∏r) Σ_m src[k + m∘n] * filt[k + m∘n], where n = size(dst) and m runs over the ∏r alias blocks: the spectrum of (src ⋆ filt) decimated by r per axis. For any spectrum Ŷ,
ifft_N(Ŷ)[1:r:end] == ifft_M(periodize_r(Ŷ)), M = N ./ rwith the 1/∏r supplying the normalisation ifft_M lacks. Indices are 0-based on unshifted grids, so bin k of dst gathers bins k, k+n, k+2n, … of src; a singleton filt axis broadcasts. Both are broadcasts only, so they run on device arrays.
ScatteringTransforms.ScatteringCore.periodize_mul2! — Function
periodize_mul2!(dst, src, f1, f2, r) -> dstperiodize_mul! with two filters, dst[k] = (1/∏r) Σ_m src[·] * f1[·] * f2[·], in one pass: the monogenic band-pass R_d · ψ_j is a product of two full-resolution filters.
ScatteringTransforms.ScatteringCore._modulus — Function
_modulus(z)|z| for the scattering nonlinearity, computed as sqrt(abs2(z)).
It agrees with abs(z) to one ulp while abs2(z) neither overflows nor underflows, i.e. for sqrt(floatmin) < |z| < sqrt(floatmax). A wavelet coefficient is O(‖x‖), so a field near those magnitudes must be rescaled before transforming.
ScatteringTransforms.ScatteringCore.periodize — Function
periodize(src, r) -> dstAllocating form of periodize! (see periodize_mul!), for the non-mutating forward that autodiff differentiates; it writes nothing in place.
ScatteringTransforms.ScatteringCore.periodize_filter! — Function
periodize_filter!(dst, src, r) -> dstA filter periodized onto a coarser grid: dst[k] = Σ_m src[k + m∘n], with no 1/∏r, which periodize_mul! applies to the product being decimated.
The periodized filter keeps the original's frequencies. A Morlet evaluated afresh on the N/r grid is a different wavelet: its profile is a function of normalised angular frequency, so its peak lands at bin (N/r)·k0/2π, an octave lower per factor of two.
ScatteringTransforms.Filters.gaussian_lowpass! — Function
gaussian_lowpass!(φ, σ) -> φ
gaussian_lowpass(T, dims, J; sigma0=0.8) -> Array{T,D}Isotropic Gaussian low-pass φ̂(k) = exp(-|k|²σ²/2) on the FFT grid of dims, with k the angular frequency (2π·fftfreq per axis) and σ = sigma0·2^J a real-space width: the averaging filter φ_J of every filter bank, and of the localized transform S_p = (U_p ⋆ φ_J) ↓ s.
φ̂(0) = 1, so averaging preserves a field's mean. Decimation by s keeps ⟨S_p⟩ = ⟨U_p⟩ when φ̂ vanishes on the lattice {2πm/s : m ≠ 0}; at s = 2^(J-1) its largest value there is exp(-(4π·sigma0)²/2), 1e-22 at sigma0 = 0.8.
ScatteringTransforms.Plans.plan_like — Function
plan_like(plan, prototype) -> plan′
plan_like(plan, prototype, D; kwargs...) -> plan′A plan of the same kind as plan, sized for arrays like prototype, for a cascade that needs plans at resolutions chosen after the transform was built. The three-argument form transforms the leading D axes of prototype and leaves its trailing stack axis alone, with kwargs going to the plan builder. A device plan has no spectral-backend tag, so its method plans on prototype's array type.
ScatteringTransforms.Plans.inplace_inverse — Function
inplace_inverse(plan) -> BoolWhether inverse_transform!(x, plan, x) is valid, letting a transform alias its convolution output with its multiply scratch. Default false: the direct-sum plan ping-pongs through its own scratch, and over an odd number of axes its first pass writes into its input.
Filter banks, filters & path graph
ScatteringTransforms.FilterBanks.FilterBank1D — Type
FilterBank1D{T,V,W,MV}Complete 1D filter bank for the scattering transform. V is the per-filter array type, W the wavelet collection and MV the metadata collection.
Fields
wavelets::W: wavelet filters in the Fourier domain (W<:AbstractVector{V})averaging::V: low-pass averaging (scaling) filtermeta::MV: per-waveletWaveletMetaJ::Int: number of octaves (scales)Q::Int: wavelets per octave
ScatteringTransforms.FilterBanks.FilterBank2D — Type
FilterBank2D{T,M,W,MV}Complete 2D filter bank with oriented wavelets. M is the per-filter matrix type, W the wavelet collection and MV the metadata collection.
Fields
wavelets::W: oriented wavelet filters (W<:AbstractVector{M})averaging::M: low-pass averaging filtermeta::MV: per-waveletWaveletMetaJ::Int: number of scalesL::Int: number of orientations
ScatteringTransforms.FilterBanks.FilterBank3D — Type
FilterBank3D{T,A,W,MV}Complete 3D oriented Morlet filter bank: J scales × n_orient sphere directions, plus a low-pass averaging filter. A is the per-filter array type, W the wavelet collection and MV the metadata collection.
ScatteringTransforms.FilterBanks.WaveletMeta — Type
WaveletMeta{T}Per-wavelet metadata.
Fields
scale::Int: octave indexjq::Int: sub-octave index within the octave (1D,0..Q-1);0otherwiseorient::Int: orientation index (0..L-1in 2D,0..n_orient-1in 3D);0in 1Dj_eff::T: effective log-scale that orders paths,j + q/Qin 1D andT(j)in 2D and 3D. A second-order path is admissible iffj_eff(child) > j_eff(parent), which in 2D and 3D admits every orientation pair at a strictly coarser scale.center_freq::T: wavelet center frequencytheta::T: orientation angle in radians (2D);0otherwise
ScatteringTransforms.FilterBanks.build_filter_bank1d — Function
build_filter_bank1d([T = Float64,] N, J; Q = 1) -> FilterBank1DBuild a 1D Morlet filter bank with dyadic scales, Littlewood–Paley normalized by lp_scale_1d.
Arguments
N::Int: Signal length (FFT size)J::Int: Maximum scale (number of octaves)Q::Int: Wavelets per octave (default 1 for dyadic, 8 for high Q)
Returns
FilterBank1D: Complete filter bank with J scales
build_filter_bank1d(T, N, J, filters::AbstractFilterStorage; Q = 1)
build_filter_bank3d(T, N, J, filters::AbstractFilterStorage; n_orient = 6)ComputedFilters() returns a computed bank, which evaluates each wavelet on demand; StoredFilters() returns the stored bank.
ScatteringTransforms.FilterBanks.build_filter_bank2d — Function
build_filter_bank2d([T = Float64,] N, J; L = 8) -> FilterBank2DBuild a 2D oriented Morlet filter bank, Littlewood–Paley normalized by lp_scale_2d.
Arguments
N::NTuple{2,Int}: Image dimensions (Ny, Nx)J::Int: Number of dyadic scalesL::Int: Number of orientations (default 8, evenly spaced)
Returns
FilterBank2D: Complete 2D filter bank
build_filter_bank2d(T, N, J, filters::AbstractFilterStorage; L = 8)ComputedFilters() returns a ComputedFilterBank2D, which evaluates each wavelet on demand; StoredFilters() returns the stored bank.
ScatteringTransforms.FilterBanks.build_filter_bank3d — Function
build_filter_bank3d([T = Float64,] N, J; n_orient = 6) -> FilterBank3DBuild a 3D oriented Morlet filter bank with J dyadic scales and n_orient near-uniform orientations on the sphere (Fibonacci spiral), Littlewood–Paley normalized by lp_scale_3d.
ScatteringTransforms.FilterBanks.ComputedFilterBank1D — Type
ComputedFilterBank1D{T,V,MV,WV}
ComputedFilterBank3D{T,A,MV,WV}The 1D and 3D counterparts of ComputedFilterBank2D.
ScatteringTransforms.FilterBanks.ComputedFilterBank2D — Type
ComputedFilterBank2D{T,M,MV,WV}A 2D bank that stores its wavelets' parameters and evaluates one, scaled by the Littlewood–Paley constant, into a single scratch array on each filter_at call.
It holds two grid-sized arrays, the low-pass and the scratch, against J·L+1 for a stored bank, and costs two exp per grid point per application. The scratch is mutable, so tasks cannot share one bank; task_bank gives each its own scratch.
ScatteringTransforms.FilterBanks.AbstractFilterStorage — Type
AbstractFilterStorageHow a transform holds its wavelets, the filters keyword of its constructor: StoredFilters or ComputedFilters.
ScatteringTransforms.FilterBanks.StoredFilters — Type
StoredFilters() <: AbstractFilterStorageEvery wavelet stored in the Fourier domain on the transform's grid, the default.
ScatteringTransforms.FilterBanks.ComputedFilters — Type
ComputedFilters() <: AbstractFilterStorageEach wavelet's parameters stored, and the wavelet evaluated on demand into one scratch array (see ComputedFilterBank2D), for grids whose stored bank does not fit in memory.
ScatteringTransforms.FilterBanks.filter_storage — Function
filter_storage(fb) -> AbstractFilterStorageThe filters that builds a bank like fb: StoredFilters() or ComputedFilters().
ScatteringTransforms.FilterBanks.nwavelets — Function
nwavelets(fb) -> IntHow many wavelets the bank holds.
ScatteringTransforms.FilterBanks.filter_at — Function
filter_at(fb, j) -> AbstractArrayThe bank's j-th wavelet in the Fourier domain. For a computed bank this is its shared scratch, valid until the next call.
ScatteringTransforms.FilterBanks.iscomputed — Function
iscomputed(fb) -> BoolWhether filter_at returns the bank's shared scratch. A caller that then needs two filters live at once, or a filter at a resolution the bank does not hold, must copy it.
ScatteringTransforms.FilterBanks.task_bank — Function
task_bank(fb) -> fb′A bank usable concurrently with fb. Stored banks are read-only and are returned as they are; a computed bank gets its own scratch, sharing everything else.
ScatteringTransforms.FilterBanks.batch_views — Function
batch_views(fb, spatial) -> VectorThe bank's filters reshaped to (spatial…, 1), so they broadcast over a batch axis.
For a computed bank every entry is the same view of its scratch, so a caller must call filter_at(fb, j) immediately before using entry j.
ScatteringTransforms.FilterBanks.littlewood_paley — Function
littlewood_paley(fb) -> AThe bank's Littlewood–Paley sum for a real field, A(ω) = |φ̂(ω)|² + ½ Σ_λ (|ψ̂_λ(ω)|² + |ψ̂_λ(−ω)|²), on its frequency grid. The wavelet transform of a real field is bounded by minimum(A)·‖x‖² ≤ ‖Wx‖² ≤ maximum(A)·‖x‖², and Inverse.iwavelet! divides by A.
littlewood_paley(fb::AnyMonogenicBank) -> AA(k) = |φ̂(k)|² + Σ_j |ψ̂_j(k)|² (1 + Σ_d |R_d(k)|²), the energy the band-pass, Riesz and low-pass outputs of a real field carry per frequency.
ScatteringTransforms.FilterBanks.lp_scale_1d — Function
lp_scale_1d(Q; r=√½) -> cThe wavelet scale of a 1D Morlet bank with Q wavelets per octave: ½ Σ_j |c·ψ̂_j(ω)|² peaks at 1 over the bank continued over every scale.
ScatteringTransforms.FilterBanks.lp_scale_2d — Function
lp_scale_2d(L; sigma0=0.8) -> cThe wavelet scale of a 2D Morlet bank with L orientations: ½ Σ_{j,ℓ} (|c·ψ̂_{j,ℓ}(k)|² + |c·ψ̂_{j,ℓ}(−k)|²) peaks at 1 over the bank continued over every scale.
ScatteringTransforms.FilterBanks.lp_scale_3d — Function
lp_scale_3d(n_orient; sigma0=0.8) -> cThe wavelet scale of a 3D Morlet bank over n_orient Fibonacci directions: ½ Σ_{j,o} (|c·ψ̂_{j,o}(k)|² + |c·ψ̂_{j,o}(−k)|²) peaks at 1 over the bank continued over every scale.
ScatteringTransforms.FilterBanks.negated — Function
negated(A) -> BB[k] = A[−k] on the DFT grid, with each index taken modulo its axis.
ScatteringTransforms.Filters.Morlet1D — Type
Morlet1D{T<:Real}1D Morlet wavelet in frequency domain, over normalized frequency ω ∈ [0, ½]:
Ψ(ω) = exp(-(ω-ξ)²/2σ²) - κ exp(-ω²/2σ²), κ = exp(-(ξ/σ)²/2)σ is a frequency-domain width. κ sets Ψ(0) = 0, so the wavelet has zero mean. The filter is analytic: zero for ω < 0.
Type Parameters
T: Element type (Float32, Float64, etc.)
Fields
center_freq::T: Center frequency ξbandwidth::T: Frequency-domain width σN::Int: Filter length (FFT size)
ScatteringTransforms.Filters.Morlet2D — Type
Morlet2D{T<:Real}2D oriented Morlet wavelet in the frequency domain, k the angular wavenumber:
Ψ(k) = exp(-((k∥ - k₀)²σ∥² + k⊥²σ⊥²)/2) - β exp(-(k∥²σ∥² + k⊥²σ⊥²)/2), β = exp(-(k₀σ∥)²/2)for k∥ ≥ 0 and zero otherwise, with k∥ = kx cos θ + ky sin θ, k⊥ = -kx sin θ + ky cos θ. The widths are real-space: σ∥ = sigma0·2ʲ, σ⊥ = σ∥·L/4, and k₀ = 3π/(4·2ʲ). The envelope's angular standard deviation at |k| = k₀ is then 4/(L·k₀σ∥), which at the default sigma0 is 0.68·π/L: a fixed fraction of the spacing π/L of the L orientations.
Fields
center_freq::T:k₀sigma_par::T,sigma_perp::T: real-space widths along and across the orientationtheta::T: orientation angle in radians, from the second array axisbeta::T: zero-mean correctionN::NTuple{2,Int}: filter dimensions(Ny, Nx)
ScatteringTransforms.Filters.Morlet3D — Type
Morlet3D{T<:Real}3D oriented Morlet wavelet in the frequency domain, a bump centered at k₀ n̂ for a unit direction n̂, analytic on the half-space k·n̂ ≥ 0: Morlet2D's envelope with k∥ = k·n̂ and k⊥ = |k − k∥ n̂|. The real-space widths are σ∥ = sigma0·2ʲ and σ⊥ = σ∥·√(π·n_orient)/8, the 2D rule σ⊥ = σ∥·π/(4Δθ) at the spacing Δθ = √(4π/n_orient) of n_orient directions spread over the sphere.
Fields
center_freq::T:|k₀|sigma_par::T,sigma_perp::T: real-space envelope widths along / perpendicular ton̂direction::NTuple{3,T}: unit orientationn̂beta::T: zero-mean correctionN::NTuple{3,Int}: grid dimensions
ScatteringTransforms.Filters.frequency_response — Function
frequency_response(m::Morlet1D{T}) -> Vector{T}The frequency response Ψ(ω) of m on its N-point FFT grid, zero at negative frequencies.
frequency_response(m::Morlet2D{T}) -> Matrix{T}The 2D frequency response Ψ(kx, ky) of an oriented Morlet wavelet, on its FFT grid.
frequency_response(m::Morlet3D{T}) -> Array{T,3}3D frequency response Ψ(kx,ky,kz) of an oriented Morlet wavelet.
ScatteringTransforms.Filters.frequency_response! — Function
frequency_response!(Ψ, m) -> ΨWrite the response into Ψ.
ScatteringTransforms.Filters._alias_rms — Function
_alias_rms(f, n, I) -> valuef at the normalized frequencies of bin I of an n-point grid, f taking an NTuple of them. On an even axis's Nyquist bin −½ and +½ are one bin, so there the value is the root mean square of f over every sign of those coordinates. A real field's Littlewood–Paley sum at that bin is then the mean of the continuous sum over its aliases: an analytic wavelet centred at +½ keeps the bin.
ScatteringTransforms.Filters.fibonacci_directions — Function
fibonacci_directions(n, ::Type{T}=Float64) -> Vector{NTuple{3,T}}n near-uniform unit directions on the sphere (Fibonacci spiral), used as 3D wavelet orientations.
ScatteringTransforms.PathGraph.ScatteringTree — Type
ScatteringTree{IV,RV}Flat CSR description of the scattering tree: wavelet indices into the filter bank and per-path order labels. The containers are parametric; build_tree produces Vector{Int} and Vector{UnitRange{Int}}.
Fields
path_data: concatenated wavelet-index lists for all pathspath_ptr: CSR offsets (lengthnpaths+1); pathpispath_data[path_ptr[p]:path_ptr[p+1]-1]order: scattering order of each path (0, 1, 2, …)by_order:by_order[o+1]is the contiguous range of path ids of ordero
ScatteringTransforms.PathGraph.build_tree — Function
build_tree(j_eff, max_order) -> ScatteringTreeEnumerate all admissible paths up to max_order from the per-wavelet effective log-scales j_eff (typically [m.j_eff for m in filter_bank.meta]). Admissibility: j_eff strictly increasing along the path. Paths are laid out grouped by order (order 0, then 1, then 2, …), so by_order ranges are contiguous.
ScatteringTransforms.PathGraph.order2_groups — Function
order2_groups(tree, nw) -> Vector{Tuple{Int,Vector{Int},Vector{Int}}}Every first-order wavelet j1 with its admissible order-2 children j2 and the tree path ids of those (j1, j2) pairs, longest group first.
The cascade computes each first-order modulus once per group, and the localized-field output is indexed by the path ids. Longest-first order balances the parallel backends, since the child count varies across scales.
ScatteringTransforms.PathGraph.order_range — Function
order_range(tree, o) -> UnitRangeContiguous range of path ids with scattering order o.
ScatteringTransforms.PathGraph.path_indices — Function
path_indices(tree, p) -> viewWavelet indices of path p (empty for the order-0 root), as a non-allocating view.
ScatteringTransforms.PathGraph.npaths — Function
npaths(tree) -> IntTotal number of paths (including the order-0 root).
Spectral plans & core operations
ScatteringTransforms.Plans.AbstractScatteringPlan — Type
AbstractScatteringPlanSupertype for spectral transform plans. A plan implements forward_transform! and inverse_transform!; the in-core default is DirectSumPlan, with fast paths (FFTW, AbstractFFTs/device, FINUFFT, NonuniformFFTs) provided by extensions.
ScatteringTransforms.Plans.DirectSumPlan — Type
DirectSumPlan{T,V,D,S}Direct-summation DFT plan: evaluates X_k = Σ_n x_n e^{-2πi kn/N} (and its inverse) by direct summation, separably over the leading D dimensions, leaving a trailing batch axis of length nbatch untouched. Memory is O(N): a per-axis table of roots of unity and its conjugate. scratch is nothing for D == 1 and a full-size complex array otherwise.
ScatteringTransforms.Plans.forward_transform! — Function
forward_transform!(out, plan, x) -> outIn-place forward (fft-convention) spectral transform. Methods provided by concrete plans.
ScatteringTransforms.Plans.inverse_transform! — Function
inverse_transform!(out, plan, x) -> outIn-place inverse (ifft-convention, 1/N-scaled) spectral transform.
ScatteringTransforms.Plans.forward_transform — Function
forward_transform(plan, x) -> X̂
inverse_transform(plan, x) -> xNon-mutating counterparts of forward_transform! and inverse_transform!, for the differentiable scattering(st, x). They allocate their output and mutate neither the plan's scratch nor x. DirectSumPlan contracts each axis against its twiddle table in scalar loops, so it accepts any element type, ForwardDiff.Dual included, and every AD backend traces it.
ScatteringTransforms.Plans.inverse_transform — Function
inverse_transform(plan, x) -> xSee forward_transform.
ScatteringTransforms.Plans.make_plan — Function
make_plan(spectral, T, dims; batch = nothing, kwargs...) -> AbstractScatteringPlanBuild the spectral plan selected by spectral for arrays whose leading dimensions are dims and whose element type is Complex{T}: arrays of size dims for batch = nothing, and (dims…, batch) stacks for an integer batch.
SpectralBackends.DirectSumSpectralBackend is the dependency-free in-core default; SpectralBackends.FFTSpectralBackend requires using FFTW; SpectralBackends.AutoSpectralBackend takes the FFTW fast path when its extension is loaded and otherwise the in-core direct sum.
ScatteringTransforms.Plans.make_scattered_plan — Function
make_scattered_plan(spectral, x, y, ms, T; period, origin = (0, 0), analysis, maxiter, rtol, damp,
tol, ntrans, nthreads) -> AbstractScatteringPlanBuild the scattered/nonuniform planar plan selected by spectral over points (x, y) and a uniform mode grid of size ms. SpectralBackends.DirectSumSpectralBackend is the dependency-free exact NUDFT; FlowTransformBindings.FINUFFTBackend() and FlowTransformBindings.NonuniformFFTsBackend() select a nonuniform-FFT library; SpectralBackends.AutoSpectralBackend takes NonuniformFFTs when it is loaded and FINUFFT when only it is, and the exact direct sum when neither is.
period is the domain's length along each axis and origin its lower corner, each a number for both axes or a 2-tuple. A point lies at 2π·mod(x - origin, period)/period on the plan's 2π-periodic domain, so mode k has wavelength period/k whatever the point set.
ntrans is the batch width and nthreads the library's own thread count (0, the default, takes Threads.nthreads()). The exact direct sum has no tolerance and runs on one thread, so it accepts tol and nthreads and ignores them.
ScatteringTransforms.Plans.available — Function
available(spectral) -> BoolWhether the extension implementing spectral is loaded: true from that extension, so the transform AutoSpectralBackend takes follows from the loaded methods.
ScatteringTransforms.Plans.spectral_backend — Function
spectral_backend(plan) -> SpectralBackends.AbstractSpectralBackendThe spectral-backend tag that rebuilds plan on another process. A plan that a tag cannot rebuild, such as a device-resident FFT plan, throws.
ScatteringTransforms.Plans.task_local_plan — Function
task_local_plan(plan) -> planA plan equivalent to plan that is safe to use concurrently with it. Stateless plans (FFTW, AbstractFFTs) return themselves; plans carrying mutable scratch return a copy that shares their read-only tables and owns fresh scratch. Called once per task by the parallel backends.
A method that builds a new library plan takes its thread count from per_task_nthreads, and the caller must close_plan! that plan when the task ends.
ScatteringTransforms.Plans.batch_width — Function
batch_width(plan) -> IntNumber of co-located fields plan transforms per execution: 1 unless it was built for a batch. A nonuniform plan's width is fixed at construction, so it transforms exactly that many fields per execution.
ScatteringTransforms.Plans.plan_points — Function
plan_points(plan) -> (x, y)The scattered sample locations a nonuniform plan was built on, already mapped onto its 2π-periodic domain, from which a transform is rebuilt on another process. Rebuilding from these requires period = (2π, 2π), since they are already scaled.
ScatteringTransforms.Plans.plan_analysis — Function
plan_analysis(plan) -> (; analysis, maxiter, rtol, damp, tol, nthreads)How a scattered-planar plan turns samples into modes, as the keyword arguments its constructor takes.
A plan rebuilt on the same points needs these too: on irregular sampling the type-1 adjoint and the least-squares inversion are different transforms. tol is nothing for the exact direct sum.
ScatteringTransforms.Plans.DirectNUFFTPlan — Type
DirectNUFFTPlan{T,TB,CV,RV,WS}Exact direct-summation NUDFT between M scattered points and an ms mode grid, transforming batch_width(plan) co-located fields per call. Memory is O(M·(ms₁ + ms₂)): one exponential table per axis.
ScatteringTransforms.Plans.NUFFTScatteringPlan — Type
NUFFTScatteringPlanScattered-planar plan over FlowTransformBindings NUFFT plans on fixed points: a complex plan for synthesis and for complex samples, and a real plan for real samples and the real solve. B is the number of co-located fields each execution transforms, and transform the NUFFT library tag the plans run on.
ScatteringTransforms.Plans.nufft_scattered_plan — Function
nufft_scattered_plan(backend, x, y, ms, T; period, origin = (0, 0), analysis, maxiter, rtol, damp,
tol, ntrans, nthreads) -> NUFFTScatteringPlanThe scattered-planar plan over points (x, y) and mode grid ms on a FlowTransformBindings NUFFT backend, on a domain of length period with lower corner origin (see make_scattered_plan). nthreads = 0 takes the session's Threads.nthreads().
ScatteringTransforms.Plans.with_fft_nthreads — Function
with_fft_nthreads(f, n) -> f()Run f, which builds plans, under FFTW.jl's planner lock with FFTW's planner thread count set to n and restored after (FFTW.set_num_threads(f, n)); without FFTW loaded, just call f().
FFTW's planner state is process-global and shared by every library that plans on libfftw3, and a plan keeps the thread count it was built with, so every plan builder here sets the count through this. The fallback takes args... so the FFTW extension's two-argument method is more specific and adds a method; redefining this one is an error during precompilation.
ScatteringTransforms.Plans.per_task_nthreads — Function
per_task_nthreads(requested) -> IntThread count for a library plan that task_local_plan builds inside a task: requested when positive, else 1, since the tasks already occupy the cores.
ScatteringTransforms.Plans.close_plan! — Function
close_plan!(plan) -> nothingRelease the foreign-library resources plan owns without waiting for garbage collection. A no-op by default, and safe to call more than once. Whoever builds a plan for a task closes it when the task ends; cuFINUFFT plans are released only by this.
ScatteringTransforms.ScatteringCore.wavelet_convolve — Function
wavelet_convolve(signal_fft, filter_fft, plan) -> AbstractArrayThe inverse transform of signal_fft .* filter_fft through plan, in a new array; wavelet_convolve! writes in place.
ScatteringTransforms.ScatteringCore.wavelet_convolve! — Function
wavelet_convolve!(out, signal_fft, filter_fft, plan, buffer)Wavelet convolution without allocation: multiplies signal_fft .* filter_fft into buffer, then applies the inverse spectral transform via Plans.inverse_transform!(out, plan, buffer).
out and buffer must both be pre-allocated complex arrays of the same size.
ScatteringTransforms.ScatteringCore.apply_modulus — Function
apply_modulus(signal) -> AbstractArray|signal| elementwise, in a new real array; apply_modulus! writes in place.
ScatteringTransforms.ScatteringCore.apply_modulus! — Function
apply_modulus!(out, signal)In-place modulus. Stores |signal| in pre-allocated out. Zero allocation.
ScatteringTransforms.ScatteringCore.modulus_mean — Function
modulus_mean(signal) -> Real⟨|signal|⟩ in one reduction, writing no modulus field: the cascade's leaf case, where no coarser scale reads it.
ScatteringTransforms.ScatteringCore.modulus_mean! — Function
modulus_mean!(out, signal) -> RealWrite |signal| into out, real or complex, and return ⟨|signal|⟩: the case where a coarser scale reads the modulus field.
ScatteringTransforms.ScatteringCore.spatial_average — Function
spatial_average(signal) -> NumberThe global mean of signal.
ScatteringTransforms.ScatteringCore.task_workspace — Function
task_workspace(st) -> st′A transform equivalent to st that shares its read-only parts — filter bank, path tree, work list — but owns fresh buffers and a task-local spectral plan, so the two can run concurrently. Methods are defined per transform type.
Scattered least-squares solve
analysis = ST.Plans.LeastSquares() fits spectral coefficients with FlowTransformBindings.lsmr!. ST.Plans.WeightedAdjoint() applies the quadrature-weighted adjoint. The planar default is WeightedAdjoint(); the scattered-sphere default is LeastSquares().
rtol controls the fit's relative normal residual. A fit that reaches its iteration or condition limit returns its best iterate. A transform whose analysis is a fit returns (; coefficients, fit): fit is the FlowTransformBindings.SolverResult (converged, iterations, residual) of the least converged fit the call ran, and a batch's fit holds one per field. A transform that fits nothing returns its coefficients alone. For scattered planar transforms, tol controls NUFFT accuracy and nthreads controls the NUFFT library's threads.
ScatteringTransforms.Plans.AbstractAnalysis — Type
AbstractAnalysisPolicy for recovering spectral coefficients from scattered samples.
ScatteringTransforms.Plans.WeightedAdjoint — Type
Analyze samples by a quadrature-weighted adjoint transform.
ScatteringTransforms.Plans.LeastSquares — Type
Analyze samples by a least-squares fit.
ScatteringTransforms.Plans.default_solver_rtol — Function
default_solver_rtol(::Type{T}, spectral, tol) -> TStopping tolerance for the scattered least-squares solve, set by the accuracy of the transform under it.
The direct sum evaluates an exact adjoint pair, so the target is sqrt(Base.eps(T)). A fast NUFFT's type-1 and type-2 are adjoints only to its tolerance tol (the library default for T when nothing), so the target is max(10·tol, sqrt(Base.eps(T))).
ScatteringTransforms.Plans.warn_underdetermined — Function
warn_underdetermined(M, ms, analysis, damp) -> nothingWarn, once, that a solve has more modes than samples and no damping.
With prod(ms) > M at least prod(ms) - M mode directions are constrained by no sample, and LSMR returns the minimum-norm iterate. Whether that is the answer wanted, or whether to reduce ms, add samples, or set damp for Tikhonov regularisation, is the caller's choice; no λ is chosen for them.
Plans supplied by extensions
These are declared in the core and given a method by the corresponding extension. Calling one without its package loaded raises with the using line to run.
ScatteringTransforms.Plans.fftw_plan — Function
fftw_plan(T, dims; batch, planning, fft_nthreads) -> AbstractScatteringPlanBuild the FFTW-backed plan, a method the FFTW extension defines; this fallback throws an ArgumentError naming using FFTW.
ScatteringTransforms.Plans.abstractffts_plan — Function
abstractffts_plan(dummy_device_array; region = 1:ndims(dummy_device_array), fft_nthreads = 1)FFT plan for the array type of dummy_device_array, built through AbstractFFTs.plan_fft and plan_ifft, so a CuArray gives a cuFFT plan and a ROCArray a rocFFT plan. region selects the transformed dimensions, e.g. (1, 2) for a (Ny, Nx, B) stack. The KernelAbstractions extension defines the method.
Execution backends
ScatteringTransforms.Execution.resolve_backend — Function
resolve_backend(backend) -> AbstractLocalBackendConcrete backends pass through unchanged — a request is honoured exactly or refused, never silently downgraded. AutoBackend resolves on real capability: ThreadedBackend when there is more than one thread and the OhMyThreads extension is loaded, otherwise SerialBackend.
ScatteringTransforms.Execution.check_available — Function
check_available(backend) -> backendReturn backend if its extension is loaded, and otherwise throw an ArgumentError naming the package to load. An AutoBackend must go through resolve_backend first.
ScatteringTransforms.Execution.available — Function
available(execution) -> BoolWhether the extension for execution is loaded.
Cascade internals
The cascade each gridded transform runs, and the per-surface in-place entry points.
ScatteringTransforms.Scattering1D.cascade! — Function
cascade!(S1, S2, st, signal_fft) -> (S1, S2)Both scattering orders in one pass over the tree, grouped by first-order wavelet:
for (j1, children): U₁ = |x ⋆ ψ_j1| ; S1[j1] = ⟨U₁⟩
Û₁ = fft(U₁) ; S2[j1,j2] = ⟨|U₁ ⋆ ψ_j2|⟩ for each childOne U₁/Û₁ pair is live at a time, and a wavelet with no admissible child reduces to a single ⟨|·|⟩. signal_fft is read only.
ScatteringTransforms.Scattering2D.cascade! — Function
cascade!(S1, S2, st, image_fft) -> (S1, S2)Both scattering orders in one grouped pass, as in the 1D cascade!. An order-2 path pairs any two orientations at strictly increasing scale.
ScatteringTransforms.Scattering3D.cascade! — Function
cascade!(S1, S2, st, vol_fft) -> (S1, S2)Both scattering orders in one grouped pass, as in the 1D cascade!.
ScatteringTransforms.ScatteredPlanar.ScatteredPlanarScatteringTransform — Type
ScatteredPlanarScatteringTransformScattering transform of a field sampled at scattered planar points, as built by scattered_planar_scattering: the samples analysed onto the ms mode grid by the spectral plan, then the cascade of the gridded Scattering2D transform on that grid, with its oriented Morlet bank.
A transform built with ntrans = B > 1 analyses B fields per call: its sample and mode buffers are (M, B) and (ms…, B), including a trailing batch axis at width 1.
ScatteringTransforms.ScatteredPlanar.scattered_planar_scattering! — Function
scattered_planar_scattering!(coeffs, st, x) -> coeffs or (; coefficients, fit)In-place counterpart of the callable: write into a preallocated ScatteringCoefficients2D, with the fit's outcome beside it under LeastSquares(). Allocation-free when coeffs carries a 1-element S0, which Coefficients.update_S0 writes in place.
ScatteringTransforms.ScatteredPlanar.scattered_planar_scattering_batch! — Function
scattered_planar_scattering_batch!(S0, S1, S2, st, X) -> (; S0, S1, S2[, fit])Cascade over a stack of B fields sampled at the same points: X is (M, B), S0 is (B), S1 is (nw, B) and S2 is (nw, nw, B), (0, 0, B) without a second order. Under LeastSquares(), fit holds each field's FlowTransformBindings.SolverResult.
The analysis covers the whole stack in one execution, and each field's cascade then runs on the mode grid; st must have been built with ntrans = B.
Spherical scattering
A spherical plan implements three primitives — analysis, multiply-and-synthesise, and the spherical mean — and everything above them is shared. A scattered transform analyses its samples once and runs the rest of its cascade on a plan of the same kind on the Gauss–Legendre grid of its band limit. The in-core direct plan is always available; NUFSHT and FastSphericalHarmonics supply the fast ones.
ScatteringTransforms.SphericalCore.AbstractSphericalPlan — Type
AbstractSphericalPlanSupertype for spherical spectral plans (scattered NUFSHT, structured SHT, …). A concrete plan must implement sphere_coeffs, sphere_apply!, and sphere_mean.
ScatteringTransforms.SphericalCore.DirectSHTSphericalPlan — Type
DirectSHTSphericalPlanThe in-core scattered-sphere plan over M points at band limit lmax, transforming B co-located fields per call. Analysis is the least-squares fit of the real spherical harmonics of degree ≤ lmax by LSMR (FlowTransformBindings.lsmr!), weighted by the quadrature weights w, which sum to 1: min Σⱼ wⱼ (fⱼ − Σ a_ℓm Y_ℓm(xⱼ))². With analysis = Plans.WeightedAdjoint() it is the weighted adjoint a_ℓm = Σⱼ wⱼ fⱼ Y_ℓm(xⱼ) over harmonics of mean square 1. Synthesis is their direct sum at the points; neither forms the M × (lmax+1)² matrix of harmonics, so memory is O(M + (lmax+1)²).
ScatteringTransforms.SphericalCore.sphere_coeffs — Function
sphere_coeffs(plan, field) -> CSpherical-harmonic analysis: the coefficients C of field up to the plan's band limit. For a structured grid this is the forward SHT; for scattered points it is the least-squares fit or the weighted adjoint. C is opaque and valid only with the interface functions of plan or of a plan of its kind at its band limit, such as sphere_apply!.
ScatteringTransforms.SphericalCore.sphere_coeffs! — Function
sphere_coeffs!(C, plan, field) -> CIn-place sphere_coeffs: analyse field into the pre-allocated coefficient container C, which must have come from sphere_coeffs_buffer(plan).
ScatteringTransforms.SphericalCore.sphere_coeffs_buffer — Function
sphere_coeffs_buffer(plan) -> CA coefficient container of the right type and size for plan, suitable for sphere_coeffs!. Backends whose coefficients are not a plain vector (the FastSphericalHarmonics triangular layout, the NUFSHT dense spin layout) return their own shape.
ScatteringTransforms.SphericalCore.sphere_field_buffer — Function
sphere_field_buffer(plan) -> fieldA grid container of the right type and size for plan, for a band synthesised at that plan's band limit. Defaults to sphere_coeffs_buffer, which is the same shape on backends whose coefficients and samples share a layout.
ScatteringTransforms.SphericalCore.sphere_apply! — Function
sphere_apply!(out, plan, C, h) -> outApply the per-degree multiplier h(ℓ) to (a copy of) the coefficients C and synthesise the result into out — i.e. out = Σ_{ℓm} h(ℓ) · C_{ℓm} · Y_{ℓm}. Does not mutate C.
ScatteringTransforms.SphericalCore.sphere_mean — Function
sphere_mean(plan, field) -> scalarSpherical average of field under the plan's quadrature: for scattered points the sample mean, or the weighted mean when the plan carries weights; for a structured grid the exact quadrature integral. Provided by each backend.
ScatteringTransforms.SphericalCore.sphere_plan_at — Function
sphere_plan_at(plan, lmax) -> plan or nothingA plan of the same kind at the lower band limit lmax, or nothing when this backend cannot be narrowed, in which case every band is synthesised at the full band limit. This is the spherical form of decimation: band-pass wavelet j is confined to degrees ≲ ℓ_j.
ScatteringTransforms.SphericalCore.sphere_lmax — Function
sphere_lmax(plan) -> IntThe band limit of plan. Every backend that defines sphere_plan_at defines this.
ScatteringTransforms.SphericalCore.sphere_restrict! — Function
sphere_restrict!(Cdst, pdst, Csrc, psrc) -> CdstCopy the spherical-harmonic coefficients of degree ≤ pdst's band limit out of Csrc (laid out for psrc) into Cdst (laid out for pdst), zeroing anything Cdst holds beyond them. Coefficient layout is backend-specific, so each backend defines this.
ScatteringTransforms.SphericalCore.grid_plan — Function
grid_plan(plan, L) -> plan or nothingA plan of plan's kind, band limit and batch width on the Gauss–Legendre grid of band limit L ≥ lmax (gauss_legendre_grid), analysing by that grid's quadrature, or nothing for a backend with none. Its coefficients are laid out as plan's. Its analysis of a field holding degrees up to 2L + 1 − lmax is exact. A scattered transform analyses its samples with plan and runs every later step of its cascade on this one.
ScatteringTransforms.SphericalCore.grid_band — Function
grid_band(grid) -> IntThe band limit L of a grid_plan's Gauss–Legendre grid, from its (L + 1)(2L + 1) nodes.
ScatteringTransforms.SphericalCore.coeffs_mean — Function
coeffs_mean(plan, C, b = 1)The spherical mean of the field whose coefficients under plan are field b of C.
ScatteringTransforms.SphericalCore.gauss_legendre_grid — Function
gauss_legendre_grid(lmax, T) -> (θ, φ, w)The Gauss–Legendre grid of band limit lmax, flattened with colatitude fastest: the lmax + 1 roots of P_{lmax+1}(cos θ) by 2lmax + 1 equispaced longitudes, and quadrature weights w summing to 1. The rule integrates the product of two harmonics of degree ≤ lmax exactly, so its weighted adjoint expands a degree-lmax field.
ScatteringTransforms.SphericalCore.batch_transform — Function
batch_transform(st, B) -> stst over B co-located fields per call, its plan and grid through batch_plan: each is st's own at its own width and otherwise built for the copy, which close_task_local! releases.
ScatteringTransforms.SphericalCore.task_local_batch — Function
task_local_batch(st, B) -> stA copy of st over B co-located fields per call, safe to run while st runs in another task: its plan and grid through task_local_batch_plan. Release it with close_task_local!.
ScatteringTransforms.SphericalCore.band_lmax — Function
band_lmax(lmax, J, j, headroom) -> IntBand limit that carries wavelet j: headroom · ℓ_j, clamped to lmax; headroom = Inf keeps lmax.
Band j is a difference of Gaussians whose transfer above its cutoff is exp(-ℓ(ℓ+1) / 2ℓ_j(ℓ_j+1)): 0.135 at 2ℓ_j, 0.011 at 3ℓ_j, 3.4e-4 at 4ℓ_j, the largest value a given headroom discards.
ScatteringTransforms.SphericalCore.band_plans — Function
band_plans(plan, lmax, ls) -> Vector or nothingOne plan per scale, scale j at band limit ls[j], or nothing if this backend cannot narrow or no band needs narrowing. A scale at the full band limit lmax reuses plan.
ScatteringTransforms.SphericalCore.SphericalScatteringTransform — Type
SphericalScatteringTransformSpherical scattering transform over a backend plan::P. sigma2[k+1] is the Gaussian-transfer variance for the dyadic low-pass cutoff ℓ_k (k=0..J); band-pass wavelet j is lowpass(ℓ_{j-1}) − lowpass(ℓ_j). bands holds one narrowed plan per scale (band_plans), or nothing. grid is the plan the cascade runs on after plan analyses the field (grid_plan), or nothing for a transform whose cascade runs on plan.
ScatteringTransforms.SphericalCore.SphericalMonogenicScatteringTransform — Type
SphericalMonogenicScatteringTransformSpherical monogenic scattering: shares the dyadic difference-of-Gaussians bands of SphericalScatteringTransform but replaces the analytic modulus with the spherical monogenic amplitude A_j = √(U⁰_j² + |∇_S g_j|²) (see monogenic_amplitude!). grid is as in SphericalScatteringTransform.
ScatteringTransforms.SphericalCore.SphericalWorkspace — Type
SphericalWorkspace{A,C,AV,CV}Scratch for one spherical cascade: the band-pass output band, the current first-order field u1, both on the samples the cascade runs on (the transform's grid, where it has one), and two coefficient containers, C for the input field and C1 for the first-order field being re-analysed. Two suffice, since the cascade finishes every child of a scale before starting the next. bband, bu1, bC and bC1 are the same per scale at its narrowed band limit, and empty when the transform has no bands. fits holds a batch's per-field fit outcomes, nothing for a plan whose analysis fits nothing.
Build one with SphericalWorkspace(st, field) and reuse it across calls; a task that transforms concurrently needs its own, with a task_local transform.
ScatteringTransforms.SphericalCore.SphericalMonogenicWorkspace — Type
SphericalMonogenicWorkspace{A,C,S}Scratch for one spherical monogenic cascade: the current amplitude field u1, a second amp for the order-2 amplitudes, two coefficient containers, and scratch — the Riesz energy field and the plan's riesz_scratch (see monogenic_amplitude!).
ScatteringTransforms.SphericalCore.spherical_scattering! — Function
spherical_scattering!(S1, S2, st, ws, field) -> ScatteringCoefficients1D or (; coefficients, fit)In-place spherical scattering into pre-allocated S1/S2 using the workspace ws (see SphericalWorkspace). The returned container uses the supplied arrays; a fitting plan returns it with its fit's outcome, as the callable does.
Grouped by first-order scale so only one first-order field and one coefficient vector are live at a time: scale j1 is band-passed, averaged into S1[j1], analysed once, and then consumed by every coarser j2 > j1 before the next j1 begins.
ScatteringTransforms.SphericalCore.spherical_scattering_batch! — Function
spherical_scattering_batch!(S1, S2, st, ws, X) -> (; S0, S1, S2[, fit])Cascade over a stack of B fields sampled at the same points: X is (M, B), S1 is (J, B) and S2 is (J, J, B). Every transform covers all B fields in one call; st.plan, and its grid, must have batch width B (batch_transform). A fitting plan adds fit, each field's FlowTransformBindings.SolverResult as the callable reports it, in ws's own buffer.
ScatteringTransforms.SphericalCore.spherical_monogenic_scattering! — Function
spherical_monogenic_scattering!(S1, S2, st, ws, field) -> ScatteringCoefficients1D or (; coefficients, fit)In-place spherical monogenic scattering, the monogenic counterpart of spherical_scattering!, grouped by first-order scale with one amplitude field live at a time.
ScatteringTransforms.SphericalCore.monogenic_amplitude! — Function
monogenic_amplitude!(amp, st, C, j, w) -> ampSpherical monogenic amplitude at scale j of the field whose (already-computed) SH coefficients are C, written into amp on the samples the cascade runs on. w holds the Riesz energy field r2 and that plan's riesz scratch.
With g_j = (−Δ_S)^{-1/2} U⁰_j the spin-1 Riesz field has |U^R_j| = |∇_S g_j|, so A_j = √(U⁰_j² + |∇_S g_j|²), the energy evaluated by sphere_riesz_energy!. The Riesz vector (orientation/phase) is spherical_monogenic_components.
ScatteringTransforms.SphericalCore.sphere_riesz_energy! — Function
sphere_riesz_energy!(out, plan, C, h, scratch) -> out|∇_S g|² at the plan's samples for g = Σ_{ℓm} h(ℓ)·C_{ℓm}·Y_{ℓm}, exact for coefficients of degree ≤ lmax. scratch comes from riesz_scratch. Does not mutate C.
ScatteringTransforms.SphericalCore.riesz_scratch — Function
riesz_scratch(plan, field) -> scratchThe scratch sphere_riesz_energy! needs for plan and fields shaped like field.
ScatteringTransforms.SphericalCore.sph_layout_riesz_energy! — Function
sph_layout_riesz_energy!(out, plan, C, h, lmax, scratch) -> outsphere_riesz_energy! for coefficients in the real sph_mode layout, by three scalar syntheses through sphere_apply!. With L = -i r×∇, a real g has |∇_S g|² = |L₊g|² + (∂_φ g)², and both operators act within each degree: L₊Y_{ℓm} = √((ℓ-m)(ℓ+m+1)) Y_{ℓ,m+1} on the Condon–Shortley complex harmonics, and ∂_φ maps cos(mφ) ↦ -m sin(mφ), sin(mφ) ↦ m cos(mφ). L₊g = P + iQ is synthesised as its real and imaginary parts.
ScatteringTransforms.SphericalCore.task_local — Function
task_local(st) -> stA copy of st safe to run concurrently with it: the plan's read-only tables are shared and its analysis and synthesis scratch duplicated by Plans.task_local_plan. Release it with close_task_local!.
ScatteringTransforms.SphericalCore.close_task_local! — Function
close_task_local!(stl, st) -> nothingPlans.close_plan! every plan task_local(st), batch_transform or task_local_batch built for stl; plans stl shares with st stay open.
ScatteringTransforms.SphericalCore.band_multiplier — Function
Per-degree multiplier for the difference-of-Gaussians band-pass wavelet j.
ScatteringTransforms.SphericalCore.dog_sigma2 — Function
dog_sigma2(lmax, J, T) -> Vector{T}Gaussian-transfer variances for cutoffs ℓ_k = lmax / 2^k, k=0..J. Band j is lowpass(ℓ_{j-1}) − lowpass(ℓ_j), with scale 1 finest.
ScatteringTransforms.SphericalCore.structured_grid — Function
structured_grid(lmax, T) -> (Θ, Φ)Colatitudes Θ (length lmax+1) and longitudes Φ (length 2lmax+1) of the equiangular structured grid. Matches FastSphericalHarmonics.sph_points(lmax+1).
ScatteringTransforms.SphericalCore.plan_points — Function
plan_points(plan) -> (θ, φ) or nothingThe sample locations a spherical plan was built on, from which a transform is rebuilt on another process, or nothing when the plan is defined by its band limit alone (a structured grid).
ScatteringTransforms.SphericalCore.plan_weights — Function
plan_weights(plan) -> weights or nothingThe quadrature weights the plan averages with, or nothing for a backend that takes the unweighted sample mean or whose quadrature follows from its grid. A plan rebuilt on the same points needs these too: the in-core structured plan's Fejér weights are not uniform.
ScatteringTransforms.SphericalCore.plan_solver — Function
plan_solver(plan) -> (; rtol, maxiter, analysis)The analysis policy and fit tolerances of a scattered-sphere plan. nothing for a plan whose analysis is an exact transform.
ScatteringTransforms.SphericalCore.batch_plan — Function
batch_plan(plan, B) -> plan or nothingAn equivalent plan that transforms B co-located fields per call, for spherical_scattering_batch!, or nothing if this backend has no batched form. Only the batch width differs from plan.
Returns plan itself when Plans.batch_width(plan) == B, and otherwise a plan the caller owns and closes with Plans.close_plan!. Concurrent tasks use task_local_batch_plan.
ScatteringTransforms.SphericalCore.task_local_batch_plan — Function
task_local_batch_plan(plan, B) -> plan or nothingA B-wide plan safe to apply while plan is applied in another task, owned by the caller, or nothing when the backend has no batched form.
A spherical plan's analysis solves through its own scratch, so tasks cannot share one. At plan's own width this is Plans.task_local_plan(plan), and at any other width batch_plan builds a fresh one.
ScatteringTransforms.SphericalCore.supports_batch — Function
supports_batch(plan) -> BoolWhether batch_plan can widen this plan, answered without building one.
ScatteringTransforms.SphericalCore.plan_nufft — Function
plan_nufft(plan) -> SpectralBackends.AbstractSpectralBackendThe NUFFT backend a scattered-sphere plan resolved to, or AutoSpectralBackend() for a plan that runs none. Plans.spectral_backend reports NUFSHTSpectralBackend whichever NUFFT runs underneath, so a transform rebuilt on another process needs this too to run the same one.
ScatteringTransforms.SphericalCore.plan_spin — Function
plan_spin(plan) -> (spin-0 plan, spin-1 plan) or nothingThe spin-weighted plan pair a scattered-sphere plan carries for spherical_monogenic_components, or nothing for a plan built without one. Only the monogenic constructors build it. The pair is working state, so concurrent use needs Plans.task_local_plan.
ScatteringTransforms.SphericalCore.default_rtol — Function
default_rtol(spectral) -> RealTolerance for the scattered-sphere analysis solve under spectral: 1e-8 for the in-core direct sum, which evaluates the harmonics exactly, and 1e-4 for NUFSHT, whose analysis is accurate only to its own approximation error.
ScatteringTransforms.SphericalCore.make_spherical_plan — Function
make_spherical_plan(kind, spectral, θ, φ, lmax, T; rtol, maxiter, weights, ntrans, nufft, analysis)
-> AbstractSphericalPlanBuild the scattered-sphere plan selected by spectral over points (θ, φ) and band limit lmax. SpectralBackends.DirectSumSpectralBackend is the dependency-free default; SpectralBackends.NUFSHTSpectralBackend (or SpectralBackends.AutoSpectralBackend once the NUFSHT extension is loaded) uses the NUFSHT fast path.
ntrans = B builds a plan that transforms B co-located fields per call, and weights are the quadrature weights of the spherical mean. LeastSquares() fits coefficients and WeightedAdjoint() applies the weighted adjoint. kind = SphericalMonogenicScatteringTransform builds NUFSHT's spin pair for spherical_monogenic_components. The in-core plan takes the surface gradient of (−Δ_S)^{-1/2}U⁰ and accepts only an Auto nufft.
ScatteringTransforms.SphericalCore.make_structured_plan — Function
make_structured_plan(spectral, lmax, T; rtol, maxiter) -> AbstractSphericalPlanBuild the structured-sphere plan selected by spectral. SpectralBackends.DirectSumSpectralBackend is the dependency-free default (direct SHT on the grid); SpectralBackends.FSHTSpectralBackend (or SpectralBackends.AutoSpectralBackend once the FastSphericalHarmonics extension is loaded) uses the fast exact SHT.
ScatteringTransforms.SphericalCore.nusht_spherical_plan — Function
nusht_spherical_plan(kind, θ, φ, lmax, T; rtol, maxiter, weights, ntrans, nufft, analysis)Scattered-sphere plan on NUFSHT, a method the NUFSHT extension defines; this fallback throws an ArgumentError naming using NUFSHT.
ScatteringTransforms.SphericalCore.fsh_structured_plan — Function
fsh_structured_plan(lmax, T)Structured-sphere plan on FastSphericalHarmonics, a method the FastSphericalHarmonics extension defines; this fallback throws an ArgumentError naming using FastSphericalHarmonics.
Plotting
Methods are supplied by the CairoMakie extension.
ScatteringTransforms.plot_coefficients — Function
plot_coefficients(c; signal=nothing) — plot 1D scattering coefficients.
plot_coefficients(c; image=nothing) — plot 2D scattering coefficients.Passing the input adds a panel showing it. Requires using CairoMakie.
ScatteringTransforms.plot_filter_bank — Function
plot_filter_bank(fb) — plot a 1D or 2D filter bank. Requires `using CairoMakie`.