nmr-processing 3.4.0 → 6.0.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/assignment/get13CAssignments.js.map +1 -1
- package/lib/assignment/utils/buildAssignments.js +0 -1
- package/lib/assignment/utils/buildAssignments.js.map +1 -1
- package/lib/assignment/utils/createMapPossibleAssignments.js +0 -1
- package/lib/assignment/utils/createMapPossibleAssignments.js.map +1 -1
- package/lib/constants/couplingValues.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/peaks/peaksFilterImpurities.js +1 -1
- package/lib/peaks/peaksFilterImpurities.js.map +1 -1
- package/lib/peaks/peaksToRanges.js +11 -17
- package/lib/peaks/peaksToRanges.js.map +1 -1
- package/lib/peaks/util/determineRealTop.d.ts +2 -2
- package/lib/peaks/util/determineRealTop.js +3 -2
- package/lib/peaks/util/determineRealTop.js.map +1 -1
- package/lib/peaks/util/jAnalyzer.js +12 -13
- package/lib/peaks/util/jAnalyzer.js.map +1 -1
- package/lib/peaks/util/peakOptimizer.d.ts +2 -2
- package/lib/peaks/util/peakOptimizer.js.map +1 -1
- package/lib/prediction/predictAll.js +1 -1
- package/lib/prediction/predictAll.js.map +1 -1
- package/lib/prediction/predictHSQC.js.map +1 -1
- package/lib/prediction/predictProton.js +1 -1
- package/lib/prediction/predictProton.js.map +1 -1
- package/lib/prediction/utils/getFilteredIDiaIDs.js.map +1 -1
- package/lib/prediction/utils/getNuclei.js +1 -1
- package/lib/prediction/utils/getNuclei.js.map +1 -1
- package/lib/prediction/utils/getPredictions.d.ts +2 -2
- package/lib/prediction/utils/queryByHOSE.js.map +1 -1
- package/lib/ranges/rangesToXY.d.ts +2 -2
- package/lib/ranges/rangesToXY.js +10 -2
- package/lib/ranges/rangesToXY.js.map +1 -1
- package/lib/signal/signalJoinCouplings.d.ts +1 -1
- package/lib/signal/signalJoinCouplings.js +3 -3
- package/lib/signal/signalJoinCouplings.js.map +1 -1
- package/lib/signals/signalsJoin.d.ts +1 -1
- package/lib/signals/signalsJoin.js +7 -7
- package/lib/signals/signalsJoin.js.map +1 -1
- package/lib/signals/signalsToXY.d.ts +2 -2
- package/lib/signals/simulation/simulate1D.d.ts +4 -3
- package/lib/signals/simulation/simulate1D.js.map +1 -1
- package/lib/signals/simulation/splitSpinSystem.js.map +1 -1
- package/lib/types/NMRPeak1D.d.ts +2 -9
- package/lib/types/NMRSignal2D.d.ts +6 -6
- package/lib/types/NMRZone.d.ts +3 -7
- package/lib/types/jcoupling.d.ts +1 -1
- package/lib/types/modules/nmr-parser.d.ts +11 -0
- package/lib/types/modules/nmr-parser.js +2 -0
- package/lib/types/modules/nmr-parser.js.map +1 -0
- package/lib/types/prediction1D.d.ts +2 -2
- package/lib/utilities/joinPatterns.js.map +1 -1
- package/lib/xy/xyAutoPeaksPicking.d.ts +4 -60
- package/lib/xy/xyAutoPeaksPicking.js +3 -3
- package/lib/xy/xyAutoPeaksPicking.js.map +1 -1
- package/lib/xyz/{xyzAutoPeaksPicking.d.ts → xyzAutoZonesPicking.d.ts} +2 -2
- package/lib/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +38 -24
- package/lib/xyz/xyzAutoZonesPicking.js.map +1 -0
- package/lib/xyz/xyzJResAnalyzer.js.map +1 -1
- package/lib-esm/assignment/get13CAssignments.js.map +1 -1
- package/lib-esm/assignment/utils/buildAssignments.js +0 -1
- package/lib-esm/assignment/utils/buildAssignments.js.map +1 -1
- package/lib-esm/assignment/utils/createMapPossibleAssignments.js +0 -1
- package/lib-esm/assignment/utils/createMapPossibleAssignments.js.map +1 -1
- package/lib-esm/constants/couplingValues.js.map +1 -1
- package/lib-esm/index.js +1 -1
- package/lib-esm/peaks/peaksFilterImpurities.js +1 -1
- package/lib-esm/peaks/peaksFilterImpurities.js.map +1 -1
- package/lib-esm/peaks/peaksToRanges.js +11 -17
- package/lib-esm/peaks/peaksToRanges.js.map +1 -1
- package/lib-esm/peaks/util/determineRealTop.js +4 -3
- package/lib-esm/peaks/util/determineRealTop.js.map +1 -1
- package/lib-esm/peaks/util/jAnalyzer.js +12 -13
- package/lib-esm/peaks/util/jAnalyzer.js.map +1 -1
- package/lib-esm/peaks/util/peakOptimizer.js.map +1 -1
- package/lib-esm/prediction/predictAll.js +1 -1
- package/lib-esm/prediction/predictAll.js.map +1 -1
- package/lib-esm/prediction/predictHSQC.js.map +1 -1
- package/lib-esm/prediction/predictProton.js +1 -1
- package/lib-esm/prediction/predictProton.js.map +1 -1
- package/lib-esm/prediction/utils/getFilteredIDiaIDs.js.map +1 -1
- package/lib-esm/prediction/utils/getNuclei.js +1 -1
- package/lib-esm/prediction/utils/getNuclei.js.map +1 -1
- package/lib-esm/prediction/utils/queryByHOSE.js.map +1 -1
- package/lib-esm/ranges/rangesToXY.js +10 -2
- package/lib-esm/ranges/rangesToXY.js.map +1 -1
- package/lib-esm/signal/signalJoinCouplings.js +3 -3
- package/lib-esm/signal/signalJoinCouplings.js.map +1 -1
- package/lib-esm/signals/signalsJoin.js +7 -7
- package/lib-esm/signals/signalsJoin.js.map +1 -1
- package/lib-esm/signals/simulation/simulate1D.js.map +1 -1
- package/lib-esm/signals/simulation/splitSpinSystem.js.map +1 -1
- package/lib-esm/types/modules/nmr-parser.js +2 -0
- package/lib-esm/types/modules/nmr-parser.js.map +1 -0
- package/lib-esm/utilities/joinPatterns.js.map +1 -1
- package/lib-esm/xy/xyAutoPeaksPicking.js +3 -3
- package/lib-esm/xy/xyAutoPeaksPicking.js.map +1 -1
- package/lib-esm/xyz/{xyzAutoPeaksPicking.js → xyzAutoZonesPicking.js} +36 -22
- package/lib-esm/xyz/xyzAutoZonesPicking.js.map +1 -0
- package/lib-esm/xyz/xyzJResAnalyzer.js.map +1 -1
- package/package.json +19 -16
- package/src/assignment/get13CAssignments.ts +4 -1
- package/src/assignment/utils/buildAssignments.ts +2 -5
- package/src/assignment/utils/createMapPossibleAssignments.ts +4 -2
- package/src/constants/couplingValues.ts +1 -1
- package/src/index.ts +1 -1
- package/src/peaks/peaksFilterImpurities.ts +1 -1
- package/src/peaks/peaksToRanges.ts +11 -17
- package/src/peaks/util/determineRealTop.ts +6 -9
- package/src/peaks/util/jAnalyzer.ts +14 -16
- package/src/peaks/util/peakOptimizer.ts +4 -3
- package/src/prediction/predictAll.ts +5 -5
- package/src/prediction/predictHSQC.ts +4 -1
- package/src/prediction/predictProton.ts +1 -1
- package/src/prediction/utils/getFilteredIDiaIDs.ts +1 -2
- package/src/prediction/utils/getNuclei.ts +3 -3
- package/src/prediction/utils/getPredictions.ts +3 -3
- package/src/prediction/utils/queryByHOSE.ts +1 -1
- package/src/ranges/rangesToXY.ts +12 -5
- package/src/signal/signalJoinCouplings.ts +3 -3
- package/src/signals/signalsJoin.ts +7 -7
- package/src/signals/signalsToXY.ts +3 -3
- package/src/signals/simulation/simulate1D.ts +4 -3
- package/src/signals/simulation/splitSpinSystem.ts +10 -2
- package/src/types/NMRPeak1D.ts +3 -9
- package/src/types/NMRSignal2D.ts +7 -7
- package/src/types/NMRZone.ts +6 -6
- package/src/types/dataStructure.ts +1 -1
- package/src/types/jcoupling.ts +1 -1
- package/src/types/ml-matrix-peaks-finder/index.d.ts +2 -2
- package/src/types/ml-simple-clustering/index.d.ts +1 -1
- package/src/types/ml-spectra-processing/index.d.ts +8 -2
- package/src/types/modules/nmr-parser.ts +17 -0
- package/src/types/openchemlib-utils/index..d.ts +17 -6
- package/src/types/prediction1D.ts +2 -2
- package/src/utilities/joinPatterns.ts +0 -1
- package/src/xy/xyAutoPeaksPicking.ts +19 -58
- package/src/xyz/{xyzAutoPeaksPicking.ts → xyzAutoZonesPicking.ts} +40 -24
- package/src/xyz/xyzJResAnalyzer.ts +4 -4
- package/CHANGELOG.md +0 -543
- package/lib/types/MPFPeak.d.ts +0 -9
- package/lib/types/MPFPeak.js +0 -3
- package/lib/types/MPFPeak.js.map +0 -1
- package/lib/xyz/xyzAutoPeaksPicking.js.map +0 -1
- package/lib-esm/types/MPFPeak.js +0 -2
- package/lib-esm/types/MPFPeak.js.map +0 -1
- package/lib-esm/xyz/xyzAutoPeaksPicking.js.map +0 -1
- package/src/types/MPFPeak.ts +0 -9
- package/src/types/ml-gsd/index.d.ts +0 -164
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import binarySearch from 'binary-search';
|
|
2
|
+
import { DataXY } from 'cheminfo-types';
|
|
2
3
|
import { Matrix, EVD } from 'ml-matrix';
|
|
3
4
|
import type { Matrix as MatrixClassType } from 'ml-matrix';
|
|
5
|
+
import type { Shape1D } from 'ml-peak-shape-generator';
|
|
4
6
|
import { SparseMatrix } from 'ml-sparse-matrix';
|
|
5
7
|
import { SpectrumGenerator } from 'spectrum-generator';
|
|
6
|
-
import type { Shape1DOptions } from 'spectrum-generator';
|
|
7
8
|
|
|
8
9
|
import type { SpinSystem } from '../../types/spinSystem';
|
|
9
10
|
|
|
@@ -46,7 +47,7 @@ interface Simulate1DOptions {
|
|
|
46
47
|
* Shape options
|
|
47
48
|
* @default {kind:'gaussian'}
|
|
48
49
|
*/
|
|
49
|
-
shape?:
|
|
50
|
+
shape?: Shape1D;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -59,7 +60,7 @@ export default function simulate1D(
|
|
|
59
60
|
*/
|
|
60
61
|
spinSystem: SpinSystem,
|
|
61
62
|
options: Simulate1DOptions = {},
|
|
62
|
-
) {
|
|
63
|
+
): DataXY {
|
|
63
64
|
let {
|
|
64
65
|
lineWidth = 1,
|
|
65
66
|
maxClusterSize = 8,
|
|
@@ -53,7 +53,11 @@ interface SplitClusterOptions {
|
|
|
53
53
|
connectivity: Matrix;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function splitCluster(
|
|
56
|
+
function splitCluster(
|
|
57
|
+
cluster: Cluster,
|
|
58
|
+
clusterList: Array<Int16Array>,
|
|
59
|
+
options: SplitClusterOptions,
|
|
60
|
+
) {
|
|
57
61
|
let { maxClusterSize, force, nSpins, connectivity } = options;
|
|
58
62
|
if (!force && cluster.size <= maxClusterSize) {
|
|
59
63
|
clusterList.push(getMembers(cluster.indices(), nSpins));
|
|
@@ -102,7 +106,11 @@ function splitCluster(cluster: Cluster, clusterList: Array<Int16Array>, options:
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
function calculateBetas(
|
|
109
|
+
function calculateBetas(
|
|
110
|
+
chemicalShifts: number[],
|
|
111
|
+
couplingConstants: Matrix,
|
|
112
|
+
frequency: number,
|
|
113
|
+
) {
|
|
106
114
|
let nRows = couplingConstants.rows;
|
|
107
115
|
let nColumns = couplingConstants.columns;
|
|
108
116
|
let betas = Matrix.zeros(nRows, nRows);
|
package/src/types/NMRPeak1D.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Peak1D } from 'ml-gsd';
|
|
2
|
+
|
|
3
|
+
export interface NMRPeak1D extends Peak1D {
|
|
2
4
|
kind?: string;
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
shape: {
|
|
6
|
-
width: number;
|
|
7
|
-
noiseLevel?: number;
|
|
8
|
-
soft?: boolean;
|
|
9
|
-
kind?: string;
|
|
10
|
-
};
|
|
11
5
|
}
|
package/src/types/NMRSignal2D.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FromTo } from 'cheminfo-types';
|
|
2
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
2
3
|
|
|
3
4
|
export interface Signal2DAxisData {
|
|
4
5
|
nucleus?: string;
|
|
@@ -6,17 +7,16 @@ export interface Signal2DAxisData {
|
|
|
6
7
|
resolution?: number;
|
|
7
8
|
atoms?: number[];
|
|
8
9
|
diaIDs?: string[];
|
|
9
|
-
fromTo?: {
|
|
10
|
-
from: number;
|
|
11
|
-
to: number
|
|
12
|
-
};
|
|
13
10
|
}
|
|
14
11
|
export interface NMRSignal2D {
|
|
15
12
|
x: Signal2DAxisData;
|
|
16
13
|
y: Signal2DAxisData;
|
|
14
|
+
j?: {
|
|
15
|
+
pathLength?: number | FromTo;
|
|
16
|
+
};
|
|
17
17
|
id?: string;
|
|
18
|
-
peaks?:
|
|
18
|
+
peaks?: Peak2D[];
|
|
19
19
|
kind?: string;
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
_highlight?: (number | string)[];
|
|
22
22
|
}
|
package/src/types/NMRZone.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FromTo } from 'cheminfo-types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { NMRSignal2D } from './NMRSignal2D';
|
|
4
4
|
|
|
5
5
|
export interface NMRZone {
|
|
6
|
-
x: FromTo
|
|
7
|
-
y: FromTo
|
|
6
|
+
x: FromTo;
|
|
7
|
+
y: FromTo;
|
|
8
8
|
id?: string;
|
|
9
|
-
signals: NMRSignal2D
|
|
10
|
-
}
|
|
9
|
+
signals: NMRSignal2D[];
|
|
10
|
+
}
|
package/src/types/jcoupling.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare module 'ml-matrix-peaks-finder' {
|
|
|
8
8
|
cols: number;
|
|
9
9
|
labelling?: 'drain' | 'floodfill';
|
|
10
10
|
}
|
|
11
|
-
interface
|
|
11
|
+
interface Peak2D {
|
|
12
12
|
x: number;
|
|
13
13
|
y: number;
|
|
14
14
|
z: number;
|
|
@@ -20,5 +20,5 @@ declare module 'ml-matrix-peaks-finder' {
|
|
|
20
20
|
function findPeaks2DRegion(
|
|
21
21
|
absoluteData: number[] | Float64Array,
|
|
22
22
|
options?: FindPeaks2DRegionOptions,
|
|
23
|
-
):
|
|
23
|
+
): Peak2D[];
|
|
24
24
|
}
|
|
@@ -45,7 +45,13 @@ declare module 'ml-spectra-processing' {
|
|
|
45
45
|
|
|
46
46
|
interface XYIntegrationOptions extends XGetFromToIndexOptions {}
|
|
47
47
|
|
|
48
|
-
function xyIntegration(
|
|
48
|
+
function xyIntegration(
|
|
49
|
+
data: XYNumberArray,
|
|
50
|
+
options?: XYIntegrationOptions,
|
|
51
|
+
): number;
|
|
49
52
|
|
|
50
|
-
function xGetFromToIndex(
|
|
53
|
+
function xGetFromToIndex(
|
|
54
|
+
x: number[] | Float64Array,
|
|
55
|
+
options?: XGetFromToIndexOptions,
|
|
56
|
+
): number;
|
|
51
57
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module 'nmr-parser' {
|
|
2
|
+
interface FromBrukerOptions {
|
|
3
|
+
base64?: boolean;
|
|
4
|
+
shiftX?: number;
|
|
5
|
+
info?: any;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function fromBruker(
|
|
10
|
+
zipFile: ArrayBuffer | string,
|
|
11
|
+
options?: Partial<FromBrukerOptions>,
|
|
12
|
+
): Promise<Array<any>>;
|
|
13
|
+
|
|
14
|
+
function fromJCAMP(buffer: string | ArrayBuffer, options?: any): Array<any>;
|
|
15
|
+
|
|
16
|
+
function fromJEOL(buffer: ArrayBuffer): any;
|
|
17
|
+
}
|
|
@@ -48,7 +48,10 @@ declare module 'openchemlib-utils' {
|
|
|
48
48
|
export interface PathInfo extends AtomInfo {
|
|
49
49
|
paths: HoseCodesForPath[];
|
|
50
50
|
}
|
|
51
|
-
function getPathsInfo(
|
|
51
|
+
function getPathsInfo(
|
|
52
|
+
molecule: Molecule,
|
|
53
|
+
options?: GetPathsInfoOptions,
|
|
54
|
+
): PathInfo[];
|
|
52
55
|
|
|
53
56
|
export interface AtomInfo {
|
|
54
57
|
oclID: string;
|
|
@@ -102,20 +105,25 @@ declare module 'openchemlib-utils' {
|
|
|
102
105
|
export interface HoseCodesForPath {
|
|
103
106
|
atoms: number[];
|
|
104
107
|
from: number;
|
|
105
|
-
to: number
|
|
106
|
-
torsion?: number
|
|
108
|
+
to: number;
|
|
109
|
+
torsion?: number;
|
|
107
110
|
hoses: Hoses;
|
|
108
111
|
length: number;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
function getHoseCodesForPath(
|
|
114
|
+
function getHoseCodesForPath(
|
|
115
|
+
molecule: Molecule,
|
|
116
|
+
from: string,
|
|
117
|
+
to: string,
|
|
118
|
+
maxLength: number,
|
|
119
|
+
): HoseCodesForPath;
|
|
112
120
|
|
|
113
121
|
export interface GetConnectivityMatrixOptions {
|
|
114
122
|
/**
|
|
115
123
|
* get the path length between atoms
|
|
116
124
|
* @default false
|
|
117
125
|
*/
|
|
118
|
-
pathLength?: boolean
|
|
126
|
+
pathLength?: boolean;
|
|
119
127
|
/**
|
|
120
128
|
* set the nominal mass of the atoms on diagonal
|
|
121
129
|
* @default false
|
|
@@ -142,7 +150,10 @@ declare module 'openchemlib-utils' {
|
|
|
142
150
|
*/
|
|
143
151
|
stda?: boolean | number;
|
|
144
152
|
}
|
|
145
|
-
function getConnectivityMatrix(
|
|
153
|
+
function getConnectivityMatrix(
|
|
154
|
+
molecule: Molecule,
|
|
155
|
+
options?: GetConnectivityMatrixOptions,
|
|
156
|
+
): number[][] | Float64Array[];
|
|
146
157
|
|
|
147
158
|
function getDiastereotopicAtomIDs(molecule: Molecule): string[];
|
|
148
159
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Molecule } from 'openchemlib';
|
|
2
2
|
|
|
3
|
-
import type { NMRRange } from
|
|
4
|
-
import type { NMRSignal1D } from
|
|
3
|
+
import type { NMRRange } from './NMRRange';
|
|
4
|
+
import type { NMRSignal1D } from './NMRSignal1D';
|
|
5
5
|
|
|
6
6
|
export interface Prediction1D {
|
|
7
7
|
molfile: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { couplingPatterns } from '../constants/couplingPatterns';
|
|
2
2
|
import { couplingValues } from '../constants/couplingValues';
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
export function joinPatterns(patterns: string[]) {
|
|
6
5
|
const sum = patterns.reduce((sum, pattern) => {
|
|
7
6
|
if (isNaN(couplingValues[pattern])) {
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { DataXY } from 'cheminfo-types';
|
|
2
2
|
import { gsd, joinBroadPeaks, optimizePeaks } from 'ml-gsd';
|
|
3
|
+
import type {
|
|
4
|
+
Peak1D,
|
|
5
|
+
GSDOptions,
|
|
6
|
+
OptimizePeaksOptions,
|
|
7
|
+
JoinBroadPeaksOptions,
|
|
8
|
+
} from 'ml-gsd';
|
|
3
9
|
import {
|
|
4
10
|
xyExtract,
|
|
5
11
|
xNoiseSanPlot,
|
|
6
12
|
xAbsoluteMedian,
|
|
7
13
|
} from 'ml-spectra-processing';
|
|
8
14
|
|
|
9
|
-
import type { NMRPeak1D } from '../types/NMRPeak1D';
|
|
10
15
|
/**
|
|
11
16
|
* Implementation of the peak picking method described by Cobas in:
|
|
12
17
|
* A new approach to improving automated analysis of proton NMR spectra
|
|
@@ -20,63 +25,19 @@ interface OptionsGetCutOff {
|
|
|
20
25
|
thresholdFactor: number;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
interface
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
noiseLevel?: number;
|
|
29
|
-
/**
|
|
30
|
-
* Threshold to determine if a given peak should be considered as a noise, bases on its relative height compared to the highest peak.
|
|
31
|
-
* @default 0.01
|
|
32
|
-
*/
|
|
33
|
-
minMaxRatio: number;
|
|
34
|
-
/**
|
|
35
|
-
* 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.
|
|
36
|
-
* @default 0.00025
|
|
37
|
-
*/
|
|
38
|
-
broadRatio: number;
|
|
39
|
-
/**
|
|
40
|
-
* Select the peak intensities from a smoothed version of the independent variables.
|
|
41
|
-
* @default true
|
|
42
|
-
*/
|
|
43
|
-
smoothY: boolean;
|
|
28
|
+
export interface IGetPeakListOptions
|
|
29
|
+
extends GSDOptions,
|
|
30
|
+
OptimizePeaksOptions,
|
|
31
|
+
JoinBroadPeaksOptions {
|
|
44
32
|
/**
|
|
45
33
|
* If it is true, the peaks parameters will be optimized.
|
|
46
34
|
* @default false
|
|
47
35
|
*/
|
|
48
36
|
optimize: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* factor to determine the width at the moment to group the peaks in signals in 'GSD.optimizePeaks' function.
|
|
51
|
-
* @default 4
|
|
52
|
-
*/
|
|
53
|
-
factorWidth: number;
|
|
54
|
-
/**
|
|
55
|
-
* if it is true, it optimizes the x and intensity by extrapolation.
|
|
56
|
-
*/
|
|
57
|
-
realTopDetection: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* options to shape used to adapt the FWHM
|
|
60
|
-
* @default {kind:'gaussian'}
|
|
61
|
-
*/
|
|
62
|
-
shape: { kind: string };
|
|
63
|
-
/**
|
|
64
|
-
* options for optimization step, kind represent the algorithm
|
|
65
|
-
* @default {kind:'lm'}
|
|
66
|
-
*/
|
|
67
|
-
optimization: { kind: string };
|
|
68
|
-
/**
|
|
69
|
-
* Threshold to determine if some peak is candidate to clustering into range.
|
|
70
|
-
* @default 0.25
|
|
71
|
-
*/
|
|
72
|
-
broadWidth: number;
|
|
73
|
-
/**
|
|
74
|
-
* Options for savitz Golay
|
|
75
|
-
*/
|
|
76
|
-
sgOptions: { windowSize: number; polynomial: number };
|
|
77
37
|
}
|
|
78
38
|
|
|
79
|
-
export interface OptionsXYAutoPeaksPicking
|
|
39
|
+
export interface OptionsXYAutoPeaksPicking
|
|
40
|
+
extends Partial<IGetPeakListOptions> {
|
|
80
41
|
/**
|
|
81
42
|
* Low limit value in the x axis to extract a sub set of points from the input data.
|
|
82
43
|
*/
|
|
@@ -105,7 +66,7 @@ export interface OptionsXYAutoPeaksPicking extends Partial<OptionsGetPeakList> {
|
|
|
105
66
|
export function xyAutoPeaksPicking(
|
|
106
67
|
data: DataXY,
|
|
107
68
|
options: OptionsXYAutoPeaksPicking = {},
|
|
108
|
-
):
|
|
69
|
+
): Peak1D[] {
|
|
109
70
|
const {
|
|
110
71
|
from,
|
|
111
72
|
to,
|
|
@@ -131,7 +92,7 @@ export function xyAutoPeaksPicking(
|
|
|
131
92
|
|
|
132
93
|
const cutOff = getCutOff(data.y, { noiseLevel, useSanPlot, thresholdFactor });
|
|
133
94
|
|
|
134
|
-
let getPeakOptions = {
|
|
95
|
+
let getPeakOptions: IGetPeakListOptions = {
|
|
135
96
|
shape,
|
|
136
97
|
broadWidth,
|
|
137
98
|
optimize,
|
|
@@ -154,7 +115,7 @@ export function xyAutoPeaksPicking(
|
|
|
154
115
|
return peaks;
|
|
155
116
|
}
|
|
156
117
|
|
|
157
|
-
function getPeakList(data: DataXY, options:
|
|
118
|
+
function getPeakList(data: DataXY, options: IGetPeakListOptions) {
|
|
158
119
|
const {
|
|
159
120
|
shape,
|
|
160
121
|
broadWidth,
|
|
@@ -173,15 +134,15 @@ function getPeakList(data: DataXY, options: OptionsGetPeakList) {
|
|
|
173
134
|
shape,
|
|
174
135
|
sgOptions,
|
|
175
136
|
minMaxRatio,
|
|
176
|
-
broadRatio,
|
|
177
137
|
noiseLevel,
|
|
178
138
|
smoothY,
|
|
179
139
|
realTopDetection,
|
|
180
140
|
});
|
|
181
141
|
|
|
182
142
|
if (broadWidth) {
|
|
183
|
-
peakList = joinBroadPeaks(peakList, {
|
|
184
|
-
|
|
143
|
+
peakList = joinBroadPeaks(data, peakList, {
|
|
144
|
+
broadRatio,
|
|
145
|
+
broadWidth,
|
|
185
146
|
shape,
|
|
186
147
|
optimization,
|
|
187
148
|
});
|
|
@@ -198,7 +159,7 @@ function getPeakList(data: DataXY, options: OptionsGetPeakList) {
|
|
|
198
159
|
return peakList;
|
|
199
160
|
}
|
|
200
161
|
|
|
201
|
-
function getNegativePeaks(data: DataXY, options:
|
|
162
|
+
function getNegativePeaks(data: DataXY, options: IGetPeakListOptions) {
|
|
202
163
|
let { x, y } = data;
|
|
203
164
|
let negativeDataY = new Float64Array(data.y.length);
|
|
204
165
|
for (let i = 0; i < negativeDataY.length; i++) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Matrix } from 'ml-matrix';
|
|
2
2
|
import * as convolution from 'ml-matrix-convolution';
|
|
3
3
|
import * as matrixPeakFinders from 'ml-matrix-peaks-finder';
|
|
4
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
4
5
|
import simpleClustering from 'ml-simple-clustering';
|
|
5
6
|
|
|
7
|
+
import { NMRZone } from '..';
|
|
6
8
|
import { determineRealTop } from '../peaks/util/determineRealTop';
|
|
7
9
|
import { getKernel } from '../peaks/util/getKernel';
|
|
8
10
|
import type { GetKernelOptions } from '../peaks/util/getKernel';
|
|
9
11
|
import * as PeakOptimizer from '../peaks/util/peakOptimizer';
|
|
10
|
-
import type { MPFPeak } from '../types/MPFPeak';
|
|
11
12
|
import type { NMRSignal2D } from '../types/NMRSignal2D';
|
|
12
13
|
|
|
13
14
|
const smallFilter = [
|
|
@@ -86,7 +87,7 @@ export interface XYZAutoPeaksPickingOptions {
|
|
|
86
87
|
kernel?: GetKernelOptions;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
export function
|
|
90
|
+
export function xyzAutoZonesPicking(
|
|
90
91
|
spectraData: Data2D,
|
|
91
92
|
options: XYZAutoPeaksPickingOptions,
|
|
92
93
|
) {
|
|
@@ -178,7 +179,41 @@ export function xyzAutoPeaksPicking(
|
|
|
178
179
|
signals = PeakOptimizer.enhanceSymmetry(signals);
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
return signals;
|
|
182
|
+
return formatZones(signals);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function formatZones(signals: NMRSignal2D[]) {
|
|
186
|
+
let zones: NMRZone[] = [];
|
|
187
|
+
for (const signal of signals) {
|
|
188
|
+
let minMax1 = [Number.MAX_VALUE, 0];
|
|
189
|
+
let minMax2 = [Number.MAX_VALUE, 0];
|
|
190
|
+
for (const peak of signal.peaks || []) {
|
|
191
|
+
if (peak.minX < minMax1[0]) {
|
|
192
|
+
minMax1[0] = peak.minX;
|
|
193
|
+
}
|
|
194
|
+
if (peak.maxX > minMax1[1]) {
|
|
195
|
+
minMax1[1] = peak.maxX;
|
|
196
|
+
}
|
|
197
|
+
if (peak.minY < minMax2[0]) {
|
|
198
|
+
minMax2[0] = peak.minY;
|
|
199
|
+
}
|
|
200
|
+
if (peak.maxY > minMax2[1]) {
|
|
201
|
+
minMax2[1] = peak.maxY;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
zones.push({
|
|
205
|
+
x: {
|
|
206
|
+
from: minMax1[0],
|
|
207
|
+
to: minMax1[1],
|
|
208
|
+
},
|
|
209
|
+
y: {
|
|
210
|
+
from: minMax2[0],
|
|
211
|
+
to: minMax2[1],
|
|
212
|
+
},
|
|
213
|
+
signals: [signal],
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return zones;
|
|
182
217
|
}
|
|
183
218
|
|
|
184
219
|
/**
|
|
@@ -201,7 +236,7 @@ export interface CreateSignals2DOptions {
|
|
|
201
236
|
minX: number;
|
|
202
237
|
maxX: number;
|
|
203
238
|
}
|
|
204
|
-
const createSignals2D = (peaks:
|
|
239
|
+
const createSignals2D = (peaks: Peak2D[], options: CreateSignals2DOptions) => {
|
|
205
240
|
let {
|
|
206
241
|
nCols,
|
|
207
242
|
nRows,
|
|
@@ -246,9 +281,6 @@ const createSignals2D = (peaks: MPFPeak[], options: CreateSignals2DOptions) => {
|
|
|
246
281
|
peaks[i].maxY = minY + dy * peaks[i].maxY;
|
|
247
282
|
|
|
248
283
|
// Still having problems to correctly detect peaks on those areas. So I'm removing everything there.
|
|
249
|
-
if (peaks[i].y < -1 || peaks[i].y >= 210) {
|
|
250
|
-
peaks.splice(i, 1);
|
|
251
|
-
}
|
|
252
284
|
}
|
|
253
285
|
// The connectivity matrix is an square and symmetric matrix, so we'll only store the upper diagonal in an
|
|
254
286
|
// array like form
|
|
@@ -283,9 +315,7 @@ const createSignals2D = (peaks: MPFPeak[], options: CreateSignals2DOptions) => {
|
|
|
283
315
|
resolution: dy,
|
|
284
316
|
},
|
|
285
317
|
};
|
|
286
|
-
let peaks2D = [];
|
|
287
|
-
let minMax1 = [Number.MAX_VALUE, 0];
|
|
288
|
-
let minMax2 = [Number.MAX_VALUE, 0];
|
|
318
|
+
let peaks2D: Peak2D[] = [];
|
|
289
319
|
let sumZ = 0;
|
|
290
320
|
|
|
291
321
|
for (let jPeak = 0; jPeak < cluster.length; jPeak++) {
|
|
@@ -294,23 +324,9 @@ const createSignals2D = (peaks: MPFPeak[], options: CreateSignals2DOptions) => {
|
|
|
294
324
|
signal.x.delta += peaks[jPeak].x * peaks[jPeak].z;
|
|
295
325
|
signal.y.delta += peaks[jPeak].y * peaks[jPeak].z;
|
|
296
326
|
sumZ += peaks[jPeak].z;
|
|
297
|
-
if (peaks[jPeak].minX < minMax1[0]) {
|
|
298
|
-
minMax1[0] = peaks[jPeak].minX;
|
|
299
|
-
}
|
|
300
|
-
if (peaks[jPeak].maxX > minMax1[1]) {
|
|
301
|
-
minMax1[1] = peaks[jPeak].maxX;
|
|
302
|
-
}
|
|
303
|
-
if (peaks[jPeak].minY < minMax2[0]) {
|
|
304
|
-
minMax2[0] = peaks[jPeak].minY;
|
|
305
|
-
}
|
|
306
|
-
if (peaks[jPeak].maxY > minMax2[1]) {
|
|
307
|
-
minMax2[1] = peaks[jPeak].maxY;
|
|
308
|
-
}
|
|
309
327
|
}
|
|
310
328
|
}
|
|
311
329
|
|
|
312
|
-
signal.x.fromTo = { from: minMax1[0], to: minMax1[1] };
|
|
313
|
-
signal.y.fromTo = { from: minMax2[0], to: minMax2[1] };
|
|
314
330
|
signal.x.delta /= sumZ;
|
|
315
331
|
signal.y.delta /= sumZ;
|
|
316
332
|
signal.peaks = peaks2D;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { Peak2D } from 'ml-matrix-peaks-finder';
|
|
1
2
|
import simpleClustering from 'ml-simple-clustering';
|
|
2
3
|
|
|
3
4
|
import type { JAxisKeys } from '../peaks/util/jAnalyzer';
|
|
4
5
|
import jAnalyzer from '../peaks/util/jAnalyzer';
|
|
5
|
-
import type { MPFPeak } from '../types/MPFPeak';
|
|
6
6
|
import type { MakeMandatory } from '../types/MakeMandatory';
|
|
7
7
|
import type { NMRSignal2D } from '../types/NMRSignal2D';
|
|
8
8
|
|
|
@@ -96,7 +96,7 @@ function compilePattern(
|
|
|
96
96
|
for (const peak of peaks) {
|
|
97
97
|
if (!peak.width) peak.width = 0.02;
|
|
98
98
|
}
|
|
99
|
-
peaks.sort((a:
|
|
99
|
+
peaks.sort((a: Peak2D, b: Peak2D) => a.y - b.y);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
for (let i = 0; i < signals.length; i++) {
|
|
@@ -137,7 +137,7 @@ function compilePattern(
|
|
|
137
137
|
return signals;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
interface Peak2DHack extends
|
|
140
|
+
interface Peak2DHack extends Peak2D {
|
|
141
141
|
width?: number;
|
|
142
142
|
}
|
|
143
143
|
type Signal2DHack = Omit<NMRSignal2D, 'peaks'> & {
|
|
@@ -149,7 +149,7 @@ type Signal2DHack = Omit<NMRSignal2D, 'peaks'> & {
|
|
|
149
149
|
observe: number;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
function createSignals2D(peaksInput:
|
|
152
|
+
function createSignals2D(peaksInput: Peak2D[], options: any) {
|
|
153
153
|
let { observedFrequencies, tolerances, nuclei, dx, dy } = options;
|
|
154
154
|
|
|
155
155
|
const peaks: Peak2DHack[] = JSON.parse(JSON.stringify(peaksInput));
|