nmrium 0.31.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.
Files changed (178) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/FooterBanner.js +17 -10
  3. package/lib/component/1d/{Integral.d.ts → integral/Integral.d.ts} +0 -0
  4. package/lib/component/1d/{Integral.js → integral/Integral.js} +2 -2
  5. package/lib/component/1d/integral/IntegralIndicator.d.ts +9 -0
  6. package/lib/component/1d/integral/IntegralIndicator.js +27 -0
  7. package/lib/component/1d/{IntegralResizable.d.ts → integral/IntegralResizable.d.ts} +0 -0
  8. package/lib/component/1d/integral/IntegralResizable.js +69 -0
  9. package/lib/component/1d/{IntegralsSeries.d.ts → integral/IntegralsSeries.d.ts} +0 -0
  10. package/lib/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  11. package/lib/component/1d/ranges/Range.js +27 -50
  12. package/lib/component/1d/utilities/scale.js +2 -2
  13. package/lib/component/2d/Contours.js +61 -42
  14. package/lib/component/2d/Left1DChart.js +1 -1
  15. package/lib/component/2d/Top1DChart.js +1 -1
  16. package/lib/component/EventsTrackers/BrushTracker.js +30 -21
  17. package/lib/component/NMRium.d.ts +1 -1
  18. package/lib/component/NMRium.js +1 -1
  19. package/lib/component/SplitPaneWrapper.js +1 -1
  20. package/lib/component/elements/EditableColumn.d.ts +3 -1
  21. package/lib/component/elements/EditableColumn.js +18 -3
  22. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  23. package/lib/component/elements/formik/FormikColorPicker.js +5 -8
  24. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  25. package/lib/component/elements/formik/FormikInput.js +8 -19
  26. package/lib/component/elements/formik/FormikOnChange.d.ts +1 -1
  27. package/lib/component/elements/formik/FormikOnChange.js +13 -10
  28. package/lib/component/elements/formik/FormikSlider.d.ts +2 -4
  29. package/lib/component/elements/formik/FormikSlider.js +8 -11
  30. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
  31. package/lib/component/hooks/useExport.js +1 -1
  32. package/lib/component/loader/DropZone.js +9 -1
  33. package/lib/component/modal/ExportAsMatrixModal.js +1 -1
  34. package/lib/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  35. package/lib/component/modal/setting/GeneralTabContent.js +1 -1
  36. package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  37. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  38. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  39. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  40. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  41. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
  42. package/lib/component/panels/RangesPanel/RangesTableRow.js +1 -3
  43. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +1 -1
  44. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.d.ts +1 -1
  45. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  46. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.d.ts +1 -1
  47. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  48. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
  49. package/lib/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  50. package/lib/component/reducer/Reducer.d.ts +20 -59
  51. package/lib/component/reducer/Reducer.js +24 -10
  52. package/lib/component/reducer/actions/DomainActions.js +3 -2
  53. package/lib/component/reducer/actions/FiltersActions.js +12 -3
  54. package/lib/component/reducer/actions/IntegralsActions.js +6 -5
  55. package/lib/component/reducer/actions/PeaksActions.js +7 -6
  56. package/lib/component/reducer/actions/PreferencesActions.js +18 -36
  57. package/lib/component/reducer/actions/RangesActions.d.ts +1 -1
  58. package/lib/component/reducer/actions/RangesActions.js +20 -16
  59. package/lib/component/reducer/actions/SpectrumsActions.js +13 -6
  60. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
  61. package/lib/component/reducer/actions/ToolsActions.js +15 -28
  62. package/lib/component/reducer/actions/ZonesActions.js +9 -8
  63. package/lib/component/reducer/core/Constants.js +1 -1
  64. package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
  65. package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
  66. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  67. package/lib/component/toolbar/BasicToolBar.js +8 -7
  68. package/lib/component/utility/FileUtility.d.ts +1 -8
  69. package/lib/component/utility/FileUtility.js +2 -17
  70. package/lib/component/utility/{Export.d.ts → export.d.ts} +0 -0
  71. package/lib/component/utility/{Export.js → export.js} +27 -44
  72. package/lib/component/utility/formatNumber.d.ts +6 -1
  73. package/lib/component/utility/formatNumber.js +4 -3
  74. package/lib/component/workspaces/Workspace.d.ts +1 -1
  75. package/lib/component/workspaces/exercise.js +4 -4
  76. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  77. package/lib/data/Filters.d.ts +1 -2
  78. package/lib/data/Filters.js +1 -2
  79. package/lib/data/SpectraManager.d.ts +1 -2
  80. package/lib/data/SpectraManager.js +22 -55
  81. package/lib/data/data1d/filter1d/fft.js +21 -4
  82. package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
  83. package/lib/data/data2d/Processing2D.js +3 -2
  84. package/lib/data/data2d/Spectrum2D/contours.d.ts +40 -0
  85. package/lib/data/data2d/Spectrum2D/contours.js +132 -0
  86. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  87. package/lib/data/types/common/Source.d.ts +1 -0
  88. package/lib/data/types/data2d/Data2D.d.ts +2 -0
  89. package/lib/data/types/data2d/Datum2D.d.ts +0 -1
  90. package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
  91. package/lib/data/utilities/calculateSanPlot.js +31 -0
  92. package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
  93. package/lib/versionInfo.js +1 -1
  94. package/lib-cjs/component/1d/Chart1D.js +1 -1
  95. package/lib-cjs/component/1d/FooterBanner.js +16 -9
  96. package/lib-cjs/component/1d/{Integral.js → integral/Integral.js} +2 -2
  97. package/lib-cjs/component/1d/integral/IntegralIndicator.js +31 -0
  98. package/lib-cjs/component/1d/integral/IntegralResizable.js +74 -0
  99. package/lib-cjs/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  100. package/lib-cjs/component/1d/ranges/Range.js +27 -50
  101. package/lib-cjs/component/1d/utilities/scale.js +2 -2
  102. package/lib-cjs/component/2d/Contours.js +60 -41
  103. package/lib-cjs/component/2d/Left1DChart.js +1 -1
  104. package/lib-cjs/component/2d/Top1DChart.js +1 -1
  105. package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
  106. package/lib-cjs/component/NMRium.js +2 -2
  107. package/lib-cjs/component/SplitPaneWrapper.js +1 -1
  108. package/lib-cjs/component/elements/EditableColumn.js +18 -3
  109. package/lib-cjs/component/elements/formik/FormikColorPicker.js +4 -7
  110. package/lib-cjs/component/elements/formik/FormikInput.js +8 -19
  111. package/lib-cjs/component/elements/formik/FormikOnChange.js +13 -10
  112. package/lib-cjs/component/elements/formik/FormikSlider.js +7 -10
  113. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
  114. package/lib-cjs/component/hooks/useExport.js +6 -6
  115. package/lib-cjs/component/loader/DropZone.js +9 -1
  116. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -2
  117. package/lib-cjs/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  118. package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
  119. package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  120. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -4
  121. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -2
  122. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  123. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +2 -2
  124. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
  125. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +1 -3
  126. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +2 -2
  127. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  128. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  129. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
  130. package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  131. package/lib-cjs/component/reducer/Reducer.js +23 -9
  132. package/lib-cjs/component/reducer/actions/DomainActions.js +3 -2
  133. package/lib-cjs/component/reducer/actions/FiltersActions.js +12 -3
  134. package/lib-cjs/component/reducer/actions/IntegralsActions.js +6 -5
  135. package/lib-cjs/component/reducer/actions/PeaksActions.js +7 -6
  136. package/lib-cjs/component/reducer/actions/PreferencesActions.js +18 -36
  137. package/lib-cjs/component/reducer/actions/RangesActions.js +20 -16
  138. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +12 -5
  139. package/lib-cjs/component/reducer/actions/ToolsActions.js +15 -28
  140. package/lib-cjs/component/reducer/actions/ZonesActions.js +9 -8
  141. package/lib-cjs/component/reducer/core/Constants.js +1 -1
  142. package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
  143. package/lib-cjs/component/toolbar/BasicToolBar.js +7 -6
  144. package/lib-cjs/component/utility/FileUtility.js +2 -18
  145. package/lib-cjs/component/utility/{Export.js → export.js} +51 -45
  146. package/lib-cjs/component/utility/formatNumber.js +4 -3
  147. package/lib-cjs/component/workspaces/exercise.js +4 -4
  148. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
  149. package/lib-cjs/data/Filters.js +1 -3
  150. package/lib-cjs/data/SpectraManager.js +23 -57
  151. package/lib-cjs/data/data1d/filter1d/fft.js +20 -3
  152. package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
  153. package/lib-cjs/data/data2d/Processing2D.js +3 -2
  154. package/lib-cjs/data/data2d/Spectrum2D/contours.js +138 -0
  155. package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  156. package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
  157. package/lib-cjs/versionInfo.js +1 -1
  158. package/package.json +21 -20
  159. package/lib/component/1d/IntegralResizable.js +0 -72
  160. package/lib/component/panels/RangesPanel/TableColumns/format.d.ts +0 -1
  161. package/lib/component/panels/RangesPanel/TableColumns/format.js +0 -8
  162. package/lib/data/data1d/Data1DManager.d.ts +0 -3
  163. package/lib/data/data1d/Data1DManager.js +0 -98
  164. package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
  165. package/lib/data/data1d/filter1d/absolute.js +0 -26
  166. package/lib/data/data2d/Data2DManager.d.ts +0 -3
  167. package/lib/data/data2d/Data2DManager.js +0 -34
  168. package/lib/data/types/data2d/Contour.d.ts +0 -4
  169. package/lib/data/types/data2d/Contour.js +0 -1
  170. package/lib/data/types/data2d/Contours.d.ts +0 -2
  171. package/lib/data/types/data2d/Contours.js +0 -1
  172. package/lib-cjs/component/1d/IntegralResizable.js +0 -77
  173. package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +0 -14
  174. package/lib-cjs/data/data1d/Data1DManager.js +0 -104
  175. package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
  176. package/lib-cjs/data/data2d/Data2DManager.js +0 -40
  177. package/lib-cjs/data/types/data2d/Contour.js +0 -2
  178. package/lib-cjs/data/types/data2d/Contours.js +0 -2
