Skip to content

Commit

Permalink
advances in the documentation
Browse files Browse the repository at this point in the history
with respect to issues #19 #28 #48 #52
  • Loading branch information
jobo322 committed Jan 16, 2017
1 parent 7746516 commit f7cbc19
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
35 changes: 20 additions & 15 deletions src/peakPicking/peaks2Ranges.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
'use strict';

const JAnalyzer = require('./jAnalyzer');
const Ranges = require('../range/Ranges');
//var extend = require("extend");
//var removeImpurities = require('./ImpurityRemover');

const defaultOptions = {
nH: 99,
clean: true,
compile: true,
integralFn: 0,
idPrefix: '',
format: 'old', // TODO: remove support for old format
frequencyCluster: 16
};
/**
* This function clustering peaks and calculate the integral value for each range from the peak list returned from extractPeaks function
* @param {Object} spectrum - SD instance
Expand All @@ -8,22 +23,10 @@
* @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.compile] - If true, the Janalyzer function is run over signals to compile the patterns.
* @param {string} [options.idPrefix] - prefix for signal ID
* @returns {Array}
*/
const JAnalyzer = require('./jAnalyzer');
const Ranges = require('../range/Ranges');
//var extend = require("extend");
//var removeImpurities = require('./ImpurityRemover');

const defaultOptions = {
nH: 99,
clean: true,
compile: true, // TODO: needs documentation
integralFn: 0,
idPrefix: '', // TODO: needs documentation
format: 'old', // TODO: remove support for old format
frequencyCluster: 16
};

function createRanges(spectrum, peakList, options) {
options = Object.assign({}, defaultOptions, options);
Expand Down Expand Up @@ -150,12 +153,14 @@ function createRanges(spectrum, peakList, options) {


/**
* @private
* Extract the signals from the peakList and the given spectrum.
* @param {object} peakList - nmr signals
* @param {object} spectrum - spectra 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.
* range = frequencyCluster / observeFrequency -> Peaks withing this range are considered to belongs to the same signal1D
* @return {Array} nmr signals
*/
function detectSignals(peakList, spectrum, nH, integralType, frequencyCluster) {
Expand All @@ -164,7 +169,7 @@ function detectSignals(peakList, spectrum, nH, integralType, frequencyCluster) {
var signal1D = {};
var prevPeak = {x: 100000, y: 0, width: 0};
var peaks = null;
var rangeX = frequencyCluster / frequency; //Peaks withing this range are considered to belongs to the same signal1D
var rangeX = frequencyCluster / frequency;
var spectrumIntegral = 0;
var cs, sum, i, j;
for (i = 0; i < peakList.length; i++) {
Expand Down
3 changes: 2 additions & 1 deletion src/range/Ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ class Ranges extends Array {

return new Ranges(result);
}



static fromSpectrum(spectrum, opt) {
this.options = Object.assign({}, {
nH: 99,
Expand Down
18 changes: 9 additions & 9 deletions src/range/peak2Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
/**
* This function converts an array of peaks [{x, y, width}] in a vector equally x,y vector from a given window
* TODO: This function is very general and should be placed somewhere else
* @param {Array} peaks
* @param {object} opt - it has some options to
* @option {number} from - one limit of given window
* @option {number} to - one limit of given window
* @option {string} fnName - function name to generate the signals form
* @option {number} nWidth - width factor of signal form
* @option {number} nbPoints - number of points
* @param {Array} peaks - List of the peaks
* @param {object} options - it has some options to
* @option {number} [options.from] - one limit of given window
* @option {number} [options.to] - one limit of given window
* @option {string} [options.fnName] - function name to generate the signals form
* @option {number} [options.nWidth] - width factor of signal form
* @option {number} [options.nbPoints] - number of points that the vector will have
* @return {{x: Array, y: Array}}
*/
function peak2Vector(peaks, opt) {
var options = opt || {};
function peak2Vector(peaks, options) {
var options = options || {};
var from = options.from;
var to = options.to;
var nbPoints = options.nbPoints || 16 * 1024;
Expand Down

0 comments on commit f7cbc19

Please sign in to comment.