nmrium 0.50.1 → 0.51.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 (151) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/LinesSeries.js +2 -2
  3. package/lib/component/1d/Viewer1D.js +6 -11
  4. package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
  5. package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
  6. package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
  7. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
  8. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
  9. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
  10. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
  11. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
  12. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
  13. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
  14. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
  15. package/lib/component/2d/Viewer2D.js +16 -15
  16. package/lib/component/2d/ft/Contours.js +6 -3
  17. package/lib/component/2d/utilities/scale.d.ts +2 -1
  18. package/lib/component/2d/utilities/scale.js +12 -2
  19. package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
  20. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  21. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
  22. package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
  23. package/lib/component/context/ToasterContext.d.ts +13 -0
  24. package/lib/component/context/ToasterContext.js +34 -0
  25. package/lib/component/elements/Select.js +2 -2
  26. package/lib/component/elements/ToolbarPopoverItem.js +1 -1
  27. package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
  28. package/lib/component/header/Header.d.ts +1 -11
  29. package/lib/component/header/Header.js +5 -6
  30. package/lib/component/header/PhaseCorrectionPanel.js +24 -33
  31. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
  32. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
  33. package/lib/component/header/RangesPickingOptionPanel.js +6 -3
  34. package/lib/component/hooks/useDialogToggle.d.ts +5 -0
  35. package/lib/component/hooks/useDialogToggle.js +16 -0
  36. package/lib/component/hooks/useExport.d.ts +9 -1
  37. package/lib/component/hooks/useExport.js +34 -36
  38. package/lib/component/hooks/useSaveSettings.js +6 -3
  39. package/lib/component/hooks/useToolsFunctions.js +6 -4
  40. package/lib/component/loader/DropZone.js +14 -14
  41. package/lib/component/main/InnerNMRium.js +5 -9
  42. package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
  43. package/lib/component/main/InnerNMRiumContents.js +5 -3
  44. package/lib/component/main/NMRium.js +2 -2
  45. package/lib/component/modal/AboutPredictionModal.js +1 -1
  46. package/lib/component/modal/ExportAsJcampModal.js +15 -15
  47. package/lib/component/modal/ImportPublicationStringModal.js +5 -3
  48. package/lib/component/modal/LoadJCAMPModal.js +6 -4
  49. package/lib/component/modal/PredictSpectraModal.js +11 -9
  50. package/lib/component/modal/SaveAsModal.d.ts +3 -4
  51. package/lib/component/modal/SaveAsModal.js +27 -27
  52. package/lib/component/modal/editRange/EditRangeModal.js +2 -2
  53. package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
  54. package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
  55. package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
  56. package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
  57. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
  58. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
  59. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
  60. package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
  61. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
  62. package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
  63. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
  64. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
  65. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
  66. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
  67. package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
  68. package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
  69. package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
  70. package/lib/component/modal/setting/GeneralSettings.js +7 -4
  71. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
  72. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
  73. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
  74. package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
  75. package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
  76. package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
  77. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
  78. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
  79. package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
  80. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  81. package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
  82. package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
  83. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
  84. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
  85. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
  86. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -5
  87. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
  88. package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
  89. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
  90. package/lib/component/reducer/Reducer.d.ts +2 -2
  91. package/lib/component/reducer/Reducer.js +23 -16
  92. package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
  93. package/lib/component/reducer/actions/FiltersActions.js +243 -91
  94. package/lib/component/reducer/actions/IntegralsActions.js +2 -2
  95. package/lib/component/reducer/actions/MoleculeActions.js +0 -1
  96. package/lib/component/reducer/actions/RangesActions.js +16 -6
  97. package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
  98. package/lib/component/reducer/actions/ToolsActions.js +75 -14
  99. package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
  100. package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
  101. package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
  102. package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
  103. package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
  104. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
  105. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
  106. package/lib/component/toolbar/ToolBar.js +17 -12
  107. package/lib/component/utility/Events.d.ts +11 -0
  108. package/lib/component/utility/Events.js +22 -0
  109. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
  110. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
  111. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
  112. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
  113. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  114. package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
  115. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
  116. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
  117. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
  118. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
  119. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
  120. package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
  121. package/lib/data/data2d/Spectrum2D/contours.js +3 -3
  122. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  123. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  124. package/lib/data/getDefaultMatrixFilters.js +2 -2
  125. package/lib/data/matrixGeneration.js +1 -1
  126. package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
  127. package/lib/versionInfo.js +1 -1
  128. package/package.json +31 -30
  129. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
  130. package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
  131. package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
  132. package/lib/component/elements/popup/Alert/Context.js +0 -10
  133. package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
  134. package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
  135. package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
  136. package/lib/component/elements/popup/Alert/Provider.js +0 -127
  137. package/lib/component/elements/popup/Alert/index.d.ts +0 -3
  138. package/lib/component/elements/popup/Alert/index.js +0 -3
  139. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
  140. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
  141. package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
  142. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
  143. package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
  144. package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
  145. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
  146. package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
  147. package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
  148. package/lib/component/modal/metaImportation/index.d.ts +0 -2
  149. package/lib/component/modal/metaImportation/index.js +0 -17
  150. package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
  151. package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