@@ -1,4 +1,4 @@
1
- import { reimFFT, reimPhaseCorrection } from 'ml-spectra-processing';
1
+ import { reimFFT, reimPhaseCorrection, xMean } from 'ml-spectra-processing';
2
2
  import { padDataToNextPowerOfTwo } from './utils/padDataToNextPowerOfTwo';
3
3
  export const id = 'fft';
4
4
  export const name = 'FFT';
@@ -11,19 +11,22 @@ export function apply(datum1D) {
11
11
  throw new Error('fft not applicable on this data');
12
12
  }
13
13
  let digitalFilterApplied = datum1D.filters.some((e) => e.name === 'digitalFilter' && e.flag);
14
- const { data } = datum1D;
14
+ const data = datum1D.meta.AQ_mod === 1
15
+ ? removeDCOffset(datum1D, digitalFilterApplied)
16
+ : { ...datum1D.data };
15
17
  if (data.x.length !== data.re.length || data.x.length !== data.im.length) {
16
18
  throw new Error('The length of data should be equal');
17
19
  }
18
20
  else if (!isPowerOfTwo(datum1D.data.x.length)) {
19
21
  padDataToNextPowerOfTwo(datum1D, digitalFilterApplied);
20
22
  }
21
- Object.assign(datum1D.data, reimFFT(datum1D.data, { applyZeroShift: true }));
23
+ Object.assign(data, reimFFT(data, { applyZeroShift: true }));
22
24
  if (digitalFilterApplied) {
23
25
  let { digitalFilter = 0 } = datum1D.info;
24
26
  let ph1 = (digitalFilter - Math.floor(digitalFilter)) * Math.PI * 2;
25
- Object.assign(datum1D.data, reimPhaseCorrection(datum1D.data, 0, ph1));
27
+ Object.assign(data, reimPhaseCorrection(data, 0, ph1));
26
28
  }
