nmrium 0.46.0 → 0.46.1

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.
@@ -18,6 +18,8 @@ import RangesIntegrals from './ranges/RangesIntegrals';
18
18
  import BaseLineZones from './tool/BaseLineZones';
19
19
  function Chart1D({ mode, width, height, margin, displayerKey }) {
20
20
  const { current: { general: { spectraRendering }, }, } = usePreferences();
21
- return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Ranges, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
21
+ const innerWidth = width - margin.left - margin.right;
22
+ const innerHeight = height - margin.bottom;
23
+ return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Ranges, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
22
24
  }
23
25
  export default Chart1D;
@@ -1,9 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { xGetFromToIndex } from 'ml-spectra-processing';
3
2
  import { useCallback, useEffect, useReducer, useRef, useState, } from 'react';
4
3
  import { ResponsiveChart } from 'react-d3-utils';
5
4
  import { useOnOff } from 'react-science/ui';
6
- import { MAX_LENGTH } from '../../data/data1d/Spectrum1D/ranges/detectSignals';
7
5
  import BrushXY, { BRUSH_TYPE } from '../1d-2d/tools/BrushXY';
8
6
  import CrossLinePointer from '../1d-2d/tools/CrossLinePointer';
9
7
  import { ViewerResponsiveWrapper } from '../2d/Viewer2D';
@@ -13,7 +11,6 @@ import { useChartData } from '../context/ChartContext';
13
11
  import { useDispatch } from '../context/DispatchContext';
14
12
  import { usePreferences } from '../context/PreferencesContext';
15
13
  import { ScaleProvider } from '../context/ScaleContext';
16
- import { useAlert } from '../elements/popup/Alert';
17
14
  import { useActiveSpectrum } from '../hooks/useActiveSpectrum';
18
15
  import { useVerticalAlign } from '../hooks/useVerticalAlign';
19
16
  import Spinner from '../loader/Spinner';
@@ -37,7 +34,6 @@ function Viewer1D({ emptyText = undefined }) {
37
34
  const activeSpectrum = useActiveSpectrum();
38
35
  const dispatch = useDispatch();
39
36
  const { dispatch: dispatchPreferences } = usePreferences();
40
- const alert = useAlert();
41
37
  const [scaleState, dispatchScale] = useReducer(scaleReducer, scaleInitialState);
42
38
  useEffect(() => {
43
39
  if (xDomain.length > 0 && yDomain.length > 0 && widthProp && heightProp) {
@@ -115,23 +111,12 @@ function Viewer1D({ emptyText = undefined }) {
115
111
  });
116
112
  break;
117
113
  case options.rangePicking.id: {
118
- const [from, to] = getRange(state, {
119
- startX: brushData.startX,
120
- endX: brushData.endX,
121
- });
122
114
  if (!activeSpectrum)
123
115
  break;
124
- const { data: { x }, } = data[activeSpectrum.index];
125
- const { fromIndex, toIndex } = xGetFromToIndex(x, { from, to });
126
- if (toIndex - fromIndex <= MAX_LENGTH) {
127
- dispatch({
128
- type: 'ADD_RANGE',
129
- payload: brushData,
130
- });
131
- }
132
- else {
133
- alert.error(`Advanced peak picking only available for area up to ${MAX_LENGTH} points`);
134
- }
116
+ dispatch({
117
+ type: 'ADD_RANGE',
118
+ payload: brushData,
119
+ });
135
120
  break;
136
121
  }
137
122
  case options.multipleSpectraAnalysis.id:
@@ -203,7 +188,6 @@ function Viewer1D({ emptyText = undefined }) {
203
188
  }, [
204
189
  scaleState,
205
190
  selectedTool,
206
- data,
207
191
  openAnalysisModal,
208
192
  activeSpectrum,
209
193
  dispatch,
@@ -211,7 +195,6 @@ function Viewer1D({ emptyText = undefined }) {
211
195
  activeTab,
212
196
  xDomain,
213
197
  state,
214
- alert,
215
198
  ]);
216
199
  const handelOnDoubleClick = useCallback(() => {
217
200
  dispatch({
@@ -26,6 +26,6 @@ function Top1DChart({ verticalMargin = 10, data: spectrum }) {
26
26
  return null;
27
27
  }
28
28
  const innerWidth = width - margin.left - margin.right;
29
- return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-top`, children: _jsx("rect", { width: innerWidth, height: height, x: margin.left, y: `${0}` }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-top)`, children: _jsx("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: path }) })] }));
29
+ return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-top`, children: _jsx("rect", { width: innerWidth, height: height, x: margin.left, y: "0" }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-top)`, children: _jsx("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: path }) })] }));
30
30
  }
31
31
  export default memo(Top1DChart);
@@ -40,6 +40,6 @@ function Signal({ signal }) {
40
40
  assignment?.hide();
41
41
  highlight.hide();
42
42
  }, cx: scaleX(signal.x.delta || 0), cy: scaleY(signal.y.delta || 0), r: isHighlighted ? 6 : 4, fill: isHighlighted ? 'green' : 'darkgreen' }, signal.id)] })), _jsx("g", { className: "zone-signal-peak", style: { pointerEvents: 'none' }, children: showPeaks &&
43
- signal?.peaks?.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, `${signal.id + i}`))) })] }));
43
+ signal?.peaks?.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, String(signal.id + i)))) })] }));
44
44
  }
