interface AutoContourDiagnostics { recommended: ThresholdDiagnostics; ridgeFree: ThresholdDiagnostics; } interface ThresholdDiagnostics { sigmaMultiplier: number; minLevel: number; occupancy: number; fdr: number; persistence: number; verticalRidgeScore: number; horizontalRidgeScore: number; } export type AutoContourResult = { /** * Recommended minimum contour level. */ minLevel: number; /** * Minimum contour level at which detected directional * ridge structures (e.g. t1-noise) are no longer present. */ minLevelWithoutT1Noise: number; /** * True when directional ridge structures were detected * at the recommended minimum. */ hasT1Noise: boolean; /** * Same values expressed in multiples of the noise level. */ sigmaMultiplier: number; sigmaMultiplierWithoutT1Noise: number; /** * Maximum absolute value in the analysis matrix used for contour level selection. */ maxAbsoluteValue: number; } & (TDiagnostics extends true ? { diagnostics: AutoContourDiagnostics; } : { diagnostics?: AutoContourDiagnostics; }); export interface AutoContourOptions { /** * Multiplicative ratio between consecutive contour levels. * * The contour levels are generated as: * * Lₙ = L₀ × contourRatioⁿ * * Must be greater than 1. * * A smaller value produces more closely spaced contour levels, * while a larger value produces fewer, more widely spaced levels. * * @default 1.4 */ contourRatio?: number; /** * Maximum acceptable false discovery rate (FDR) for the * automatically selected minimum contour level. * * The FDR estimates the fraction of pixels above the selected * threshold that could be explained by Gaussian noise, assuming * the supplied noiseLevel is accurate. * * Smaller values produce a cleaner visualization but may suppress * weak peaks. * * @default 0.05 */ maxFdr?: number; /** * Maximum fraction of the spectrum that may be above the * automatically selected minimum contour level. * * This prevents very low thresholds from producing contours over * a large fraction of the spectrum. * * Expressed as a fraction in the range [0, 1]. * * For example, 0.02 means that at most 2% of pixels may be above * the minimum contour threshold. * * @default 0.02 */ maxOccupancy?: number; /** * Minimum persistence required for spectral structures across * successive exponential contour levels. * * Persistence measures how much of the active spectral structure * remains when moving from one contour level to the next. * * Higher values favor stable, coherent peaks and reject fragmented * noise structures more aggressively. * * Expressed as a fraction in the range [0, 1]. * * @default 0.35 */ minPersistence?: number; /** * Maximum acceptable score for vertical ridge-like structures. * * This is primarily intended to detect structured artifacts such * as t1 noise, which often appears as elongated structures along * the F1 dimension. * * Smaller values make the ridge-free threshold more conservative. * * @default 0.25 */ maxVerticalRidgeScore?: number; /** * Maximum acceptable score for horizontal ridge-like structures. * * This can detect horizontal streaks or other structured artifacts * extending predominantly along the F2 dimension. * * Smaller values make the ridge-free threshold more conservative. * * @default 0.25 */ maxHorizontalRidgeScore?: number; /** * Fraction of a row or column that must be occupied by active * contour pixels for the row or column to be considered * ridge-like. * * For vertical ridge detection, a column is considered suspicious * when the fraction of active pixels along F1 is greater than or * equal to this value. * * For horizontal ridge detection, the same criterion is applied * along F2. * * Expressed as a fraction in the range [0, 1]. * * Lower values make ridge detection more sensitive. * * @default 0.5 */ ridgeCoverageThreshold?: number; /** * Lowest threshold considered by the automatic contour search, * expressed as a multiple of the supplied noise level. * * For example, minSigma = 2 means that thresholds below 2 × * noiseLevel are never considered. * * Lower values can preserve weaker peaks but increase the risk * of including noise. * * @default 2 */ minSigma?: number; /** * Exponent used to determine the spacing between candidate * minimum contour levels. * * Candidate thresholds are generated multiplicatively using: * * candidateStep = contourRatio ** candidateRatioExponent * * For example, with contourRatio = 1.4 and exponent = 0.5: * * candidateStep = sqrt(1.4) * * A value of 1 evaluates candidates directly on the contour-level * hierarchy. Smaller values provide finer threshold resolution * while increasing the amount of analysis. * * @default 0.5 */ candidateRatioExponent?: number; /** * Number of successive contour levels used when evaluating * spectral persistence. * * A larger value requires spectral structures to remain stable * across more contour levels and therefore produces a more * conservative threshold. * * @default 4 */ persistenceLevels?: number; /** * Maximum dimension used for spatial analysis. * * Large input matrices are reduced using max pooling before * calculating occupancy, persistence, and ridge metrics. * * The original matrix is not modified. * * Max pooling is used instead of averaging so that narrow, * high-intensity spectral features are preserved during analysis. * * Larger values improve spatial resolution but increase * computational cost and memory usage. * * @default 384 */ maxAnalysisDimension?: number; /** * Whether diagnostic information should be returned. * * Diagnostics include the selected thresholds, FDR, occupancy, * persistence, vertical and horizontal ridge scores, and the * individual criteria used by the automatic threshold selection. * * Disable this when diagnostics are not needed and the smallest * possible result object is preferred. * * @default true */ diagnostics?: boolean; } export declare function findAutomaticContourLevels(matrix: ArrayLike, rows: number, cols: number, noiseLevel: number, options: AutoContourOptions & { diagnostics: true; }): AutoContourResult; export declare function findAutomaticContourLevels(matrix: ArrayLike, rows: number, cols: number, noiseLevel: number, options?: AutoContourOptions): AutoContourResult; export declare function findAutomaticContourLevels(matrix: ArrayLike, rows: number, cols: number, noiseLevel: number, options: AutoContourOptions & { diagnostics: false; }): AutoContourResult; export {}; //# sourceMappingURL=findAutomaticContourLevels.d.ts.map