Skip to content

Commit

Permalink
Merge pull request #46 from l-ramirez-lopez/v0.2.5
Browse files Browse the repository at this point in the history
V0.2.5
  • Loading branch information
l-ramirez-lopez authored Jul 19, 2022
2 parents 2f98025 + fdb79af commit 64a402c
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 93 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ code_ex.R
^\.Rprofile$c
TODO
epo.R
NEWS.html

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Imports:
mathjaxr (>= 1.0),
lifecycle (>= 0.2.0)
RdMacros: mathjaxr
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
NeedsCompilation: yes
LazyData: true
LazyDataCompression: xz
Expand Down
103 changes: 54 additions & 49 deletions NEWS → NEWS.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,62 @@
prospectr 0.2.5
# `prospectr`

`prospectr` 0.2.5
===============

## Improvements and fixes
### Improvements and fixes

* kenStone(): an error in a sanity check that prevented the
* `kenStone()`: an error in a sanity check that prevented the
function to run when the number of groups to be selected was smaller than the
total number of groups. This sanity check has been fixed. Thanks to
Pogs Manalili for reporting this.
Pogs Manalili for reporting this ([#41](https://github.com/l-ramirez-lopez/prospectr/issues/41)).

* kenStone(): this function was failing when when using the Mahalanobis distance
on a matrix of one column. By default the funcion transforms the matrix onto
* `kenStone()`: this function was failing when when using the Mahalanobis distance
on a matrix of one column. By default the function transforms the matrix onto
the Mahalanobis space using either SVD or eigendecomposition. This makes sense
for matrices with more than two columns. However for a matrix of one column, we
now assume that such space is equivalent to the variable divided by the its
standard deviation. Thanks to Sergio Roldán (https://github.com/sdroldan) for
reporting this.
standard deviation. Thanks to Sergio Roldan (https://github.com/sdroldan) for
reporting this ([#40](https://github.com/l-ramirez-lopez/prospectr/issues/40])).


* spliceCorrection(): correcting more than one point at once (argument splice)
* `spliceCorrection()`: correcting more than one point at once (argument splice)
in the spectra was returning an error. This was a bug introduced in
version 0.2.4. Thanks to José Lucas Safanelli (https://github.com/zecojls)
for reporting this.
version 0.2.4. Thanks to Jose Lucas Safanelli (https://github.com/zecojls)
for reporting this ([#39](https://github.com/l-ramirez-lopez/prospectr/issues/39)).


prospectr 0.2.4
`prospectr` 0.2.4
===============

## Improvements and fixes
### Improvements and fixes

* baseline(): in some cases the function did not properly capture the baseline
* `baseline()`: in some cases the function did not properly capture the baseline
confounding maximum values of a peaks as part of the baseline. This has been
addressed in this version by ensuring the envelope used in the computation of the
convex hull (used to extract the baseline) is properly defined. At the edges,
this envelope has always values higher than any peak of the spectrum.

* read_nircal(): the function was wrongly identifying actual .nir files as
* `read_nircal()`: the function was wrongly identifying actual .nir files as
invalid. This preventing the function from reading any nir file. This has been
fixed.


prospectr 0.2.3
`prospectr` 0.2.3
===============

## New features
### New features

* The `kenStone` function now includes a new feature that allows to initialize the
* The `kenStone()` function now includes a new feature that allows to initialize the
calibration sample search with a user-defined subset of observations (which are
to be included in the final calibration subset). Thanks to Thorsten Behrens and
Philipp Baumann for suggesting this feature.

* The gap-segment derivatives (gapDer) function now allows for high order
* The gap-segment derivatives (`gapDer()`) function now allows for high order
derivatives. In previous versions the function only allowed up to derivatives of
4th order, in this version the the function accepts as derivative order
any integer larger than 1.

## Improvements and fixes
### Improvements and fixes
* `binning() `a bug in the creation of the binning groups has been fixed. This bug
is in fact inherited from a problem in the `findInterval()` function. The breaks
(given in the vec arument) might get corrupted when they contain many decimal
Expand All @@ -63,83 +66,85 @@ variable (e.g. wavelength) was exactly on the left of the bin
range the variable was assigned to the next bin. In some cases this lead to
small discrepancies in the in the computation of the mean of the bins.

* `spliceCorrection()` now accepts one or two values as input for the splice
* ``spliceCorrection()`` now accepts one or two values as input for the splice
argument. Previously it only accepted a vector of length two. For example, now it
corrrects for splice steps of spectra that originates from spectrometers
with two detectors (i.e. it corrects for the potential abrupt transition
betwteen the two detectors).

* An extra sanity check has been added to the `read_nircal()` function. The
* An extra sanity check has been added to the ``read_nircal()`` function. The
function evaluaes whether it is indeed a file properly produced by the BUCHI
nircal software.

* There was a bug in the filter for the 3rd order derivative in gap segment
derivative (`gapDer`) function. One of the factors in the filter had a wrong
derivative (`gapDer()`) function. One of the factors in the filter had a wrong
negative sign.

* There was a bug in the `read_nircal` function. It emerged only in some files and
* There was a bug in the `read_nircal()` function. It emerged only in some files and
prevented the function from reading the Description field properly

## Changes
### Changes
* In the `msc()` function the argument `reference_spc` has been renamed to
`ref_spectrum` to emphasize that its input must be is a vector and not a
matrix of spectra.

prospectr 0.2.2
`prospectr` 0.2.2
===============

## New features
### New features

* a new function for baseline correction was added. See baseline()
* a new function for baseline correction was added. See `baseline()`

## Improvements and fixes
### Improvements and fixes

* The package was stripping some symbols for Rcpp functions in Makevars in order
to reduce the installation size of the package. Now these lines have been
commented to comply with CRAN policies

* standardNormalVariate returns now a matrix (previosuly a data.frame)
* `standardNormalVariate()` returns now a matrix (previously a data.frame)


prospectr 0.2.1
`prospectr` 0.2.1
===============
* New license
* The detrend function now allows to remove trends corresponding to different
polynomial orders. Check the new 'p' argument.
* New preprocessing function: multiplicative scatter correction (msc)
* Now resample() also has a new argument (...) to pass additional arguments to the
splinefun() function (of stats) used within resample() when the argument
interpol = "spline" (the default since version 0.2.0)
* Bug fix: in read_nircal, the description file was not being properly read
* Now `resample()` also has a new argument (`...`) to pass additional arguments to the
`splinefun()` function (of stats) used within `resample()` when the argument
`interpol = 'spline'` (the default since version 0.2.0)
* Bug fix: in `read_nircal()`, the description file was not being properly read
* Now performing automatic unit tests with the package testthat

prospectr 0.2.0
`prospectr` 0.2.0
===============
* New maintainer [Leo Ramirez-Lopez]
* Updated vignette
* A new function (read_nircal) for reading buchi NIRcal files has been added
* A new function (`read_nircal()`) for reading buchi NIRcal files has been added
* Documentation reviewed
* The description of the continuum removal algorithm is was adjusted. Previously was indicated that the implemented algorithm was based on the search for a local minimum of
the absorbance spectra the algorithm, however in fact it looks for the convex hull. Thanks to Peter Tillmann for noticing this.
* The description of the continuum removal algorithm is was adjusted. Previously
was indicated that the implemented algorithm was based on the search for a
local minimum of the absorbance spectra the algorithm, however in fact it looks
for the convex hull. Thanks to Peter Tillmann for noticing this.

prospectr 0.1.4
`prospectr` 0.1.4
===============
* Fix bug in kenStone and duplex when the group parameter is used
* Fix bug in `kenStone()` and `duplex()` when the group parameter is used

prospectr 0.1.3
`prospectr` 0.1.3
===============
* Fix in DESCRITPION and NAMESPACE as required by Rcpp 0.11

prospectr 0.1.2
`prospectr` 0.1.2
===============
* bug fix for readASD when ASD file version = 7.0
* add sanity check in spliceCorrection
* bug fix for `readASD()` when ASD file version = 7.0
* add sanity check in `spliceCorrection()`

prospectr 0.1.1
`prospectr` 0.1.1
===============
* bug fix for shenkWest when rm.outlier = T
* bug fix for gapDer when input is a data.frame
* bug fix for `shenkWest()` when `rm.outlier = TRUE`
* bug fix for `gapDer()` when input is a data.frame

prospectr 0.1
`prospectr` 0.1
===============
* Initial release of the package
20 changes: 10 additions & 10 deletions R/baseline.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,32 @@ baseline <- function(X, wav) {
if (is.data.frame(X)) {
X <- as.matrix(X)
}

if (missing(wav)) {
wav <- 1:ncol(X)
}

wav <- c(
wav[1] - diff(wav[1:2]),
wav,
wav[length(wav)] + diff(wav[(length(wav) - 1):length(wav)])
)

# make sure the edges will be well above any peak
edges <- abs(apply(X, 1, "max")) + abs(apply(X, 1, "min"))
edges <- edges * 2

X <- cbind(edges, X, edges)
colnames(X) <- wav

## simple baseline function
simple_bs <- function(x, wav) {
id <- sort(chull(wav, x))
id <- id[-c(1, length(id))]
hull_line <- approx(x = wav[id], y = x[id], xout = wav, method = "linear")$y
return(hull_line)
}

if (is.matrix(X)) {
if (missing(wav)) {
wav <- seq_len(ncol(X))
Expand All @@ -87,14 +87,14 @@ baseline <- function(X, wav) {
} else {
hull_line <- simple_bs(X, wav)
}

hull_line <- hull_line[, -c(1, ncol(hull_line))]
X <- X[, -c(1, ncol(X))]

baselined <- X - hull_line

wav <- wav[-c(1, length(wav))]

if (is.matrix(X)) {
colnames(hull_line) <- colnames(baselined) <- wav
rownames(hull_line) <- rownames(baselined) <- rownames(X)
Expand Down
2 changes: 1 addition & 1 deletion R/cochranTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#' which can be evaluated with ('t Lam, 2010):
#'
#'
#' \mjdeqn{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1} }{C_{UL}(\alpha, n, N) = 1 + \[\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}\]^{-1}}
#' \mjdeqn{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1} }{C_{UL}(\alpha, n, N) = 1 + [\frac{N-1}{F_{c}(\alpha/N,(n-1),(N-1)(n-1))}]^{-1}}
#'
#' where \mjeqn{\alpha}{\alpha} is the *p*-value of the test, \mjeqn{n}{n} is the (average)
#' number of replicates and \mjeqn{F_c}{F_c} is the critical value of the Fisher's \mjeqn{F}{F} ratio.
Expand Down
2 changes: 1 addition & 1 deletion R/e2m.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ e2m <- function(X, sm.method = c("svd", "eigen")) {
ms_x <- X / sd(X)
} else {
sm_method <- match.arg(sm.method)

X <- as.matrix(X)
vcv <- cov(X)
sq_vcv <- sqrtSm(vcv, method = sm_method)
Expand Down
8 changes: 4 additions & 4 deletions R/msc.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#' @param ref_spectrum a numeric vector corresponding to an "ideal" reference
#' spectrum (e.g. free of scattering effects). By default the function uses the
#' mean spectrum of the input \code{X}. See details. Note that this argument was
#' previously named as `reference_spc`, however, it has been renamed to
#' `ref_spectrum` to emphasize that this argument is a vector and not a
#' matrix of spectra.
#' previously named as `reference_spc`, however, it has been renamed to
#' `ref_spectrum` to emphasize that this argument is a vector and not a
#' matrix of spectra.
#'
#' @details
#' The Multiplicative Scatter Correction (MSC) is a normalization method that
Expand Down Expand Up @@ -47,7 +47,7 @@
#' @examples
#' data(NIRsoil)
#' NIRsoil$msc_spc <- msc(X = NIRsoil$spc)
#'
#'
#' # 10 first msc spectra
#' matplot(
#' x = as.numeric(colnames(NIRsoil$msc_spc)),
Expand Down
6 changes: 3 additions & 3 deletions R/spliceCorrection.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#' @description
#' Corrects steps in an input spectral matrix by linear interpolation of the
#' values of the edges of the middle sensor
#'
#'
#' @usage
#'
#'
#' spliceCorrection(X, wav, splice = c(1000, 1830), interpol.bands = 10)
#'
#'
#' @param X a numeric matrix or vector to transform (optionally a data frame that can
#' be coerced to a numerical matrix).
#' @param wav a numeric vector with band positions.
Expand Down
Loading

0 comments on commit 64a402c

Please sign in to comment.