45
45
  export default Signal;
@@ -61,6 +61,6 @@ function Zone({ zoneData }) {
61
61
  }, onMouseLeave: () => {
62
62
  assignmentZone.hide();
63
63
  highlightZone.hide();
64
- }, children: [showZones && (_jsx("g", { transform: `translate(${scaleX(x2)},${scaleY(y1)})`, children: _jsx("rect", { x: "0", width: scaleX(x1) - scaleX(x2), height: scaleY(y2) - scaleY(y1), className: "integral-area", fill: "#0000000f", stroke: reduceOpacity ? '#343a40' : 'darkgreen', strokeWidth: reduceOpacity ? '0' : '1' }) })), signals.map((_signal, i) => (_jsx(Signal, { signal: _signal }, `${id + i}`)))] }, id));
64
+ }, children: [showZones && (_jsx("g", { transform: `translate(${scaleX(x2)},${scaleY(y1)})`, children: _jsx("rect", { x: "0", width: scaleX(x1) - scaleX(x2), height: scaleY(y2) - scaleY(y1), className: "integral-area", fill: "#0000000f", stroke: reduceOpacity ? '#343a40' : 'darkgreen', strokeWidth: reduceOpacity ? '0' : '1' }) })), signals.map((_signal, i) => (_jsx(Signal, { signal: _signal }, String(id + i))))] }, id));
65
65
  }
66
66
  export default Zone;
@@ -5,7 +5,7 @@ const styles = {
5
5
  display: 'flex',
6
6
  flexDirection: 'row',
7
7
  justifyContent: 'space-between',
8
- borderBottom: '1px solid rgb(247, 247, 247);',
8
+ borderBottom: '1px solid rgb(247, 247, 247)',
9
9
  boxShadow: 'rgb(255, 255, 255) 0px 1px 0px 0px inset',
10
10
  },
11
11
  };
