Skip to content

Commit

Permalink
Fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 committed Jan 15, 2017
1 parent d527965 commit 398389b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
17 changes: 16 additions & 1 deletion src/peakPicking/peakPicking.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
'use strict';
/**
* Implementation of the peak pickig method described by Cobas in:
* Implementation of the peak picking method described by Cobas in:
* A new approach to improving automated analysis of proton NMR spectra
* through Global Spectral Deconvolution (GSD)
* http://www.spectroscopyeurope.com/images/stories/ColumnPDFs/TD_23_1.pdf
* @param {Object} spectrum - SD instance
* @param {Object} peakList - nmr signals
* @param {Object} options - options object with some parameter for GSD, detectSignal functions.
* @param {number} [options.nH] - Number of hydrogens or some number to normalize the integral data.
* @param {number} [options.integralFn] - option to chose between approx area with gaussian function or sum of the points of given range
* @param {number} [options.frequencyCluster] - distance limit to clustering the peaks.
* @param {boolean} [options.clean] - If true remove all the signals with integral < 0.5
* @param {boolean} [options.minMaxRatio] - Threshold to determine if a given peak should be considered as a noise, bases on its relative height compared to the highest peak.
* @param {boolean} [options.broadRatio] - If broadRatio is higher than 0, then all the peaks which second derivative smaller than broadRatio * maxAbsSecondDerivative will be marked with the soft mask equal to true.
* @param {boolean} [options.smoothY] - Select the peak intensities from a smoothed version of the independent variables?
* @param {boolean} [options.nL] - factor to determine the width at the moment to group the peaks in signals in 'GSD.optimizePeaks' function.
* @param {boolean} [options.optimize] - if it's true adjust an train of gaussian or lorentzian shapes to spectrum.
* @param {boolean} [options.functionType] - This option allows us choose between gaussian or lorentzian function when options.optimize is true.
* @param {boolean} [options.broadWidth] - Threshold to determine if some peak is candidate to clustering into range. /@TODO it's review
* @returns {Array}
*/
const GSD = require('ml-gsd');
//var extend = require("extend");
Expand Down
29 changes: 16 additions & 13 deletions src/peakPicking/peaks2Ranges.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
'use strict';
/**
* Implementation of the peak pickig method described by Cobas in:
* A new approach to improving automated analysis of proton NMR spectra
* through Global Spectral Deconvolution (GSD)
* http://www.spectroscopyeurope.com/images/stories/ColumnPDFs/TD_23_1.pdf
* This function clustering peaks and calculate the integral value for each range from the peak list returned from extractPeaks function

This comment has been minimized.

Copy link
@lpatiny

lpatiny Jan 16, 2017

Member

There is no problem to put the description on many lines

* @param {Object} spectrum - SD instance
* @param {Object} peakList - nmr signals
* @param {Object} options - options object with some parameter for GSD, detectSignal functions.
* @param {number} [options.nH] - Number of hydrogens or some number to normalize the integral data.
* @param {number} [options.integralFn] - option to chose between approx area with gaussian function or sum of the points of given range
* @param {number} [options.frequencyCluster] - distance limit to clustering the peaks.
* @param {boolean} [options.clean] - If true remove all the signals with integral < 0.5
* @returns {Array}
*/
const JAnalyzer = require('./jAnalyzer');
const Ranges = require('../range/Ranges');
//var extend = require("extend");
//var removeImpurities = require('./ImpurityRemover');

const defaultOptions = {
nH: 99, // Number of hydrogens
clean: true, // If true remove all the signals with integral < 0.5
nH: 99,
clean: true,
compile: true, // TODO: needs documentation
integralFn: 0, // TODO: needs documentation
optimize: true, // TODO: should this be removed? Can't find a ref to this option
integralFn: 0,
idPrefix: '', // TODO: needs documentation
format: 'old', // TODO: remove support for old format
frequencyCluster: 16 // TODO: needs documentation
frequencyCluster: 16
};


function createRanges(spectrum, peakList, options) {
options = Object.assign({}, defaultOptions, options);
var i, j, nHi, sum;
Expand Down Expand Up @@ -147,10 +150,10 @@ function createRanges(spectrum, peakList, options) {


/**
* Extract the signals from the peakList and the given spectrum
* Extract the signals from the peakList and the given spectrum.
* @param {object} peakList - nmr signals
* @param {object} spectrum - spectra data
* @param {number} nH - number to normalize the integral data
* @param {number} nH - Number of hydrogens or some number to normalize the integral data
* @param {number} integralType - option to chose between approx area with gaussian function or sum of the points of given range
* @param {number} frequencyCluster - distance limit to clustering the peaks.
* @return {Array} nmr signals
Expand Down Expand Up @@ -209,7 +212,7 @@ function detectSignals(peakList, spectrum, nH, integralType, frequencyCluster) {
if (integralType === 0) {
integral.value = sum;
} else {
integral.value = spectrum.getArea(integral.from, integral.to);//*nH/spectrumIntegral;
integral.value = spectrum.getArea(integral.from, integral.to);
}
spectrumIntegral += integral.value;

Expand Down
7 changes: 1 addition & 6 deletions src/range/Ranges.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
'use strict';
/**
* Implementation of the peak pickig method described by Cobas in:
* A new approach to improving automated analysis of proton NMR spectra
* through Global Spectral Deconvolution (GSD)
* http://www.spectroscopyeurope.com/images/stories/ColumnPDFs/TD_23_1.pdf
*/

//const JAnalyzer = require('./../peakPicking/JAnalyzer');
const peakPicking = require('./../peakPicking/peakPicking');
const acs = require('./acs/acs');
Expand Down

0 comments on commit 398389b

Please sign in to comment.