Coder Social home page Coder Social logo

spectra-processing's Introduction

ml-spectra-processing

NPM version build status Test coverage npm download DOI

Various functions to process spectra. Those are pure functions.

They are sorted in various categories:

  • matrix: functions on ml-matrix instances (or array or array)
  • x: functions that apply on a 1D array
  • xy: functions that apply on an object {x: [], y:[]}
  • xy2: functions that apply on an array of array of 2 numbers [[x,y], [x,y]]
  • xyArray: functions that apply on an array of objects {x: [], y:[]}
  • xyObject: functions that apply on an array of point [{x,y}]
  • xreim: functions that apply on an object {x: [], re:[], im:[]}
  • reim: functions that apply on an object {re: [], im:[]}
  • zone: functions that apply on a zone {from,to}
  • zones: functions that apply on an array of zone [{from,to}]

The name of the functions start with the first argument on which they apply.

Installation

$ npm i ml-spectra-processing

Usage

import { xAdd } from 'ml-spectra-processing';

const array = [1, 2, 3];
const result = xAdd(array, 5);
console.log(result);

License

MIT

spectra-processing's People

Contributors

aiday-mar avatar cheminfo-bot avatar escapedgibbon avatar gcartier-epfl avatar github-actions[bot] avatar hamed-musallam avatar jobo322 avatar josoriom avatar kjappelbaum avatar lpatiny avatar maasencioh avatar mljs-bot avatar opatiny avatar ricardosilvestr avatar targos avatar wadjih-bencheikh18 avatar wargnerm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spectra-processing's Issues

Documentation of parameters

We are using typedoc to generate the documentation in typescript projects.

When describing a parameter the - is mandatory otherwise the description does not appear in the documentation.

You can always check the documentation locally using:

npm i --global typedoc
typedoc src/index.ts

Example of modified code:

8600c20

Example of resulting help

image

@wadjih-bencheikh18 Please could you have a look through all the code to fix similar problems ?

feat: add matrixBoxPlot

Should accept an array of NumberArray and returns an object:

   {
    q1: [],
    median: [],
    q3: [],
    min: [],
    max: [],
  };

replace new Array by new Float64Array

If possible we should replace new Array by new Float64Array and adapt the tests.

Please note that new Float64Array fill by default the array by '0' !!!! No need to fill them.

Check if gaussian

@aiday-mar could you add a test that actually checks that it is a gaussian distribution with the correct SD ?

https://github.com/mljs/spectra-processing/blob/adbf2b4b06cf6f25575c87e87926d7b4cbb2e3c7/src/utils/__tests__/createRandomArray.test.ts

I changed the code so that it is seeded random number to avoid problems with the test.

You could create an histogram (with xHistogram) and use as developper dependency http://mljs.github.io/spectra-fitting/ to check if it match a gaussian.

Add phase correction in reim

Add a function allowing phase correction. What is the best name for this mathematical operation ? Phase correction seems quite NMR specific

No inline help for parameters

I don't know if it is an isolated case but we don't need a help for the property of a parameter that has a specific interface. The help is at the level of the definition of the interface.

Also if we don't have a description of the parameter there is no reason to add an @param

4c6b59a

@wadjih-bencheikh18 could you have a look if there are similar problems ?

Split method xSequentialFill in xSequentialFillFromTo and xSequentialFillFromStep

We try to have too many options in this method and I think it should be split in 2 methods. The current code is pretty complex.

export function xSequentialFill(
input: NumberArray | undefined,
options?: XSequentialFillOptions,
): NumberArray;

xSequentialFillFromTo(from, to, size, {ArrayConstructor})

xSequentialFillFromStep(from, step, size, {ArrayConstructor})

Both methods will return a Float64Array or the output if it has been provided.

Check return value type

If a method returns for sure a Float64Array we should not say it returns a DoubleArray but specify it is a Float64Array

export function xSubtract(
  array1: DoubleArray,
  array2: DoubleArray | number,
): DoubleArray {

Hilbert-transform could use FFT for non power of 2 data

In case the data is not a power of 2 Hilbert transform could use xSampling but this should be an option. I don't think that it will be 100% the same result if you go through power of 2 (to be checked).

If it is not 100% please add an option 'forceFFT' that is only useful if it is not a power of 2 and we use xSampling.

Typedoc and options

In order to be able to describe the documentation of optional parameters with their default value we should either describe them 'inline' or create a new type in which we take the name of the method and append 'Options'. Like for example: XFindClosestIndexOptions.

If you have only 1 to 3 options it is possible to describe them inline but otherwise the new type is required. Same is true when the same type is reused in many functions.

Here is an example of inline help:

63f3fc9

And the corresponding result in which we see the default value

image

Please could you go through all the code to fix similar problems ?

Rename "monotone" to "monotonic"

  • Change isMonotone to isMonotonic and make it return a number:
    • 0 -> not monotonic
    • 1 -> monotonic increasing
    • -1 -> monotonic decreasing
    • For a constant function, I guess we can decide to return 1?
  • Remove isMonotoneIncreasing function

Add options

In:

https://github.com/mljs/spectra-processing/blob/master/src/x/xMaxIndex.ts
https://github.com/mljs/spectra-processing/blob/master/src/x/xMinIndex.ts

Allow to have the from / to / fromIndex / toIndex like in:

https://github.com/mljs/spectra-processing/blob/master/src/x/xMaxValue.ts

What you would need to do:

  • fork the project on your account
  • clone the project from your account
  • try to add the options
  • add test cases
  • create a pull request

This is a typescript project and is therefore a little bit different from javascript but I think you could manage.

After cloning the project don't forget:

  • npm i
  • npx jest --watch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.