@@ -114,7 +114,7 @@ function InnerMultipleAnalysis(props) {
114
114
  maxTestedJ: 17,
115
115
  takeBestPartMultiplet: true,
116
116
  correctVerticalOffset: true,
117
- symmetrizeEachStep: false,
117
+ symmetrizeEachStep: true,
118
118
  decreasingJvalues: true,
119
119
  makeShortCutForSpeed: true,
120
120
  debug: true,
@@ -74,7 +74,7 @@ function FormattingTabContent() {
74
74
  const nucleiList = Object.keys(nuclei);
75
75
  return (_jsx(GroupPane, { text: "Number formatting for crosshair and info line", children: _jsx("div", { css: styles, children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "counter-col", children: "#" }), _jsx("th", { className: "nucleus-label-col", children: "Nucleus " }), _jsx("th", { className: "nucleus-format-input-col", children: "\u03B4 (ppm)" }), _jsx("th", { className: "nucleus-format-input-col", children: "Coupling (Hz)" }), _jsx("th", { className: "nucleus-format-input-col" })] }) }), _jsx("tbody", { children: nucleiList?.map((key, index) => {
76
76
  const num = index + 1;
77
- return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.name`, className: "input", checkErrorAfterInputTouched: false }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.ppm`, className: "input" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.hz`, className: "input" }) }), _jsxs("td", { className: "operation-container", children: [_jsx(Button.Danger, { style: { fontSize: '14px' }, fill: "clear", onClick: () => deleteHandler(key), children: _jsx(FaTimes, {}) }), nucleiList.length === index + 1 && (_jsx(Button.Done, { fill: "clear", style: { fontSize: '14px' }, onClick: addHandler, children: _jsx(FaPlus, {}) }))] })] }, `${key}`));
77
+ return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.name`, className: "input", checkErrorAfterInputTouched: false }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.ppm`, className: "input" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.hz`, className: "input" }) }), _jsxs("td", { className: "operation-container", children: [_jsx(Button.Danger, { style: { fontSize: '14px' }, fill: "clear", onClick: () => deleteHandler(key), children: _jsx(FaTimes, {}) }), nucleiList.length === index + 1 && (_jsx(Button.Done, { fill: "clear", style: { fontSize: '14px' }, onClick: addHandler, children: _jsx(FaPlus, {}) }))] })] }, key));
78
78
  }) })] }) }) }));
79
79
  }
80
80
  export default FormattingTabContent;
@@ -97,6 +97,6 @@ function ExclusionZonesGroupHeader({ text }) {
97
97
  return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsx("p", { style: { flex: 1, ...GroupPanelStyle.header }, children: text }), _jsx(ToggleButton, { defaultValue: selectedTool === options.matrixGenerationExclusionZones.id, popupTitle: "Select exclusions zones", popupPlacement: "left", onClick: () => handleChangeOption(options.matrixGenerationExclusionZones.id), children: _jsx(SvgNmrMultipleAnalysis, { style: {
98
98
  pointerEvents: 'none',
99
99
  fontSize: '12px',
100
- } }) }, `${selectedTool}`)] }));
100
+ } }) }, selectedTool)] }));
101
101
  }
102
102
  export default MatrixGenerationPanel;
@@ -36,7 +36,7 @@ const moveLinkStyles = css `
36
36
  `;
37
37
  function getCorrelationLabel(correlation) {
38
38
  const delta = getCorrelationDelta(correlation);
39
- return `${delta ? delta.toFixed(2) : '?'}`;
39
+ return delta ? delta.toFixed(2) : '?';
40
40
  }