@@ -3,23 +3,25 @@ import { current } from 'immer';
3
3
  import { xFindClosestIndex } from 'ml-spectra-processing';
4
4
  import { Filters, FiltersManager, getBaselineZones, } from 'nmr-processing';
5
5
  import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions';
6
- import { getSlice, isSpectrum2D } from '../../../data/data2d/Spectrum2D';
6
+ import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
7
+ import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
7
8
  import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection';
8
9
  import { getXScale } from '../../1d/utilities/scale';
9
10
  import { get2DXScale, get2DYScale } from '../../2d/utilities/scale';
10
11
  import { options as Tools } from '../../toolbar/ToolTypes';
11
12
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
12
13
  import nucleusToString from '../../utility/nucleusToString';
13
- import { getInitialState } from '../Reducer';
14
+ import { getDefaultTwoDimensionsPhaseCorrectionTraceOptions, getInitialState, } from '../Reducer';
14
15
  import zoomHistoryManager from '../helper/ZoomHistoryManager';
16
+ import { findStrongestPeak } from '../helper/findStrongestPeak';
15
17
  import { getActiveSpectrum } from '../helper/getActiveSpectrum';
16
18
  import getRange from '../helper/getRange';
17
- import { getStrongestPeak } from '../helper/getStrongestPeak';
19
+ import { getSpectrum } from '../helper/getSpectrum';
18
20
  import { getTwoDimensionPhaseCorrectionOptions } from '../helper/getTwoDimensionPhaseCorrectionOptions';
19
21
  import { setDomain, setMode } from './DomainActions';
20
22
  import { changeSpectrumVerticalAlignment } from './PreferencesActions';
21
23
  import { activateTool, resetSelectedTool } from './ToolsActions';
