[hyperSpec-help] Hyperspec start

beleites,claudia claudia.beleites at ipht-jena.de
Sun Oct 23 15:43:32 CEST 2011


Dear Holger,

welcome to R and hyperSpec.

- did you find the vignettes? Both vignette ("introduction") and vignette ("fileio") may be of interest for you  (though I have to admit that the introduction has become rather a large manual than a quick introduction by now...

- Wrt. to your spectra:
Are the "multifile spc" many files with single spectra each or one spc file with many spectra inside?
read.spc takes one spc file at a time (though that file may contain multiple spectra).

if you need to read multiple spc files, you need to work along the line of

arSpektren <- lapply (filenames, read.spc, <whatever other arguments to read.spc are needed>)

arSpektren is now a list of hyperSpec objects - which is not very handy for further work and takes a lot more memory than having the spectra in one object.
If you already know that the wavelength (frequency, wavenumber, ...)  axis is the same, you can use rbind instead of collapse to put them all in one object

arSpektren <- do.call (rbind, spc)

If your multifile spc happen to be Raman maps acquired with a Kaiser spectrometer, there's already a complete function doing this: read.spc.KaiserMap.
Otherwise, if you think your routine may be useful to other hyperSpec users, I'd be happy to include your import script into hyperSpec. Just send me the script or preferrably function that works for your spectrometer's output and a small test data set. 
read.spc.KaiserMap.R may be a useful example.

- you can retrieve the abscissa with
wl (arSpektren)

- and the nth spectrum with
arSpektren [n] # gives hyperSpec object containing that spectrum
or
arSpektren [[n]] # gives 1 x p matrix containing the spectral intensities.
or
arSpektren [[n, drop = TRUE]]  # which returns a vector instead of 1 x p matrix

please see the introduction vignette about the very powerful extraction (and replacement) operators.

Have a nice day,

Claudia





________________________________________
Von: hyperspec-help-bounces at r-forge.wu-wien.ac.at [hyperspec-help-bounces at r-forge.wu-wien.ac.at] im Auftrag von Dr. Holger van Lishaut [H.v.Lishaut at gmx.de]
Gesendet: Sonntag, 23. Oktober 2011 00:25
An: HyperSpec Mailing List
Betreff: [hyperSpec-help] Hyperspec start

Dear all,

I am a spectrocopist and would like to perform some preprocessing
assessments on spc spectra. In particular, I'd like to read spc files,
preprocess them and display them as well as their Savitzky-Golay
derivatives graphically.

I have found hyperspec, which seems to allow importing spc files.

However, I am a newbie to R, and currently struggle a bit: hyperspec seems
to be quite powerful, but I am missing a detailed documentation - so I
would really appreciate if you could help me get going!

Here is, what I got so far:

#Task 1. Reading a multifile spc (common axis) into an hyperspec object

setwd("C:/temp/spectra")
library(hyperspec)

arSpektren <- read.spc(file.choose())
arSpektren <- do.call (collapse, arSpektren)
#I suppose collapsing helps to easier submit all spectra to functions
without losing access to single spectra when needed?

#Task 2. Access for calculation: a) abscissa data b) n.th spectrum
(ordinate values)
#Here I'm stuck!

Thanks in advance and best regards
Holger van Lishaut
_______________________________________________
hyperspec-help mailing list
hyperspec-help at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/hyperspec-help


More information about the hyperspec-help mailing list