41
41
  function MoveLink({ correlationDim1, correlationDim2, link, correlations, onEdit, }) {
42
42
  const [selectedCorrelationIdDim1, setSelectedCorrelationIdDim1] = useState(correlationDim1.id);
@@ -14,7 +14,7 @@ function getLabelColor(correlationData, correlation) {
14
14
  for (const { key, color } of ErrorColors) {
15
15
  if (key !== 'incomplete' && // do not consider this for a single atom type
16
16
  (key === 'notAttached' || key === 'ambiguousAttachment') &&
17
- lodashGet(error, `${key}`, []).some((index) => correlationData.values[index].id === correlation.id)) {
17
+ lodashGet(error, key, []).some((index) => correlationData.values[index].id === correlation.id)) {
18
18
  return color;
19
19
  }
20
20
  }
@@ -45,7 +45,7 @@ export function DatabaseSearchOptions({ databases, defaultDatabase, keywords, re
45
45
  pointerEvents: 'none',
46
46
  fontSize: '12px',
47
47
  transform: 'rotate(90deg)',
48
- } }) }, `${selectedTool}`), _jsx(Input, { value: keywords.searchKeywords, renderIcon: () => _jsx(IoSearchOutline, {}), style: { inputWrapper: { flex: 3 } }, className: "search-input", type: "text", debounceTime: 250, placeholder: "Search for parameter...", onChange: handleSearch, onClear: clearHandler, canClear: true }), _jsx(Button.Done, { fill: "clear", onClick: onStructureClick, style: { padding: '5px' }, children: !idCode ? (_jsx(BsHexagon, { style: {
48
+ } }) }, selectedTool), _jsx(Input, { value: keywords.searchKeywords, renderIcon: () => _jsx(IoSearchOutline, {}), style: { inputWrapper: { flex: 3 } }, className: "search-input", type: "text", debounceTime: 250, placeholder: "Search for parameter...", onChange: handleSearch, onClear: clearHandler, canClear: true }), _jsx(Button.Done, { fill: "clear", onClick: onStructureClick, style: { padding: '5px' }, children: !idCode ? (_jsx(BsHexagon, { style: {
49
49
  fontSize: '12px',
50
50
  } })) : (_jsx(BsHexagonFill, { style: {
51
51
  fontSize: '12px',
@@ -4,9 +4,9 @@ import { xFindClosestIndex } from 'ml-spectra-processing';
4
4
  import { getShiftX, autoPeakPicking, optimizePeaks, } from '../../../data/data1d/Spectrum1D';
5
5
  import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
6
6
  import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
7
+ import { getClosePeak } from '../../utility/getClosePeak';
7
8
  import { getActiveSpectrum } from '../helper/getActiveSpectrum';
8
9
  import getRange from '../helper/getRange';
9
- import { getClosePeak } from '../../utility/getClosePeak';
10
10
  //action
11
11
  function handleAddPeak(draft, action) {
12
12
  const { x: mouseXPosition } = action.payload;
@@ -15,7 +15,7 @@ import useToolsFunctions from '../hooks/useToolsFunctions';
15
15
  import { useVerticalAlign } from '../hooks/useVerticalAlign';
16
16
  import ImportPublicationStringModal from '../modal/ImportPublicationStringModal';
17
17
  import { LoadJCAMPModal } from '../modal/LoadJCAMPModal';
18
- import { useMetaInformationImportationModal } from '../modal/metaImportation/index';
18
+ import { useMetaInformationImportationModal } from '../modal/metaImportation';
19
19
  import { options } from './ToolTypes';
20
20
  const IMPORT_MENU = [
21
21
  {
@@ -161,11 +161,11 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
161
161
  saveAsHandler,
162
162
  saveToClipboardHandler,
163
163
  ]);
164
- return (_jsxs(Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadModalOpened, onCloseDialog: closeLoadModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right", onSelect: (data) => {
164
+ return (_jsxs(Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadModalOpened, onCloseDialog: closeLoadModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right-start", onSelect: (data) => {
165
165
  importHandler(data);
166
- }, options: importMenu, renderTarget: (targetProps) => (_jsx("div", { ...targetProps, style: { flex: 'none' }, children: _jsx(Toolbar.Item, { id: options.import.id, title: options.import.label, icon: _jsx(FaFileImport, {}) }) })) })), isButtonVisible('exportAs') && (_jsx(DropdownMenu, { onSelect: (data) => {
166
+ }, targetTagName: "div", targetProps: { style: { flex: 'none' } }, options: importMenu, children: _jsx(Toolbar.Item, { id: options.import.id, title: options.import.label, icon: _jsx(FaFileImport, {}) }) })), isButtonVisible('exportAs') && (_jsx(DropdownMenu, { onSelect: (data) => {
167
167
  exportHandler(data);
168
- }, placement: "right", options: exportMenu, renderTarget: (targetProps) => (_jsx("div", { ...targetProps, style: { flex: 'none' }, children: _jsx(Toolbar.Item, { id: options.exportAs.id, title: options.import.label, icon: _jsx(FaFileExport, {}) }) })) })), isButtonVisible('spectraStackAlignments') && ftCounter > 1 && (_jsx(Toolbar.Item, { id: "spectra-alignment", className: "cheminfo", title: "Spectra alignment ( Press s )", onClick: changeDisplayViewModeHandler, icon: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})) })), isButtonVisible('realImaginary') && (_jsx(Toolbar.Item, { id: "display", title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary', onClick: changeSpectrumViewHandler, className: "cheminfo", icon: _jsx(SvgNmrRealImag, {}) })), isButtonVisible('spectraCenterAlignments') &&
168
+ }, placement: "right-start", targetTagName: "div", targetProps: { style: { flex: 'none' } }, options: exportMenu, children: _jsx(Toolbar.Item, { id: options.exportAs.id, title: options.exportAs.label, icon: _jsx(FaFileExport, {}) }) })), isButtonVisible('spectraStackAlignments') && ftCounter > 1 && (_jsx(Toolbar.Item, { id: "spectra-alignment", className: "cheminfo", title: "Spectra alignment ( Press s )", onClick: changeDisplayViewModeHandler, icon: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})) })), isButtonVisible('realImaginary') && (_jsx(Toolbar.Item, { id: "display", title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary', onClick: changeSpectrumViewHandler, className: "cheminfo", icon: _jsx(SvgNmrRealImag, {}) })), isButtonVisible('spectraCenterAlignments') &&
169
169
  (ftCounter > 0 || fidCounter > 0) && (_jsx(Toolbar.Item, { id: "baseline-position", title: verticalAlign === 'bottom'
170
170
  ? 'Baseline center ( Press c )'
171
171
  : 'Baseline bottom ( Press c )', onClick: alignSpectrumsVerticallyHandler, className: "cheminfo", icon: _jsx(_Fragment, { children: verticalAlign === 'bottom' ? (_jsx(SvgNmrAlignCenter, {})) : (_jsx(SvgNmrAlignBottom, {})) }) }))] }));
