nmrium 0.44.1-pre.1700644530 → 0.45.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.
@@ -3,7 +3,7 @@ import { xGetFromToIndex } from 'ml-spectra-processing';
3
3
  import { useCallback, useEffect, useReducer, useRef, useState, } from 'react';
4
4
  import { ResponsiveChart } from 'react-d3-utils';
5
5
  import { useOnOff } from 'react-science/ui';
6
- import { MAX_LENGTH } from '../../data/data1d/Spectrum1D/ranges/detectSignal';
6
+ import { MAX_LENGTH } from '../../data/data1d/Spectrum1D/ranges/detectSignals';
7
7
  import BrushXY, { BRUSH_TYPE } from '../1d-2d/tools/BrushXY';
8
8
  import CrossLinePointer from '../1d-2d/tools/CrossLinePointer';
9
9
  import { ViewerResponsiveWrapper } from '../2d/Viewer2D';
@@ -12,21 +12,21 @@ function Signal({ signal }) {
12
12
  const buildIDs = useCallback((id) => {
13
13
  return [id].concat(buildID(id, 'X'), buildID(id, 'Y'));
14
14
  }, []);
15
- const assignment = useAssignment(signal.id);
15
+ const assignment = useAssignment(signal?.id || '');
16
16
  const { showSignals, showPeaks } = useActiveSpectrumZonesViewState();
17
- const highlight = useHighlight(buildIDs(assignment.id));
17
+ const highlight = useHighlight(buildIDs(assignment?.id));
18
18
  const highlightData = useHighlightData();
19
19
  const [isHighlighted, setIsHighlighted] = useState(false);
20
20
  useEffect(() => {
21
21
  if (highlightData.highlight.highlighted.some((_highlighted) => buildIDs(signal.id).includes(_highlighted)) ||
22
- assignment.isActive) {
22
+ assignment?.isActive) {
23
23
  setIsHighlighted(true);
24
24
  }
25
25
  else {
26
26
  setIsHighlighted(false);
27
27
  }
28
28
  }, [
29
- assignment.isActive,
29
+ assignment?.isActive,
30
30
  buildIDs,
31
31
  highlightData.highlight.highlighted,
32
32
  signal.id,
@@ -34,10 +34,10 @@ function Signal({ signal }) {
34
34
  if (!signal)
35
35
  return null;
36
36
  return (_jsxs("g", { className: "zone-signal", children: [showSignals && (_jsxs("g", { children: [_jsx(SignalCrosshair, { signal: signal }), _jsx("circle", { onMouseEnter: () => {
37
- assignment.show();
37
+ assignment?.show();
38
38
  highlight.show();
39
39
  }, onMouseLeave: () => {
40
- assignment.hide();
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
43
  signal?.peaks?.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, `${signal.id + i}`))) })] }));
@@ -21,7 +21,7 @@ export interface AssignmentsData extends Pick<AssignmentState, 'activated' | 'hi
21
21
  id: string;
22
22
  isActive: boolean;
23
23
  isOver: boolean;
24
- assigned: Record<Axis, string[]>;
24
+ assigned: Partial<Record<Axis, string[]>>;
25
25
  removeAll: (axis: Axis) => void;
26
26
  toggle: (atomIDs: string[], dimension: AssignmentDimension) => void;
27
27
  setActive: (axis: Axis) => void;
@@ -19,7 +19,7 @@ export function useAssignmentData() {
19
19
  // key can be signal id,range id or zone id
20
20
  export function useAssignment(key) {
21
21
  const { data: { activated, highlighted, assignments }, dispatch, } = useAssignmentData();
22
- if ((typeof key !== 'string' && typeof key !== 'number') || key === '') {
22
+ if (!['string', 'number'].includes(typeof key)) {
23
23
  throw new Error(`assignment key must be a non-empty string or number`);
24
24
  }
25
25
  const id = String(key);
@@ -30,37 +30,56 @@ export function useAssignment(key) {
30
30
  return highlighted?.id === id;
31
31
  }, [highlighted?.id, id]);
32
32
  const assigned = useMemo(() => {
33
- return assignments[id] || null;
33
+ if (!(id in assignments)) {
34
+ return {};
35
+ }
36
+ return assignments[id];
34
37
  }, [assignments, id]);
35
38
  const removeAll = useCallback((axis) => {
36
- dispatch({
37
- type: 'REMOVE',
38
- payload: { ids: [id], axis },
39
- });
39
+ if (id) {
40
+ dispatch({
41
+ type: 'REMOVE',
42
+ payload: { ids: [id], axis },
43
+ });
44
+ return true;
45
+ }
46
+ return false;
40
47
  }, [dispatch, id]);
41
48
  const toggle = useCallback((atomIDs, dimension) => {
42
- dispatch({
43
- type: 'TOGGLE',
44
- payload: { atomIDs, id, dimension },
45
- });
49
+ if (id) {
50
+ dispatch({
51
+ type: 'TOGGLE',
52
+ payload: { atomIDs, id, dimension },
53
+ });
54
+ return true;
55
+ }
56
+ return false;
46
57
  }, [dispatch, id]);
47
58
  const setActive = useCallback((axis) => {
48
- dispatch({
49
- type: 'SET_ACTIVE',
50
- payload: {
51
- id,
52
- axis,
53
- },
54
- });
59
+ if (id) {
60
+ dispatch({
61
+ type: 'SET_ACTIVE',
62
+ payload: {
63
+ id,
64
+ axis,
65
+ },
66
+ });
67
+ return true;
68
+ }
69
+ return false;
55
70
  }, [dispatch, id]);
56
71
  const show = useCallback((axis) => {
57
- dispatch({
58
- type: 'SHOW',
59
- payload: {
60
- id,
61
- axis,
62
- },
63
- });
72
+ if (id) {
73
+ dispatch({
74
+ type: 'SHOW',
75
+ payload: {
76
+ id,
77
+ axis,
78
+ },
79
+ });
80
+ return true;
81
+ }
82
+ return false;
64
83
  }, [dispatch, id]);
65
84
  const hide = useCallback(() => {
66
85
  dispatch({
@@ -27,8 +27,10 @@ function RangesTableRow({ rowData, onUnlink, onContextMenuSelect, contextMenu =
27
27
  const assignmentRange = useAssignment(rowData.id);
28
28
  const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, rowData.signals.map((_signal) => _signal.id))), { type: HighlightEventSource.RANGE });
29
29
  const highlightRangeAssignmentsColumn = useHighlight(assignmentRange.assigned?.x || [], { type: HighlightEventSource.RANGE });
30
- const assignmentSignal = useAssignment(rowData.tableMetaInfo.id);
31
- const highlightSignal = useHighlight([assignmentSignal.id].concat(assignmentSignal.assigned?.x || []), { type: HighlightEventSource.SIGNAL });
30
+ const assignmentSignal = useAssignment(rowData?.tableMetaInfo?.id || '');
31
+ const highlightSignal = useHighlight(assignmentSignal?.id
32
+ ? [assignmentSignal.id].concat(assignmentSignal.assigned?.x || [])
33
+ : [], { type: HighlightEventSource.SIGNAL });
32
34
  const highlightData = useHighlightData();
33
35
  const rowSpanTags = useMemo(() => {
34
36
  return {
@@ -101,6 +103,8 @@ function RangesTableRow({ rowData, onUnlink, onContextMenuSelect, contextMenu =
101
103
  ? ConstantlyHighlightedRowStyle
102
104
  : null;
103
105
  }, [assignmentRange.isActive, highlightRange.isActive, rowData]);
104
- return (_jsxs(DropdownMenu, { trigger: "contextMenu", options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, rowData), as: "tr", css: trCss, children: [preferences.showSerialNumber && (_jsx("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 })), preferences.from.show && (_jsx(RangeColumn, { value: rowData.from, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.from.format })), preferences.to.show && (_jsx(RangeColumn, { value: rowData.to, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && (_jsx(SignalDeltaColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaPPM.format })), preferences.deltaHz.show && (_jsx(SignalDeltaHzColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaHz.format, info: info })), preferences.relative.show && (_jsx(RelativeColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && (_jsx(AbsoluteColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.absolute.format })), preferences.showMultiplicity && (_jsx("td", { ...onHoverSignal, children: lodashGet(rowData, 'tableMetaInfo.signal.multiplicity', '') })), preferences.coupling.show && (_jsx(CouplingColumn, { row: rowData, onHover: onHoverSignal, format: preferences.coupling.format })), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx(SignalAssignmentsColumn, { row: rowData, assignment: assignmentSignal, highlight: highlightSignal, onHover: onHoverSignal, onLink: linkHandler, onUnlink: unlinkHandler }), _jsx(RangeAssignmentsColumn, { row: rowData, assignment: assignmentRange, highlight: highlightRangeAssignmentsColumn, onHover: onHoverRangeAssignmentsColumn, onLink: linkHandler, onUnlink: unlinkHandler, rowSpanTags: rowSpanTags, highlightData: highlightData })] })), _jsx(ActionsColumn, { row: rowData, onHoverSignal: onHoverSignal, onHoverRange: onHoverRange, rowSpanTags: rowSpanTags, showKind: preferences.showKind, showDeleteAction: preferences.showDeleteAction, showEditAction: preferences.showEditAction, showZoomAction: preferences.showZoomAction })] }));
106
+ return (_jsxs(DropdownMenu, { trigger: "contextMenu", options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, rowData), as: "tr", css: trCss, children: [preferences.showSerialNumber && (_jsx("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 })), preferences.from.show && (_jsx(RangeColumn, { value: rowData.from, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.from.format })), preferences.to.show && (_jsx(RangeColumn, { value: rowData.to, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && (_jsx(SignalDeltaColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaPPM.format })), preferences.deltaHz.show && (_jsx(SignalDeltaHzColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaHz.format, info: info })), preferences.relative.show && (_jsx(RelativeColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && (_jsx(AbsoluteColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.absolute.format })), preferences.showMultiplicity && (_jsx("td", { ...onHoverSignal, children: !rowData?.tableMetaInfo?.signal
107
+ ? 'm'
108
+ : lodashGet(rowData, 'tableMetaInfo.signal.multiplicity', '') })), preferences.coupling.show && (_jsx(CouplingColumn, { row: rowData, onHover: onHoverSignal, format: preferences.coupling.format })), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx(SignalAssignmentsColumn, { row: rowData, assignment: assignmentSignal, highlight: highlightSignal, onHover: onHoverSignal, onLink: linkHandler, onUnlink: unlinkHandler }), _jsx(RangeAssignmentsColumn, { row: rowData, assignment: assignmentRange, highlight: highlightRangeAssignmentsColumn, onHover: onHoverRangeAssignmentsColumn, onLink: linkHandler, onUnlink: unlinkHandler, rowSpanTags: rowSpanTags, highlightData: highlightData })] })), _jsx(ActionsColumn, { row: rowData, onHoverSignal: onHoverSignal, onHoverRange: onHoverRange, rowSpanTags: rowSpanTags, showKind: preferences.showKind, showDeleteAction: preferences.showDeleteAction, showEditAction: preferences.showEditAction, showZoomAction: preferences.showZoomAction })] }));
105
109
  }
106
110
  export default RangesTableRow;
@@ -29,6 +29,6 @@ const selectBoxStyle = {
29
29
  function ActionsColumn({ row, onHoverSignal, rowSpanTags, showKind, showDeleteAction, showEditAction, showZoomAction, }) {
30
30
  const { editRange, deleteRange, changeRangeSignalKind, zoomRange } = useEditRangeModal(row);
31
31
  const showActions = showDeleteAction || showEditAction || showZoomAction;
32
- return (_jsxs(Fragment, { children: [showKind && (_jsx("td", { ...onHoverSignal, children: _jsx(Select, { onChange: changeRangeSignalKind, items: SIGNAL_KINDS, defaultValue: row.tableMetaInfo.signal.kind, style: selectBoxStyle }) })), showActions && (_jsxs("td", { ...rowSpanTags, css: styles, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: () => deleteRange(), children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: () => zoomRange(), children: _jsx(FaSearchPlus, { title: "Zoom to range in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: () => editRange(), children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
32
+ return (_jsxs(Fragment, { children: [showKind && (_jsx("td", { ...onHoverSignal, children: !row?.tableMetaInfo?.signal ? ('') : (_jsx(Select, { onChange: changeRangeSignalKind, items: SIGNAL_KINDS, defaultValue: row?.tableMetaInfo?.signal?.kind, style: selectBoxStyle })) })), showActions && (_jsxs("td", { ...rowSpanTags, css: styles, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: () => deleteRange(), children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: () => zoomRange(), children: _jsx(FaSearchPlus, { title: "Zoom to range in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: () => editRange(), children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
33
33
  }
34
34
  export default ActionsColumn;
@@ -5,7 +5,7 @@ import EditableColumn from '../../../elements/EditableColumn';
5
5
  import { formatNumber } from '../../../utility/formatNumber';
6
6
  function SignalDeltaColumn({ row, onHover, format, rowSpanTags, }) {
7
7
  const dispatch = useDispatch();
8
- const signal = row.tableMetaInfo.signal;
8
+ const signal = row?.tableMetaInfo?.signal;
9
9
  function saveHandler(event) {
10
10
  dispatch({
11
11
  type: 'CHANGE_RANGE_SIGNAL_VALUE',
@@ -16,8 +16,10 @@ function SignalDeltaColumn({ row, onHover, format, rowSpanTags, }) {
16
16
  },
17
17
  });
18
18
  }
19
- if (!signal)
20
- return _jsx("td", { children: '' });
21
- return (_jsx("td", { ...rowSpanTags, ...onHover, children: !checkMultiplicity(signal.multiplicity, ['m']) ? (`${formatNumber(row.from, format)} - ${formatNumber(row.to, format)}`) : (_jsx(EditableColumn, { value: formatNumber(signal.delta, format), onSave: saveHandler, type: "number", style: { padding: '0.1rem 0.4rem' }, validate: (val) => val !== '' })) }));
19
+ const rangeText = `${formatNumber(row.from, format)} - ${formatNumber(row.to, format)}`;
20
+ if (!signal || !checkMultiplicity(signal.multiplicity, ['m'])) {
21
+ return (_jsx("td", { ...rowSpanTags, ...onHover, children: rangeText }));
22
+ }
23
+ return (_jsx("td", { ...rowSpanTags, ...onHover, children: _jsx(EditableColumn, { value: formatNumber(signal.delta, format), onSave: saveHandler, type: "number", style: { padding: '0.1rem 0.4rem' }, validate: (val) => val !== '' }) }));
22
24
  }
23
25
  export default SignalDeltaColumn;
@@ -9,6 +9,10 @@ function useMapRanges(data) {
9
9
  rangesData.push({
10
10
  rowKey: v4(),
11
11
  ...range,
12
+ tableMetaInfo: {
13
+ ...range.tableMetaInfo,
14
+ rowIndex: i,
15
+ },
12
16
  });
13
17
  }
14
18
  else if (range.signals.length === 1) {
@@ -4,8 +4,8 @@ interface RangeOptions {
4
4
  from: number;
5
5
  to: number;
6
6
  }
7
- export declare function createRangeObj({ from, to, absolute, signal, }: RangeOptions & {
8
- signal: Omit<Signal1D, 'id'>;
7
+ export declare function createRangeObj({ from, to, absolute, signals, }: RangeOptions & {
8
+ signals: Array<Omit<Signal1D, 'id'>>;
9
9
  absolute: number;
10
10
  }): {
11
11
  id: string;
@@ -2,41 +2,37 @@ import { v4 } from '@lukeed/uuid';
2
2
  import { xyIntegration } from 'ml-spectra-processing';
3
3
  import { mapRanges } from 'nmr-processing';
4
4
  import { DATUM_KIND } from '../../../constants/signalsKinds';
5
- import detectSignal from './detectSignal';
6
- export function createRangeObj({ from, to, absolute, signal, }) {
5
+ import detectSignals from './detectSignals';
6
+ export function createRangeObj({ from, to, absolute, signals, }) {
7
7
  return {
8
8
  id: v4(),
9
9
  from,
10
10
  to,
11
11
  absolute,
12
- signals: [{ id: v4(), ...signal }],
12
+ signals: signals.map((signal) => ({ id: v4(), ...signal })),
13
13
  kind: DATUM_KIND.signal,
14
14
  integration: 0,
15
15
  };
16
16
  }
17
17
  export function addRange(spectrum, options) {
18
18
  const { from, to } = options;
19
- const { x, re } = spectrum.data;
20
- const absolute = xyIntegration({ x, y: re }, { from, to, reverse: true });
21
- // detectSignal use the advance multiplet-analysis that can crash if too many points
22
- const signal = detectSignal({ x, re }, {
19
+ const { x, re: y } = spectrum.data;
20
+ const { nucleus, originFrequency: frequency } = spectrum.info;
21
+ const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
22
+ const signals = detectSignals({ x, y }, {
23
23
  from,
24
24
  to,
25
- frequency: spectrum.info.originFrequency,
26
- });
27
- let range;
28
- if (signal) {
29
- range = createRangeObj({
30
- from,
31
- to,
32
- absolute,
33
- signal,
34
- });
35
- }
25
+ nucleus,
26
+ frequency,
27
+ }) || [];
28
+ const range = {
29
+ from,
30
+ to,
31
+ absolute,
32
+ signals,
33
+ };
36
34
  try {
37
- if (range) {
38
- spectrum.ranges.values = spectrum.ranges.values.concat(mapRanges([range], spectrum));
39
- }
35
+ spectrum.ranges.values = spectrum.ranges.values.concat(mapRanges([range], spectrum));
40
36
  }
41
37
  catch (error) {
42
38
  reportError(error);
@@ -1,38 +1,29 @@
1
- import { v4 } from '@lukeed/uuid';
2
1
  import { xyIntegration } from 'ml-spectra-processing';
3
- import { updateRangesRelativeValues } from 'nmr-processing';
4
- import detectSignal from './detectSignal';
2
+ import { mapRanges, updateRangesRelativeValues, } from 'nmr-processing';
3
+ import detectSignals from './detectSignals';
5
4
  export function changeRange(spectrum, range) {
6
5
  const { from, to, id } = range;
7
- const { x, re } = spectrum.data;
6
+ const { x, re: y } = spectrum.data;
7
+ const { originFrequency: frequency, nucleus } = spectrum.info;
8
8
  const index = spectrum.ranges.values.findIndex((i) => i.id === id);
9
- const absolute = xyIntegration({ x, y: re }, { from, to, reverse: true });
10
- const signal = detectSignal({ x, re }, {
9
+ const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
10
+ const signals = detectSignals({ x, y }, {
11
11
  from,
12
12
  to,
13
- frequency: spectrum.info.originFrequency,
14
- checkMaxLength: false,
13
+ nucleus,
14
+ frequency,
15
15
  });
16
16
  if (index !== -1) {
17
- spectrum.ranges.values[index] = {
18
- ...spectrum.ranges.values[index],
19
- originalFrom: from,
20
- originalTo: to,
21
- ...range,
22
- absolute,
23
- signals: [
24
- {
25
- id: v4(),
26
- ...(signal || {
27
- multiplicity: 's',
28
- kind: 'signal',
29
- delta: 0,
30
- js: [],
31
- diaIDs: [],
32
- }),
33
- },
34
- ],
35
- };
17
+ spectrum.ranges.values[index] = mapRanges([
18
+ {
19
+ ...spectrum.ranges.values[index],
20
+ originalFrom: from,
21
+ originalTo: to,
22
+ ...range,
23
+ absolute,
24
+ signals,
25
+ },
26
+ ], spectrum)[0];
36
27
  updateRangesRelativeValues(spectrum);
37
28
  }
38
29
  }
@@ -0,0 +1,27 @@
1
+ import { DataXY } from 'cheminfo-types';
2
+ export declare const MAX_LENGTH = 4092;
3
+ export default function detectSignals(data: DataXY, options: {
4
+ from: number;
5
+ to: number;
6
+ nucleus: string;
7
+ frequency: number;
8
+ }): {
9
+ delta: number;
10
+ id?: string | undefined;
11
+ js: import("nmr-processing").Jcoupling[];
12
+ atoms?: number[] | undefined;
13
+ assignment?: string | undefined;
14
+ kind?: string | undefined;
15
+ multiplicity: string;
16
+ diaIDs?: string[] | undefined;
17
+ nbAtoms?: number | undefined;
18
+ integration?: number | undefined;
19
+ peaks?: import("nmr-processing").NMRPeak1D[] | undefined;
20
+ statistic?: {
21
+ mean: number;
22
+ sd: number;
23
+ min: number;
24
+ max: number;
25
+ nb: number;
26
+ } | undefined;
27
+ }[];
@@ -0,0 +1,23 @@
1
+ import { xyAutoRangesPicking } from 'nmr-processing';
2
+ export const MAX_LENGTH = 4092;
3
+ export default function detectSignals(data, options) {
4
+ 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
+ },
19
+ });
20
+ return ranges
21
+ .flatMap((r) => r.signals || [])
22
+ .map((s) => ({ multiplicity: '', js: [], ...s }));
23
+ }
@@ -1 +1 @@
1
- export default { version: 'v0.44.1-pre.1700644530' };
1
+ export default { version: 'v0.45.0' };
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.44.1-pre.1700644530",
4
+ "version": "0.45.0",
5
5
  "license": "MIT",
6
6
  "module": "lib/component/main/index.js",
7
7
  "types": "lib/component/main/index.d.ts",
@@ -85,7 +85,7 @@
85
85
  "ml-stat": "^1.3.3",
86
86
  "multiplet-analysis": "^2.1.2",
87
87
  "nmr-correlation": "^2.3.3",
88
- "nmr-load-save": "^0.23.4",
88
+ "nmr-load-save": "^0.23.6",
89
89
  "nmr-processing": "^11.6.0",
90
90
  "nmredata": "^0.9.7",
91
91
  "numeral": "^2.0.6",
@@ -1,16 +0,0 @@
1
- export declare const MAX_LENGTH = 2048;
2
- export default function detectSignal(data: {
3
- x: Float64Array;
4
- re: Float64Array;
5
- }, options: {
6
- from: number;
7
- to: number;
8
- frequency: number;
9
- checkMaxLength?: boolean;
10
- }): {
11
- multiplicity: any;
12
- kind: string;
13
- delta: number;
14
- js: any;
15
- diaIDs: never[];
16
- } | undefined;
@@ -1,76 +0,0 @@
1
- import { xGetFromToIndex } from 'ml-spectra-processing';
2
- import { analyseMultiplet } from 'multiplet-analysis';
3
- import { signalJoinCouplings, xyAutoPeaksPicking } from 'nmr-processing';
4
- export const MAX_LENGTH = 2048;
5
- export default function detectSignal(data, options) {
6
- const { x, re } = data;
7
- const { from, to, frequency, checkMaxLength = true } = options;
8
- const { fromIndex, toIndex } = xGetFromToIndex(x, {
9
- from,
10
- to,
11
- });
12
- if (!checkMaxLength ||
13
- (checkMaxLength && toIndex - fromIndex <= MAX_LENGTH)) {
14
- const dataRoi = {
15
- x: x.slice(fromIndex, toIndex),
16
- y: re.slice(fromIndex, toIndex),
17
- };
18
- const result = analyseMultiplet(dataRoi, {
19
- frequency,
20
- minimalResolution: 0.1,
21
- maxTestedJ: 17,
22
- checkSymmetryFirst: true,
23
- takeBestPartMultiplet: true,
24
- correctVerticalOffset: true,
25
- symmetrizeEachStep: false,
26
- decreasingJvalues: true,
27
- makeShortCutForSpeed: true,
28
- });
29
- if (result && result.chemShift === undefined)
30
- return;
31
- const { delta, js } = joinCouplings(result);
32
- let cs = 0;
33
- let area = 0;
34
- for (let i = 0; i < dataRoi.x.length; i++) {
35
- cs += dataRoi.x[i] * dataRoi.y[i];
36
- area += dataRoi.y[i];
37
- }
38
- cs /= area;
39
- const peakList = js.length === 0 ? xyAutoPeaksPicking(dataRoi, { frequency }) : [];
40
- return {
41
- multiplicity: js.length > 0
42
- ? js.map((j) => j.multiplicity).join('')
43
- : Math.abs(cs - delta) / cs < 1e-3
44
- ? peakList.length === 1
45
- ? 's'
46
- : 'm'
47
- : 'm',
48
- kind: 'signal',
49
- delta: cs,
50
- js,
51
- diaIDs: [],
52
- };
53
- }
54
- else {
55
- throw new Error(`length of signal should not exceed ${MAX_LENGTH} points`);
56
- }
57
- }
58
- function joinCouplings(result) {
59
- const { chemShift: delta, js } = result;
60
- let jCouplings = js;
61
- if (js.length > 1) {
62
- try {
63
- jCouplings = signalJoinCouplings({
64
- delta,
65
- js,
66
- }, { tolerance: 0.6, ignoreDiaIDs: true }).js;
67
- }
68
- catch (error) {
69
- reportError(error);
70
- }
71
- }
72
- return {
73
- delta,
74
- js: jCouplings,
75
- };
76
- }