Utility functions for analysis of MRS data.
The bi-square weight function calculated over values of xx
Parameters: | xx: float array : |
---|
Notes
This is the first equation on page 831 of [Cleveland79].
Detects outliers more than X standard deviations from mean.
Parameters: | in_list: ndarray :
thresh: float (optional) :
|
---|---|
Returns: | outlier_idx: ndarray of boolean :
|
Calculate a kernel function on x in the neighborhood of x0
Parameters: | x: float array :
x0: float :
l: float or float array (with shape = x.shape) :
|
---|
The Epanechnikov kernel estimated for xx values at indices idx (zero elsewhere)
Parameters: | xx: float array :
idx: tuple :
|
---|
Notes
This is equation 6.4 in FHT chapter 6
Convert a set of numbers from frequenxy in hertz to chemical shift in ppm
A Gaussian function with flexible offset, drift and amplitude
The l2 norm of an array is is defined as: sqrt(||x||), where ||x|| is the dot product of the vector.
Apply line-broadening to a time-series
Parameters: | ts : a nitime.TimeSeries class instance width : float
|
---|---|
Returns: | A nitime.TimeSeries class instance with windowed data : |
Notes
For details, see page 92 of Keeler2005.
[Keeler2005] | Keeler, J (2005). Understanding NMR spectroscopy, second edition. Wiley (West Sussex, UK). |
Lorentzian line-shape function
Parameters: | freq : float or float array
freq0 : float
area : float hwhm: float :
|
---|
Locally linear regression with the LOWESS algorithm.
Parameters: | x: float n-d array :
w: float array :
x0: float or float array. :
kernel: callable :
l: float or float array with shape = x.shape :
robust: bool :
|
---|---|
Returns: | The function estimated at x0. : |
Notes
The solution to this problem is given by equation 6.8 in Friedman, Hastie and Tibshirani (2008). The Elements of Statistical Learning (Chapter 6).
This is a little utility function to replace an oft-called set of operations
Parameters: | f : 1d array
lb : float
ub : float
|
---|---|
Returns: | idx : a slice object |
Generate the matrix used to solve OLS regression.
Parameters: | A: float array :
|
---|
See also
is given by:
..math
\hat{eta} = (A' x A)^{-1} A' y
First order phase correction.
Parameters: | spec : float array
freq : float array
k : float
|
---|---|
Returns: | The phase-corrected spectrum. : |
Notes
Correct the phases of a spectrum by phi radians
Parameters: | spec : float array of complex dtype
phi : float |
---|---|
Returns: | spec : float array
|
Notes
Create a slice object according to the ppm scale
Parameters: | f_ppm : float array
lb,ub : float
|
---|---|
Returns: | idx : slice object which can be used to index |
Convert an array from chemical shift to Hz
The root of the mean of the squared error between arr1 and arr2
Parameters: | arr1, arr2 : ndarray
|
---|---|
Returns: | RMSE : float |
Notes
The RMSE will be summarized in one number. That is, even if the two arrays are multi-dimensional, the error between them will be averaged over the entire array and then the sqrt will be derived.
The tri-cube kernel estimated for xx values at indices idx (zero elsewhere)
Parameters: | xx: float array :
idx: tuple :
|
---|
Notes
This is equation 6.6 in FHT chapter 6
A two-Gaussian model.
This is simply the sum of two gaussian functions in some part of the spectrum. Each individual gaussian has its own peak frequency, sigma, and amp, but they share common offset and drift parameters.
A two-Lorentzian model.
This is simply the sum of two lorentzian functions in some part of the spectrum. Each individual Lorentzian has its own peak frequency, area, hwhm and phase, but they share common offset and drift parameters.