Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-spectra-processing

Package Overview
Dependencies
Maintainers
6
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-spectra-processing - npm Package Compare versions

Comparing version 4.10.0 to 4.11.0

src/utils/createSequentialArray.js

13

CHANGELOG.md
# Changelog
## [4.11.0](https://www.github.com/mljs/spectra-processing/compare/v4.10.0...v4.11.0) (2021-01-08)
### Features
* add createSequentialArray ([649547d](https://www.github.com/mljs/spectra-processing/commit/649547d48c51f8b4ce95553824ed8b92b6b17040))
* add xParetoNormalization ([ec0c517](https://www.github.com/mljs/spectra-processing/commit/ec0c5170f097fb0d4e8ed2a05e8aa96c5a4062b4))
### Bug Fixes
* change mean by median close[#32](https://www.github.com/mljs/spectra-processing/issues/32) ([#40](https://www.github.com/mljs/spectra-processing/issues/40)) ([9272c73](https://www.github.com/mljs/spectra-processing/commit/9272c7373b930567ee5ca2ab01ca746af495e8bc))
## [4.10.0](https://www.github.com/mljs/spectra-processing/compare/v4.9.4...v4.10.0) (2020-12-08)

@@ -4,0 +17,0 @@

15

package.json
{
"name": "ml-spectra-processing",
"version": "4.10.0",
"version": "4.11.0",
"description": "Various method to process spectra",

@@ -44,5 +44,5 @@ "main": "lib/index.js",

"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.20",
"cheminfo-build": "^1.1.8",
"eslint": "^7.13.0",
"eslint": "^7.17.0",
"eslint-config-cheminfo": "^5.2.2",

@@ -52,4 +52,4 @@ "esm": "^3.2.25",

"jest-matcher-deep-close-to": "^2.0.1",
"prettier": "^2.1.2",
"rollup": "^2.33.3"
"prettier": "^2.2.1",
"rollup": "^2.36.1"
},

@@ -61,6 +61,7 @@ "dependencies": {

"ml-array-median": "^1.1.4",
"ml-gsd": "^6.1.2",
"ml-matrix": "^6.5.3",
"ml-array-standard-deviation": "^1.1.5",
"ml-gsd": "^6.4.0",
"ml-matrix": "^6.6.0",
"spline-interpolator": "^1.0.0"
}
}

@@ -44,2 +44,3 @@ /**

export * from './x/xNorm';
export * from './x/xParetoNormalization';
export * from './x/xPadding';

@@ -102,1 +103,3 @@ export * from './x/xRotate';

export * from './matrix/probabilisticQuotientNormalization';
export * from './utils/createSequentialArray';

@@ -1,2 +0,2 @@

import mean from 'ml-array-mean';
import median from 'ml-array-median';
import { Matrix } from 'ml-matrix';

@@ -11,40 +11,35 @@

* @param {number} [options.max=100] - Normalization integral constant.
* @return {Object} { data, averageQuotients }.
* @return {Object} { data, medianOfQuotients }.
* data: Normalized dataset.
* averageQuotients: The quotients of all variables of interest.
* medianOfQuotients: The median of quotients of each variables.
*/
export function probabilisticQuotientNormalization(matrix, options = {}) {
let { max = 100 } = options;
const { max = 100 } = options;
matrix = new Matrix(matrix);
for (let i = 0; i < matrix.rows; i++) {
let row = matrix.getRowVector(i).div(matrix.getRowVector(i).norm() / max);
const normalizationFactor = matrix.getRowVector(i).norm() / max;
const row = matrix.getRowVector(i).div(normalizationFactor);
matrix.setRow(i, row);
}
let normalizationFactor = matrix.norm() / max;
matrix.div(normalizationFactor);
let referenceSpectrum = [];
for (let i = 0; i < matrix.columns; i++) {
let currentVariable = [];
for (let j = 0; j < matrix.rows; j++) {
currentVariable.push(matrix.get(j, i));
}
referenceSpectrum.push(mean(currentVariable));
const currentVariable = matrix.getColumn(i);
referenceSpectrum.push(median(currentVariable));
}
let averageQuotients = [];
for (let i = 0; i < matrix.rows; i++) {
let quotients = [];
for (let j = 0; j < matrix.columns; j++) {
let quotient = matrix.get(i, j) / referenceSpectrum[j];
quotients.push(quotient);
}
averageQuotients.push(mean(quotients));
let medianOfQuotients = [];
for (let i = 0; i < matrix.columns; i++) {
let quotients = matrix.getColumnVector(i).div(referenceSpectrum[i]);
medianOfQuotients.push(median(quotients.getColumn(0)));
}
for (let i = 0; i < matrix.rows; i++) {
matrix.mulRow(i, averageQuotients[i]);
matrix.mulRow(i, 1 / medianOfQuotients[i]);
}
return {
data: matrix,
averageQuotients: averageQuotients,
medianOfQuotients: medianOfQuotients,
};
}

@@ -192,4 +192,4 @@ import { xNoiseSanPlot } from '../x/xNoiseSanPlot';

/* Just to know what is the matrix system that we solve
let Mx = [[sxtw, swx], [swx, sw]];
let My = [[sxtwy], [swy]];
let Mx=[[sxtw, swx], [swx, sw]];
let My=[[sxtwy], [swy]];
*/

@@ -196,0 +196,0 @@

/**
* Phase correction filter
* @param {object} reim - An object of kind {re:[], im:[]}
* @param {number} [phi0 = 0] - Angle in radians for zero order phase correction
* @param {number} [phi1 = 0] - Angle in radians for first order phase correction
* @param {number} [phi0=0] - Angle in radians for zero order phase correction
* @param {number} [phi1=0] - Angle in radians for first order phase correction
* @return {object} returns a new object {re:[], im:[]}

@@ -7,0 +7,0 @@ */

@@ -218,3 +218,3 @@ /* eslint-disable no-loss-of-precision */

}
// [2] Get the sign and make use of `erfc` reflection formula: `erfc(-z) = 2 - erfc(z)`...
// [2] Get the sign and make use of `erfc` reflection formula: `erfc(-z)=2 - erfc(z)`...
if (x > 1) {

@@ -221,0 +221,0 @@ q = 2 - x;

@@ -7,4 +7,4 @@ import { xCrossCorrelation } from './xCrossCorrelation';

* @param {object} [options={}]
* @param {number} [options.tau = 1] - sweep increment size (in number of points, min = 1, max = A.length)
* @param {number} [options.lag = A.length - 1] - scalar lag parameter
* @param {number} [options.tau=1] - sweep increment size (in number of points, min=1, max=A.length)
* @param {number} [options.lag=A.length - 1] - scalar lag parameter
*/

@@ -11,0 +11,0 @@

@@ -8,4 +8,4 @@ import { xDotProduct } from './xDotProduct';

* @param {object} [options={}]
* @param {number} [options.tau = 1] - sweep increment size (in number of points, min = 1, max = A.length)
* @param {number} [options.lag = A.length - 1] - scalar lag parameter
* @param {number} [options.tau=1] - sweep increment size (in number of points, min=1, max=A.length)
* @param {number} [options.lag=A.length - 1] - scalar lag parameter
*/

@@ -12,0 +12,0 @@

@@ -7,7 +7,7 @@ /**

* @param {DataXY} spectrum2 Second spectrum data
* @param {object} options
* @param {number} [options.delta = 1] The range in which the two x values of the spectra must be to be placed on the same line
* @param {boolean} [options.common = true] If `true`, only the data considered as common to both spectra is kept. If `false`, the data y arrays are completed with zeroes where no common values are found
* @param {string} [options.x = 'x1'] Defines what x values should be kept (`x1` : spectrum 1 x values, `x2` spectrum 2 x values, `weighted`: weighted average of both spectra x values)
* @param {function} [options.weightFunction = undefined] Function that allows to weight `delta` depending on the X values of the spectrum
* @param {object} [options={}]
* @param {number} [options.delta=1] The range in which the two x values of the spectra must be to be placed on the same line
* @param {boolean} [options.common=true] If `true`, only the data considered as common to both spectra is kept. If `false`, the data y arrays are completed with zeroes where no common values are found
* @param {string} [options.x='x1'] Defines what x values should be kept (`x1` : spectrum 1 x values, `x2` spectrum 2 x values, `weighted`: weighted average of both spectra x values)
* @param {function} [options.weightFunction=undefined] Function that allows to weight `delta` depending on the X values of the spectrum
*/

@@ -14,0 +14,0 @@ export function xyAlign(spectrum1, spectrum2, options = {}) {

Sorry, the diff of this file is too big to display

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