ldata | R Documentation |
Returns a data frame of signals and annotations for requested epochs
ldata(e, chs, annots = character(0))
e |
a required vector of 1-based epoch numbers corresponding to the current epoch numbering of the attached EDF |
chs |
a required vector of channel names to be returned, i.e. as from |
annots |
an optional vector of annotation names to be returned, i.e. as from |
a data frame where each row is one sample point, containing the raw signal (and annotation) data
The following command would request all the data in an EDF (assuming that all
channels have similar sampling rates) and all associated annotation information:
ne <- lepoch()
d <- ldata(1:ne, lchs(), lannots())
That is, for long EDFs, with a large number of channels and/or high sampling rates,
the size of the data frame returned by ldata()
may be large (i.e. too large),
if many epochs, channels and/or annotations are requested.
The returned data frame has the following columns:
epoch number E
elapsed time since the start of the current first epoch SEC
any signals, in alphabetical order, where column/variable names are the channel labels,
potentially sanitized if need be to remove special characters with an underscore
(e.g. here EEG(sec)
becomes EEG_sec_
)
any annotations, where 1
and 0
indicate the presence/absence of that annotation at that time-point
If different channels have different sampling rates, use the RESAMPLE
command to resample one or more channels first, e.g.
leval("RESAMPLE sig=ECG sr=125")
. Otherwise it will yield an error:
Error in ldata(...) : requires uniform sampling rate across signals
See leval
for more details.
## Not run:
## request EEG and EMG channels, for epochs 211 and 212, along with the
## arousal annotation
> d <- ldata( 211:212 , chs = c("EEG", "EMG") , annots = "arousal" )
> head(d)
E SEC EEG EMG arousal
1 211 6300.000 -4.411765 -2.8411765 0
2 211 6300.008 -5.392157 0.8647059 0
3 211 6300.016 -4.411765 -1.6058824 0
4 211 6300.024 -4.411765 -2.8411765 0
5 211 6300.032 -6.372549 1.3588235 0
6 211 6300.040 -6.372549 -0.1235294 0
## plotting the the two signals and annotation:
> par(mfcol=c(3,1),mar=c(1,4,2,1))
> plot( d$SEC , d$EEG , type="l" , lwd=0.5 , col="darkgray",ylab="EEG")
> plot( d$SEC , d$EMG , type="l" , lwd=0.5 , col="darkgray",ylab="EMG")
> plot( d$SEC , d$arousal , type="l" , col="blue" , lwd=2,ylab="Arousal")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.