@@ -1,6 +1,6 @@
1
1
  import { MultiplicityPatterns } from 'nmr-processing';
2
2
  export const Multiplets = MultiplicityPatterns.map(({ label, value, acs, multiplicity }) => ({
3
- label: `${label}`,
3
+ label,
4
4
  value: acs || value,
5
5
  multiplicity,
6
6
  }));
@@ -15,6 +15,7 @@ export declare function createRangeObj({ from, to, absolute, signals, }: RangeOp
15
15
  signals: {
16
16
  peaks?: import("nmr-processing").NMRPeak1D[] | undefined;
17
17
  kind?: string | undefined;
18
+ assignment?: string | undefined;
18
19
  diaIDs?: string[] | undefined;
19
20
  integration?: number | undefined;
20
21
  multiplicity: string;
@@ -22,7 +23,6 @@ export declare function createRangeObj({ from, to, absolute, signals, }: RangeOp
22
23
  js: import("nmr-processing").Jcoupling[];
23
24
  delta: number;
24
25
  atoms?: number[] | undefined;
25
- assignment?: string | undefined;
26
26
  statistic?: {
27
27
  mean: number;
28
28
  sd: number;
@@ -14,7 +14,7 @@ export function changeRange(spectrum, range) {
14
14
  frequency,
15
15
  });
16
16
  if (index !== -1) {
17
- spectrum.ranges.values[index] = mapRanges([
17
+ const [newRange] = mapRanges([
18
18
  {
19
19
  ...spectrum.ranges.values[index],
20
20
  originalFrom: from,
@@ -23,7 +23,10 @@ export function changeRange(spectrum, range) {
23
23
  absolute,
24
24
  signals,
25
25
  },
26
- ], spectrum)[0];
27
- updateRangesRelativeValues(spectrum);
26
+ ], spectrum);
27
+ if (newRange) {
28
+ spectrum.ranges.values[index] = newRange;
29
+ updateRangesRelativeValues(spectrum);
30
+ }
28
31
  }
29
32
  }
@@ -1,5 +1,4 @@
1
1
  import { DataXY } from 'cheminfo-types';
2
- export declare const MAX_LENGTH = 4092;
3
2
  export default function detectSignals(data: DataXY, options: {
4
3
  from: number;
5
4
  to: number;
@@ -24,4 +23,10 @@ export default function detectSignals(data: DataXY, options: {
24
23
  max: number;
25
24
  nb: number;
26
25
  } | undefined;
26
+ }[] | {
27
+ multiplicity: any;
28
+ kind: string;
29
+ delta: number;
30
+ js: any;
31
+ diaIDs: never[];
27
32
  }[];
@@ -1,23 +1,110 @@
1
- import { xyAutoRangesPicking } from 'nmr-processing';
2
- export const MAX_LENGTH = 4092;
1
+ import { xGetFromToIndex } from 'ml-spectra-processing';
2
+ import { analyseMultiplet } from 'multiplet-analysis';
3
+ import { signalJoinCouplings, xyAutoPeaksPicking, xyAutoRangesPicking, } from 'nmr-processing';
4
+ const MAX_LENGTH = 4092;
3
5
  export default function detectSignals(data, options) {
4
6
  const { from, to, frequency, nucleus } = options;
5
- const ranges = xyAutoRangesPicking(data, {
6
- peakPicking: {
7
- to,
8
- from,
9
- frequency,
10
- },
11
- ranges: {
12
- frequency,
13
- nucleus,
14
- compile: true,
15
- frequencyCluster: 16,
16
- keepPeaks: true,
17
- clean: 0.3,
18
- },
7
+ const { fromIndex, toIndex } = xGetFromToIndex(data.x, { from, to });
8
+ if (toIndex - fromIndex >= MAX_LENGTH) {
9
+ const ranges = xyAutoRangesPicking(data, {
10
+ peakPicking: {
11
+ to,
12
+ from,
13
+ frequency,
14
+ },
15
+ ranges: {
16
+ symRatio: 2.5,
17
+ frequency,
18
+ nucleus,
19
+ compile: true,
20
+ frequencyCluster: 16,
21
+ keepPeaks: true,
22
+ clean: 0.3,
23
+ },
24
+ });
25
+ return ranges
26
+ .flatMap((r) => r.signals || [])
27
+ .map((s) => ({ multiplicity: '', js: [], ...s }));
28
+ }
29
+ else {
30
+ return detectSignalsByMultipletAnalysis(data, {
31
+ ...options,
32
+ fromIndex,
33
+ toIndex,
34
+ });
35
+ }
36
+ }
37
+ function detectSignalsByMultipletAnalysis(data, options) {
38
+ const { fromIndex, toIndex, frequency } = options;
39
+ const dataRoi = {
40
+ x: data.x.slice(fromIndex, toIndex),
41
+ y: data.y.slice(fromIndex, toIndex),
42
+ };
43
+ const result = analyseMultiplet(dataRoi, {
44
+ frequency,
45
+ minimalResolution: 0.1,
46
+ maxTestedJ: 17,
47
+ checkSymmetryFirst: true,
48
+ takeBestPartMultiplet: true,
49
+ correctVerticalOffset: true,
50
+ symmetrizeEachStep: false,
51
+ decreasingJvalues: true,
52
+ makeShortCutForSpeed: true,
19
53
  });
20
- return ranges
21
- .flatMap((r) => r.signals || [])
22
- .map((s) => ({ multiplicity: '', js: [], ...s }));
54
+ if (result && result.chemShift === undefined)
55
+ return [];
56
+ const { delta, js } = joinCouplings(result);
57
+ let cs = 0;
58
+ let area = 0;
59
+ for (let i = 0; i < dataRoi.x.length; i++) {
60
+ cs += dataRoi.x[i] * dataRoi.y[i];
61
+ area += dataRoi.y[i];
62
+ }
63
+ cs /= area;
64
+ const multiplicity = getMultiplicity(js, { cs, data, delta, frequency });
65
+ return [
66
+ {
67
+ multiplicity,
68
+ kind: 'signal',
69
+ delta: cs,
70
+ js,
71
+ diaIDs: [],
72
+ },
73
+ ];
74
+ }
75
+ function getMultiplicity(js, options) {
76
+ const { cs, delta, frequency, data } = options;
77
+ if (js?.length > 0) {
78
+ return js.map((j) => j.multiplicity).join('');
79
+ }
80
+ //check if the massive center is closer to the shift from multiplet-analysis,
81
+ //if true, is it possibly a singlet.
82
+ if (Math.abs(cs - delta) / cs < 1e-3) {
83
+ let peaks = [];
84
+ if (js?.length === 0) {
85
+ peaks = xyAutoPeaksPicking(data, { frequency });
86
+ }
87
+ if (peaks.length === 1)
88
+ return 's';
89
+ }
90
+ return 'm';
91
+ }
92
+ function joinCouplings(result) {
93
+ const { chemShift: delta, js } = result;
94
+ let jCouplings = js;
95
+ if (js.length > 1) {
96
+ try {
97
+ jCouplings = signalJoinCouplings({
98
+ delta,
99
+ js,
100
+ }, { tolerance: 0.6, ignoreDiaIDs: true }).js;
101
+ }
102
+ catch (error) {
103
+ reportError(error);
104
+ }
105
+ }
106
+ return {
107
+ delta,
108
+ js: jCouplings,
109
+ };
23
110
  }
@@ -45,6 +45,7 @@ export declare function initiateRanges(inputSpectrum: Partial<Spectrum1D>, spect
45
45
  nbAtoms?: number | undefined;
46
46
  multiplicity?: string | undefined;
47
47
  diaIDs?: string[] | undefined;
48
+ assignment?: string | undefined;
48
49
  pubIntegral?: number | undefined;
49
50
  }[];
50
51
  };
@@ -1 +1 @@
1
- export default { version: 'v0.46.0' };
1
+ export default { version: 'v0.46.1' };
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.46.0",
4
+ "version": "0.46.1",
5
5
  "license": "MIT",
6
6
  "module": "lib/component/main/index.js",
7
7
  "types": "lib/component/main/index.d.ts",
@@ -87,7 +87,7 @@
87
87
  "multiplet-analysis": "^2.1.2",
88
88
  "nmr-correlation": "^2.3.3",
89
89
  "nmr-load-save": "^0.23.11",
90
- "nmr-processing": "^11.6.1",
90
+ "nmr-processing": "^11.7.0",
91
91
  "nmredata": "^0.9.9",
92
92
  "numeral": "^2.0.6",
93
93
  "openchemlib": "^8.7.2",
@@ -96,7 +96,7 @@
96
96
  "re-resizable": "6.9.11",
97
97
  "react-d3-utils": "^1.0.0",
98
98
  "react-dropzone": "^14.2.3",
99
- "react-error-boundary": "^4.0.11",
99
+ "react-error-boundary": "^4.0.12",
100
100
  "react-icons": "^4.12.0",
101
101
  "react-inspector": "^6.0.2",
102
102
  "react-mf": "^2.0.2",
@@ -104,13 +104,13 @@
104
104
  "react-ocl-nmr": "^3.0.1",
105
105
  "react-plot": "^1.4.2",
106
106
  "react-rnd": "^10.4.1",
107
- "react-science": "^0.32.1",
107
+ "react-science": "^0.32.2",
108
108
  "react-slider": "^2.0.6",
109
109
  "react-table": "^7.8.0",
110
110
  "react-transition-group": "^4.4.5",
111
111
  "react-use": "^17.4.2",
112
112
  "smart-array-filter": "^4.0.2",
113
- "yup": "^1.3.2"
113
+ "yup": "^1.3.3"
114
114
  },
115
115
  "devDependencies": {
116
116
  "@babel/plugin-transform-modules-commonjs": "^7.23.3",
@@ -120,16 +120,16 @@
120
120
  "@simbathesailor/use-what-changed": "^2.0.0",
121
121
  "@types/d3": "^7.4.3",
122
122
  "@types/lodash": "^4.14.202",
123
- "@types/node": "^20.10.4",
123
+ "@types/node": "^20.10.5",
124
124
  "@types/papaparse": "^5.3.14",
125
125
  "@types/react": "^18.2.45",
126
- "@types/react-dom": "^18.2.17",
126
+ "@types/react-dom": "^18.2.18",
127
127
  "@types/react-table": "^7.7.18",
128
128
  "@vitejs/plugin-react-swc": "^3.5.0",
129
129
  "@vitest/coverage-v8": "^1.0.4",
130
130
  "cross-env": "^7.0.3",
131
131
  "cspell": "^8.1.3",
132
- "eslint": "^8.55.0",
132
+ "eslint": "^8.56.0",
133
133
  "eslint-config-cheminfo-react": "^10.1.0",
134
134
  "eslint-config-cheminfo-typescript": "^12.1.0",
135
135
  "modern-normalize": "^2.0.0",
@@ -145,7 +145,7 @@
145
145
  "stylelint": "^16.0.2",
146
146
  "stylelint-config-standard": "^35.0.0",
147
147
  "typescript": "^5.3.3",
148
- "vite": "^5.0.8",
148
+ "vite": "^5.0.10",
149
149
  "vitest": "^1.0.4"
150
150
  }
151
151
  }