<commit_before>'use strict';
/**
 * Created by abol on 12/9/16.
 */

const ML = require('ml-curve-fitting');
const LM = ML.LM;
const math = ML.algebra;

/**
 *  This function extract the grandient concentration for a spatial (z) profile acquired with a spatially selective NMR experiment.
 * @param {array} pdata
 * @param {array} signals
 * @param {number} threshold
 * @returns {Array}
 */

function profile(pdata, signals, threshold) {

    var peaks = pdata[0].peakPicking;

    var Data = new Array(signals.length);

    var dataShift = {}, dataProfile = {};

    for (var i = 0; i < signals.length; i++) {
        var ini = true;
        for (var k = 0; k < peaks.length; k++) {
            if (Math.abs(peaks[k].signal[0].delta - signals[i]) <= threshold) {
                dataShift = {x: [peaks[k].signal[0].delta], y: [Number(pdata[0].filename)]};
                dataProfile = {x: [Number(pdata[0].filename)], y: [peaks[k].integral]};
                Data[i] = {title: signals[i].toString(), shift: {data: dataShift}, profile: {data: dataProfile}};
                k = peaks.length;
                ini = false;
            }
        }
        if (ini) {
            dataShift = {x: [], y: []};
            dataProfile = {x: [], y: []};
            Data[i] = {title: signals[i].toString(), shift: {data: dataShift}, profile: {data: dataProfile}};
        }
    }

    for (i = 1; i < pdata.length; i++) {
        peaks = pdata[i].peakPicking;
        for (var j = 0; j < signals.length; j++) {
            for (k = 0; k < peaks.length; k++) {
                if (Math.abs(peaks[k].signal[0].delta - signals[j]) <= threshold) {
                    var temp = Data[j];
                    temp.profile.data.y.push(peaks[k].integral);
                    temp.profile.data.x.push(Number(pdata[i].filename));
                    temp.shift.data.y.push(Number(pdata[i].filename));
                    temp.shift.data.x.push(peaks[k].signal[0].delta);
                    signals[j] = peaks[k].signal[0].delta;
                    k = peaks.length;
                }
            }
        }
    }
    return Data;
}






module.exports = profile;<commit_msg>description of the function profiles in analisys<commit_after>'use strict';
/**
 * Created by abol on 12/9/16.
 */

const ML = require('ml-curve-fitting');
const LM = ML.LM;
const math = ML.algebra;

/**
 * This function extract the grandient of concentration from a spatial (z) profile acquired with successives
 * experiments of spatially selective NMR . more information with descriptive pictures are found here: 10.1002/mrc.4561
 *
 * @param {array} pdata - array of SD instances with peakPicking done.
 * @param {array} signals - list of chemical shift of signals.
 * @param {number} maxShiftDiference - maximal difference between two signals from subsequent slices.
 * @returns {Array}
 */

function profile(pdata, signals, maxShiftDiference) {

    var peaks = pdata[0].peakPicking;

    var Data = new Array(signals.length);

    var dataShift = {}, dataProfile = {};

    for (var i = 0; i < signals.length; i++) {
        var ini = true;
        for (var k = 0; k < peaks.length; k++) {
            if (Math.abs(peaks[k].signal[0].delta - signals[i]) <= maxShiftDiference) {
                dataShift = {x: [peaks[k].signal[0].delta], y: [Number(pdata[0].filename)]};
                dataProfile = {x: [Number(pdata[0].filename)], y: [peaks[k].integral]};
                Data[i] = {title: signals[i].toString(), shift: {data: dataShift}, profile: {data: dataProfile}};
                k = peaks.length;
                ini = false;
            }
        }
        if (ini) {
            dataShift = {x: [], y: []};
            dataProfile = {x: [], y: []};
            Data[i] = {title: signals[i].toString(), shift: {data: dataShift}, profile: {data: dataProfile}};
        }
    }

    for (i = 1; i < pdata.length; i++) {
        peaks = pdata[i].peakPicking;
        for (var j = 0; j < signals.length; j++) {
            for (k = 0; k < peaks.length; k++) {
                if (Math.abs(peaks[k].signal[0].delta - signals[j]) <= maxShiftDiference) {
                    var temp = Data[j];
                    temp.profile.data.y.push(peaks[k].integral);
                    temp.profile.data.x.push(Number(pdata[i].filename));
                    temp.shift.data.y.push(Number(pdata[i].filename));
                    temp.shift.data.x.push(peaks[k].signal[0].delta);
                    signals[j] = peaks[k].signal[0].delta;
                    k = peaks.length;
                }
            }
        }
    }
    return Data;
}






module.exports = profile;
{'fraction_non_alphanumeric': 0.15762273901808785, 'fraction_numerical': 0.009905254091300603, 'mean_word_length': 2.0103694102397927, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2324305', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1410, 'n_words': 357}