22
- const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
24
+ const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, phaseCorrectionTwoDimensions, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
23
25
  function getFilterUpdateDomainRules(filterName, defaultRule) {
24
26
  return (Filters[filterName]?.DOMAIN_UPDATE_RULES ||
25
27
  defaultRule || {
@@ -123,6 +125,7 @@ function rollbackSpectrum(draft, options) {
123
125
  ? true
124
126
  : [
125
127
  phaseCorrection.id,
128
+ phaseCorrectionTwoDimensions.id,
126
129
  fft.id,
127
130
  shiftX.id,
128
131
  shift2DX.id,
@@ -138,9 +141,91 @@ function rollbackSpectrum(draft, options) {
138
141
  });
139
142
  afterRollback(draft, filterKey);
140
143
  }
144
+ function getTwoDimensionFilterOptions(draft) {
145
+ const spectrum = getSpectrum(draft);
146
+ const phaseCorrectionFilter = spectrum.filters.find((filter) => filter.name === Tools.phaseCorrectionTwoDimensions.id);
147
+ if (!isSpectrum2D(spectrum)) {
148
+ return null;
149
+ }
150
+ const { value } = phaseCorrectionFilter || {};
151
+ let filterOptions = getDefaultTwoDimensionsPhaseCorrectionTraceOptions();
152
+ if (value) {
153
+ filterOptions = value;
154
+ }
155
+ return filterOptions;
156
+ }
141
157
  function beforeRollback(draft, filterKey) {
142
158
  const activeSpectrum = getActiveSpectrum(draft);
143
159
  switch (filterKey) {
160
+ case phaseCorrection.id: {
161
+ if (activeSpectrum) {
162
+ const spectrum = current(draft).data[activeSpectrum.index];
163
+ const phaseCorrectionFilter = spectrum.filters.find((filter) => filter.name === Tools.phaseCorrectionTwoDimensions.id);
164
+ if (isSpectrum1D(spectrum)) {
165
+ const { value: filterOptions } = phaseCorrectionFilter || {};
166
+ let pivotObj = {
167
+ value: 0,
168
+ index: 0,
169
+ };
170
+ if (typeof filterOptions?.pivot === 'number') {
171
+ const { pivot } = filterOptions;
172
+ const index = xFindClosestIndex(spectrum.data.re, pivot);
173
+ pivotObj = { value: pivot, index };
174
+ }
175
+ else {
176
+ // look for the strongest peak to set it as a pivot
177
+ const peak = findStrongestPeak(spectrum.data);
178
+ if (peak) {
179
+ const { xValue, index } = peak;
180
+ pivotObj = { value: xValue, index };
181
+ }
182
+ }
183
+ draft.toolOptions.data.pivot = pivotObj;
184
+ }
185
+ }
186
+ break;
187
+ }
188
+ case phaseCorrectionTwoDimensions.id: {
189
+ if (activeSpectrum) {
190
+ const spectrum = current(draft).data[activeSpectrum.index];
191
+ const filterOptions = getTwoDimensionFilterOptions(draft);
192
+ if (!isSpectrum2D(spectrum) || !filterOptions) {
193
+ return;
194
+ }
195
+ for (const direction in filterOptions) {
196
+ const phaseOptions = draft.toolOptions.data
197
+ .twoDimensionPhaseCorrection.traces[direction];
198
+ const { ph0, ph1, pivot, spectra = [] } = filterOptions[direction];
199
+ phaseOptions.ph0 = ph0;
200
+ phaseOptions.ph1 = ph1;
201
+ phaseOptions.scaleRatio = 1;
202
+ phaseOptions.spectra = spectra.map((spectrum) => ({
203
+ ...spectrum,
204
+ id: spectrum?.id || v4(),
205
+ }));
206
+ const datum = getProjection(spectrum.data.rr, direction === 'horizontal' ? 0 : 1);
207
+ if (typeof pivot === 'number') {
208
+ const index = xFindClosestIndex(datum.x, pivot, {
209
+ sorted: false,
210
+ });
211
+ phaseOptions.pivot = { index, value: pivot };
212
+ }
213
+ else {
214
+ const peak = findStrongestPeak(datum);
215
+ let pivotObj = {
216
+ value: 0,
217
+ index: 0,
218
+ };
219
+ if (peak) {
220
+ const { xValue, index } = peak;
221
+ pivotObj = { value: xValue, index };
222
+ }
223
+ phaseOptions.pivot = pivotObj;
224
+ }
225
+ }
226
+ }
227
+ break;
228
+ }
144
229
  case baselineCorrection.id: {
145
230
  if (activeSpectrum) {
146
231
  const datum = current(draft).data[activeSpectrum.index];
@@ -162,16 +247,8 @@ function beforeRollback(draft, filterKey) {
162
247
  }
163
248
  }
164
249
  function afterRollback(draft, filterKey) {
250
+ // const activeSpectrum = getActiveSpectrum(draft);
165
251
  switch (filterKey) {
166
- case phaseCorrection.id: {
167
- // look for the strongest peak to set it as a pivot
168
- const { xValue, index } = getStrongestPeak(draft) || {
169
- xValue: 0,
170
- index: 0,
171
- };
172
- draft.toolOptions.data.pivot = { value: xValue, index };
173
- break;
174
- }
175
252
  case apodization.id: {
176
253
  draft.toolOptions.data.apodizationOptions = defaultApodizationOptions;
177
254
  break;
@@ -256,9 +333,10 @@ function handleApplyZeroFillingFilter(draft, action) {
256
333
  value: action.payload.options,
257
334
  },
258
335
  ];
259
- FiltersManager.applyFilter(draft.data[index], filters, {
336
+ FiltersManager.applyFilter(draft.tempData[index], filters, {
260
337
  filterIndex: activeFilterIndex,
261
338
  });
339
+ draft.data[index] = draft.tempData[index];
262
340
  if (activeFilterIndex !== -1) {
263
341
  rollbackSpectrumByFilter(draft, {
264
342
  searchBy: 'name',
@@ -320,12 +398,13 @@ function handleApplyApodizationFilter(draft, action) {
320
398
  if (activeSpectrum) {
321
399
  const index = activeSpectrum.index;
322
400
  const activeFilterIndex = getActiveFilterIndex(draft);
323
- FiltersManager.applyFilter(draft.data[index], [
401
+ FiltersManager.applyFilter(draft.tempData[index], [
324
402
  {
325
403
  name: apodization.id,
326
404
  value: action.payload.options,
327
405
  },
328
406
  ], { filterIndex: activeFilterIndex });
407
+ draft.data[index] = draft.tempData[index];
329
408
  if (activeFilterIndex !== -1) {
330
409
  rollbackSpectrumByFilter(draft, {
331
410
  searchBy: 'name',
@@ -341,59 +420,81 @@ function handleApplyApodizationFilter(draft, action) {
341
420
  //action
342
421
  function handleApplyFFTFilter(draft) {
343
422
  const activeSpectrum = getActiveSpectrum(draft);
344
- if (activeSpectrum) {
345
- const { index } = activeSpectrum;
346
- const activeFilterIndex = getActiveFilterIndex(draft);
347
- //apply filter into the spectrum
348
- FiltersManager.applyFilter(draft.data[index], [{ name: fft.id, value: {} }], { filterIndex: activeFilterIndex });
349
- if (activeFilterIndex !== -1) {
350
- rollbackSpectrumByFilter(draft, {
351
- searchBy: 'name',
352
- key: fft.id,
353
- });
354
- }
355
- else {
356
- updateView(draft, fft.DOMAIN_UPDATE_RULES);
357
- }
358
- //clear zoom history
359
- draft.zoom.history[draft.view.spectra.activeTab] = [];
423
+ if (!activeSpectrum)
424
+ return;
425
+ const { index } = activeSpectrum;
426
+ const activeFilterIndex = getActiveFilterIndex(draft);
427
+ //apply filter into the spectrum
428
+ FiltersManager.applyFilter(activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index], [{ name: fft.id, value: {} }], { filterIndex: activeFilterIndex });
429
+ if (activeFilterIndex !== -1) {
430
+ draft.data[index] = draft.tempData[index];
431
+ }
432
+ if (activeFilterIndex !== -1) {
433
+ rollbackSpectrumByFilter(draft, {
434
+ searchBy: 'name',
435
+ key: fft.id,
436
+ triggerSource: 'Apply',
437
+ });
438
+ }
439
+ else {
440
+ updateView(draft, fft.DOMAIN_UPDATE_RULES);
360
441
  }
442
+ //clear zoom history
443
+ draft.zoom.history[draft.view.spectra.activeTab] = [];
444
+ draft.toolOptions.selectedOptionPanel = null;
445
+ draft.toolOptions.selectedTool = 'zoom';
361
446
  }
362
447
  function handleApplyFFtDimension1Filter(draft) {
363
448
  const activeSpectrum = getActiveSpectrum(draft);
364
- if (activeSpectrum) {
365
- const { index } = activeSpectrum;
366
- const activeFilterIndex = getActiveFilterIndex(draft);
367
- //apply filter into the spectrum
368
- FiltersManager.applyFilter(draft.data[index], [{ name: fftDimension1.id, value: {} }], { filterIndex: activeFilterIndex });
369
- if (activeFilterIndex !== -1) {
370
- rollbackSpectrumByFilter(draft, {
371
- searchBy: 'name',
372
- key: fftDimension1.id,
373
- });
374
- }
375
- else {
376
- updateView(draft, fftDimension1.DOMAIN_UPDATE_RULES);
377
- }
449
+ if (!activeSpectrum)
450
+ return;
451
+ const { index } = activeSpectrum;
452
+ const activeFilterIndex = getActiveFilterIndex(draft);
453
+ //apply filter into the spectrum
454
+ FiltersManager.applyFilter(activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index], [{ name: fftDimension1.id, value: {} }], { filterIndex: activeFilterIndex });
455
+ if (activeFilterIndex !== -1) {
456
+ draft.data[index] = draft.tempData[index];
457
+ }
458
+ if (activeFilterIndex !== -1) {
459
+ rollbackSpectrumByFilter(draft, {
460
+ searchBy: 'name',
461
+ key: fftDimension1.id,
462
+ triggerSource: 'Apply',
463
+ });
378
464
  }
465
+ else {
466
+ updateView(draft, fftDimension1.DOMAIN_UPDATE_RULES);
467
+ }
468
+ //clear zoom history
469
+ draft.zoom.history[draft.view.spectra.activeTab] = [];
470
+ draft.toolOptions.selectedOptionPanel = null;
471
+ draft.toolOptions.selectedTool = 'zoom';
379
472
  }
380
473
  function handleApplyFFtDimension2Filter(draft) {
381
474
  const activeSpectrum = getActiveSpectrum(draft);
382
- if (activeSpectrum) {
383
- const { index } = activeSpectrum;
384
- const activeFilterIndex = getActiveFilterIndex(draft);
385
- //apply filter into the spectrum
386
- FiltersManager.applyFilter(draft.data[index], [{ name: fftDimension2.id, value: {} }], { filterIndex: activeFilterIndex });
387
- if (activeFilterIndex !== -1) {
388
- rollbackSpectrumByFilter(draft, {
389
- searchBy: 'name',
390
- key: fftDimension2.id,
391
- });
392
- }
393
- else {
394
- updateView(draft, fftDimension2.DOMAIN_UPDATE_RULES);
395
- }
475
+ if (!activeSpectrum)
476
+ return;
477
+ const { index } = activeSpectrum;
478
+ const activeFilterIndex = getActiveFilterIndex(draft);
479
+ //apply filter into the spectrum
480
+ FiltersManager.applyFilter(activeFilterIndex !== -1 ? draft.tempData[index] : draft.data[index], [{ name: fftDimension2.id, value: {} }], { filterIndex: activeFilterIndex });
481
+ if (activeFilterIndex !== -1) {
482
+ draft.data[index] = draft.tempData[index];
483
+ }
484
+ if (activeFilterIndex !== -1) {
485
+ rollbackSpectrumByFilter(draft, {
486
+ searchBy: 'name',
487
+ key: fftDimension2.id,
488
+ triggerSource: 'Apply',
489
+ });
490
+ }
491
+ else {
492
+ updateView(draft, fftDimension2.DOMAIN_UPDATE_RULES);
396
493
  }
494
+ //clear zoom history
495
+ draft.zoom.history[draft.view.spectra.activeTab] = [];
496
+ draft.toolOptions.selectedOptionPanel = null;
497
+ draft.toolOptions.selectedTool = 'zoom';
397
498
  }
398
499
  //action
399
500
  function handleApplyManualPhaseCorrectionFilter(draft, action) {
@@ -403,12 +504,13 @@ function handleApplyManualPhaseCorrectionFilter(draft, action) {
403
504
  const { ph0, ph1 } = action.payload;
404
505
  draft.data = draft.tempData;
405
506
  const activeFilterIndex = getActiveFilterIndex(draft);
406
- FiltersManager.applyFilter(draft.data[index], [
507
+ FiltersManager.applyFilter(draft.tempData[index], [
407
508
  {
408
509
  name: phaseCorrection.id,
409
510
  value: { ph0, ph1 },
410
511
  },
411
512
  ], { filterIndex: activeFilterIndex });
513
+ draft.data[index] = draft.tempData[index];
412
514
  if (activeFilterIndex !== -1) {
413
515
  rollbackSpectrumByFilter(draft, {
414
516
  searchBy: 'name',
@@ -426,7 +528,7 @@ function handleAddPhaseCorrectionTrace(draft, action) {
426
528
  const { x, y } = action.payload;
427
529
  const activeSpectrum = getActiveSpectrum(draft);
428
530
  const { margin, width, height, xDomain, yDomain, mode, data: spectra, } = draft;
429
- const { activeTraces, activeTraceDirection } = getTwoDimensionPhaseCorrectionOptions(draft);
531
+ const { activeTraces, traces, addTracesToBothDirections } = getTwoDimensionPhaseCorrectionOptions(draft);
430
532
  if (activeSpectrum?.id) {
431
533
  const spectrum = spectra[activeSpectrum.index];
432
534
  if (isSpectrum2D(spectrum)) {
@@ -434,14 +536,17 @@ function handleAddPhaseCorrectionTrace(draft, action) {
434
536
  const scale2dY = get2DYScale({ margin, height, yDomain });
435
537
  const xPPM = scale2dX.invert(x);
436
538
  const yPPM = scale2dY.invert(y);
437
- const sliceData = getSlice(spectrum, {
438
- x: xPPM,
439
- y: yPPM,
440
- });
441
- if (sliceData) {
442
- const { data } = sliceData[activeTraceDirection];
539
+ if (addTracesToBothDirections) {
540
+ for (const direction of Object.keys(traces)) {
541
+ traces[direction].spectra.push({
542
+ id: v4(),
543
+ x: xPPM,
544
+ y: yPPM,
545
+ });
546
+ }
547
+ }
548
+ else {
443
549
  activeTraces.spectra.push({
444
- data,
445
550
  id: v4(),
446
551
  x: xPPM,
447
552
  y: yPPM,
@@ -451,6 +556,11 @@ function handleAddPhaseCorrectionTrace(draft, action) {
451
556
  }
452
557
  }
453
558
  //action
559
+ function handleToggleAddTracesToBothDirections(draft) {
560
+ const options = draft.toolOptions.data.twoDimensionPhaseCorrection;
561
+ options.addTracesToBothDirections = !options.addTracesToBothDirections;
562
+ }
563
+ //action
454
564
  function handleChangePhaseCorrectionDirection(draft, action) {
455
565
  const { direction } = action.payload;
456
566
  const { data: { twoDimensionPhaseCorrection }, } = draft.toolOptions;
@@ -484,12 +594,13 @@ function handleApplyAbsoluteFilter(draft) {
484
594
  if (activeSpectrum) {
485
595
  const { index } = activeSpectrum;
486
596
  const activeFilterIndex = getActiveFilterIndex(draft);
487
- FiltersManager.applyFilter(draft.data[index], [
597
+ FiltersManager.applyFilter(draft.tempData[index], [
488
598
  {
489
599
  name: phaseCorrection.id,
490
600
  value: { absolute: true },
491
601
  },
492
602
  ], { filterIndex: activeFilterIndex });
603
+ draft.data[index] = draft.tempData[index];
493
604
  if (activeFilterIndex !== -1) {
494
605
  rollbackSpectrumByFilter(draft, {
495
606
  searchBy: 'name',
@@ -508,12 +619,13 @@ function handleApplyAutoPhaseCorrectionFilter(draft) {
508
619
  if (activeSpectrum) {
509
620
  const { index } = activeSpectrum;
510
621
  const activeFilterIndex = getActiveFilterIndex(draft);
511
- FiltersManager.applyFilter(draft.data[index], [
622
+ FiltersManager.applyFilter(draft.tempData[index], [
512
623
  {
513
624
  name: phaseCorrection.id,
514
625
  value: {},
515
626
  },
516
627
  ], { filterIndex: activeFilterIndex });
628
+ draft.data[index] = draft.tempData[index];
517
629
  if (activeFilterIndex !== -1) {
518
630
  rollbackSpectrumByFilter(draft, {
519
631
  searchBy: 'name',
@@ -530,10 +642,11 @@ function handleApplyAutoPhaseCorrectionFilter(draft) {
530
642
  function handleBaseLineCorrectionFilter(draft, action) {
531
643
  const activeSpectrum = getActiveSpectrum(draft);
532
644
  if (activeSpectrum) {
645
+ const { index } = activeSpectrum;
533
646
  const { zones } = draft.toolOptions.data.baselineCorrection;
534
647
  const { options } = action.payload;
535
648
  const activeFilterIndex = getActiveFilterIndex(draft);
536
- FiltersManager.applyFilter(draft.data[activeSpectrum.index], [
649
+ FiltersManager.applyFilter(draft.tempData[index], [
537
650
  {
538
651
  name: baselineCorrection.id,
539
652
  value: {
@@ -542,6 +655,7 @@ function handleBaseLineCorrectionFilter(draft, action) {
542
655
  },
543
656
  },
544
657
  ], { filterIndex: activeFilterIndex });
658
+ draft.data[index] = draft.tempData[index];
545
659
  if (activeFilterIndex !== -1) {
546
660
  rollbackSpectrumByFilter(draft, {
547
661
  searchBy: 'name',
@@ -766,29 +880,67 @@ function handleSetTwoDimensionPhaseCorrectionPivotPoint(draft, action) {
766
880
  }
767
881
  //action
768
882
  function handleCalculateManualTwoDimensionPhaseCorrection(draft, action) {
883
+ const activeSpectrum = getActiveSpectrum(draft);
884
+ const { activeTraces } = getTwoDimensionPhaseCorrectionOptions(draft);
885
+ const { ph0, ph1, applyOn2D = false } = action.payload;
886
+ activeTraces.ph0 = ph0;
887
+ activeTraces.ph1 = ph1;
888
+ if (!applyOn2D || !activeSpectrum) {
889
+ return;
890
+ }
891
+ const { index } = activeSpectrum;
892
+ const spectrum = draft.tempData[index];
893
+ if (!isSpectrum2D(spectrum)) {
894
+ return;
895
+ }
896
+ const filterOptions = getTwoDimensionsPhaseCorrectionOptions(draft);
897
+ const { data, info } = spectrum;
898
+ const _data = { data, info };
899
+ phaseCorrectionTwoDimensions.apply(_data, filterOptions);
900
+ draft.data[index].data = _data.data;
901
+ }
902
+ function getTwoDimensionsPhaseCorrectionOptions(draft) {
903
+ const filterOptions = draft.toolOptions.data.twoDimensionPhaseCorrection.traces;
904
+ const result = {};
905
+ for (const direction in filterOptions) {
906
+ const { ph0, ph1, pivot, spectra } = filterOptions[direction];
907
+ result[direction] = {
908
+ ph0,
909
+ ph1,
910
+ pivot: pivot?.value,
911
+ spectra: spectra.map(({ x, y }) => ({
912
+ x,
913
+ y,
914
+ })),
915
+ };
916
+ }
917
+ return result;
918
+ }
919
+ //action
920
+ function handleApplyManualTowDimensionsPhaseCorrectionFilter(draft) {
769
921
  const activeSpectrum = getActiveSpectrum(draft);
770
922
  if (activeSpectrum) {
771
923
  const { index } = activeSpectrum;
772
- const { activeTraces, activeTraceDirection } = getTwoDimensionPhaseCorrectionOptions(draft);
773
- const { ph0, ph1 } = action.payload;
774
- activeTraces.ph0 = ph0;
775
- activeTraces.ph1 = ph1;
776
- for (const spectrumTrace of activeTraces.spectra) {
777
- const { x, y } = spectrumTrace;
778
- const spectrumData = draft.data[index];
779
- const sliceData = getSlice(spectrumData, { x, y }, { sliceType: 'both' });
780
- if (sliceData) {
781
- const { data, info } = sliceData[activeTraceDirection];
782
- const _data = {
783
- data,
784
- info,
785
- };
786
- phaseCorrection.apply(_data, { ph0, ph1 });
787
- const { im: newIm, re: newRe } = _data.data;
788
- spectrumTrace.data.im = newIm;
789
- spectrumTrace.data.re = newRe;
790
- }
924
+ draft.data = draft.tempData;
925
+ const activeFilterIndex = getActiveFilterIndex(draft);
926
+ const filterOptions = getTwoDimensionsPhaseCorrectionOptions(draft);
927
+ FiltersManager.applyFilter(draft.tempData[index], [
928
+ {
929
+ name: phaseCorrectionTwoDimensions.id,
930
+ value: filterOptions,
931
+ },
932
+ ], { filterIndex: activeFilterIndex });
933
+ draft.data[index] = draft.tempData[index];
934
+ if (activeFilterIndex !== -1) {
935
+ rollbackSpectrumByFilter(draft, {
936
+ searchBy: 'name',
937
+ key: phaseCorrectionTwoDimensions.id,
938
+ triggerSource: 'Apply',
939
+ });
940
+ }
941
+ else {
942
+ updateView(draft, phaseCorrectionTwoDimensions.DOMAIN_UPDATE_RULES);
791
943
  }
792
944
  }
793
945
  }
794
- export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, handleAddPhaseCorrectionTrace, handleChangePhaseCorrectionDirection, handleDeletePhaseCorrectionTrace, handleSetOneDimensionPhaseCorrectionPivotPoint, handleSetTwoDimensionPhaseCorrectionPivotPoint, handleCalculateManualTwoDimensionPhaseCorrection, };
946
+ export { handleShiftSpectrumAlongXAxis, handleApplyZeroFillingFilter, handleApplyApodizationFilter, handleApplyFFTFilter, handleApplyFFtDimension1Filter, handleApplyFFtDimension2Filter, handleApplyManualPhaseCorrectionFilter, handleApplyManualTowDimensionsPhaseCorrectionFilter, handleApplyAutoPhaseCorrectionFilter, handleApplyAbsoluteFilter, handleCalculateManualPhaseCorrection, calculateBaseLineCorrection, handleCalculateBaseLineCorrection, handleCalculateApodizationFilter, handleCalculateZeroFillingFilter, handleEnableFilter, handleDeleteFilter, handleDeleteSpectraFilter, handleBaseLineCorrectionFilter, handleSetFilterSnapshotHandler, handleAddExclusionZone, handleDeleteExclusionZone, handleSignalProcessingFilter, rollbackSpectrum, rollbackSpectrumByFilter, handleAddPhaseCorrectionTrace, handleChangePhaseCorrectionDirection, handleDeletePhaseCorrectionTrace, handleSetOneDimensionPhaseCorrectionPivotPoint, handleSetTwoDimensionPhaseCorrectionPivotPoint, handleCalculateManualTwoDimensionPhaseCorrection, handleToggleAddTracesToBothDirections, };
@@ -29,7 +29,7 @@ function addIntegral(datum, options) {
29
29
  const { from, to } = options;
30
30
  const { x, re } = datum.data;
31
31
  const shiftX = getShiftX(datum);
32
- const integration = xyIntegration({ x, y: re }, { from, to, reverse: true });
32
+ const integration = xyIntegration({ x, y: re }, { from, to });
33
33
  const integral = {
34
34
  id: v4(),
35
35
  originalFrom: from - shiftX,
@@ -86,7 +86,7 @@ function handleChangeIntegral(draft, action) {
86
86
  ...integral,
87
87
  originalFrom: integral.from,
88
88
  originalTo: integral.to,
89
- absolute: xyIntegration({ x, y: re }, { from: integral.from, to: integral.to, reverse: true }),
89
+ absolute: xyIntegration({ x, y: re }, { from: integral.from, to: integral.to }),
90
90
  };
91
91
  updateIntegralsRelativeValues(datum);
92
92
  }
@@ -117,7 +117,6 @@ function checkPredictions(predictedSpectra, inputOptions, molfile, logger) {
117
117
  const { spectra } = inputOptions;
118
118
  const missing2DPrediction = [];
119
119
  const molecule = OCL.Molecule.fromMolfile(molfile);
120
- //@ts-expect-error Will be fixed once OCL-utils is typed correctly
121
120
  const { atoms } = getAtoms(molecule);
122
121
  for (const [experiment, required] of Object.entries(spectra)) {
123
122
  if (!required || predictedSpectra[experiment])
@@ -31,13 +31,16 @@ function handleAutoRangesDetection(draft, action) {
31
31
  // minMaxRatio default 0.05, lookNegative default false,
32
32
  const { minMaxRatio, lookNegative } = action.payload;
33
33
  const detectionOptions = {
34
- peakPicking: {
35
- factorStd: 8,
34
+ rangePicking: {
36
35
  integrationSum: 100,
37
36
  compile: true,
38
37
  frequencyCluster: 16,
39
- clean: true,
38
+ clean: 0.3,
40
39
  keepPeaks: true,
40
+ },
41
+ peakPicking: {
42
+ broadWidth: 0.05,
43
+ thresholdFactor: 8,
41
44
  minMaxRatio,
42
45
  direction: lookNegative ? 'both' : 'positive',
43
46
  },
@@ -55,18 +58,25 @@ function handleAutoRangesDetection(draft, action) {
55
58
  //action
56
59
  function handleAutoSpectraRangesDetection(draft) {
57
60
  const peakPicking = {
58
- factorStd: 8,
61
+ thresholdFactor: 8,
59
62
  minMaxRatio: 0.05,
63
+ };
64
+ const rangePicking = {
60
65
  integrationSum: 100,
61
66
  compile: true,
62
67
  frequencyCluster: 16,
63
- clean: true,
68
+ clean: 0.3,
64
69
  keepPeaks: true,
65
70
  };
66
71
  const { data, view: { spectra: { activeTab: nucleus }, }, molecules, } = draft;
67
72
  for (const datum of data) {
68
73
  if (datum.info.dimension === 1) {
69
- detectRanges(datum, { peakPicking, molecules, nucleus });
74
+ detectRanges(datum, {
75
+ peakPicking,
76
+ rangePicking,
77
+ molecules,
78
+ nucleus,
79
+ });
70
80
  handleUpdateCorrelations(draft);
71
81
  }
72
82
  }
@@ -2,6 +2,7 @@ import { Draft } from 'immer';
2
2
  import { BaselineCorrectionZone } from 'nmr-processing';
3
3
  import { Nucleus } from '../../../data/types/common/Nucleus';
4
4
  import { Layout } from '../../2d/utilities/DimensionLayout';
5
+ import { ZoomOptions } from '../../EventsTrackers/BrushTracker';
5
6
  import { Tool } from '../../toolbar/ToolTypes';
6
7
  import { State } from '../Reducer';
7
8
  import { ZoomType } from '../helper/Zoom1DManager';
@@ -32,7 +33,7 @@ type DeleteBaseLineZoneAction = ActionType<'DELETE_BASE_LINE_ZONE', {
32
33
  }>;
33
34
  type BrushEndAction = ActionType<'BRUSH_END', BrushBoundary>;
34
35
  type ZoomAction = ActionType<'SET_ZOOM', {
35
- event: any;
36
+ options: ZoomOptions;
36
37
  trackID?: Layout;
37
38
  selectedTool?: Tool;
38
39
  }>;
@@ -44,8 +45,7 @@ type SetActiveTabAction = ActionType<'SET_ACTIVE_TAB', {
44
45
  tab?: Nucleus;
45
46
  }>;
46
47
  type LevelChangeAction = ActionType<'SET_2D_LEVEL', {
47
- deltaY: number;
48
- shiftKey: boolean;
48
+ options: ZoomOptions;
49
49
  }>;
50
50
  export type ToolsActions = ActionType<'TOGGLE_REAL_IMAGINARY_VISIBILITY' | 'RESET_SELECTED_TOOL' | 'SET_SPECTRUMS_VERTICAL_ALIGN' | 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE' | 'SET_SPECTRA_SAME_TOP' | 'RESET_SPECTRA_SCALE'> | SetSelectedToolAction | AddBaseLineZoneAction | DeleteBaseLineZoneAction | ResizeBaseLineZoneAction | BrushEndAction | ZoomAction | ZoomOutAction | SetActiveTabAction | LevelChangeAction;
51
51
  declare function handleResetSelectedTool(draft: Draft<State>): void;