nmr-processing
Advanced tools
Comparing version 0.2.4 to 0.2.5
{ | ||
"name": "nmr-processing", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "", | ||
@@ -44,3 +44,3 @@ "main": "lib/index.js", | ||
"@types/jest": "^25.2.1", | ||
"cheminfo-build": "^1.1.3", | ||
"cheminfo-build": "^1.1.4", | ||
"eslint": "^7.7.0", | ||
@@ -47,0 +47,0 @@ "eslint-config-cheminfo": "^3.0.0", |
@@ -155,6 +155,11 @@ import * as convolution from 'ml-matrix-convolution'; | ||
peaks = getFromTo(peaks, spectraData); | ||
for (let i = peaks.length - 1; i >= 0; i--) { | ||
peaks[i].x = firstX + dx * peaks[i].x; | ||
peaks[i].y = firstY + dy * peaks[i].y; | ||
peaks[i].fromY = firstY + dy * peaks[i].fromY; | ||
peaks[i].toY = firstY + dy * peaks[i].toY; | ||
peaks[i].fromX = firstX + dx * peaks[i].fromX; | ||
peaks[i].toX = firstX + dx * peaks[i].toX; | ||
// Still having problems to correctly detect peaks on those areas. So I'm removing everything there. | ||
@@ -210,13 +215,13 @@ if (peaks[i].y < -1 || peaks[i].y >= 210) { | ||
sumZ += peaks[jPeak].z; | ||
if (peaks[jPeak].x < minMax1[0]) { | ||
minMax1[0] = peaks[jPeak].x; | ||
if (peaks[jPeak].toX < minMax1[0]) { | ||
minMax1[0] = peaks[jPeak].toX; | ||
} | ||
if (peaks[jPeak].x > minMax1[1]) { | ||
minMax1[1] = peaks[jPeak].x; | ||
if (peaks[jPeak].fromX > minMax1[1]) { | ||
minMax1[1] = peaks[jPeak].fromX; | ||
} | ||
if (peaks[jPeak].y < minMax2[0]) { | ||
minMax2[0] = peaks[jPeak].y; | ||
if (peaks[jPeak].toY < minMax2[0]) { | ||
minMax2[0] = peaks[jPeak].toY; | ||
} | ||
if (peaks[jPeak].y > minMax2[1]) { | ||
minMax2[1] = peaks[jPeak].y; | ||
if (peaks[jPeak].fromY > minMax2[1]) { | ||
minMax2[1] = peaks[jPeak].fromY; | ||
} | ||
@@ -238,1 +243,45 @@ } | ||
}; | ||
function getFromTo(peaks, spectraData) { | ||
let z = spectraData.z; | ||
for (let i = 0; i < peaks.length; i++) { | ||
let peak = peaks[i]; | ||
let xIndex = Math.floor(peak.x); | ||
let yIndex = Math.floor(peak.y); | ||
let value = z[yIndex][xIndex] / 4; | ||
let fromX = xIndex; | ||
let toX = xIndex; | ||
let fromY = yIndex; | ||
let toY = yIndex; | ||
for (let j = xIndex + 1; j < z[0].length; j++) { | ||
if (z[yIndex][j] <= value) { | ||
fromX = j; | ||
// j = z[0].length; | ||
break; | ||
} | ||
} | ||
for (let j = yIndex + 1; j < z.length; j++) { | ||
if (z[j][xIndex] <= value) { | ||
fromY = j; | ||
// j = z.length; | ||
break; | ||
} | ||
} | ||
for (let j = xIndex - 1; j >= 0; j--) { | ||
if (z[yIndex][j] <= value) { | ||
toX = j; | ||
// j = -1; | ||
break; | ||
} | ||
} | ||
for (let j = yIndex - 1; j >= 0; j--) { | ||
if (z[j][xIndex] <= value) { | ||
toY = j; | ||
// j = -1; | ||
break; | ||
} | ||
} | ||
peaks[i] = Object.assign(peak, { fromX, toX, fromY, toY }); | ||
} | ||
return peaks; | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
232199
9909