nmr-processing 6.0.8 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -1
- package/lib/peaks/NMRPeak1D.d.ts +5 -2
- package/lib/peaks/peaksToRanges.d.ts +3 -1
- package/lib/peaks/peaksToRanges.js.map +1 -1
- package/lib/peaks/util/jAnalyzer.d.ts +1 -1
- package/lib/peaks/util/jAnalyzer.js.map +1 -1
- package/lib/prediction/predictAllSpectra.d.ts +18 -0
- package/lib/prediction/predictAllSpectra.js +40 -0
- package/lib/prediction/predictAllSpectra.js.map +1 -0
- package/lib/prediction/utils/getFilteredIDiaIDs.d.ts +1 -1
- package/lib/utilities/resurrectRange.js +12 -16
- package/lib/utilities/resurrectRange.js.map +1 -1
- package/lib/xy/xyAutoPeaksPicking.d.ts +5 -4
- package/lib/xy/xyAutoPeaksPicking.js +14 -23
- package/lib/xy/xyAutoPeaksPicking.js.map +1 -1
- package/lib/xyz/xyzAutoZonesPicking.js +5 -1
- package/lib/xyz/xyzAutoZonesPicking.js.map +1 -1
- package/lib-esm/index.js +1 -0
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/peaks/peaksToRanges.js.map +1 -1
- package/lib-esm/peaks/util/jAnalyzer.js.map +1 -1
- package/lib-esm/prediction/predictAllSpectra.js +36 -0
- package/lib-esm/prediction/predictAllSpectra.js.map +1 -0
- package/lib-esm/utilities/resurrectRange.js +12 -16
- package/lib-esm/utilities/resurrectRange.js.map +1 -1
- package/lib-esm/xy/xyAutoPeaksPicking.js +15 -24
- package/lib-esm/xy/xyAutoPeaksPicking.js.map +1 -1
- package/package.json +14 -15
- package/src/index.ts +1 -0
- package/src/{openchemlib.d.ts → openchemlib-utils.d.ts} +0 -1
- package/src/peaks/NMRPeak1D.ts +5 -2
- package/src/peaks/peaksToRanges.ts +5 -3
- package/src/peaks/util/jAnalyzer.ts +3 -1
- package/src/prediction/predictAllSpectra.ts +48 -0
- package/src/utilities/resurrectRange.ts +17 -17
- package/src/xy/xyAutoPeaksPicking.ts +25 -36
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DataXY } from 'cheminfo-types';
|
|
2
|
-
import { gsd, joinBroadPeaks,
|
|
2
|
+
import { gsd, optimizePeaks, joinBroadPeaks, appendShapeAndFWHM } from 'ml-gsd';
|
|
3
3
|
import type {
|
|
4
|
-
Peak1D,
|
|
5
4
|
GSDOptions,
|
|
6
5
|
OptimizePeaksOptions,
|
|
7
6
|
JoinBroadPeaksOptions,
|
|
@@ -12,6 +11,8 @@ import {
|
|
|
12
11
|
xAbsoluteMedian,
|
|
13
12
|
} from 'ml-spectra-processing';
|
|
14
13
|
|
|
14
|
+
import { NMRPeak1D } from '..';
|
|
15
|
+
|
|
15
16
|
/**
|
|
16
17
|
* Implementation of the peak picking method described by Cobas in:
|
|
17
18
|
* A new approach to improving automated analysis of proton NMR spectra
|
|
@@ -25,7 +26,7 @@ interface OptionsGetCutOff {
|
|
|
25
26
|
thresholdFactor: number;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export interface
|
|
29
|
+
export interface GetPeakListOptions
|
|
29
30
|
extends GSDOptions,
|
|
30
31
|
OptimizePeaksOptions,
|
|
31
32
|
JoinBroadPeaksOptions {
|
|
@@ -35,9 +36,7 @@ export interface IGetPeakListOptions
|
|
|
35
36
|
*/
|
|
36
37
|
optimize: boolean;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
export interface OptionsXYAutoPeaksPicking
|
|
40
|
-
extends Partial<IGetPeakListOptions> {
|
|
39
|
+
export interface OptionsXYAutoPeaksPicking extends Partial<GetPeakListOptions> {
|
|
41
40
|
/**
|
|
42
41
|
* Low limit value in the x axis to extract a sub set of points from the input data.
|
|
43
42
|
*/
|
|
@@ -66,7 +65,7 @@ export interface OptionsXYAutoPeaksPicking
|
|
|
66
65
|
export function xyAutoPeaksPicking(
|
|
67
66
|
data: DataXY,
|
|
68
67
|
options: OptionsXYAutoPeaksPicking = {},
|
|
69
|
-
):
|
|
68
|
+
): NMRPeak1D[] {
|
|
70
69
|
const {
|
|
71
70
|
from,
|
|
72
71
|
to,
|
|
@@ -77,28 +76,31 @@ export function xyAutoPeaksPicking(
|
|
|
77
76
|
useSanPlot = false,
|
|
78
77
|
smoothY = true,
|
|
79
78
|
optimize = false,
|
|
80
|
-
|
|
79
|
+
factorLimits = 4,
|
|
81
80
|
realTopDetection = true,
|
|
82
81
|
shape = { kind: 'gaussian' },
|
|
83
82
|
optimization = { kind: 'lm' },
|
|
84
83
|
broadWidth = 0.25,
|
|
84
|
+
sgOptions = {},
|
|
85
85
|
lookNegative = false,
|
|
86
|
-
sgOptions = { windowSize: 9, polynomial: 3 },
|
|
87
86
|
} = options;
|
|
88
87
|
|
|
88
|
+
const { windowSize = 9, polynomial = 3 } = sgOptions;
|
|
89
|
+
|
|
89
90
|
if (from !== undefined && to !== undefined) {
|
|
90
91
|
data = xyExtract(data, { zones: [{ from, to }] });
|
|
91
92
|
}
|
|
92
|
-
if (data.x.length <
|
|
93
|
+
if (data.x.length < windowSize) return [];
|
|
93
94
|
|
|
94
95
|
const cutOff = getCutOff(data.y, { noiseLevel, useSanPlot, thresholdFactor });
|
|
95
96
|
|
|
96
|
-
let getPeakOptions:
|
|
97
|
+
let getPeakOptions: GetPeakListOptions = {
|
|
97
98
|
shape,
|
|
98
99
|
broadWidth,
|
|
99
100
|
optimize,
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
factorLimits,
|
|
102
|
+
maxCriteria: true,
|
|
103
|
+
sgOptions: { windowSize, polynomial },
|
|
102
104
|
minMaxRatio,
|
|
103
105
|
broadRatio,
|
|
104
106
|
noiseLevel: cutOff.positive,
|
|
@@ -111,17 +113,19 @@ export function xyAutoPeaksPicking(
|
|
|
111
113
|
|
|
112
114
|
if (lookNegative) {
|
|
113
115
|
getPeakOptions.noiseLevel = cutOff.negative;
|
|
114
|
-
|
|
116
|
+
getPeakOptions.maxCriteria = false;
|
|
117
|
+
peaks.push(...getPeakList(data, getPeakOptions));
|
|
115
118
|
}
|
|
116
119
|
return peaks;
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
function getPeakList(data: DataXY, options:
|
|
122
|
+
function getPeakList(data: DataXY, options: GetPeakListOptions) {
|
|
120
123
|
const {
|
|
121
124
|
shape,
|
|
122
125
|
broadWidth,
|
|
123
126
|
optimize,
|
|
124
|
-
|
|
127
|
+
maxCriteria,
|
|
128
|
+
factorLimits,
|
|
125
129
|
sgOptions,
|
|
126
130
|
minMaxRatio,
|
|
127
131
|
broadRatio,
|
|
@@ -132,8 +136,8 @@ function getPeakList(data: DataXY, options: IGetPeakListOptions) {
|
|
|
132
136
|
} = options;
|
|
133
137
|
|
|
134
138
|
let peakList = gsd(data, {
|
|
135
|
-
shape,
|
|
136
139
|
sgOptions,
|
|
140
|
+
maxCriteria,
|
|
137
141
|
minMaxRatio,
|
|
138
142
|
noiseLevel,
|
|
139
143
|
smoothY,
|
|
@@ -141,7 +145,7 @@ function getPeakList(data: DataXY, options: IGetPeakListOptions) {
|
|
|
141
145
|
});
|
|
142
146
|
|
|
143
147
|
if (broadWidth) {
|
|
144
|
-
peakList = joinBroadPeaks(
|
|
148
|
+
peakList = joinBroadPeaks(peakList, {
|
|
145
149
|
broadRatio,
|
|
146
150
|
broadWidth,
|
|
147
151
|
shape,
|
|
@@ -150,29 +154,14 @@ function getPeakList(data: DataXY, options: IGetPeakListOptions) {
|
|
|
150
154
|
}
|
|
151
155
|
|
|
152
156
|
if (optimize) {
|
|
153
|
-
|
|
157
|
+
return optimizePeaks(data, peakList, {
|
|
154
158
|
shape,
|
|
155
|
-
|
|
159
|
+
factorLimits,
|
|
156
160
|
optimization,
|
|
157
161
|
});
|
|
158
162
|
}
|
|
159
163
|
|
|
160
|
-
return peakList;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function getNegativePeaks(data: DataXY, options: IGetPeakListOptions) {
|
|
164
|
-
let { x, y } = data;
|
|
165
|
-
let negativeDataY = new Float64Array(data.y.length);
|
|
166
|
-
for (let i = 0; i < negativeDataY.length; i++) {
|
|
167
|
-
negativeDataY[i] = -1 * y[i];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let peakList = getPeakList({ x, y: negativeDataY }, options);
|
|
171
|
-
|
|
172
|
-
for (const peak of peakList) {
|
|
173
|
-
peak.y *= -1;
|
|
174
|
-
}
|
|
175
|
-
return peakList;
|
|
164
|
+
return appendShapeAndFWHM(peakList, { shape });
|
|
176
165
|
}
|
|
177
166
|
|
|
178
167
|
function getCutOff(data: number[] | Float64Array, options: OptionsGetCutOff) {
|