diff --git a/package-lock.json b/package-lock.json index 0649e74e9..18773f771 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "ml-array-mean": "^2.0.0", "ml-array-median": "^2.0.0", "ml-conrec": "^6.0.0", - "ml-gsd": "^14.2.0", + "ml-gsd": "^14.2.1", "ml-signal-processing": "^2.2.2", "ml-spectra-processing": "^14.29.1", "ml-tree-similarity": "^2.2.0", @@ -9401,9 +9401,9 @@ } }, "node_modules/ml-gsd": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/ml-gsd/-/ml-gsd-14.2.0.tgz", - "integrity": "sha512-dX/VA9yj8GnenbE7prMPuki9/8cV43VcTqaxeZ4stMuUuO98QhFKkkQ/rBgJ9/t0g/sXWtToihHGrIUbP8+AEA==", + "version": "14.2.1", + "resolved": "https://registry.npmjs.org/ml-gsd/-/ml-gsd-14.2.1.tgz", + "integrity": "sha512-5RwHGZL61Pf7LBVaWkQ4Qsnr1CHFg+pZ4sAxpufEMM4pignoS6NqVkwAk0aCRb97gZsLIL3srDcRRExNcqGGpw==", "license": "MIT", "dependencies": { "cheminfo-types": "^1.15.0", diff --git a/package.json b/package.json index 4f25b97c1..b5b73ddff 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,7 @@ "ml-array-mean": "^2.0.0", "ml-array-median": "^2.0.0", "ml-conrec": "^6.0.0", - "ml-gsd": "^14.2.0", + "ml-gsd": "^14.2.1", "ml-signal-processing": "^2.2.2", "ml-spectra-processing": "^14.29.1", "ml-tree-similarity": "^2.2.0", diff --git a/src/component/panels/PeaksPanel/PeaksPanel.tsx b/src/component/panels/PeaksPanel/PeaksPanel.tsx index 995fd25d4..680dc3706 100644 --- a/src/component/panels/PeaksPanel/PeaksPanel.tsx +++ b/src/component/panels/PeaksPanel/PeaksPanel.tsx @@ -111,14 +111,7 @@ function PeaksPanelInner(props: PeaksPanelInnerProps) { const filterPeaks = peaks.values.filter((peak) => isInRange(peak.x, { from, to }), ); - if (filterPeaks.length <= 15) { - dispatch({ type: 'OPTIMIZE_PEAKS', payload: { peaks: filterPeaks } }); - } else { - toaster.show({ - message: 'optimization can be done on no more than 15 peaks', - intent: 'danger', - }); - } + dispatch({ type: 'OPTIMIZE_PEAKS', payload: { peaks: filterPeaks } }); }; function toggleViewProperty(key: keyof FilterType) { diff --git a/src/component/reducer/actions/RangesActions.ts b/src/component/reducer/actions/RangesActions.ts index c067b6996..80a79a577 100644 --- a/src/component/reducer/actions/RangesActions.ts +++ b/src/component/reducer/actions/RangesActions.ts @@ -234,6 +234,7 @@ function handleAutoRangesDetection( broadWidth: 0.05, thresholdFactor: 8, minMaxRatio, + maxAbsoluteRatio: minMaxRatio, direction: lookNegative ? 'both' : 'positive', }, }; diff --git a/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts b/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts index 63cef1c70..05bc64342 100644 --- a/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts +++ b/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts @@ -48,6 +48,7 @@ export function autoPeakPicking( sensitivity: 100, shape: defaultPeakShape, noiseLevel: noise * noiseFactor, + maxAbsoluteRatio: minMaxRatio, // Threshold to determine if a given peak should be considered as a noise minMaxRatio, // Threshold to determine if a given peak should be considered as a noise realTopDetection: true, smoothY: false, diff --git a/src/data/data1d/Spectrum1D/peaks/optimizePeaks.ts b/src/data/data1d/Spectrum1D/peaks/optimizePeaks.ts index 057b512c1..ae6401cbc 100644 --- a/src/data/data1d/Spectrum1D/peaks/optimizePeaks.ts +++ b/src/data/data1d/Spectrum1D/peaks/optimizePeaks.ts @@ -36,6 +36,9 @@ export function optimizePeaks( groupingFactor: 10, stages: [ { + // Stage 1: local stabilization + factorLimits: 2, + maxNumberOfPeaks: 40, optimization: { kind: 'lm', options: { maxIterations: 20, errorTolerance: 1e-3 }, @@ -43,98 +46,100 @@ export function optimizePeaks( parameters: { fwhm: { optimize: true, - min: (peak: any) => (peak.shape?.fwhm ?? 0) / 2, + min: (peak: any) => (peak.shape?.fwhm ?? 0) * 0.5, max: (peak: any) => (peak.shape?.fwhm ?? 0) * 2, }, mu: { optimize: false }, x: { optimize: false }, y: { optimize: true, - init: (peak: any) => peak.y * 0.8, + init: (peak: any) => peak.y, }, }, }, { + factorLimits: 2, + maxNumberOfPeaks: 40, optimization: { kind: 'lm', - options: { maxIterations: 20, errorTolerance: 5e-4 }, + options: { maxIterations: 20, errorTolerance: 1e-3 }, }, parameters: { fwhm: { optimize: true, - min: (peak: any) => (peak.shape?.fwhm ?? 0) / 2, + min: (peak: any) => (peak.shape?.fwhm ?? 0) * 0.5, max: (peak: any) => (peak.shape?.fwhm ?? 0) * 2, }, mu: { optimize: false }, x: { optimize: false }, y: { optimize: true, + init: (peak: any) => peak.y, }, }, }, { + // Stage 2: regroup into the real overlapping cluster + factorLimits: 2, + maxNumberOfPeaks: 40, optimization: { kind: 'lm', - options: { maxIterations: 20, errorTolerance: 1e-5 }, + options: { maxIterations: 25, errorTolerance: 1e-4 }, }, parameters: { fwhm: { optimize: true, - min: (peak: any) => (peak.shape?.fwhm ?? 0) / 2, + min: (peak: any) => (peak.shape?.fwhm ?? 0) * 0.5, max: (peak: any) => (peak.shape?.fwhm ?? 0) * 2, }, mu: { optimize: true }, x: { optimize: false }, - y: { - optimize: true, - }, + y: { optimize: true }, }, }, { + // Stage 3: final polish + factorLimits: 2, + maxNumberOfPeaks: 40, optimization: { kind: 'lm', - options: { maxIterations: 20, errorTolerance: 5e-4 }, + options: { maxIterations: 30, errorTolerance: 1e-5 }, }, parameters: { fwhm: { optimize: true, - min: (peak: any) => (peak.shape?.fwhm ?? 0) / 3, - max: (peak: any) => (peak.shape?.fwhm ?? 0) * 3, + min: (peak: any) => (peak.shape?.fwhm ?? 0) * 0.5, + max: (peak: any) => (peak.shape?.fwhm ?? 0) * 2, }, mu: { optimize: true }, - x: { optimize: true }, - y: { optimize: true }, - }, - }, - { - optimization: { - kind: 'lm', - options: { maxIterations: 20, errorTolerance: 1e-4 }, - }, - parameters: { - fwhm: { + x: { optimize: true, - min: (peak: any) => (peak.shape?.fwhm ?? 0) / 2, - max: (peak: any) => (peak.shape?.fwhm ?? 0) * 2, + min: (peak: any) => peak.x - (peak.shape?.fwhm ?? 0) / 4, + max: (peak: any) => peak.x + (peak.shape?.fwhm ?? 0) / 4, }, - mu: { optimize: false }, - x: { optimize: true }, y: { optimize: true }, }, }, { + // Stage 3: final polish + factorLimits: 2, + maxNumberOfPeaks: 40, optimization: { kind: 'lm', - options: { maxIterations: 20, errorTolerance: 1e-8 }, + options: { maxIterations: 30, errorTolerance: 1e-5 }, }, parameters: { fwhm: { optimize: true, - min: (peak: any) => (peak.shape?.fwhm ?? 0) / 2, + min: (peak: any) => (peak.shape?.fwhm ?? 0) * 0.5, max: (peak: any) => (peak.shape?.fwhm ?? 0) * 2, }, mu: { optimize: true }, - x: { optimize: true }, + x: { + optimize: true, + min: (peak: any) => peak.x - (peak.shape?.fwhm ?? 0) / 4, + max: (peak: any) => peak.x + (peak.shape?.fwhm ?? 0) / 4, + }, y: { optimize: true }, }, }, diff --git a/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts b/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts index 494402256..64c8e9f2b 100644 --- a/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts +++ b/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts @@ -35,6 +35,7 @@ export function detectSignalsByMultipletAnalysis( to, frequency, minMaxRatio: 0.1, + maxAbsoluteRatio: 0.1, broadWidth: 0.25, broadRatio: 0.0025, optimize: true,