-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Added KZ spectrum smoothing and tests #631
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tidy up those spots and we're good to go
double[] smoothedIntArray = KZ1D(YArray, window, iterations); | ||
if(smoothedIntArray.Length < YArray.Length) | ||
{ | ||
throw new ArgumentException("output length is unequal to input length"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's change this to an mzlib exception with a message. add a unit test for that exception to make sure it happens and to make sure the message is correct. this gets passed to metamorpheus and are really helpful
/// Algorithm employed is the Kolmogorov-Zurbenko algorithm originally written in C for R: | ||
/// https://github.com/cran/kza/blob/master/src/kz.c | ||
/// </summary> | ||
public double[,] SmoothSpectrumKZ(int window, int iterations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use an informative name for window and have variable explanations for window and iterations before the method with recommendations.
/// </summary> | ||
/// <param name="x"></param><summary>double array (double[]) of the intensity values.</summary> | ||
/// <param name="window"></param><summary>The window size over which to perform the filtering.</summary> | ||
/// <param name="iterations"></param><summary>The number of smoothering iterations to perform.</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smoothering?
/// <summary> | ||
/// Computes the moving average for a given window. Used in conjuction with the KZ1D method. | ||
/// </summary> | ||
/// <param name="v"></param><summary>The source data array.</summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use more informative variable names here for v and w at least
} | ||
if (z == 0) | ||
{ | ||
return double.NaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please cover this with a unit test
My new deconvolution algorithm idea relies on high quality smoothing of the data. I implemented the Kolmogorov-Zurbenko filter, directly porting to C# most of the C code written originally for R found here: https://github.com/cran/kza/blob/master/src/kz.c.
This is a re-do of my previous commit that included some changes that I didn't want to include in this pull request.