|
| 1 | +export interface XYNumberArray { |
| 2 | + x: Array<number> | Float64Array; |
| 3 | + y: Array<number> | Float64Array; |
| 4 | +} |
| 5 | + |
| 6 | +interface GsdOptions { |
| 7 | + /** |
| 8 | + * Noise threshold in spectrum y units. Default is three/thresholdFactor times the absolute median of data.y. |
| 9 | + * @default `median(data.y) * (options.thresholdFactor || 3)` |
| 10 | + */ |
| 11 | + noiseLevel?: number; |
| 12 | + /** |
| 13 | + * Threshold to determine if a given peak should be considered as a noise, bases on its relative height compared to the highest peak. |
| 14 | + * @default 0.01 |
| 15 | + */ |
| 16 | + minMaxRatio?: number; |
| 17 | + /** |
| 18 | + * If broadRatio is higher than 0, then all the peaks which second derivative smaller than broadRatio * maxAbsSecondDerivative will be marked with the soft mask equal to true. |
| 19 | + * @default 0.00025 |
| 20 | + */ |
| 21 | + broadRatio?: number; |
| 22 | + /** |
| 23 | + * Select the peak intensities from a smoothed version of the independent variables. |
| 24 | + * @default true |
| 25 | + */ |
| 26 | + smoothY?: boolean; |
| 27 | + /** |
| 28 | + * if it is true, it optimizes the x and intensity by extrapolation. |
| 29 | + * @default false |
| 30 | + */ |
| 31 | + realTopDetection?: boolean; |
| 32 | + /** |
| 33 | + * options to shape used to adapt the FWHM |
| 34 | + * @default {kind:'gaussian'} |
| 35 | + */ |
| 36 | + shape?: { kind: string }; |
| 37 | + // /** |
| 38 | + // * Threshold to determine if some peak is candidate to clustering into range. |
| 39 | + // * @default 0.25 |
| 40 | + // */ |
| 41 | + // broadWidth: number; |
| 42 | + /** |
| 43 | + * Options for savitz Golay |
| 44 | + */ |
| 45 | + sgOptions?: { windowSize: number; polynomial: number }; |
| 46 | + /** |
| 47 | + * filter based on intensity of the first derive. |
| 48 | + * @default -1; |
| 49 | + */ |
| 50 | +} |
| 51 | + |
| 52 | +export interface Peak { |
| 53 | + x: number; |
| 54 | + y: number; |
| 55 | + width: number; |
| 56 | + left?: number; |
| 57 | + right?: number; |
| 58 | + base?: number; |
| 59 | + soft?: boolean; |
| 60 | + kind?: string; |
| 61 | +} |
| 62 | + |
| 63 | +export interface OptimizePeaksOptions { |
| 64 | + /** |
| 65 | + * factor to determine the width at the moment to group the peaks in signals in 'GSD.optimizePeaks' function. |
| 66 | + * @default 1 |
| 67 | + */ |
| 68 | + factorWidth?: number; |
| 69 | + /** |
| 70 | + * times of width to use to optimize peaks |
| 71 | + * @default 2 |
| 72 | + */ |
| 73 | + factorLimits?: number; |
| 74 | + /** |
| 75 | + * options to shape used to adapt the FWHM |
| 76 | + * @default {kind:'gaussian'} |
| 77 | + */ |
| 78 | + shape?: { kind: string }; |
| 79 | + /** |
| 80 | + * options for optimization step |
| 81 | + */ |
| 82 | + optimization?: OptimizationOptions; |
| 83 | +} |
| 84 | + |
| 85 | +export interface OptimizationOptions { |
| 86 | + /** |
| 87 | + * represent the algorithm to optimize. |
| 88 | + * @default {kind:'lm'} |
| 89 | + */ |
| 90 | + kind?: string; |
| 91 | + /** |
| 92 | + * Time limit to stop the optimization in seconds. |
| 93 | + * @default 10 |
| 94 | + */ |
| 95 | + timeout?: number |
| 96 | +} |
| 97 | + |
| 98 | +export interface OptimizedPeak { |
| 99 | + x: number; |
| 100 | + y: number; |
| 101 | + width: number; |
| 102 | + mu?: number; |
| 103 | +} |
| 104 | + |
| 105 | +export function gsd(data: XYNumberArray, options?: GsdOptions): Peak[]; |
| 106 | + |
| 107 | +export function optimizePeaks( |
| 108 | + data: XYNumberArray, |
| 109 | + peakList: Peak[], |
| 110 | + options?: OptimizePeaksOptions, |
| 111 | +): OptimizedPeak[]; |
| 112 | + |
| 113 | +export function joinBroadPeaks( |
| 114 | + peakList: Peak[], |
| 115 | + options?: JoinBroadPeaksOptions, |
| 116 | +): Peak[]; |
| 117 | + |
| 118 | +export interface JoinBroadPeaksOptions { |
| 119 | + /** |
| 120 | + * @default 0.25 |
| 121 | + */ |
| 122 | + width: number; |
| 123 | + /** |
| 124 | + * @default { kind: 'gaussian' } |
| 125 | + */ |
| 126 | + shape: { kind: string }; |
| 127 | + /** |
| 128 | + * @default { kind: 'lm', timeout: 10 } |
| 129 | + */ |
| 130 | + optimization: OptimizationOptions; |
| 131 | +} |
| 132 | + |
| 133 | +export function groupPeaks(peakList: Peak[], factor?: number): Peak[][]; |
| 134 | + |
| 135 | +export function broadenPeaks( |
| 136 | + peakList: Peak[], |
| 137 | + options?: { |
| 138 | + /** |
| 139 | + * @default 2 |
| 140 | + */ |
| 141 | + factor: number; |
| 142 | + /** |
| 143 | + * @default false |
| 144 | + */ |
| 145 | + overlap: boolean; |
| 146 | + }, |
| 147 | +): Peak[]; |
0 commit comments