Debian Codegraph @

biosig4c++/R/README

raw
1
2 = Introduction =
3
4 This provides an interface of libbiosig to R.
5 There are two ways to access biosig data. One
6 approach is with loadgdf.r and biosig2gdf.exe,
7 the other approach is by using a shared
8 object library sload.so to libbiosig.
9
10
11 = A) loadgdf and biosig2exe.gdf =
12 loadgdf(filename) will use biosig2exe
13 to load and convert the data into a GDF data stream,
14 which is then parsed by loadgdf.r
15 This approach is will work on all platforms
16 for which biosig2exe is available.
17 Especially, it will also work in MS Windows.
18
19 = B) Installation and use of sload.so =
20 This approach will work on all *nix operating
21 systems (GNU/Linux, BSD, MacOSX, etc), but
22 does not work on MS Windows.
23
24 # 0) Requirements
25
26 apt-get install r-base-dev
27
28 # 1) Make sure libbiosig and libbiosig2 are installed
29
30 make -C .. && sudo make -C .. install
31
32 # 2) Compile R binding
33
34 make
35 # or
36 R CMD SHLIB sload.c -lbiosig
37
38 # 3) Use of sload in R
39
40 dyn.load("sload.so")
41 sload <- function(filename,channels=0) {
42 result <- .Call("sload", filename, channels=0)
43 return(result)
44 }
45 jsonHeader <- function(filename) {
46 result <- .Call("jsonHeader", filename)
47 return(result)
48 }
49 jsonHeader("filename.gdf")
50
51 # read header information
52 library(rjson)
53 HDR = fromJSON(jsonHeader("../data/Newtest17-256.bdf"))
54
55 # read data
56 data = sload("../data/Newtest17-256.bdf")
57 plot((1:nrow(data))/HDR$Samplingrate,data[,1],"l",xlab="time [s]",ylab=HDR$CHANNEL[[1]]$Label)
58