nmrium 0.44.1-pre.1700644530 → 0.45.1-pre.1701344673
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component/1d/Viewer1D.js +1 -1
- package/lib/component/2d/zones/Signal.js +6 -6
- package/lib/component/assignment/AssignmentsContext.d.ts +1 -1
- package/lib/component/assignment/AssignmentsContext.js +43 -24
- package/lib/component/elements/Select.js +11 -4
- package/lib/component/hooks/useActiveSpectrumIntegralsViewState.js +3 -1
- package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +3 -1
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +3 -1
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +6 -2
- package/lib/component/hooks/useActiveSpectrumZonesViewState.js +3 -1
- package/lib/component/hooks/useSaveSettings.js +1 -1
- package/lib/component/hooks/useSpectrum.js +1 -1
- package/lib/component/modal/MultipletAnalysisModal.d.ts +1 -2
- package/lib/component/panels/MatrixGenerationPanel/FiltersOptions.js +7 -2
- package/lib/component/panels/RangesPanel/RangesTableRow.js +7 -3
- package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +1 -1
- package/lib/component/panels/RangesPanel/TableColumns/SignalDeltaColumn.js +6 -4
- package/lib/component/panels/RangesPanel/hooks/useMapRanges.js +4 -0
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectraTable.d.ts +1 -2
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +3 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -2
- package/lib/component/reducer/Reducer.d.ts +0 -4
- package/lib/component/reducer/actions/FiltersActions.d.ts +2 -1
- package/lib/component/reducer/actions/FiltersActions.js +1 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +1 -0
- package/lib/component/reducer/actions/ToolsActions.js +8 -6
- package/lib/component/reducer/helper/getActiveSpectra.js +2 -1
- package/lib/component/reducer/helper/getActiveSpectrum.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +17 -21
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +18 -27
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +27 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +23 -0
- package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +0 -16
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +0 -76
|
@@ -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/
|
|
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
|
|
15
|
+
const assignment = useAssignment(signal?.id || '');
|
|
16
16
|
const { showSignals, showPeaks } = useActiveSpectrumZonesViewState();
|
|
17
|
-
const highlight = useHighlight(buildIDs(assignment
|
|
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
|
|
22
|
+
assignment?.isActive) {
|
|
23
23
|
setIsHighlighted(true);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
setIsHighlighted(false);
|
|
27
27
|
}
|
|
28
28
|
}, [
|
|
29
|
-
assignment
|
|
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
|
|
37
|
+
assignment?.show();
|
|
38
38
|
highlight.show();
|
|
39
39
|
}, onMouseLeave: () => {
|
|
40
|
-
assignment
|
|
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 (
|
|
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
|
-
|
|
33
|
+
if (!(id in assignments)) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
return assignments[id];
|
|
34
37
|
}, [assignments, id]);
|
|
35
38
|
const removeAll = useCallback((axis) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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({
|
|
@@ -39,12 +39,19 @@ const Select = forwardRef(function Select(props, ref) {
|
|
|
39
39
|
onChange(returnValue ? selectedData[itemValueField] : selectedData);
|
|
40
40
|
}, [itemValueField, onChange, returnValue]);
|
|
41
41
|
return (_jsxs("select", { ref: ref, css: styles.select(style?.width), name: name, onChange: handleOnChanged, defaultValue: defaultValue, value: value, className: className, style: style, required: true, children: [placeholder && (_jsx("option", { value: "", disabled: true, children: placeholder })), items.map((option) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
42
|
+
const value = option[itemValueField];
|
|
43
|
+
if (!['number', 'string'].includes(typeof option[itemTextField])) {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.log(`The '${itemTextField}' field should be a string , option : ${JSON.stringify(option)}`);
|
|
45
46
|
return null;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
if (!['number', 'string'].includes(typeof value)) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log(`The '${itemValueField}' field should be either a string or a number, option : ${JSON.stringify(option)}`);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const label = String(option[itemTextField]);
|
|
54
|
+
return (_jsx("option", { value: value, "data-value": JSON.stringify(option), children: textRender?.(label) || label }, JSON.stringify(option)));
|
|
48
55
|
})] }));
|
|
49
56
|
});
|
|
50
57
|
export default Select;
|
|
@@ -6,7 +6,9 @@ export const defaultIntegralsViewState = {
|
|
|
6
6
|
export function useActiveSpectrumIntegralsViewState() {
|
|
7
7
|
const activeSpectrum = useActiveSpectrum();
|
|
8
8
|
const { view: { integrals }, } = useChartData();
|
|
9
|
-
if (activeSpectrum?.id &&
|
|
9
|
+
if (activeSpectrum?.id &&
|
|
10
|
+
activeSpectrum?.selected &&
|
|
11
|
+
integrals[activeSpectrum?.id]) {
|
|
10
12
|
return integrals[activeSpectrum?.id];
|
|
11
13
|
}
|
|
12
14
|
else {
|
|
@@ -9,7 +9,9 @@ export const defaultPeaksViewState = {
|
|
|
9
9
|
export function useActiveSpectrumPeaksViewState() {
|
|
10
10
|
const activeSpectrum = useActiveSpectrum();
|
|
11
11
|
const { view: { peaks }, } = useChartData();
|
|
12
|
-
if (activeSpectrum?.id &&
|
|
12
|
+
if (activeSpectrum?.id &&
|
|
13
|
+
activeSpectrum?.selected &&
|
|
14
|
+
peaks[activeSpectrum?.id]) {
|
|
13
15
|
return peaks[activeSpectrum?.id];
|
|
14
16
|
}
|
|
15
17
|
else {
|
|
@@ -11,7 +11,9 @@ export const defaultRangesViewState = {
|
|
|
11
11
|
export function useActiveSpectrumRangesViewState() {
|
|
12
12
|
const activeSpectrum = useActiveSpectrum();
|
|
13
13
|
const { view: { ranges }, } = useChartData();
|
|
14
|
-
if (activeSpectrum?.id &&
|
|
14
|
+
if (activeSpectrum?.id &&
|
|
15
|
+
activeSpectrum?.selected &&
|
|
16
|
+
ranges[activeSpectrum?.id]) {
|
|
15
17
|
return ranges[activeSpectrum?.id];
|
|
16
18
|
}
|
|
17
19
|
else {
|
|
@@ -6,8 +6,12 @@ export default function useActiveSpectrumStyleOptions(id) {
|
|
|
6
6
|
const activeSpectra = useActiveSpectra();
|
|
7
7
|
const preferences = usePreferences();
|
|
8
8
|
return useMemo(() => {
|
|
9
|
-
const index = activeSpectra?.findIndex((activeSpectrum) => activeSpectrum.id === id);
|
|
10
|
-
|
|
9
|
+
const index = activeSpectra?.findIndex((activeSpectrum) => activeSpectrum?.selected && activeSpectrum.id === id);
|
|
10
|
+
let isNoneSelected = false;
|
|
11
|
+
isNoneSelected =
|
|
12
|
+
activeSpectra?.every((activeSpectrum) => !activeSpectrum?.selected) ||
|
|
13
|
+
false;
|
|
14
|
+
const isActive = !!(activeSpectra?.length === 0 || index !== -1) || isNoneSelected;
|
|
11
15
|
const opacity = isActive
|
|
12
16
|
? 1
|
|
13
17
|
: get(preferences.current, 'general.dimmedSpectraOpacity', 0.1);
|
|
@@ -8,7 +8,9 @@ export const defaultZonesViewState = {
|
|
|
8
8
|
export function useActiveSpectrumZonesViewState() {
|
|
9
9
|
const activeSpectrum = useActiveSpectrum();
|
|
10
10
|
const { view: { zones }, } = useChartData();
|
|
11
|
-
if (activeSpectrum?.id &&
|
|
11
|
+
if (activeSpectrum?.id &&
|
|
12
|
+
activeSpectrum?.selected &&
|
|
13
|
+
zones[activeSpectrum?.id]) {
|
|
12
14
|
return zones[activeSpectrum?.id];
|
|
13
15
|
}
|
|
14
16
|
else {
|
|
@@ -13,7 +13,7 @@ const schema = Yup.object().shape({
|
|
|
13
13
|
const WorkspaceAddForm = forwardRef(({ className, message, onSave }, ref) => {
|
|
14
14
|
return (_jsxs("div", { className: className, children: [_jsx("p", { style: { paddingBottom: '10px' }, children: message }), _jsx(Formik, { initialValues: { workspaceName: '' }, validationSchema: schema, onSubmit: onSave, innerRef: ref, children: _jsx(FormikInput, { name: "workspaceName", placeholder: "Enter workspace Name", style: {
|
|
15
15
|
input: {
|
|
16
|
-
|
|
16
|
+
padding: '0.5em',
|
|
17
17
|
width: '90%',
|
|
18
18
|
fontWeight: 'normal',
|
|
19
19
|
color: 'black',
|
|
@@ -5,7 +5,7 @@ export default function useSpectrum(defaultValue = null) {
|
|
|
5
5
|
const { data } = useChartData();
|
|
6
6
|
const activeSpectrum = useActiveSpectrum();
|
|
7
7
|
return useMemo(() => {
|
|
8
|
-
if (data && activeSpectrum?.id) {
|
|
8
|
+
if (data && activeSpectrum?.id && activeSpectrum?.selected) {
|
|
9
9
|
const datum = data.find((datum) => datum.id === activeSpectrum.id) || defaultValue;
|
|
10
10
|
return datum;
|
|
11
11
|
}
|
|
@@ -12,7 +12,7 @@ import FormikInput from '../../elements/formik/FormikInput';
|
|
|
12
12
|
import FormikSelect from '../../elements/formik/FormikSelect';
|
|
13
13
|
import { DEFAULT_MATRIX_FILTERS, GroupPanelStyle, } from './MatrixGenerationPanel';
|
|
14
14
|
const inputStyle = {
|
|
15
|
-
input: { padding: '0.
|
|
15
|
+
input: { padding: '0.4em', width: '100%' },
|
|
16
16
|
};
|
|
17
17
|
export function FiltersOptions() {
|
|
18
18
|
const { values } = useFormikContext();
|
|
@@ -96,7 +96,12 @@ function FiltersPanelGroupHeader({ index, name }) {
|
|
|
96
96
|
function handleDelete(index) {
|
|
97
97
|
void setFieldValue('filters', values.filters.filter((_, i) => i !== index));
|
|
98
98
|
}
|
|
99
|
-
return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsxs("p", { style: {
|
|
99
|
+
return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsxs("p", { style: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
margin: 0,
|
|
102
|
+
paddingRight: '5px',
|
|
103
|
+
...GroupPanelStyle.header,
|
|
104
|
+
}, children: [index + 1, "-"] }), _jsx(Select, { value: name, items: DEFAULT_MATRIX_FILTERS, onChange: (value) => handelSelectFilter(value, index), style: { width: '100%' }, returnValue: false, itemTextField: "name", itemValueField: "name", textRender: (text) => normalCase(text) }), _jsxs("div", { style: { display: 'flex' }, children: [_jsx(Button.Danger, { fill: "outline", onClick: () => handleDelete(index), style: { marginLeft: '5px' }, children: _jsx(FaTimes, {}) }), _jsx(Button.Done, { fill: "outline", onClick: () => handleAdd(index + 1), style: { marginLeft: '5px' }, children: _jsx(FaPlus, {}) })] })] }));
|
|
100
105
|
}
|
|
101
106
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
107
|
function FieldInfo(props) {
|
|
@@ -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
|
|
31
|
-
const highlightSignal = useHighlight(
|
|
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:
|
|
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
|
|
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
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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;
|
|
@@ -11,7 +11,7 @@ import { useModal } from '../../elements/popup/Modal';
|
|
|
11
11
|
import { useActiveSpectra } from '../../hooks/useActiveSpectra';
|
|
12
12
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
13
13
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
14
|
-
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
14
|
+
import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
|
|
15
15
|
import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
|
|
16
16
|
function getMissingProjection(SpectrumsData, activeTab) {
|
|
17
17
|
let nucleus = activeTab.split(',');
|
|
@@ -29,7 +29,6 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
|
|
|
29
29
|
const modal = useModal();
|
|
30
30
|
const alert = useAlert();
|
|
31
31
|
const dispatch = useDispatch();
|
|
32
|
-
const spectra = getSpectraByNucleus(activeTab, data);
|
|
33
32
|
const handleDelete = useCallback(() => {
|
|
34
33
|
modal.showConfirmDialog({
|
|
35
34
|
message: (_jsxs("span", { children: ["You are about to delete", _jsxs("span", { style: { color: 'black' }, children: [" ", activeSpectra?.length, " "] }), "spectra, Are you sure?"] })),
|
|
@@ -81,7 +80,8 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
|
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
const hasActiveSpectra = activeSpectra && activeSpectra?.length > 0;
|
|
84
|
-
|
|
83
|
+
const spectraLengthPerTab = getSpectraByNucleus(activeTab, data)?.length;
|
|
84
|
+
return (_jsxs(DefaultPanelHeader, { onDelete: handleDelete, counter: data?.length, counterLabel: createFilterLabel(data?.length, spectraLengthPerTab), deleteToolTip: "Delete selected spectra", disableDelete: !hasActiveSpectra, showSettingButton: true, onSettingClick: onSettingClick, children: [_jsx(Button.BarButton, { toolTip: "Hide selected spectra", onClick: hideAllSpectrumsHandler, tooltipOrientation: "horizontal", disabled: !hasActiveSpectra, children: _jsx(FaEyeSlash, {}) }), _jsx(Button.BarButton, { onClick: showAllSpectrumsHandler, toolTip: "Show selected spectra", tooltipOrientation: "horizontal", disabled: !hasActiveSpectra, children: _jsx(FaEye, {}) }), displayerMode === '2D' && activeSpectrum?.info.isFt && (_jsx(Button.BarButton, { toolTip: "Add missing projection", tooltipOrientation: "horizontal", onClick: addMissingProjectionHandler, children: _jsx(FaCreativeCommonsSamplingPlus, {}) })), displayerMode === '1D' && spectraLengthPerTab > 1 && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Reset scale", onClick: resetScaleHandler, children: _jsx(SvgNmrResetScale, {}) }), _jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Same top", onClick: setSameTopHandler, children: _jsx(SvgNmrSameTop, {}) })] })), _jsx(SpectraAutomaticPickingButton, {}), _jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Recolor spectra", onClick: recolorSpectraHandler, children: _jsx(IoColorPaletteOutline, {}) })] }));
|
|
85
85
|
}
|
|
86
86
|
const MemoizedSpectraPanelHeader = memo(SpectraPanelHeaderInner);
|
|
87
87
|
export default function SpectrumsTabs({ onSettingClick, }) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Spectrum } from 'nmr-load-save';
|
|
2
|
-
import { ActiveSpectrum } from '../../reducer/Reducer';
|
|
1
|
+
import { ActiveSpectrum, Spectrum } from 'nmr-load-save';
|
|
3
2
|
import { OnChangeVisibilityEvent } from './base/ShowHideSpectrumButton';
|
|
4
3
|
interface SpectraTableProps extends OnChangeVisibilityEvent {
|
|
5
4
|
data: any;
|
|
@@ -24,7 +24,9 @@ function getActiveSpectraAsObject(activeSpectra) {
|
|
|
24
24
|
const result = {};
|
|
25
25
|
if (activeSpectra) {
|
|
26
26
|
for (const activeSpectrum of activeSpectra) {
|
|
27
|
-
|
|
27
|
+
if (activeSpectrum?.selected) {
|
|
28
|
+
result[activeSpectrum.id] = true;
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Correlation, Link } from 'nmr-correlation';
|
|
2
|
-
import { Spectrum2D, Spectrum } from 'nmr-load-save';
|
|
3
|
-
import {
|
|
2
|
+
import { Spectrum2D, Spectrum, ActiveSpectrum } from 'nmr-load-save';
|
|
3
|
+
import { DisplayerMode } from '../../../reducer/Reducer';
|
|
4
4
|
declare function getAtomType(nucleus: string): string;
|
|
5
5
|
declare function getLabelColor(correlationData: any, correlation: any): string | null;
|
|
6
6
|
declare function findSignalMatch1D(spectrum: Spectrum2D, link: Link, factor: number, xDomain0: number, xDomain1: number): boolean;
|
|
@@ -9,10 +9,6 @@ import { UsedColors } from '../../types/UsedColors';
|
|
|
9
9
|
import { Action } from '../context/DispatchContext';
|
|
10
10
|
import { Tool } from '../toolbar/ToolTypes';
|
|
11
11
|
import { ZoomHistory } from './helper/ZoomHistoryManager';
|
|
12
|
-
export interface ActiveSpectrum {
|
|
13
|
-
id: string;
|
|
14
|
-
index: number;
|
|
15
|
-
}
|
|
16
12
|
export type DisplayerMode = '1D' | '2D';
|
|
17
13
|
export interface Pivot {
|
|
18
14
|
value: number;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { ActiveSpectrum } from 'nmr-load-save';
|
|
2
3
|
import { BaselineCorrectionOptions, ApodizationOptions } from 'nmr-processing';
|
|
3
4
|
import { ExclusionZone } from '../../../data/types/data1d/ExclusionZone';
|
|
4
5
|
import { MatrixOptions } from '../../../data/types/data1d/MatrixOptions';
|
|
5
|
-
import {
|
|
6
|
+
import { State, TraceDirection } from '../Reducer';
|
|
6
7
|
import { ActionType } from '../types/ActionType';
|
|
7
8
|
type ShiftSpectrumAlongXAxisAction = ActionType<'SHIFT_SPECTRUM', {
|
|
8
9
|
shift: number;
|
|
@@ -10,7 +10,7 @@ import { get2DXScale, get2DYScale } from '../../2d/utilities/scale';
|
|
|
10
10
|
import { options as Tools } from '../../toolbar/ToolTypes';
|
|
11
11
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
12
12
|
import nucleusToString from '../../utility/nucleusToString';
|
|
13
|
-
import { getInitialState
|
|
13
|
+
import { getInitialState } from '../Reducer';
|
|
14
14
|
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
15
15
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
16
16
|
import getRange from '../helper/getRange';
|
|
@@ -327,23 +327,25 @@ function setTabActiveSpectrum(draft, dataGroupByTab) {
|
|
|
327
327
|
}
|
|
328
328
|
if (data.length === 1) {
|
|
329
329
|
const index = draft.data.findIndex((datum) => datum.id === data[0].id);
|
|
330
|
-
tabActiveSpectrum[tabKey] = [{ id: data[0].id, index }];
|
|
330
|
+
tabActiveSpectrum[tabKey] = [{ id: data[0].id, index, selected: true }];
|
|
331
331
|
}
|
|
332
332
|
else {
|
|
333
333
|
const tabSpectra = dataGroupByTab[tabKey];
|
|
334
334
|
const tabSpectraLength = tabSpectra.length;
|
|
335
335
|
if (tabSpectraLength >= 2) {
|
|
336
336
|
const FTSpectrums = tabSpectra.filter((d) => !d.info.isFid);
|
|
337
|
-
if (FTSpectrums.length > 0
|
|
338
|
-
|
|
339
|
-
(nucleusLength === 1 && tabSpectraLength !== FTSpectrums.length)
|
|
337
|
+
if (FTSpectrums.length > 0) {
|
|
338
|
+
const selected = nucleusLength === 2 ||
|
|
339
|
+
(nucleusLength === 1 && tabSpectraLength !== FTSpectrums.length);
|
|
340
340
|
const index = draft.data.findIndex((datum) => datum.id === FTSpectrums[0].id);
|
|
341
|
-
tabActiveSpectrum[tabKey] = [
|
|
341
|
+
tabActiveSpectrum[tabKey] = [
|
|
342
|
+
{ id: FTSpectrums[0].id, index, selected },
|
|
343
|
+
];
|
|
342
344
|
}
|
|
343
345
|
else if (tabSpectraLength - FTSpectrums > 0) {
|
|
344
346
|
const id = tabSpectra[0].id;
|
|
345
347
|
const index = draft.data.findIndex((datum) => datum.id === id);
|
|
346
|
-
tabActiveSpectrum[tabKey] = [{ id, index }];
|
|
348
|
+
tabActiveSpectrum[tabKey] = [{ id, index, selected: true }];
|
|
347
349
|
}
|
|
348
350
|
else {
|
|
349
351
|
tabActiveSpectrum[tabKey] = null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export function getActiveSpectra(state) {
|
|
2
2
|
const { activeSpectra, activeTab } = state.view.spectra;
|
|
3
|
-
|
|
3
|
+
const spectra = activeSpectra?.[activeTab]?.filter((spectrum) => spectrum?.selected);
|
|
4
|
+
return Array.isArray(spectra) && spectra.length > 0 ? spectra : null;
|
|
4
5
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function getActiveSpectrum(state) {
|
|
2
2
|
const { activeSpectra, activeTab } = state.view.spectra;
|
|
3
3
|
const spectra = activeSpectra[activeTab];
|
|
4
|
-
if (spectra?.length === 1) {
|
|
4
|
+
if (spectra?.length === 1 && spectra[0]?.selected) {
|
|
5
5
|
return spectra[0];
|
|
6
6
|
}
|
|
7
7
|
return null;
|
|
@@ -4,8 +4,8 @@ interface RangeOptions {
|
|
|
4
4
|
from: number;
|
|
5
5
|
to: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function createRangeObj({ from, to, absolute,
|
|
8
|
-
|
|
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
|
|
6
|
-
export function createRangeObj({ from, to, absolute,
|
|
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:
|
|
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
|
|
21
|
-
|
|
22
|
-
const
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
}
|
|
25
|
+
nucleus,
|
|
26
|
+
frequency,
|
|
27
|
+
}) || [];
|
|
28
|
+
const range = {
|
|
29
|
+
from,
|
|
30
|
+
to,
|
|
31
|
+
absolute,
|
|
32
|
+
signals,
|
|
33
|
+
};
|
|
36
34
|
try {
|
|
37
|
-
|
|
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
|
|
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
|
|
10
|
-
const
|
|
9
|
+
const absolute = xyIntegration({ x, y }, { from, to, reverse: true });
|
|
10
|
+
const signals = detectSignals({ x, y }, {
|
|
11
11
|
from,
|
|
12
12
|
to,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
nucleus,
|
|
14
|
+
frequency,
|
|
15
15
|
});
|
|
16
16
|
if (index !== -1) {
|
|
17
|
-
spectrum.ranges.values[index] =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
}
|
package/lib/versionInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v0.
|
|
1
|
+
export default { version: 'v0.45.1-pre.1701344673' };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmrium",
|
|
3
3
|
"description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.45.1-pre.1701344673",
|
|
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.
|
|
88
|
+
"nmr-load-save": "^0.23.8",
|
|
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
|
-
}
|