filter_quality — Rule-based row-level spectral quality filter

Group: Sample / feature filters · C ABI: n4m_outlier_detection_spectral_quality_*

Description

Stateless row-level spectrum quality filter.

Parameters

Name

Type

Default

max_nan_ratio

float

0.1

max_zero_ratio

float

0.5

min_variance

float

1e-08

max_value

float | None

None

min_value

float | None

None

check_inf

bool

True

API and bindings

C ABI (ABI 2): n4m_outlier_detection_spectral_quality_apply · n4m_outlier_detection_spectral_quality_create · n4m_outlier_detection_spectral_quality_destroy. Use the linked public header for the exact signature, configuration, and result handles.

Python (verified public re-export):

from n4m.outlier_detection import SpectralQualityFilter

Source signature: SpectralQualityFilter(max_nan_ratio: float = 0.1, max_zero_ratio: float = 0.5, min_variance: float = 1e-08, max_value: float | None = None, min_value: float | None = None, check_inf: bool = True).

R: no current source-verified entry point was found for this catalog method.

MATLAB / Octave: no current source-verified entry point was found for this catalog method.

Explanations

Bibliographic source

No canonical paper defines this conjunction of data-quality checks. It is an explicit internal quality-control rule set whose thresholds are user policy.

Mathematical principle

A row is kept only if every enabled rule passes: NaN fraction \(\le\) max_nan_ratio; no infinity when check_inf; exact-zero fraction \(\le\) max_zero_ratio; NaN-aware population variance \(\ge\) min_variance; and optional finite extrema within min_value/max_value. Fit is an idempotent no-op.

Appropriate uses

Rejecting empty, flat, non-finite, saturated, or out-of-range acquisitions before modeling.

Limits and validation

Thresholds are scale- and representation-specific. NaNs count as nonzero for the zero-ratio rule, and a row can pass these syntactic checks while remaining chemically implausible.

Implementation

Python role API n4m.outlier_detection.SpectralQualityFilter; ABI 2 family n4m_outlier_detection_spectral_quality_{create,apply,destroy}.

The ABI-2 implementation is the n4m_outlier_detection_spectral_quality_* lifecycle in libn4m.

Sources and provenance

https://github.com/GBeurier/nirs4all-methods/blob/main/cpp/src/core/filters/spectral_quality.h


See also: methods index · interactive dashboard