Skip to content

Commit c4fff76

Browse files
fix: rescale predicted 1d spectrum
1 parent 14cfa88 commit c4fff76

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/data/PredictionManager.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import type { Peak2D, Signal2D, Zone } from '@zakodium/nmr-types';
22
import type { Spectrum } from '@zakodium/nmrium-core';
33
import type { Logger } from 'cheminfo-types';
4-
import { xMinMaxValues } from 'ml-spectra-processing';
4+
import {
5+
xMaxAbsoluteValue,
6+
xMinMaxValues,
7+
xNormed,
8+
} from 'ml-spectra-processing';
59
import type {
610
NMRZone,
711
Predicted,
@@ -283,6 +287,11 @@ function generated1DSpectrum(params: {
283287
lineWidth,
284288
});
285289

290+
const normalizedY = xNormed(y, {
291+
algorithm: 'max',
292+
value: xMaxAbsoluteValue(y),
293+
});
294+
286295
const first = x[0] ?? 0;
287296
const last = x.at(-1) ?? 0;
288297
const getFreqOffset = (freq: number) => {
@@ -291,7 +300,7 @@ function generated1DSpectrum(params: {
291300

292301
const datum = initiateDatum1D(
293302
{
294-
data: { x, im: null, re: y },
303+
data: { x, im: null, re: normalizedY },
295304
display: {
296305
color,
297306
},

0 commit comments

Comments
 (0)