Skip to content

Commit 720722b

Browse files
authored
feat: carbon solvent labelling (#3693)
* feat: example of auto ranges options to works with carbon spectrum and solvent labelling * chore: compile only if nucleus is a proton * chore: fix peaksFilterImpurities by updating nmr-processing * chore: handle sensitivity from the options of autoPeakPicking function * chore: set default sensitivity to 100 * chore: default sensitivity to 100 * chore: move the rangePicking option and use the info.nucleus instead of view information * chore: update nmr-processing to 19.3.2 * chore: adapt ranges panel test case to new result
1 parent de0fabf commit 720722b

5 files changed

Lines changed: 30 additions & 23 deletions

File tree

src/component/reducer/actions/RangesActions.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,15 @@ function handleAutoRangesDetection(
231231
const detectionOptions: any = {
232232
rangePicking: {
233233
integrationSum: 100,
234-
compile: true,
235-
frequencyCluster: 16,
234+
compile: nucleus === '1H',
235+
frequencyCluster: nucleus === '1H' ? 16 : 0,
236236
clean: 0.3,
237237
keepPeaks: true,
238+
joinOverlapRanges: nucleus === '1H',
238239
},
239240
peakPicking: {
241+
smoothY: false,
242+
sensitivity: 100,
240243
broadWidth: 0.05,
241244
thresholdFactor: 8,
242245
minMaxRatio,
@@ -257,25 +260,23 @@ function handleAutoRangesDetection(
257260
//action
258261
function handleAutoSpectraRangesDetection(draft: Draft<State>) {
259262
const peakPicking = {
263+
sensitivity: 100,
260264
thresholdFactor: 8,
261265
minMaxRatio: 0.05,
262266
};
263-
const rangePicking = {
264-
integrationSum: 100,
265-
compile: true,
266-
frequencyCluster: 16,
267-
clean: 0.3,
268-
keepPeaks: true,
269-
};
270-
const {
271-
data,
272-
view: {
273-
spectra: { activeTab: nucleus },
274-
},
275-
molecules,
276-
} = draft;
267+
const { data, molecules } = draft;
268+
277269
for (const datum of data) {
278270
if (datum.info.dimension === 1) {
271+
const nucleus = datum.info.nucleus as string;
272+
const rangePicking = {
273+
integrationSum: 100,
274+
compile: nucleus === '1H',
275+
frequencyCluster: nucleus === '1H' ? 16 : 0,
276+
clean: 0.3,
277+
keepPeaks: true,
278+
joinOverlapRanges: nucleus === '1H',
279+
};
279280
detectRanges(datum as Spectrum1D, {
280281
peakPicking,
281282
rangePicking,

src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export function autoPeakPicking(spectrum: Spectrum1D, options: any) {
99
maxNumberOfPeaks,
1010
noiseFactor,
1111
direction,
12+
sensitivity = 100,
1213
windowFromIndex,
1314
windowToIndex,
1415
} = options;
@@ -28,6 +29,7 @@ export function autoPeakPicking(spectrum: Spectrum1D, options: any) {
2829
{
2930
frequency,
3031
direction,
32+
sensitivity,
3133
shape: { kind: 'lorentzian' },
3234
noiseLevel: noise * noiseFactor,
3335
minMaxRatio, // Threshold to determine if a given peak should be considered as a noise

src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const defaultPeakPickingOptions = {
88
realTopDetection: true,
99
maxCriteria: true,
1010
smoothY: true,
11+
sensitivity: 100,
1112
broadWidth: 0.25,
1213
broadRatio: 0.0025,
1314
integrationSum: 100,
@@ -23,7 +24,7 @@ export default function autoRangesDetection(
2324

2425
let { re, x } = spectrum.data;
2526

26-
const { originFrequency, nucleus } = spectrum.info;
27+
const { originFrequency, nucleus, solvent } = spectrum.info;
2728

2829
const { windowFromIndex, windowToIndex, peakPicking, rangePicking } = options;
2930

@@ -34,12 +35,13 @@ export default function autoRangesDetection(
3435
};
3536

3637
const rangesOptions = {
37-
frequency: originFrequency,
3838
nucleus,
39-
compile: true,
40-
frequencyCluster: 13,
41-
keepPeaks: true,
4239
clean: 0.3,
40+
keepPeaks: true,
41+
compile: nucleus === '1H',
42+
frequency: originFrequency,
43+
joinOverlapRanges: nucleus === '1H',
44+
frequencyCluster: nucleus === '1H' ? 13 : 0,
4345
...rangePicking,
4446
};
4547

@@ -54,6 +56,7 @@ export default function autoRangesDetection(
5456
const ranges = xyAutoRangesPicking(
5557
{ x, y: re },
5658
{
59+
impurities: { solvent },
5760
peakPicking: peakPickingOptions,
5861
ranges: rangesOptions,
5962
},

src/data/data1d/__tests__/autoPeakPicking.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('test peakPicking', () => {
1212
it('check baseline', () => {
1313
const datum = initiateDatum1D({ data, info: { originFrequency: 150 } });
1414
const peaks = autoPeakPicking(datum, {
15+
sensitivity: 100,
1516
maxNumberOfPeaks: 20,
1617
minMaxRatio: 0.1,
1718
});

test-e2e/panels/ranges.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ test('Auto peak picking on all spectra', async ({ page }) => {
367367
await test.step("Check 13C spectrum's ranges", async () => {
368368
// switch to 13C tab.
369369
await nmrium.page.click('_react=SpectraTabs >> _react=Tab[tabid="13C"]');
370-
await expect(nmrium.page.getByTestId('range')).toHaveCount(15);
370+
await expect(nmrium.page.getByTestId('range')).toHaveCount(17);
371371
await expect(
372372
nmrium.page.locator('_react=RangesPanel >> _react=PanelHeader'),
373-
).toContainText('[ 15 ]');
373+
).toContainText('[ 17 ]');
374374
});
375375

376376
await test.step("Check 1H,1H spectrum's ranges", async () => {

0 commit comments

Comments
 (0)