
= Introduction =
 
This provides an interface of libbiosig to R. 
There are two ways to access biosig data. One 
approach is with loadgdf.r and biosig2gdf.exe, 
the other approach is by using a shared 
object library sload.so to libbiosig. 


= A) loadgdf and biosig2exe.gdf =
   loadgdf(filename) will use biosig2exe 
   to load and convert the data into a GDF data stream,
   which is then parsed by loadgdf.r 
   This approach is will work on all platforms
   for which biosig2exe is available. 
   Especially, it will also work in MS Windows. 
 
= B) Installation and use of sload.so =
   This approach will work on all *nix operating 
   systems (GNU/Linux, BSD, MacOSX, etc), but 
   does not work on MS Windows.    

# 0) Requirements

       apt-get install r-base-dev

# 1) Make sure libbiosig and libbiosig2 are installed 
     
 	make -C .. && sudo make -C .. install      
  
# 2) Compile R binding

	make
#    or 
	R CMD SHLIB sload.c -lbiosig

# 3) Use of sload in R 
       
	dyn.load("sload.so")
	sload <- function(filename,channels=0) {
	  result <- .Call("sload", filename, channels=0)
	  return(result)
	}
	jsonHeader <- function(filename) {
	  result <- .Call("jsonHeader", filename)
	  return(result)
	}
	jsonHeader("filename.gdf")

	# read header information
	library(rjson)
	HDR = fromJSON(jsonHeader("../data/Newtest17-256.bdf"))

	# read data
	data = sload("../data/Newtest17-256.bdf")
	plot((1:nrow(data))/HDR$Samplingrate,data[,1],"l",xlab="time [s]",ylab=HDR$CHANNEL[[1]]$Label)

