Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions src/component/reducer/actions/RangesActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,15 @@ function handleAutoRangesDetection(
const detectionOptions: any = {
rangePicking: {
integrationSum: 100,
compile: true,
frequencyCluster: 16,
compile: nucleus === '1H',
frequencyCluster: nucleus === '1H' ? 16 : 0,
clean: 0.3,
keepPeaks: true,
joinOverlapRanges: nucleus === '1H',
},
peakPicking: {
smoothY: false,
sensitivity: 100,
broadWidth: 0.05,
thresholdFactor: 8,
minMaxRatio,
Expand All @@ -257,25 +260,23 @@ function handleAutoRangesDetection(
//action
function handleAutoSpectraRangesDetection(draft: Draft<State>) {
const peakPicking = {
sensitivity: 100,
thresholdFactor: 8,
minMaxRatio: 0.05,
};
const rangePicking = {
integrationSum: 100,
compile: true,
frequencyCluster: 16,
clean: 0.3,
keepPeaks: true,
};
const {
data,
view: {
spectra: { activeTab: nucleus },
},
molecules,
} = draft;
const { data, molecules } = draft;

for (const datum of data) {
if (datum.info.dimension === 1) {
const nucleus = datum.info.nucleus as string;
const rangePicking = {
integrationSum: 100,
compile: nucleus === '1H',
frequencyCluster: nucleus === '1H' ? 16 : 0,
clean: 0.3,
keepPeaks: true,
joinOverlapRanges: nucleus === '1H',
};
detectRanges(datum as Spectrum1D, {
peakPicking,
rangePicking,
Expand Down
2 changes: 2 additions & 0 deletions src/data/data1d/Spectrum1D/peaks/autoPeakPicking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function autoPeakPicking(spectrum: Spectrum1D, options: any) {
maxNumberOfPeaks,
noiseFactor,
direction,
sensitivity = 100,
Comment thread
lpatiny marked this conversation as resolved.
windowFromIndex,
windowToIndex,
} = options;
Expand All @@ -28,6 +29,7 @@ export function autoPeakPicking(spectrum: Spectrum1D, options: any) {
{
frequency,
direction,
sensitivity,
shape: { kind: 'lorentzian' },
noiseLevel: noise * noiseFactor,
minMaxRatio, // Threshold to determine if a given peak should be considered as a noise
Expand Down
13 changes: 8 additions & 5 deletions src/data/data1d/Spectrum1D/ranges/autoRangesDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const defaultPeakPickingOptions = {
realTopDetection: true,
maxCriteria: true,
smoothY: true,
sensitivity: 100,
broadWidth: 0.25,
broadRatio: 0.0025,
integrationSum: 100,
Expand All @@ -23,7 +24,7 @@ export default function autoRangesDetection(

let { re, x } = spectrum.data;

const { originFrequency, nucleus } = spectrum.info;
const { originFrequency, nucleus, solvent } = spectrum.info;

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

Expand All @@ -34,12 +35,13 @@ export default function autoRangesDetection(
};

const rangesOptions = {
frequency: originFrequency,
nucleus,
compile: true,
frequencyCluster: 13,
keepPeaks: true,
clean: 0.3,
keepPeaks: true,
compile: nucleus === '1H',
frequency: originFrequency,
joinOverlapRanges: nucleus === '1H',
frequencyCluster: nucleus === '1H' ? 13 : 0,
...rangePicking,
};

Expand All @@ -54,6 +56,7 @@ export default function autoRangesDetection(
const ranges = xyAutoRangesPicking(
{ x, y: re },
{
impurities: { solvent },
peakPicking: peakPickingOptions,
ranges: rangesOptions,
},
Expand Down
1 change: 1 addition & 0 deletions src/data/data1d/__tests__/autoPeakPicking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('test peakPicking', () => {
it('check baseline', () => {
const datum = initiateDatum1D({ data, info: { originFrequency: 150 } });
const peaks = autoPeakPicking(datum, {
sensitivity: 100,
maxNumberOfPeaks: 20,
minMaxRatio: 0.1,
});
Expand Down
4 changes: 2 additions & 2 deletions test-e2e/panels/ranges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ test('Auto peak picking on all spectra', async ({ page }) => {
await test.step("Check 13C spectrum's ranges", async () => {
// switch to 13C tab.
await nmrium.page.click('_react=SpectraTabs >> _react=Tab[tabid="13C"]');
await expect(nmrium.page.getByTestId('range')).toHaveCount(15);
await expect(nmrium.page.getByTestId('range')).toHaveCount(17);
await expect(
nmrium.page.locator('_react=RangesPanel >> _react=PanelHeader'),
).toContainText('[ 15 ]');
).toContainText('[ 17 ]');
});

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