New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ml-rolling-ball-baseline

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-rolling-ball-baseline - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

40

lib/index.js

@@ -6,13 +6,4 @@ 'use strict';

var isAnyArray = require('is-any-array');
var max = require('ml-array-max');
var mean = require('ml-array-mean');
var min = require('ml-array-min');
var mlSpectraProcessing = require('ml-spectra-processing');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var isAnyArray__default = /*#__PURE__*/_interopDefaultLegacy(isAnyArray);
var max__default = /*#__PURE__*/_interopDefaultLegacy(max);
var mean__default = /*#__PURE__*/_interopDefaultLegacy(mean);
var min__default = /*#__PURE__*/_interopDefaultLegacy(min);
/**

@@ -38,6 +29,6 @@ * Rolling ball baseline correction algorithm.

* @param {Number} [options.windowM] - width of local window for minimization/maximization, defaults to 4% of the spectrum length
* @param {Number} [options.windowS] - width of local window for smoothing, defaults to 8% of the specturm length
* @param {Number} [options.windowS] - width of local window for smoothing, defaults to 8% of the spectrum length
*/
function rollingBall(spectrum, options = {}) {
if (!isAnyArray__default['default'](spectrum)) {
if (!isAnyArray.isAnyArray(spectrum)) {
throw new Error('Spectrum must be an array');

@@ -64,5 +55,9 @@ }

for (let i = 0; i < spectrum.length; i++) {
let windowLeft = max__default['default']([0, i - windowM]);
let windowRight = min__default['default']([i + windowM + 1, spectrum.length]);
minima[i] = min__default['default'](spectrum.slice(windowLeft, windowRight));
let windowLeft = Math.max(0, i - windowM);
let windowRight = Math.min(i + windowM + 1, spectrum.length);
minima[i] = mlSpectraProcessing.xMinValue(spectrum, {
fromIndex: windowLeft,
toIndex: windowRight,
});
}

@@ -72,11 +67,14 @@

for (let i = 0; i < minima.length; i++) {
let windowLeft = max__default['default']([0, i - windowM]);
let windowRight = min__default['default']([i + windowM + 1, minima.length]);
maxima[i] = max__default['default'](minima.slice(windowLeft, windowRight));
let windowLeft = Math.max(0, i - windowM);
let windowRight = Math.min(i + windowM + 1, minima.length);
maxima[i] = mlSpectraProcessing.xMaxValue(minima, {
fromIndex: windowLeft,
toIndex: windowRight,
});
}
for (let i = 0; i < minima.length; i++) {
let windowLeft = max__default['default']([0, i - windowS]);
let windowRight = min__default['default']([i + windowS + 1, maxima.length]);
baseline[i] = mean__default['default'](maxima.slice(windowLeft, windowRight));
let windowLeft = Math.max(0, i - windowS);
let windowRight = Math.min(i + windowS + 1, maxima.length);
baseline[i] = mlSpectraProcessing.xMean(maxima.subarray(windowLeft, windowRight));
}

@@ -83,0 +81,0 @@

{
"name": "ml-rolling-ball-baseline",
"version": "1.0.0",
"version": "1.1.0",
"description": "Rolling ball baseline correction",

@@ -14,6 +14,7 @@ "main": "lib/index.js",

"eslint-fix": "npm run eslint -- --fix",
"prepublishOnly": "rollup -c",
"test": "npm run test-coverage && npm run eslint",
"test-coverage": "jest --coverage",
"test-only": "jest"
"prepack": "rollup -c",
"prettier": "prettier --check src",
"prettier-write": "prettier --write src",
"test": "npm run test-only && npm run eslint && npm run prettier",
"test-only": "jest --coverage"
},

@@ -31,27 +32,15 @@ "repository": {

"homepage": "https://github.com/mljs/rolling-ball-baseline#readme",
"jest": {
"testEnvironment": "node"
},
"prettier": {
"arrowParens": "always",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.13.8",
"@types/jest": "^26.0.21",
"eslint": "^7.22.0",
"eslint-config-cheminfo": "^5.2.3",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"rollup": "^2.42.3"
"@babel/plugin-transform-modules-commonjs": "^7.17.7",
"@types/jest": "^27.4.1",
"eslint": "^8.12.0",
"eslint-config-cheminfo": "^7.3.0",
"jest": "^27.5.1",
"prettier": "^2.6.1",
"rollup": "^2.70.1"
},
"dependencies": {
"is-any-array": "^1.0.0",
"ml-array-max": "^1.2.3",
"ml-array-mean": "^1.1.5",
"ml-array-min": "^1.2.2"
"is-any-array": "^2.0.0",
"ml-spectra-processing": "^11.2.0"
}
}

@@ -1,5 +0,3 @@

import isAnyArray from 'is-any-array';
import max from 'ml-array-max';
import mean from 'ml-array-mean';
import min from 'ml-array-min';
import { isAnyArray } from 'is-any-array';
import { xMean, xMaxValue, xMinValue } from 'ml-spectra-processing';

@@ -26,3 +24,3 @@ /**

* @param {Number} [options.windowM] - width of local window for minimization/maximization, defaults to 4% of the spectrum length
* @param {Number} [options.windowS] - width of local window for smoothing, defaults to 8% of the specturm length
* @param {Number} [options.windowS] - width of local window for smoothing, defaults to 8% of the spectrum length
*/

@@ -52,5 +50,9 @@ export function rollingBall(spectrum, options = {}) {

for (let i = 0; i < spectrum.length; i++) {
let windowLeft = max([0, i - windowM]);
let windowRight = min([i + windowM + 1, spectrum.length]);
minima[i] = min(spectrum.slice(windowLeft, windowRight));
let windowLeft = Math.max(0, i - windowM);
let windowRight = Math.min(i + windowM + 1, spectrum.length);
minima[i] = xMinValue(spectrum, {
fromIndex: windowLeft,
toIndex: windowRight,
});
}

@@ -60,11 +62,14 @@

for (let i = 0; i < minima.length; i++) {
let windowLeft = max([0, i - windowM]);
let windowRight = min([i + windowM + 1, minima.length]);
maxima[i] = max(minima.slice(windowLeft, windowRight));
let windowLeft = Math.max(0, i - windowM);
let windowRight = Math.min(i + windowM + 1, minima.length);
maxima[i] = xMaxValue(minima, {
fromIndex: windowLeft,
toIndex: windowRight,
});
}
for (let i = 0; i < minima.length; i++) {
let windowLeft = max([0, i - windowS]);
let windowRight = min([i + windowS + 1, maxima.length]);
baseline[i] = mean(maxima.slice(windowLeft, windowRight));
let windowLeft = Math.max(0, i - windowS);
let windowRight = Math.min(i + windowS + 1, maxima.length);
baseline[i] = xMean(maxima.subarray(windowLeft, windowRight));
}

@@ -71,0 +76,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc