chromatography
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -986,2 +986,29 @@ 'use strict'; | ||
function percentageFilter(chromatogram, serieName, options = {}) { | ||
const { | ||
percentage = 0.1 | ||
} = options; | ||
var serie = chromatogram.getSerie(serieName); | ||
var filtered = []; | ||
for (var i = 0; i < serie.data.length; i++) { | ||
filtered.push(applyFilter$1(serie.data[i], percentage)); | ||
} | ||
return serieFromArray(filtered); | ||
} | ||
function applyFilter$1(serie, percentage) { | ||
var basePeak = max(serie[1]); | ||
var filtered = [[], []]; | ||
for (var i = 0; i < serie[0].length; i++) { | ||
if (serie[1][i] > percentage * basePeak) { | ||
filtered[0].push(serie[0][i]); | ||
filtered[1].push(serie[1][i]); | ||
} | ||
} | ||
return filtered; | ||
} | ||
/** | ||
@@ -1278,2 +1305,18 @@ * Create an object of Chromatogram | ||
} | ||
/** | ||
* Filter the given serie2D based on the percentage of the highest value | ||
* @param {string} serieName | ||
* @param {object} [options] | ||
* @param {string} [options.serieName = 'msPercentage'] - Name of the new serie | ||
* @param {number} [options.percentage = 0.1] - The values under the median times this factor are removed | ||
*/ | ||
percentageFilter(serieName, options = {}) { | ||
var serie = percentageFilter(this, serieName, options); | ||
if (options.serieName) { | ||
this.series[options.serieName] = serie; | ||
} else { | ||
this.series.msPercentage = serie; | ||
} | ||
} | ||
} | ||
@@ -1590,3 +1633,2 @@ | ||
exports.vectorify = vectorify; | ||
exports.cosine = cosine; | ||
exports.massFilter = massFilter; | ||
@@ -1600,2 +1642,5 @@ exports.spectraComparison = spectraComparison; | ||
exports.getKovatsRescale = getKovatsRescale; | ||
exports.cosine = cosine; | ||
exports.meanFilter = meanFilter; | ||
exports.percentageFilter = percentageFilter; | ||
exports.fromJcamp = fromJcamp; | ||
@@ -1602,0 +1647,0 @@ exports.fromJSON = fromJSON; |
{ | ||
"name": "chromatography", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Tools for storing, search and analize GC/MS spectra", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -13,3 +13,4 @@ import {rescaleTime} from './rescaleTime'; | ||
import {applyLockMass} from './ms/applyLockMass'; | ||
import {meanFilter} from './ms/meanFilter'; | ||
import {meanFilter} from './filter/meanFilter'; | ||
import {percentageFilter} from './filter/percentageFilter'; | ||
import {toJSON} from './to/json'; | ||
@@ -282,2 +283,18 @@ import {getClosestData} from './util/getClosestData'; | ||
} | ||
/** | ||
* Filter the given serie2D based on the percentage of the highest value | ||
* @param {string} serieName | ||
* @param {object} [options] | ||
* @param {string} [options.serieName = 'msPercentage'] - Name of the new serie | ||
* @param {number} [options.percentage = 0.1] - The values under the median times this factor are removed | ||
*/ | ||
percentageFilter(serieName, options = {}) { | ||
var serie = percentageFilter(this, serieName, options); | ||
if (options.serieName) { | ||
this.series[options.serieName] = serie; | ||
} else { | ||
this.series.msPercentage = serie; | ||
} | ||
} | ||
} | ||
@@ -284,0 +301,0 @@ |
@@ -5,3 +5,2 @@ export {Chromatogram} from './Chromatogram'; | ||
export {vectorify} from './vectorify'; | ||
export {cosine} from './filter/cosine'; | ||
export {massFilter} from './massFilter'; | ||
@@ -16,2 +15,7 @@ export {spectraComparison} from './spectraComparison'; | ||
export {cosine} from './ms/cosine'; | ||
export {meanFilter} from './filter/meanFilter'; | ||
export {percentageFilter} from './filter/percentageFilter'; | ||
export {fromJcamp} from './from/jcamp'; | ||
@@ -18,0 +22,0 @@ export {fromJSON} from './from/json'; |
import {getPeaks} from './util/getPeaks'; | ||
import {massInPeaks} from './massInPeaks'; | ||
import {vectorify} from './vectorify'; | ||
import {cosine} from './filter/cosine'; | ||
import {cosine} from './ms/cosine'; | ||
@@ -6,0 +6,0 @@ /** |
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
168931
70
4398