29
+ Object.assign(datum1D.data, data);
27
30
  datum1D.data.x = generateXAxis(datum1D);
28
31
  datum1D.info = { ...datum1D.info, isFid: false, isFt: true };
29
32
  }
@@ -58,3 +61,17 @@ function generateXAxis(datum1D) {
58
61
  function isPowerOfTwo(n) {
59
62
  return n !== 0 && (n & (n - 1)) === 0;
60
63
  }
64
+ function removeDCOffset(datum1D, digitalFilterApplied) {
65
+ let { digitalFilter = 0 } = digitalFilterApplied ? datum1D.info : {};
66
+ const data = { ...datum1D.data };
67
+ const nbPoints = data.re.length;
68
+ const newRe = new Float64Array(data.re);
69
+ const newIm = new Float64Array(data.im);
70
+ const averageRe = xMean(data.re.slice((nbPoints * 0.75) >> 0, nbPoints - digitalFilter));
71
+ const averageIm = xMean(data.im.slice((nbPoints * 0.75) >> 0, nbPoints - digitalFilter));
72
+ for (let i = digitalFilterApplied ? 0 : digitalFilter; i < nbPoints - digitalFilter; i++) {
73
+ newRe[i] -= averageRe;
74
+ newIm[i] -= averageIm;
75
+ }
76
+ return { x: data.x, re: newRe, im: newIm };
77
+ }
@@ -1,4 +1,4 @@
1
- import { reimPhaseCorrection } from 'ml-spectra-processing';
1
+ import { reimAbsolute, reimPhaseCorrection } from 'ml-spectra-processing';
2
2
  export const id = 'phaseCorrection';
3
3
  export const name = 'Phase correction';
4
4
  /**
@@ -12,10 +12,16 @@ export function apply(datum1D, options = {}) {
12
12
  if (!isApplicable(datum1D)) {
13
13
  throw new Error('phaseCorrection not applicable on this data');
14
14
  }
15
- let { ph0, ph1 } = options;
16
- ph0 *= Math.PI / 180.0;
17
- ph1 *= Math.PI / 180.0;
18
- Object.assign(datum1D.data, reimPhaseCorrection(datum1D.data, ph0, ph1));
15
+ let { ph0, ph1, absolute } = options;
16
+ if (absolute) {
17
+ datum1D.data.re = reimAbsolute(datum1D.data);
18
+ datum1D.data.im = new Float64Array(0);
19
+ }
20
+ else {
21
+ ph0 *= Math.PI / 180.0;
22
+ ph1 *= Math.PI / 180.0;
23
+ Object.assign(datum1D.data, reimPhaseCorrection(datum1D.data, ph0, ph1));
24
+ }
19
25
  }
20
26
  export function isApplicable(datum1D) {
21
27
  if (datum1D.info.isComplex && !datum1D.info.isFid)
@@ -1,5 +1,5 @@
1
1
  import { Conrec } from 'ml-conrec';
2
- import { matrixAbsoluteMedian } from 'ml-spectra-processing';
2
+ import { calculateSanPlot } from '../utilities/calculateSanPlot';
3
3
  export const defaultContourOptions = {
4
4
  positive: {
5
5
  contourLevels: [0, 21],
@@ -22,7 +22,8 @@ export default class Processing2D {
22
22
  const xs = getRange(minMax.minX, minMax.maxX, minMax.z[0].length);
23
23
  const ys = getRange(minMax.minY, minMax.maxY, minMax.z.length);
24
24
  this.conrec = new Conrec(minMax.z, { xs, ys, swapAxes: false });
25
- this.median = matrixAbsoluteMedian(minMax.z);
25
+ const sanResult = calculateSanPlot('2D', minMax);
26
+ this.median = sanResult.positive;
26
27
  this.minMax = minMax;
27
28
  }
28
29
  getLevel() {
@@ -0,0 +1,40 @@
1
+ import { Datum2D } from '../../types/data2d';
2
+ interface Level {
3
+ positive: number;
4
+ negative: number;
5
+ }
6
+ interface ContourItem {
7
+ contourLevels: [number, number];
8
+ numberOfLayers: number;
9
+ }
10
+ interface ContourOptions {
11
+ positive: ContourItem;
12
+ negative: ContourItem;
13
+ }
14
+ interface ContoursLevels {
15
+ [key: string]: Level;
16
+ }
17
+ declare const DEFAULT_CONTOURS_OPTIONS: {
18
+ positive: {
19
+ contourLevels: number[];
20
+ numberOfLayers: number;
21
+ };
22
+ negative: {
23
+ contourLevels: number[];
24
+ numberOfLayers: number;
25
+ };
26
+ };
27
+ declare type LevelSign = keyof Level;
28
+ interface ReturnContoursManager {
29
+ wheel: (value: number, shift: boolean) => Level;
30
+ getLevel: () => Level;
31
+ checkLevel: () => Level;
32
+ }
33
+ declare function getDefaultContoursLevel(options: ContourOptions): Level;
34
+ declare function contoursManager(spectrumID: string, state: ContoursLevels, options: ContourOptions): ReturnContoursManager;
35
+ declare function drawContours(level: number, datum: Datum2D, negative?: boolean): {
36
+ contours: any;
37
+ timeout: boolean;
38
+ };
39
+ export { drawContours, contoursManager, getDefaultContoursLevel, DEFAULT_CONTOURS_OPTIONS, };
40
+ export type { ContoursLevels, ReturnContoursManager, Level, LevelSign };
@@ -0,0 +1,132 @@
1
+ import { Conrec } from 'ml-conrec';
2
+ import { calculateSanPlot } from '../../utilities/calculateSanPlot';
3
+ const DEFAULT_CONTOURS_OPTIONS = {
4
+ positive: {
5
+ contourLevels: [0, 21],
6
+ numberOfLayers: 10,
7
+ },
8
+ negative: {
9
+ contourLevels: [0, 21],
10
+ numberOfLayers: 10,
11
+ },
12
+ };
13
+ const LEVEL_SIGNS = ['positive', 'negative'];
14
+ function getDefaultContoursLevel(options) {
15
+ const defaultLevel = { negative: 10, positive: 10 };
16
+ for (const sign of LEVEL_SIGNS) {
17
+ const [min, max] = options[sign].contourLevels;
18
+ defaultLevel[sign] = min + max / 2;
19
+ }
20
+ return defaultLevel;
21
+ }
22
+ function contoursManager(spectrumID, state, options) {
23
+ const spectraLevels = { ...state };
24
+ const contourOptions = { ...options };
25
+ if (!state || !state[spectrumID]) {
26
+ const defaultLevel = getDefaultContoursLevel(contourOptions);
27
+ spectraLevels[spectrumID] = defaultLevel;
28
+ }
29
+ const currentLevel = spectraLevels[spectrumID];
30
+ const wheel = (value, shiftKey) => prepareWheel(value, { shiftKey, contourOptions, currentLevel });
31
+ const getLevel = () => currentLevel;
32
+ const checkLevel = () => prepareCheckLevel(currentLevel, contourOptions);
33
+ return { wheel, getLevel, checkLevel };
34
+ }
35
+ function prepareWheel(value, options) {
36
+ let { shiftKey, currentLevel, contourOptions } = options;
37
+ const sign = Math.sign(value);
38
+ const positiveBoundary = contourOptions.positive.contourLevels;
39
+ const negativeBoundary = contourOptions.negative.contourLevels;
40
+ if (shiftKey) {
41
+ if ((currentLevel.positive === positiveBoundary[0] && sign === -1) ||
42
+ (currentLevel.positive >= positiveBoundary[1] && sign === 1)) {
43
+ return currentLevel;
44
+ }
45
+ currentLevel.positive += sign;
46
+ }
47
+ else {
48
+ if ((currentLevel.positive > positiveBoundary[0] && sign === -1) ||
49
+ (currentLevel.positive < positiveBoundary[1] && sign === 1)) {
50
+ currentLevel.positive += sign;
51
+ }
52
+ if ((currentLevel.negative > negativeBoundary[0] && sign === -1) ||
53
+ (currentLevel.negative < negativeBoundary[1] && sign === 1)) {
54
+ currentLevel.negative += sign;
55
+ }
56
+ }
57
+ return currentLevel;
58
+ }
59
+ function prepareCheckLevel(currentLevel, options) {
60
+ const level = { ...currentLevel };
61
+ for (const sign of LEVEL_SIGNS) {
62
+ const [min, max] = options[sign].contourLevels;
63
+ //check if the level is out of the boundary
64
+ if (level[sign] > max) {
65
+ level[sign] = max;
66
+ }
67
+ else if (level[sign] < min) {
68
+ level[sign] = min;
69
+ }
70
+ }
71
+ return level;
72
+ }
73
+ function getRange(min, max, length, exp) {
74
+ if (exp !== undefined) {
75
+ const factors = [];
76
+ factors[0] = 0;
77
+ for (let i = 1; i <= length; i++) {
78
+ factors[i] = factors[i - 1] + (exp - 1) / Math.pow(exp, i);
79
+ }
80
+ const lastFactor = factors[length];
81
+ const result = new Array(length);
82
+ for (let i = 0; i < length; i++) {
83
+ result[i] = (max - min) * (1 - factors[i + 1] / lastFactor) + min;
84
+ }
85
+ return result;
86
+ }
87
+ else {
88
+ const step = (max - min) / (length - 1);
89
+ return range(min, max + step / 2, step);
90
+ }
91
+ }
92
+ function range(from, to, step) {
93
+ const result = [];
94
+ for (let i = from; i < to; i += step) {
95
+ result.push(i);
96
+ }
97
+ return result;
98
+ }
99
+ function drawContours(level, datum, negative = false) {
100
+ const zoom = level / 2 + 1;
101
+ const { positive: { numberOfLayers: numberOfPositiveLayer }, negative: { numberOfLayers: numberOfNegativeLayer }, } = datum.display.contourOptions;
102
+ if (negative) {
103
+ return getContours(zoom, {
104
+ negative,
105
+ nbLevels: numberOfNegativeLayer,
106
+ data: datum.data,
107
+ });
108
+ }
109
+ return getContours(zoom, {
110
+ nbLevels: numberOfPositiveLayer,
111
+ data: datum.data,
112
+ });
113
+ }
114
+ function getContours(zoomLevel, options) {
115
+ const { negative = false, timeout = 2000, nbLevels, data } = options;
116
+ const xs = getRange(data.minX, data.maxX, data.z[0].length);
117
+ const ys = getRange(data.minY, data.maxY, data.z.length);
118
+ const conrec = new Conrec(data.z, { xs, ys, swapAxes: false });
119
+ const sanResult = calculateSanPlot('2D', data);
120
+ const median = sanResult.positive;
121
+ const max = Math.max(Math.abs(data.maxZ), Math.abs(data.minZ));
122
+ let _range = getRange(median * 1 * Math.pow(2, zoomLevel), max, nbLevels, 2);
123
+ if (negative) {
124
+ _range = _range.map((value) => -value);
125
+ }
126
+ return conrec.drawContour({
127
+ contourDrawer: 'basic',
128
+ levels: _range,
129
+ timeout,
130
+ });
131
+ }
132
+ export { drawContours, contoursManager, getDefaultContoursLevel, DEFAULT_CONTOURS_OPTIONS, };
@@ -1,7 +1,7 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import * as FiltersManager from '../../FiltersManager';
3
3
  import { get2DColor } from '../../utilities/getColor';
4
- import Processing2D, { defaultContourOptions } from '../Processing2D';
4
+ import { DEFAULT_CONTOURS_OPTIONS } from './contours';
5
5
  export function initiateDatum2D(options, usedColors = {}) {
6
6
  const datum = {};
7
7
  datum.id = options.id || v4();
@@ -15,7 +15,7 @@ export function initiateDatum2D(options, usedColors = {}) {
15
15
  isPositiveVisible: true,
16
16
  isNegativeVisible: true,
17
17
  isVisible: true,
18
- contourOptions: defaultContourOptions,
18
+ contourOptions: DEFAULT_CONTOURS_OPTIONS,
19
19
  dimension: 2,
20
20
  ...options.display,
21
21
  };
@@ -40,7 +40,6 @@ export function initiateDatum2D(options, usedColors = {}) {
40
40
  datum.originalData = datum.data;
41
41
  datum.filters = Object.assign([], options.filters);
42
42
  datum.zones = { values: [], options: {}, ...options.zones };
43
- datum.processingController = new Processing2D(datum.data, datum.display.contourOptions);
44
43
  //reapply filters after load the original data
45
44
  FiltersManager.reapplyFilters(datum);
46
45
  return datum;
@@ -1,4 +1,5 @@
1
1
  export interface Source {
2
+ jcamp: string;
2
3
  jcampURL: string;
3
4
  jcampSpectrumIndex: number;
4
5
  file: File;
@@ -2,6 +2,8 @@ export interface Data2D {
2
2
  z: Array<Array<number>>;
3
3
  minX: number;
4
4
  minY: number;
5
+ minZ: number;
5
6
  maxX: number;
6
7
  maxY: number;
8
+ maxZ: number;
7
9
  }
@@ -15,5 +15,4 @@ export interface Datum2D {
15
15
  originalData?: Data2D;
16
16
  zones: Zones;
17
17
  filters: Array<Filter>;
18
- processingController: any;
19
18
  }
@@ -0,0 +1,8 @@
1
+ import { Data1D } from '../types/data1d';
2
+ import { Data2D } from '../types/data2d';
3
+ export declare function calculateSanPlot<T extends '1D' | '2D'>(dimension: T, data: T extends '1D' ? Data1D : Data2D): {
4
+ positive: number;
5
+ negative: number;
6
+ snr: number;
7
+ sanplot: Record<string, import("cheminfo-types").DataXY<import("cheminfo-types").DoubleArray>>;
8
+ };
@@ -0,0 +1,31 @@
1
+ import { xNoiseSanPlot } from 'ml-spectra-processing';
2
+ export function calculateSanPlot(dimension, data) {
3
+ const input = dimension === '1D'
4
+ ? prepare1DData(data)
5
+ : prepare2DData(data);
6
+ return xNoiseSanPlot(input);
7
+ }
8
+ function prepare1DData(data) {
9
+ const length = data.re.length;
10
+ const jump = Math.floor(length / 307200) || 1;
11
+ const array = new Float64Array((length / jump) >> 0);
12
+ let index = 0;
13
+ for (let i = 0; i < array.length; i += jump) {
14
+ array[index++] = data.re[i];
15
+ }
16
+ return array;
17
+ }
18
+ function prepare2DData(data) {
19
+ let cols = data.z[0].length;
20
+ let rows = data.z.length;
21
+ let jump = Math.floor((cols * rows) / 204800) || 1;
22
+ const array = new Float64Array(((cols * rows) / jump) >> 0);
23
+ let index = 0;
24
+ // console.log('jump', jump, cols * rows);
25
+ for (let r = 0; r < rows; r += 1) {
26
+ for (let c = 0; c < cols; c += jump) {
27
+ array[index++] = data.z[r][c];
28
+ }
29
+ }
30
+ return array;
31
+ }
@@ -1,8 +1,8 @@
1
- import { InitialSeparation } from 'analysis-ui-components/lib-esm/components/SplitPane';
1
+ import { SplitPaneSize } from 'analysis-ui-components';
2
2
  import { PanelPreferencesType } from './PanelPreferencesType';
3
3
  export interface NMRiumGeneralPreferences {
4
4
  hideGeneralSettings: boolean;
5
5
  experimentalFeatures: PanelPreferencesType;
6
6
  hidePanelOnLoad: boolean;
7
- initialPanelWidth?: InitialSeparation;
7
+ initialPanelWidth?: SplitPaneSize;
8
8
  }
@@ -1 +1 @@
1
- export default { version: 'v0.31.0' };
1
+ export default { version: 'v0.33.0' };
@@ -7,10 +7,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const FloatMoleculeStructures_1 = __importDefault(require("../tool/FloatMoleculeStructures"));
8
8
  const ApodizationLine_1 = __importDefault(require("./ApodizationLine"));
9
9
  const ExclusionZonesAnnotations_1 = __importDefault(require("./ExclusionZonesAnnotations"));
10
- const IntegralsSeries_1 = __importDefault(require("./IntegralsSeries"));
11
10
  const LinesSeries_1 = __importDefault(require("./LinesSeries"));
12
11
  const XAxis_1 = __importDefault(require("./XAxis"));
13
12
  const DatabaseElements_1 = __importDefault(require("./database/DatabaseElements"));
13
+ const IntegralsSeries_1 = __importDefault(require("./integral/IntegralsSeries"));
14
14
  const JGraph_1 = __importDefault(require("./jCouplingGraph/JGraph"));
15
15
  const MultiAnalysisRanges_1 = __importDefault(require("./multiAnalysis/MultiAnalysisRanges"));
16
16
  const PeakAnnotations_1 = __importDefault(require("./peaks/PeakAnnotations"));
@@ -72,14 +72,6 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
72
72
  const { startX, endX, step } = (0, react_2.useContext)(BrushTracker_1.BrushContext);
73
73
  const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
74
74
  const format = (0, useFormatNumberByNucleus_1.useFormatNumberByNucleus)(activeTab);
75
- const getYValue = (0, react_2.useCallback)((xPosition) => {
76
- if (spectrum) {
77
- const data = (0, get1DDataXY_1.get1DDataXY)(spectrum);
78
- const xIndex = (0, ml_spectra_processing_1.xFindClosestIndex)(data.x, scaleX().invert(xPosition));
79
- return data.y[xIndex];
80
- }
81
- return 1;
82
- }, [spectrum, scaleX]);
83
75
  if (!position ||
84
76
  position.y < margin.top ||
85
77
  position.x < margin.left ||
@@ -87,7 +79,22 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
87
79
  position.y > height - margin.bottom) {
88
80
  return (0, jsx_runtime_1.jsx)("div", { css: styles });
89
81
  }
90
- return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(bs_1.BsCursor, {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \uD835\uDEC5: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: format(scaleX().invert(position.x)) }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "Hz" }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ") " })] }))] }), step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394ppm: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394Hz: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
82
+ function getXIndex(xPosition) {
83
+ if (spectrum) {
84
+ const data = (0, get1DDataXY_1.get1DDataXY)(spectrum);
85
+ return (0, ml_spectra_processing_1.xFindClosestIndex)(data.x, scaleX().invert(xPosition));
86
+ }
87
+ return 0;
88
+ }
89
+ function getYValue(xPosition) {
90
+ if (spectrum) {
91
+ const data = (0, get1DDataXY_1.get1DDataXY)(spectrum);
92
+ const xIndex = getXIndex(xPosition);
93
+ return data.y[xIndex];
94
+ }
95
+ return 1;
96
+ }
97
+ return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(bs_1.BsCursor, {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \uD835\uDEC5: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: format(scaleX().invert(position.x)) }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "Hz" }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ") " }), (0, jsx_runtime_1.jsx)("span", { children: "," }), (0, jsx_runtime_1.jsx)("span", { className: "label", children: " Index: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: getXIndex(position.x) })] }))] }), step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394ppm: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394Hz: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
91
98
  spectrum?.info?.originFrequency).toPrecision(5) })] })), step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " ratio :" }), (0, jsx_runtime_1.jsxs)("span", { className: "value", children: [((getYValue(startX) / (getYValue(endX) || Number.MIN_VALUE)) *
92
99
  100).toFixed(2), "%"] })] }))] })), activeSpectrum && ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "separator" }), (0, jsx_runtime_1.jsx)(io5_1.IoPulseSharp, {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "Intensity: " }), (0, jsx_runtime_1.jsx)("span", { className: "value yvalue", children: format(getYValue(position.x)) })] })] }))] }));
93
100
  }
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const useIntegralPath_1 = __importDefault(require("../hooks/useIntegralPath"));
8
- const usePanelPreferences_1 = require("../hooks/usePanelPreferences");
7
+ const useIntegralPath_1 = __importDefault(require("../../hooks/useIntegralPath"));
8
+ const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
9
9
  const IntegralResizable_1 = __importDefault(require("./IntegralResizable"));
10
10
  function Integral({ integral, isActive, nucleus }) {
11
11
  const path = (0, useIntegralPath_1.default)(integral);
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IntegralIndicator = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ChartContext_1 = require("../../context/ChartContext");
6
+ const formatNumber_1 = require("../../utility/formatNumber");
7
+ const styles = {
8
+ text: {
9
+ fontSize: '11px',
10
+ textAnchor: 'middle',
11
+ dominantBaseline: 'middle',
12
+ writingMode: 'vertical-rl',
13
+ fill: 'black',
14
+ },
15
+ path: {
16
+ fill: 'none',
17
+ strokeWidth: '1px',
18
+ shapeRendering: 'crispEdges',
19
+ stroke: 'black',
20
+ },
21
+ };
22
+ function IntegralIndicator(props) {
23
+ const { value, width, format, opacity = 1 } = props;
24
+ const { height, margin } = (0, ChartContext_1.useChartData)();
25
+ const bottom = height - margin.bottom;
26
+ return ((0, jsx_runtime_1.jsxs)("g", { style: { transform: `translate(0,${bottom - 10}px) `, opacity }, children: [(0, jsx_runtime_1.jsx)("text", { style: {
27
+ ...styles.text,
28
+ transform: `translate(${width / 2}px,-12px) scale(-1)`,
29
+ }, children: value ? (0, formatNumber_1.formatNumber)(value, format) : '' }), (0, jsx_runtime_1.jsx)("path", { style: styles.path, d: `M0 0 L0 5 L${width} 5 L${width} 0 ` })] }));
30
+ }
31
+ exports.IntegralIndicator = IntegralIndicator;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
7
+ /** @jsxImportSource @emotion/react */
8
+ const react_1 = require("@emotion/react");
9
+ const ChartContext_1 = require("../../context/ChartContext");
10
+ const DispatchContext_1 = require("../../context/DispatchContext");
11
+ const GlobalContext_1 = require("../../context/GlobalContext");
12
+ const ScaleContext_1 = require("../../context/ScaleContext");
13
+ const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
14
+ const index_1 = require("../../highlight/index");
15
+ const Types_1 = require("../../reducer/types/Types");
16
+ const ToolTypes_1 = require("../../toolbar/ToolTypes");
17
+ const IntegralIndicator_1 = require("./IntegralIndicator");
18
+ const stylesOnHover = (0, react_1.css) `
19
+ pointer-events: bounding-box;
20
+ @-moz-document url-prefix() {
21
+ pointer-events: fill;
22
+ }
23
+ .highlight {
24
+ fill: transparent;
25
+ }
26
+ .target {
27
+ visibility: hidden;
28
+ }
29
+ `;
30
+ const stylesHighlighted = (0, react_1.css) `
31
+ pointer-events: bounding-box;
32
+
33
+ @-moz-document url-prefix() {
34
+ pointer-events: fill;
35
+ }
36
+ fill: #ff6f0057;
37
+
38
+ .target {
39
+ visibility: visible;
40
+ }
41
+ `;
42
+ function IntegralResizable({ integralData, integralFormat, }) {
43
+ const { height, margin, toolOptions: { selectedTool }, } = (0, ChartContext_1.useChartData)();
44
+ const { viewerRef } = (0, GlobalContext_1.useGlobal)();
45
+ const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
46
+ const dispatch = (0, DispatchContext_1.useDispatch)();
47
+ const { id, integral } = integralData;
48
+ const highlight = (0, index_1.useHighlight)([id], {
49
+ type: index_1.HighlightEventSource.INTEGRAL,
50
+ extra: { id },
51
+ });
52
+ function handleOnStopResizing(position) {
53
+ dispatch({
54
+ type: Types_1.RESIZE_INTEGRAL,
55
+ payload: {
56
+ data: {
57
+ ...integralData,
58
+ from: scaleX().invert(position.x2),
59
+ to: scaleX().invert(position.x1),
60
+ },
61
+ },
62
+ });
63
+ }
64
+ const from = integralData.from ? scaleX()(integralData.from) : 0;
65
+ const to = integralData.to ? scaleX()(integralData.to) : 0;
66
+ const bottom = height - margin.bottom;
67
+ return ((0, jsx_runtime_1.jsx)("g", { onMouseEnter: () => highlight.show(), onMouseLeave: () => highlight.hide(), children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: to, x2: from }, onEnd: handleOnStopResizing, parentElement: viewerRef, disabled: selectedTool !== ToolTypes_1.options.integral.id, children: ({ x1, x2 }, isActive) => {
68
+ const width = x2 - x1;
69
+ return ((0, jsx_runtime_1.jsxs)("g", { css: highlight.isActive || isActive
70
+ ? stylesHighlighted
71
+ : stylesOnHover, children: [(0, jsx_runtime_1.jsx)("rect", { width: width, height: bottom, className: "highlight", "data-no-export": "true" }), (0, jsx_runtime_1.jsx)(IntegralIndicator_1.IntegralIndicator, { value: integral, format: integralFormat, width: width })] }));
72
+ } }, `${id}_${to}_${from}`) }));
73
+ }
74
+ exports.default = IntegralResizable;
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
- const Spectrum1D_1 = require("../../data/data1d/Spectrum1D");
9
- const ChartContext_1 = require("../context/ChartContext");
10
- const Reducer_1 = require("../reducer/Reducer");
8
+ const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
9
+ const ChartContext_1 = require("../../context/ChartContext");
10
+ const Reducer_1 = require("../../reducer/Reducer");
11
11
  const Integral_1 = __importDefault(require("./Integral"));
12
12
  function IntegralsSeries() {
13
13
  const { xDomains, data, displayerKey, view: { spectra: { activeTab: nucleus }, }, } = (0, ChartContext_1.useChartData)();