nmrium 0.32.0 → 0.33.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/component/1d/Chart1D.js +1 -1
- package/lib/component/1d/{Integral.d.ts → integral/Integral.d.ts} +0 -0
- package/lib/component/1d/{Integral.js → integral/Integral.js} +2 -2
- package/lib/component/1d/integral/IntegralIndicator.d.ts +9 -0
- package/lib/component/1d/integral/IntegralIndicator.js +27 -0
- package/lib/component/1d/{IntegralResizable.d.ts → integral/IntegralResizable.d.ts} +0 -0
- package/lib/component/1d/integral/IntegralResizable.js +69 -0
- package/lib/component/1d/{IntegralsSeries.d.ts → integral/IntegralsSeries.d.ts} +0 -0
- package/lib/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
- package/lib/component/1d/ranges/Range.js +27 -50
- package/lib/component/1d/utilities/scale.js +2 -2
- package/lib/component/2d/Contours.js +61 -42
- package/lib/component/NMRium.d.ts +1 -1
- package/lib/component/NMRium.js +1 -1
- package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
- package/lib/component/elements/formik/FormikColorPicker.js +5 -8
- package/lib/component/elements/formik/FormikInput.d.ts +0 -1
- package/lib/component/elements/formik/FormikInput.js +8 -19
- package/lib/component/elements/formik/FormikOnChange.d.ts +1 -1
- package/lib/component/elements/formik/FormikOnChange.js +13 -10
- package/lib/component/elements/formik/FormikSlider.d.ts +2 -4
- package/lib/component/elements/formik/FormikSlider.js +8 -11
- package/lib/component/hooks/useExport.js +1 -1
- package/lib/component/modal/ExportAsMatrixModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +1 -3
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.d.ts +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.d.ts +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
- package/lib/component/panels/extra/preferences/ColumnsHelper.js +5 -2
- package/lib/component/reducer/Reducer.d.ts +18 -12
- package/lib/component/reducer/Reducer.js +23 -9
- package/lib/component/reducer/actions/PreferencesActions.js +16 -35
- package/lib/component/reducer/actions/RangesActions.js +6 -4
- package/lib/component/reducer/actions/SpectrumsActions.js +10 -4
- package/lib/component/reducer/actions/ToolsActions.js +7 -22
- package/lib/component/reducer/core/Constants.js +1 -1
- package/lib/component/utility/FileUtility.d.ts +1 -8
- package/lib/component/utility/FileUtility.js +2 -17
- package/lib/component/utility/{Export.d.ts → export.d.ts} +0 -0
- package/lib/component/utility/{Export.js → export.js} +26 -49
- package/lib/component/utility/formatNumber.d.ts +6 -1
- package/lib/component/utility/formatNumber.js +4 -3
- package/lib/data/SpectraManager.d.ts +1 -2
- package/lib/data/SpectraManager.js +22 -55
- package/lib/data/data1d/filter1d/fft.js +21 -4
- package/lib/data/data2d/Spectrum2D/contours.d.ts +40 -0
- package/lib/data/data2d/Spectrum2D/contours.js +132 -0
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
- package/lib/data/types/common/Source.d.ts +1 -0
- package/lib/data/types/data2d/Data2D.d.ts +2 -0
- package/lib/data/types/data2d/Datum2D.d.ts +0 -1
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +1 -1
- package/lib-cjs/component/1d/{Integral.js → integral/Integral.js} +2 -2
- package/lib-cjs/component/1d/integral/IntegralIndicator.js +31 -0
- package/lib-cjs/component/1d/integral/IntegralResizable.js +74 -0
- package/lib-cjs/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
- package/lib-cjs/component/1d/ranges/Range.js +27 -50
- package/lib-cjs/component/1d/utilities/scale.js +2 -2
- package/lib-cjs/component/2d/Contours.js +60 -41
- package/lib-cjs/component/NMRium.js +2 -2
- package/lib-cjs/component/elements/formik/FormikColorPicker.js +4 -7
- package/lib-cjs/component/elements/formik/FormikInput.js +8 -19
- package/lib-cjs/component/elements/formik/FormikOnChange.js +13 -10
- package/lib-cjs/component/elements/formik/FormikSlider.js +7 -10
- package/lib-cjs/component/hooks/useExport.js +6 -6
- package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -2
- package/lib-cjs/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -4
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +1 -3
- package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +2 -2
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
- package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +5 -2
- package/lib-cjs/component/reducer/Reducer.js +22 -8
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +16 -35
- package/lib-cjs/component/reducer/actions/RangesActions.js +6 -4
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +9 -3
- package/lib-cjs/component/reducer/actions/ToolsActions.js +7 -22
- package/lib-cjs/component/reducer/core/Constants.js +1 -1
- package/lib-cjs/component/utility/FileUtility.js +2 -18
- package/lib-cjs/component/utility/{Export.js → export.js} +50 -50
- package/lib-cjs/component/utility/formatNumber.js +4 -3
- package/lib-cjs/data/SpectraManager.js +23 -57
- package/lib-cjs/data/data1d/filter1d/fft.js +20 -3
- package/lib-cjs/data/data2d/Spectrum2D/contours.js +138 -0
- package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +6 -6
- package/lib/component/1d/IntegralResizable.js +0 -72
- package/lib/component/panels/RangesPanel/TableColumns/format.d.ts +0 -1
- package/lib/component/panels/RangesPanel/TableColumns/format.js +0 -8
- package/lib/data/data1d/Data1DManager.d.ts +0 -3
- package/lib/data/data1d/Data1DManager.js +0 -98
- package/lib/data/data2d/Data2DManager.d.ts +0 -3
- package/lib/data/data2d/Data2DManager.js +0 -34
- package/lib/data/types/data2d/Contour.d.ts +0 -4
- package/lib/data/types/data2d/Contour.js +0 -1
- package/lib/data/types/data2d/Contours.d.ts +0 -2
- package/lib/data/types/data2d/Contours.js +0 -1
- package/lib-cjs/component/1d/IntegralResizable.js +0 -77
- package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +0 -14
- package/lib-cjs/data/data1d/Data1DManager.js +0 -104
- package/lib-cjs/data/data2d/Data2DManager.js +0 -40
- package/lib-cjs/data/types/data2d/Contour.js +0 -2
- package/lib-cjs/data/types/data2d/Contours.js +0 -2
|
@@ -23,13 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.toJSON = exports.addJcamps = exports.
|
|
26
|
+
exports.toJSON = exports.addJcamps = exports.addJcamp = exports.addJcampFromURL = exports.DataExportOptions = void 0;
|
|
27
27
|
const nmr_load_save_1 = require("nmr-load-save");
|
|
28
|
-
const nmr_parser_1 = require("nmr-parser");
|
|
29
28
|
const Constants_1 = require("../component/reducer/core/Constants");
|
|
30
|
-
const Data1DManager = __importStar(require("./data1d/Data1DManager"));
|
|
31
29
|
const Datum1D = __importStar(require("./data1d/Spectrum1D"));
|
|
32
|
-
const Data2DManager = __importStar(require("./data2d/Data2DManager"));
|
|
33
30
|
const Datum2D = __importStar(require("./data2d/Spectrum2D"));
|
|
34
31
|
const Molecule = __importStar(require("./molecules/Molecule"));
|
|
35
32
|
var DataExportOptions;
|
|
@@ -37,6 +34,15 @@ var DataExportOptions;
|
|
|
37
34
|
DataExportOptions["ROW_DATA"] = "ROW_DATA";
|
|
38
35
|
DataExportOptions["DATA_SOURCE"] = "DATA_SOURCE";
|
|
39
36
|
})(DataExportOptions = exports.DataExportOptions || (exports.DataExportOptions = {}));
|
|
37
|
+
function getData(datum, usedColors) {
|
|
38
|
+
const dimension = datum.info.dimension;
|
|
39
|
+
if (dimension === 1) {
|
|
40
|
+
return Datum1D.initiateDatum1D(datum, usedColors);
|
|
41
|
+
}
|
|
42
|
+
else if (dimension === 2) {
|
|
43
|
+
return Datum2D.initiateDatum2D(datum, usedColors);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
40
46
|
function addJcampFromURL(spectra, jcampURL, options, usedColors) {
|
|
41
47
|
return fetch(jcampURL)
|
|
42
48
|
.then((response) => response.arrayBuffer())
|
|
@@ -45,68 +51,28 @@ function addJcampFromURL(spectra, jcampURL, options, usedColors) {
|
|
|
45
51
|
});
|
|
46
52
|
}
|
|
47
53
|
exports.addJcampFromURL = addJcampFromURL;
|
|
48
|
-
function addJcamp(
|
|
54
|
+
function addJcamp(output, jcamp, options, usedColors) {
|
|
49
55
|
options = options || {};
|
|
50
|
-
const
|
|
51
|
-
|
|
56
|
+
const name = options?.display?.name;
|
|
57
|
+
const { spectra: spectraIn } = (0, nmr_load_save_1.processJcamp)(jcamp, {
|
|
58
|
+
name,
|
|
59
|
+
noContours: true,
|
|
52
60
|
xy: true,
|
|
53
61
|
keepRecordsRegExp: /.*/,
|
|
54
62
|
profiling: true,
|
|
55
63
|
});
|
|
56
|
-
if (
|
|
64
|
+
if (spectraIn.length === 0)
|
|
57
65
|
return;
|
|
58
|
-
// Should be improved when we have a more complex case
|
|
59
|
-
for (let index = 0; index < entries.length; index++) {
|
|
60
|
-
let entry = entries[index];
|
|
61
|
-
const components = entry.dependentVariables?.[0]?.components;
|
|
62
|
-
if (components && (components.length > 0 || components.z)) {
|
|
63
|
-
addJcampSS(spectra, { index, entry }, options, usedColors);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.addJcamp = addJcamp;
|
|
68
|
-
function addJcampSS(spectra, jcampDatum, options, usedColors) {
|
|
69
|
-
const source = options?.source || {};
|
|
70
|
-
if (!('jcampSpectrumIndex' in source) ||
|
|
71
|
-
source.jcampSpectrumIndex === jcampDatum.index) {
|
|
72
|
-
const dimension = jcampDatum.entry.info.dimension;
|
|
73
|
-
if (dimension === 1) {
|
|
74
|
-
spectra.push(Data1DManager.fromParsedJcamp(jcampDatum.entry, options, usedColors, jcampDatum.index));
|
|
75
|
-
}
|
|
76
|
-
if (dimension === 2) {
|
|
77
|
-
// console.log(options, jcampDatum.entry);
|
|
78
|
-
spectra.push(Data2DManager.fromParsedJcamp(jcampDatum.entry, options, usedColors, jcampDatum.index));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function addData(spectra, datum, usedColors) {
|
|
83
|
-
const dimension = datum.info.dimension;
|
|
84
|
-
if (dimension === 1) {
|
|
85
|
-
spectra.push(Datum1D.initiateDatum1D(datum, usedColors));
|
|
86
|
-
}
|
|
87
|
-
if (dimension === 2) {
|
|
88
|
-
spectra.push(Datum2D.initiateDatum2D(datum, usedColors));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async function fromJSON(data = [], usedColors = {}) {
|
|
92
66
|
const spectra = [];
|
|
93
|
-
let
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
else if (jcampURL != null) {
|
|
100
|
-
promises.push(addJcampFromURL(spectra, jcampURL, datum, usedColors));
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
addData(spectra, datum, usedColors);
|
|
104
|
-
}
|
|
67
|
+
for (let spectrum of spectraIn) {
|
|
68
|
+
const data = getData(spectrum, usedColors);
|
|
69
|
+
if (!data)
|
|
70
|
+
continue;
|
|
71
|
+
spectra.push(data);
|
|
105
72
|
}
|
|
106
|
-
|
|
107
|
-
return spectra;
|
|
73
|
+
output.push(...spectra);
|
|
108
74
|
}
|
|
109
|
-
exports.
|
|
75
|
+
exports.addJcamp = addJcamp;
|
|
110
76
|
function addJcamps(files, usedColors) {
|
|
111
77
|
const spectra = [];
|
|
112
78
|
for (const file of files) {
|
|
@@ -14,19 +14,22 @@ function apply(datum1D) {
|
|
|
14
14
|
throw new Error('fft not applicable on this data');
|
|
15
15
|
}
|
|
16
16
|
let digitalFilterApplied = datum1D.filters.some((e) => e.name === 'digitalFilter' && e.flag);
|
|
17
|
-
const
|
|
17
|
+
const data = datum1D.meta.AQ_mod === 1
|
|
18
|
+
? removeDCOffset(datum1D, digitalFilterApplied)
|
|
19
|
+
: { ...datum1D.data };
|
|
18
20
|
if (data.x.length !== data.re.length || data.x.length !== data.im.length) {
|
|
19
21
|
throw new Error('The length of data should be equal');
|
|
20
22
|
}
|
|
21
23
|
else if (!isPowerOfTwo(datum1D.data.x.length)) {
|
|
22
24
|
(0, padDataToNextPowerOfTwo_1.padDataToNextPowerOfTwo)(datum1D, digitalFilterApplied);
|
|
23
25
|
}
|
|
24
|
-
Object.assign(
|
|
26
|
+
Object.assign(data, (0, ml_spectra_processing_1.reimFFT)(data, { applyZeroShift: true }));
|
|
25
27
|
if (digitalFilterApplied) {
|
|
26
28
|
let { digitalFilter = 0 } = datum1D.info;
|
|
27
29
|
let ph1 = (digitalFilter - Math.floor(digitalFilter)) * Math.PI * 2;
|
|
28
|
-
Object.assign(
|
|
30
|
+
Object.assign(data, (0, ml_spectra_processing_1.reimPhaseCorrection)(data, 0, ph1));
|
|
29
31
|
}
|
|
32
|
+
Object.assign(datum1D.data, data);
|
|
30
33
|
datum1D.data.x = generateXAxis(datum1D);
|
|
31
34
|
datum1D.info = { ...datum1D.info, isFid: false, isFt: true };
|
|
32
35
|
}
|
|
@@ -64,3 +67,17 @@ function generateXAxis(datum1D) {
|
|
|
64
67
|
function isPowerOfTwo(n) {
|
|
65
68
|
return n !== 0 && (n & (n - 1)) === 0;
|
|
66
69
|
}
|
|
70
|
+
function removeDCOffset(datum1D, digitalFilterApplied) {
|
|
71
|
+
let { digitalFilter = 0 } = digitalFilterApplied ? datum1D.info : {};
|
|
72
|
+
const data = { ...datum1D.data };
|
|
73
|
+
const nbPoints = data.re.length;
|
|
74
|
+
const newRe = new Float64Array(data.re);
|
|
75
|
+
const newIm = new Float64Array(data.im);
|
|
76
|
+
const averageRe = (0, ml_spectra_processing_1.xMean)(data.re.slice((nbPoints * 0.75) >> 0, nbPoints - digitalFilter));
|
|
77
|
+
const averageIm = (0, ml_spectra_processing_1.xMean)(data.im.slice((nbPoints * 0.75) >> 0, nbPoints - digitalFilter));
|
|
78
|
+
for (let i = digitalFilterApplied ? 0 : digitalFilter; i < nbPoints - digitalFilter; i++) {
|
|
79
|
+
newRe[i] -= averageRe;
|
|
80
|
+
newIm[i] -= averageIm;
|
|
81
|
+
}
|
|
82
|
+
return { x: data.x, re: newRe, im: newIm };
|
|
83
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_CONTOURS_OPTIONS = exports.getDefaultContoursLevel = exports.contoursManager = exports.drawContours = void 0;
|
|
4
|
+
const ml_conrec_1 = require("ml-conrec");
|
|
5
|
+
const calculateSanPlot_1 = require("../../utilities/calculateSanPlot");
|
|
6
|
+
const DEFAULT_CONTOURS_OPTIONS = {
|
|
7
|
+
positive: {
|
|
8
|
+
contourLevels: [0, 21],
|
|
9
|
+
numberOfLayers: 10,
|
|
10
|
+
},
|
|
11
|
+
negative: {
|
|
12
|
+
contourLevels: [0, 21],
|
|
13
|
+
numberOfLayers: 10,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
exports.DEFAULT_CONTOURS_OPTIONS = DEFAULT_CONTOURS_OPTIONS;
|
|
17
|
+
const LEVEL_SIGNS = ['positive', 'negative'];
|
|
18
|
+
function getDefaultContoursLevel(options) {
|
|
19
|
+
const defaultLevel = { negative: 10, positive: 10 };
|
|
20
|
+
for (const sign of LEVEL_SIGNS) {
|
|
21
|
+
const [min, max] = options[sign].contourLevels;
|
|
22
|
+
defaultLevel[sign] = min + max / 2;
|
|
23
|
+
}
|
|
24
|
+
return defaultLevel;
|
|
25
|
+
}
|
|
26
|
+
exports.getDefaultContoursLevel = getDefaultContoursLevel;
|
|
27
|
+
function contoursManager(spectrumID, state, options) {
|
|
28
|
+
const spectraLevels = { ...state };
|
|
29
|
+
const contourOptions = { ...options };
|
|
30
|
+
if (!state || !state[spectrumID]) {
|
|
31
|
+
const defaultLevel = getDefaultContoursLevel(contourOptions);
|
|
32
|
+
spectraLevels[spectrumID] = defaultLevel;
|
|
33
|
+
}
|
|
34
|
+
const currentLevel = spectraLevels[spectrumID];
|
|
35
|
+
const wheel = (value, shiftKey) => prepareWheel(value, { shiftKey, contourOptions, currentLevel });
|
|
36
|
+
const getLevel = () => currentLevel;
|
|
37
|
+
const checkLevel = () => prepareCheckLevel(currentLevel, contourOptions);
|
|
38
|
+
return { wheel, getLevel, checkLevel };
|
|
39
|
+
}
|
|
40
|
+
exports.contoursManager = contoursManager;
|
|
41
|
+
function prepareWheel(value, options) {
|
|
42
|
+
let { shiftKey, currentLevel, contourOptions } = options;
|
|
43
|
+
const sign = Math.sign(value);
|
|
44
|
+
const positiveBoundary = contourOptions.positive.contourLevels;
|
|
45
|
+
const negativeBoundary = contourOptions.negative.contourLevels;
|
|
46
|
+
if (shiftKey) {
|
|
47
|
+
if ((currentLevel.positive === positiveBoundary[0] && sign === -1) ||
|
|
48
|
+
(currentLevel.positive >= positiveBoundary[1] && sign === 1)) {
|
|
49
|
+
return currentLevel;
|
|
50
|
+
}
|
|
51
|
+
currentLevel.positive += sign;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if ((currentLevel.positive > positiveBoundary[0] && sign === -1) ||
|
|
55
|
+
(currentLevel.positive < positiveBoundary[1] && sign === 1)) {
|
|
56
|
+
currentLevel.positive += sign;
|
|
57
|
+
}
|
|
58
|
+
if ((currentLevel.negative > negativeBoundary[0] && sign === -1) ||
|
|
59
|
+
(currentLevel.negative < negativeBoundary[1] && sign === 1)) {
|
|
60
|
+
currentLevel.negative += sign;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return currentLevel;
|
|
64
|
+
}
|
|
65
|
+
function prepareCheckLevel(currentLevel, options) {
|
|
66
|
+
const level = { ...currentLevel };
|
|
67
|
+
for (const sign of LEVEL_SIGNS) {
|
|
68
|
+
const [min, max] = options[sign].contourLevels;
|
|
69
|
+
//check if the level is out of the boundary
|
|
70
|
+
if (level[sign] > max) {
|
|
71
|
+
level[sign] = max;
|
|
72
|
+
}
|
|
73
|
+
else if (level[sign] < min) {
|
|
74
|
+
level[sign] = min;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return level;
|
|
78
|
+
}
|
|
79
|
+
function getRange(min, max, length, exp) {
|
|
80
|
+
if (exp !== undefined) {
|
|
81
|
+
const factors = [];
|
|
82
|
+
factors[0] = 0;
|
|
83
|
+
for (let i = 1; i <= length; i++) {
|
|
84
|
+
factors[i] = factors[i - 1] + (exp - 1) / Math.pow(exp, i);
|
|
85
|
+
}
|
|
86
|
+
const lastFactor = factors[length];
|
|
87
|
+
const result = new Array(length);
|
|
88
|
+
for (let i = 0; i < length; i++) {
|
|
89
|
+
result[i] = (max - min) * (1 - factors[i + 1] / lastFactor) + min;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const step = (max - min) / (length - 1);
|
|
95
|
+
return range(min, max + step / 2, step);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function range(from, to, step) {
|
|
99
|
+
const result = [];
|
|
100
|
+
for (let i = from; i < to; i += step) {
|
|
101
|
+
result.push(i);
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
function drawContours(level, datum, negative = false) {
|
|
106
|
+
const zoom = level / 2 + 1;
|
|
107
|
+
const { positive: { numberOfLayers: numberOfPositiveLayer }, negative: { numberOfLayers: numberOfNegativeLayer }, } = datum.display.contourOptions;
|
|
108
|
+
if (negative) {
|
|
109
|
+
return getContours(zoom, {
|
|
110
|
+
negative,
|
|
111
|
+
nbLevels: numberOfNegativeLayer,
|
|
112
|
+
data: datum.data,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return getContours(zoom, {
|
|
116
|
+
nbLevels: numberOfPositiveLayer,
|
|
117
|
+
data: datum.data,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
exports.drawContours = drawContours;
|
|
121
|
+
function getContours(zoomLevel, options) {
|
|
122
|
+
const { negative = false, timeout = 2000, nbLevels, data } = options;
|
|
123
|
+
const xs = getRange(data.minX, data.maxX, data.z[0].length);
|
|
124
|
+
const ys = getRange(data.minY, data.maxY, data.z.length);
|
|
125
|
+
const conrec = new ml_conrec_1.Conrec(data.z, { xs, ys, swapAxes: false });
|
|
126
|
+
const sanResult = (0, calculateSanPlot_1.calculateSanPlot)('2D', data);
|
|
127
|
+
const median = sanResult.positive;
|
|
128
|
+
const max = Math.max(Math.abs(data.maxZ), Math.abs(data.minZ));
|
|
129
|
+
let _range = getRange(median * 1 * Math.pow(2, zoomLevel), max, nbLevels, 2);
|
|
130
|
+
if (negative) {
|
|
131
|
+
_range = _range.map((value) => -value);
|
|
132
|
+
}
|
|
133
|
+
return conrec.drawContour({
|
|
134
|
+
contourDrawer: 'basic',
|
|
135
|
+
levels: _range,
|
|
136
|
+
timeout,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
@@ -27,7 +27,7 @@ exports.initiateDatum2D = void 0;
|
|
|
27
27
|
const uuid_1 = require("@lukeed/uuid");
|
|
28
28
|
const FiltersManager = __importStar(require("../../FiltersManager"));
|
|
29
29
|
const getColor_1 = require("../../utilities/getColor");
|
|
30
|
-
const
|
|
30
|
+
const contours_1 = require("./contours");
|
|
31
31
|
function initiateDatum2D(options, usedColors = {}) {
|
|
32
32
|
const datum = {};
|
|
33
33
|
datum.id = options.id || (0, uuid_1.v4)();
|
|
@@ -41,7 +41,7 @@ function initiateDatum2D(options, usedColors = {}) {
|
|
|
41
41
|
isPositiveVisible: true,
|
|
42
42
|
isNegativeVisible: true,
|
|
43
43
|
isVisible: true,
|
|
44
|
-
contourOptions:
|
|
44
|
+
contourOptions: contours_1.DEFAULT_CONTOURS_OPTIONS,
|
|
45
45
|
dimension: 2,
|
|
46
46
|
...options.display,
|
|
47
47
|
};
|
|
@@ -66,7 +66,6 @@ function initiateDatum2D(options, usedColors = {}) {
|
|
|
66
66
|
datum.originalData = datum.data;
|
|
67
67
|
datum.filters = Object.assign([], options.filters);
|
|
68
68
|
datum.zones = { values: [], options: {}, ...options.zones };
|
|
69
|
-
datum.processingController = new Processing2D_1.default(datum.data, datum.display.contourOptions);
|
|
70
69
|
//reapply filters after load the original data
|
|
71
70
|
FiltersManager.reapplyFilters(datum);
|
|
72
71
|
return datum;
|
package/lib-cjs/versionInfo.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmrium",
|
|
3
3
|
"description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.33.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib-cjs/component/NMRium.js",
|
|
7
7
|
"module": "lib/component/NMRium.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"url": "git+https://github.com/cheminfo/nmrium.git"
|
|
39
39
|
},
|
|
40
40
|
"volta": {
|
|
41
|
-
"node": "16.
|
|
41
|
+
"node": "16.18.0"
|
|
42
42
|
},
|
|
43
43
|
"overrides": {
|
|
44
44
|
"react": "$react",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"analysis-ui-components": "^0.17.3",
|
|
55
55
|
"cheminfo-font": "^1.9.0",
|
|
56
56
|
"cheminfo-types": "^1.4.0",
|
|
57
|
+
"clipboard-polyfill": "^4.0.0-rc1",
|
|
57
58
|
"d3": "^7.6.1",
|
|
58
59
|
"eventemitter3": "^4.0.7",
|
|
59
60
|
"file-saver": "^2.0.5",
|
|
@@ -69,14 +70,13 @@
|
|
|
69
70
|
"ml-array-median": "^1.1.6",
|
|
70
71
|
"ml-array-xy-equally-spaced": "^1.2.1",
|
|
71
72
|
"ml-baseline-correction-regression": "^1.0.0",
|
|
72
|
-
"ml-conrec": "^
|
|
73
|
+
"ml-conrec": "^4.0.0",
|
|
73
74
|
"ml-gsd": "^12.1.2",
|
|
74
75
|
"ml-spectra-processing": "^11.13.0",
|
|
75
76
|
"ml-stat": "^1.3.3",
|
|
76
77
|
"multiplet-analysis": "^2.0.0",
|
|
77
78
|
"nmr-correlation": "^2.3.3",
|
|
78
|
-
"nmr-load-save": "^0.
|
|
79
|
-
"nmr-parser": "^3.0.1",
|
|
79
|
+
"nmr-load-save": "^0.4.6",
|
|
80
80
|
"nmr-processing": "^9.2.0",
|
|
81
81
|
"nmredata": "^0.9.0",
|
|
82
82
|
"numeral": "^2.0.6",
|
|
@@ -128,4 +128,4 @@
|
|
|
128
128
|
"typescript": "~4.8.4",
|
|
129
129
|
"vite": "^3.1.7"
|
|
130
130
|
}
|
|
131
|
-
}
|
|
131
|
+
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { useCallback } from 'react';
|
|
5
|
-
import { useChartData } from '../context/ChartContext';
|
|
6
|
-
import { useDispatch } from '../context/DispatchContext';
|
|
7
|
-
import { useGlobal } from '../context/GlobalContext';
|
|
8
|
-
import { useScaleChecked } from '../context/ScaleContext';
|
|
9
|
-
import Resizer from '../elements/resizer/Resizer';
|
|
10
|
-
import { HighlightEventSource, useHighlight } from '../highlight/index';
|
|
11
|
-
import { RESIZE_INTEGRAL } from '../reducer/types/Types';
|
|
12
|
-
import { options } from '../toolbar/ToolTypes';
|
|
13
|
-
import { formatNumber } from '../utility/formatNumber';
|
|
14
|
-
const stylesOnHover = css `
|
|
15
|
-
pointer-events: bounding-box;
|
|
16
|
-
@-moz-document url-prefix() {
|
|
17
|
-
pointer-events: fill;
|
|
18
|
-
}
|
|
19
|
-
.highlight {
|
|
20
|
-
fill: transparent;
|
|
21
|
-
}
|
|
22
|
-
.target {
|
|
23
|
-
visibility: hidden;
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
const stylesHighlighted = css `
|
|
27
|
-
pointer-events: bounding-box;
|
|
28
|
-
|
|
29
|
-
@-moz-document url-prefix() {
|
|
30
|
-
pointer-events: fill;
|
|
31
|
-
}
|
|
32
|
-
fill: #ff6f0057;
|
|
33
|
-
|
|
34
|
-
.target {
|
|
35
|
-
visibility: visible;
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
function IntegralResizable({ integralData, integralFormat, }) {
|
|
39
|
-
const { height, margin, toolOptions: { selectedTool }, } = useChartData();
|
|
40
|
-
const { viewerRef } = useGlobal();
|
|
41
|
-
const { scaleX } = useScaleChecked();
|
|
42
|
-
const dispatch = useDispatch();
|
|
43
|
-
const { id, integral } = integralData;
|
|
44
|
-
const highlight = useHighlight([id], {
|
|
45
|
-
type: HighlightEventSource.INTEGRAL,
|
|
46
|
-
extra: { id },
|
|
47
|
-
});
|
|
48
|
-
const handleOnStopResizing = useCallback((position) => {
|
|
49
|
-
dispatch({
|
|
50
|
-
type: RESIZE_INTEGRAL,
|
|
51
|
-
payload: {
|
|
52
|
-
data: {
|
|
53
|
-
...integralData,
|
|
54
|
-
from: scaleX().invert(position.x2),
|
|
55
|
-
to: scaleX().invert(position.x1),
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}, [dispatch, integralData, scaleX]);
|
|
60
|
-
const handleOnEnterNotation = useCallback(() => {
|
|
61
|
-
highlight.show();
|
|
62
|
-
}, [highlight]);
|
|
63
|
-
const handleOnMouseLeaveNotation = useCallback(() => {
|
|
64
|
-
highlight.hide();
|
|
65
|
-
}, [highlight]);
|
|
66
|
-
const from = integralData.from ? scaleX()(integralData.from) : 0;
|
|
67
|
-
const to = integralData.to ? scaleX()(integralData.to) : 0;
|
|
68
|
-
return (_jsx("g", { onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: _jsx(Resizer, { tag: "svg", initialPosition: { x1: to, x2: from }, onEnd: handleOnStopResizing, parentElement: viewerRef, disabled: selectedTool !== options.integral.id, children: ({ x1, x2 }, isActive) => (_jsxs("g", { css: highlight.isActive || isActive ? stylesHighlighted : stylesOnHover, children: [_jsx("rect", { x: "0", y: "0", width: x2 - x1, height: height - margin.bottom, className: "highlight", "data-no-export": "true" }), _jsx("text", { x: 0, y: height - margin.bottom + 30, fill: "black", style: { fontSize: '12px', fontWeight: 'bold' }, children: integral !== undefined
|
|
69
|
-
? formatNumber(integral, integralFormat)
|
|
70
|
-
: '' })] })) }, `${id}_${to}_${from}`) }));
|
|
71
|
-
}
|
|
72
|
-
export default IntegralResizable;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function useFormat(preferences: any): (value: any, keysPath: any, prefix?: string, suffix?: string) => any;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import lodashGet from 'lodash/get';
|
|
2
|
-
import { formatNumber } from '../../../utility/formatNumber';
|
|
3
|
-
export default function useFormat(preferences) {
|
|
4
|
-
return (value, keysPath, prefix = '', suffix = '') => {
|
|
5
|
-
const format = lodashGet(preferences, keysPath, '0.000');
|
|
6
|
-
return formatNumber(value, format, prefix, suffix);
|
|
7
|
-
};
|
|
8
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function fromBruker(result: any, options?: {}, usedColors?: {}): import("../types/data1d").Datum1D;
|
|
2
|
-
export declare function fromCSD(result: any, options?: {}, usedColors?: {}): import("../types/data1d").Datum1D;
|
|
3
|
-
export declare function fromParsedJcamp(parsedJcamp: any, options: any, usedColors: any, jcampSpectrumIndex: number): import("../types/data1d").Datum1D;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { initiateDatum1D } from './Spectrum1D';
|
|
2
|
-
export function fromBruker(result, options = {}, usedColors = {}) {
|
|
3
|
-
const { dependentVariables, info, meta, source } = result;
|
|
4
|
-
let { data } = dependentVariables[0].components[0];
|
|
5
|
-
const { x, re, im } = data;
|
|
6
|
-
if (x[0] > x[1]) {
|
|
7
|
-
x.reverse();
|
|
8
|
-
re.reverse();
|
|
9
|
-
if (im)
|
|
10
|
-
im.reverse();
|
|
11
|
-
}
|
|
12
|
-
if (data.im)
|
|
13
|
-
info.isComplex = true;
|
|
14
|
-
if (Array.isArray(info.nucleus))
|
|
15
|
-
info.nucleus = info.nucleus[0];
|
|
16
|
-
const datum1D = initiateDatum1D({
|
|
17
|
-
...options,
|
|
18
|
-
source,
|
|
19
|
-
info,
|
|
20
|
-
meta,
|
|
21
|
-
data,
|
|
22
|
-
}, usedColors);
|
|
23
|
-
return datum1D;
|
|
24
|
-
}
|
|
25
|
-
export function fromCSD(result, options = {}, usedColors = {}) {
|
|
26
|
-
let dimension = result.dimensions[0];
|
|
27
|
-
let dependentVariables = result.dependentVariables;
|
|
28
|
-
let quantityName = dimension.quantityName;
|
|
29
|
-
let n = dimension.count;
|
|
30
|
-
let incr = dimension.increment.magnitude;
|
|
31
|
-
let origin = dimension.originOffset.magnitude;
|
|
32
|
-
let offset = dimension.coordinatesOffset.magnitude;
|
|
33
|
-
let buffer = dependentVariables[0].components[0];
|
|
34
|
-
const re = new Float64Array(n);
|
|
35
|
-
const im = new Float64Array(n);
|
|
36
|
-
for (let i = buffer.length - 1, index = 0; i > 0; i -= 2) {
|
|
37
|
-
re[index] = buffer[i - 1];
|
|
38
|
-
im[index++] = buffer[i];
|
|
39
|
-
}
|
|
40
|
-
let data = {};
|
|
41
|
-
let i, x0;
|
|
42
|
-
switch (quantityName) {
|
|
43
|
-
case 'frequency':
|
|
44
|
-
x0 = 0 + (offset / origin) * 1000000;
|
|
45
|
-
i = (incr / origin) * 1000000;
|
|
46
|
-
data.re = re;
|
|
47
|
-
data.im = im;
|
|
48
|
-
break;
|
|
49
|
-
case 'time':
|
|
50
|
-
x0 = origin;
|
|
51
|
-
i = incr;
|
|
52
|
-
data.re = re.reverse();
|
|
53
|
-
data.im = im.reverse().map((z) => -z);
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
let scale = [];
|
|
59
|
-
for (let x = 0; x < n; x++) {
|
|
60
|
-
scale.push(x0 + x * i);
|
|
61
|
-
}
|
|
62
|
-
data.x = scale;
|
|
63
|
-
const datum1D = initiateDatum1D({
|
|
64
|
-
...options,
|
|
65
|
-
data,
|
|
66
|
-
}, usedColors);
|
|
67
|
-
return datum1D;
|
|
68
|
-
}
|
|
69
|
-
export function fromParsedJcamp(parsedJcamp, options, usedColors, jcampSpectrumIndex) {
|
|
70
|
-
const { dependentVariables, info, meta } = parsedJcamp;
|
|
71
|
-
let data = getData(dependentVariables[0].components);
|
|
72
|
-
if (Array.isArray(info.nucleus))
|
|
73
|
-
info.nucleus = info.nucleus[0];
|
|
74
|
-
const datum1D = initiateDatum1D({
|
|
75
|
-
...options,
|
|
76
|
-
source: { ...options.source, jcampSpectrumIndex },
|
|
77
|
-
display: {
|
|
78
|
-
...options.display,
|
|
79
|
-
name: options?.display?.name ? options.display.name : info?.title,
|
|
80
|
-
},
|
|
81
|
-
info,
|
|
82
|
-
meta,
|
|
83
|
-
data,
|
|
84
|
-
}, usedColors);
|
|
85
|
-
return datum1D;
|
|
86
|
-
}
|
|
87
|
-
function getData(spectra) {
|
|
88
|
-
let x = spectra[0]?.data?.x ? spectra[0].data.x : [];
|
|
89
|
-
let re = spectra[0]?.data?.y ? spectra[0].data.y : [];
|
|
90
|
-
let im = spectra[1]?.data?.y ? spectra[1].data.y : null;
|
|
91
|
-
if (x[0] > x[1]) {
|
|
92
|
-
x.reverse();
|
|
93
|
-
re.reverse();
|
|
94
|
-
if (im)
|
|
95
|
-
im.reverse();
|
|
96
|
-
}
|
|
97
|
-
return { x, re, im };
|
|
98
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function fromParsedJcamp(parsedJcamp: any, options: any, usedColors: any, jcampSpectrumIndex: number): import("../types/data2d").Datum2D;
|
|
2
|
-
export declare function fromBruker(result: any, options?: {}, usedColors?: {}): import("../types/data2d").Datum2D;
|
|
3
|
-
export declare function fromCSD(result: any, options?: {}, usedColors?: {}): import("../types/data2d").Datum2D;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { initiateDatum2D } from './Spectrum2D';
|
|
2
|
-
export function fromParsedJcamp(parsedJcamp, options, usedColors, jcampSpectrumIndex) {
|
|
3
|
-
const { dependentVariables, info, meta } = parsedJcamp;
|
|
4
|
-
let data = dependentVariables[0].components;
|
|
5
|
-
const ob = initiateDatum2D({
|
|
6
|
-
...options,
|
|
7
|
-
source: { ...options?.source, jcampSpectrumIndex },
|
|
8
|
-
display: {
|
|
9
|
-
...options.display,
|
|
10
|
-
name: options?.display?.name ? options.display.name : info?.title,
|
|
11
|
-
},
|
|
12
|
-
info,
|
|
13
|
-
meta,
|
|
14
|
-
data,
|
|
15
|
-
}, usedColors);
|
|
16
|
-
return ob;
|
|
17
|
-
}
|
|
18
|
-
export function fromBruker(result, options = {}, usedColors = {}) {
|
|
19
|
-
const { dependentVariables, meta, source } = result;
|
|
20
|
-
let data = dependentVariables[0].components;
|
|
21
|
-
const datum2D = initiateDatum2D({
|
|
22
|
-
...options,
|
|
23
|
-
source,
|
|
24
|
-
meta,
|
|
25
|
-
data,
|
|
26
|
-
}, usedColors);
|
|
27
|
-
return datum2D;
|
|
28
|
-
}
|
|
29
|
-
// TODO: implement this.
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
|
-
export function fromCSD(result, options = {}, usedColors = {}) {
|
|
32
|
-
const datum2D = initiateDatum2D({}, usedColors);
|
|
33
|
-
return datum2D;
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|