From 90a75a77d25630170d806007664aa5ef184b5466 Mon Sep 17 00:00:00 2001 From: Jose Alejandro Bolanos Arroyave Date: Fri, 23 Sep 2022 11:10:02 -0500 Subject: [PATCH] fix: peak shape drawing (#1767) * chore: change default shape to Lorentzian. close: #1747 * chore: pass from-to to peakToXY close: #1746 --- package-lock.json | 26 +++++++++++++------ package.json | 4 +-- src/component/1d/peaks/PeaksShapes.tsx | 1 - src/component/1d/peaks/usePeakShapesPath.ts | 8 ++++-- .../Spectrum1D/peaks/autoPeakPicking.ts | 1 + .../Spectrum1D/ranges/autoRangesDetection.ts | 1 + 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index a599e99c6..4c73d31aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "nmr-correlation": "^2.3.3", "nmr-load-save": "^0.2.1", "nmr-parser": "^2.0.1", - "nmr-processing": "^9.1.0", + "nmr-processing": "^9.2.0", "nmredata": "^0.7.1", "numeral": "^2.0.6", "openchemlib": "^8.0.1", @@ -8743,6 +8743,15 @@ "resolved": "https://registry.npmjs.org/ml-conrec/-/ml-conrec-3.2.1.tgz", "integrity": "sha512-lyme1FxJAFKrsktywn4N+67FJLBdQ3w9TI6o5dtJ1GBTX08n/z7tmxd4wQDto2vGPBepeOO+eGJTT3wJT+5hyg==" }, + "node_modules/ml-direct": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ml-direct/-/ml-direct-0.1.1.tgz", + "integrity": "sha512-9CP/MgFcPcmch9YvaroPePEkNITcFRt8orJzDY7MBNT5oszBiFBccWVN4358QbPOg26fWqH2CBhLIJKgjYfnBA==", + "dependencies": { + "ml-matrix": "^6.10.2", + "ml-spectra-processing": "^11.12.0" + } + }, "node_modules/ml-disjoint-set": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/ml-disjoint-set/-/ml-disjoint-set-1.0.0.tgz", @@ -8772,9 +8781,9 @@ } }, "node_modules/ml-gsd": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/ml-gsd/-/ml-gsd-12.1.0.tgz", - "integrity": "sha512-YzqsPtKaYBIE+qbt6ida0y0AdU+xKpjpjeFaruCjh3WPdNF7HAbfOGWwj+opuBsrhvRZjCoOOmGGRDsfDMVD7A==", + "version": "12.1.2", + "resolved": "https://registry.npmjs.org/ml-gsd/-/ml-gsd-12.1.2.tgz", + "integrity": "sha512-UIURtVzRzMJAvbyGZGW5T1cYTRCNKLFkTOf+MgaSox2s/EeTrw+CWWRkPdkElZCPau001II8hGYMWav+ujvtcg==", "dependencies": { "@lukeed/uuid": "^2.0.0", "cheminfo-types": "^1.1.0", @@ -9175,9 +9184,9 @@ } }, "node_modules/nmr-processing": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/nmr-processing/-/nmr-processing-9.1.0.tgz", - "integrity": "sha512-r1Nw3fbfWgEOBwQ6WHQ4yCb5n3BxClyi/FE0COHggemqyvdZ9QptJgdrv17feyc6HI/MX+IzLH+7zsZIC+NXkA==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/nmr-processing/-/nmr-processing-9.2.0.tgz", + "integrity": "sha512-c8KizuK/VQJBJtexAGGPX0i7+GAfLDAHjAFBas9jUnjybBJ5ebw0MOE4ioR3qoviI6a5cZOxgBIUhmnNDsPFaA==", "dependencies": { "@lukeed/uuid": "^2.0.0", "binary-search": "^1.3.6", @@ -9189,7 +9198,8 @@ "ml-array-mean": "^1.1.6", "ml-array-rescale": "^1.3.7", "ml-array-sum": "^1.1.6", - "ml-gsd": "^12.1.0", + "ml-direct": "^0.1.1", + "ml-gsd": "^12.1.2", "ml-hclust": "^3.1.0", "ml-levenberg-marquardt": "^4.1.0", "ml-matrix": "^6.10.2", diff --git a/package.json b/package.json index b4c36423e..51958342b 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "nmr-correlation": "^2.3.3", "nmr-load-save": "^0.2.1", "nmr-parser": "^2.0.1", - "nmr-processing": "^9.1.0", + "nmr-processing": "^9.2.0", "nmredata": "^0.7.1", "numeral": "^2.0.6", "openchemlib": "^8.0.1", @@ -127,4 +127,4 @@ "typescript": "~4.8.3", "vite": "^3.1.1" } -} +} \ No newline at end of file diff --git a/src/component/1d/peaks/PeaksShapes.tsx b/src/component/1d/peaks/PeaksShapes.tsx index bd33080a9..9722ea60f 100644 --- a/src/component/1d/peaks/PeaksShapes.tsx +++ b/src/component/1d/peaks/PeaksShapes.tsx @@ -46,7 +46,6 @@ function PeaksShapesItems(props: { vAlign: number }) { {' '} {spectrum.peaks.values.map((peak) => { const { fill, path } = getPath({ target: 'peakShape', peak }); - return ( | null = null; switch (target) { case 'peakShape': pathSeries = peakToXY(options.peak, { - frequency: spectrum.info.originFrequency, + frequency, + nbPoints: 1024, + from: options.peak.x - (options.peak.width / frequency) * 9, + to: options.peak.x + (options.peak.width / frequency) * 9, }); break; case 'peaksSum': pathSeries = peaksToXY(options.peaks, { - frequency: spectrum.info.originFrequency, + frequency, nbPoints: width, from: xDomain[0], to: xDomain[1], diff --git a/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts b/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts index d8d6f32af..5389e2573 100644 --- a/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts +++ b/src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts @@ -30,6 +30,7 @@ export function autoPeakPicking(datum1D: Datum1D, options) { { frequency, direction, + shape: { kind: 'lorentzian' }, noiseLevel: noise * noiseFactor, minMaxRatio, // Threshold to determine if a given peak should be considered as a noise realTopDetection: true, diff --git a/src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts b/src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts index f4d573a71..06872d94b 100644 --- a/src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts +++ b/src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts @@ -4,6 +4,7 @@ import { Datum1D, Range } from '../../../types/data1d'; const defaultPeakPickingOptions = { minMaxRatio: 1, + shape: { kind: 'lorentzian' }, realTopDetection: true, maxCriteria: true, smoothY: false,