GithubHelp home page GithubHelp logo

statguyuser / baselineremoval Goto Github PK

View Code? Open in Web Editor NEW
48.0 2.0 13.0 239 KB

Perform baseline removal, baseline correction and baseline substraction for raman spectra using Modpoly, ImodPoly and Zhang fit. Returns baseline-subtracted spectrum. Please give proper citation as specified in the documentation if it has helped you.

License: MIT License

Python 100.00%
baseline-removal signal-processing raman-spectroscopy raman-spectra raman machine-learning machinelearning python

baselineremoval's People

Contributors

lesteve avatar statguyuser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

baselineremoval's Issues

TypeError: arrays to stack must be passed as a "sequence" type such as list or tuple.

the version of numpy and python is 1.26 and 3.10 respectively.
when i ran the example in readme, i got following error:

TypeError Traceback (most recent call last)
......
File ~/miniconda3/envs/xxx/lib/python3.10/site-packages/BaselineRemoval.py:49, in BaselineRemoval.ModPoly(self, degree, repitition, gradient)
46 yold=self.input_array
47 yorig=self.input_array
---> 49 polx=self.poly(list(range(1,len(yorig)+1)),degree)
50 nrep=0
52 while (criteria>=gradient) and (nrep<=repitition):

File ~/miniconda3/envs/xx/lib/python3.10/site-packages/BaselineRemoval.py:27, in BaselineRemoval.poly(self, input_array_for_poly, degree_for_poly)
18 '''qr factorization of a matrix. qis orthonormal andr` is upper-triangular.
19 - QR decomposition is equivalent to Gram Schmidt orthogonalization, which builds a sequence of orthogonal polynomials that approximate your function with minimal least-squares error
20 - in the next step, discard the first column from above matrix.
(...)
24 - concatenate all of these arrays created through loop, as a master array. This is done through (np.vstack)
25 - transpose the master array, so that its more like a tabular form(np.transpose)'''
26 input_array_for_poly = np.array(input_array_for_poly,dtype='object')
---> 27 X = np.transpose(np.vstack((input_array_for_poly**k for k in range(degree_for_poly+1))))
28 return np.linalg.qr(X)[0][:,1:]
...
--> 209 raise TypeError('arrays to stack must be passed as a "sequence" type '
210 'such as list or tuple.')
212 return tuple(arrays)

TypeError: arrays to stack must be passed as a "sequence" type such as list or tuple.
`

Then, i modify the 27th line in BaselineRemoval.py from
X = np.transpose(np.vstack((input_array_for_poly**k for k in range(degree_for_poly+1))))
to X = np.transpose(np.vstack([input_array_for_poly**k for k in range(degree_for_poly+1)]))
and it finally works.

Different results on Spyder vs Visual Studio

Hi, I've been trying to troubleshoot this for a few days, but can't figure it out. I'm running the same code using baselineremoval with imodpoly, but I'm getting different results on Visual Studio compared to Spyder. It seems Spyder's results are the wrong ones. It specifically happens when the input array gets large (in mycase, ~1300). If I shorten the array to 1200, the results are the same, but once past 1300, then the results are different. I've written about the issues here

For Visual Studio I'm using:
VS: 1.74.2
Python: 3.8.8
Numpy: 1.20.1
Pandas: 1.2.4
sklearn: 0.24.1
scipy: 1.6.2

For Spyder I'm using:
Spyder: 4.2.5
Python: 3.8.8
Numpy: 1.20.1
Pandas: 1.2.4
sklearn: 0.24.1
scipy: 1.6.2

Tilted curve issue when using zhang fit

Hi,

I am currently using zhng fit model for the values mentioned below.
6441.98,6383.192,6325.8344,6269.60528,6214.487936,6159.418643,6105.581316,6053.799992,6001.876262,5950.335251,5898.042302,5847.675511,5796.543563,5741.443815,5684.597475,5629.008258,5580.121147,5536.025881,5495.629406,5456.531057,5419.432093,5381.39263,5344.964945,5307.471515,5272.287292,5237.151761,5204.087811,5172.047914,5142.027145,5112.015012,5083.808431,5056.964689,5031.754624,5008.143863,4985.179697,4965.064712,4944.248882,4924.062719,4902.46232,4882.505008,4862.247234,4842.734536

where the values are raw values which didnt have baseline corrected when i am trying to correct baseline using zhang fit it is showing as tilted curve. Is there anything can you help to make the curve corrected or any suggestion is good enough.
image

Different baselines on different operating systems

Hello,

I am using your code to baseline some Raman spectra that I have. Running it on my Macbook results in different baselining to when I run it on a Windows PC. I am using identical code and identical data (have triple checked this) so am unsure what the issue is.

I have attached images of the results from both systems.
Mac Baselining
Windows Baselining

Thank you.

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.