usnistgov / pyMCR

pyMCR: Multivariate Curve Resolution for Python
https://pages.nist.gov/pyMCR
Other
80 stars 27 forks source link

Is matrix augmentation supported #35

Open aminsagar opened 3 years ago

aminsagar commented 3 years ago

Hello.

Is matrix augmentation supported like in MATLAB MCR-ALS? If not, is there a straightforward way to extend the code to allow row and column augmented matrices?

Thanks. Amin.

CCampJr commented 3 years ago

@aminsagar Thanks for the question!

I'm not 100% familiar with the row- and column-wise data augmentation in the MCR-ALS package.

Thanks!

aminsagar commented 3 years ago

Thanks for the response. I collect data using different techniques and different experiments. Generally, in MCR-ALS, data from different techniques, i.e. matrices with same concentrations but different spectra are joined row-wise, while data from different experiments, i.e different concentration but common spectra is joined column-wise. All this data augmentation is done to reduce ambiguity of the solutions. Screenshot_2020-09-01 mcr_2005 ppt - MCR_2005 pdf

CCampJr commented 3 years ago

@aminsagar Great description.

I can see possible ways to implement it -- let me check into that.

I'll see what I can do to make that happen. Do you have the same constraints on your augmented matrices (e.g., sum-to-one, or non-negativity)?

aminsagar commented 3 years ago

Thanks. It would be awesome if this could be implemented. I use non-negativity on all the matrices, for both concentrations and spectra. I actually don't use sum-to-one on all the matrices but using it is not essential for my problem.

Again, thanks a lot.

CCampJr commented 3 years ago

@aminsagar

Sorry it's going to take a bit to implement this: just busy with work. If you have any coding expertise and want to take a crack at it, feel free -- always looking for collaborators.

Thanks again for bringing this to my attention: I wasn't aware of this "data augmentation" capabilities.

aminsagar commented 3 years ago

@CCampJr No problem. I will try to implement a simple version of matrix augmentation first (all matrices having the same set of restraints) to see how hard it is for me.

aminsagar commented 3 years ago

@CCampJr Sorry, I wanted to say I would try to implement a simple version with different restraints in only one dimension.

HaasCP commented 3 years ago

@CCampJr @aminsagar

Is there any follow-up/new information on this issue?

CCampJr commented 3 years ago

@CCampJr @aminsagar

Is there any follow-up/new information on this issue?

@HaasCP I haven't heard anything. Are you, too, interested in this?

HaasCP commented 3 years ago

@CCampJr I might be but I am not quite sure, yet. Just looking in the pros and cons of implementing this package or using the R/MATLAB packages.

CCampJr commented 3 years ago

@HaasCP Gotcha.

This package is a lot more flexible (matrix augmentation withstanding) than the MATLAB one because one can choose any algorithm for regression and constraints are easy to implement. That being said if the MATLAB one can do what you want then it's a very solid choice.

Admittedly, I've been too busy to take a crack at coding data augmentation, but I hope to get to it soon.

aminsagar commented 3 years ago

@HaasCP @CCampJr I tried to modify the code but it was beyond my abilities atleast in the time frame I could dedicate to this. I completely agree with @CCampJr on the advantages of the package. While I couldn't modify pyMCR, I was able to write the code for decomposition with matrix augmentation rather easily using NNLS and some simple restraints that I require. As you know, the only requirement is to separate the decomposition and determination of convergence. Conceptually, it goes like this. while (number of iterations < max interations) for i in range (1,number of matrices) do NNLS for ith matrix apply restraints on ith matrix calculate residuals for the augmented matrix (d - augmented concentrations * augmented spectra) determine convergence

What I have works quite well for my problem but is not general at all. Unfortunately, I don't think I will be able to modify pyMCR to support this. Hoping @CCampJr gets some time to do this.