| 1 | # |
| 2 | # Copyright (C) 2016,2019 Alois Schloegl <[email protected]> |
| 3 | # This file is part of the "BioSig for C/C++" repository |
| 4 | # (biosig4c++/libbiosig) at http://biosig.sf.net/ |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or |
| 7 | # modify it under the terms of the GNU General Public License |
| 8 | # as published by the Free Software Foundation; either version 3 |
| 9 | # of the License, or (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | |
| 20 | dyn.load("sload.so") |
| 21 | |
| 22 | #' Loads biomedical signal data |
| 23 | #' |
| 24 | #' @param filename name of biosig data file |
| 25 | #' @param channel indicates which channel should be loaded, (default 0: indicaes all channels) |
| 26 | #' @return matrix containing sample values |
| 27 | sload <- function(filename, channel=0) { |
| 28 | result <- .Call("sload", filename, channel=0) |
| 29 | return(result) |
| 30 | } |
| 31 | |
| 32 | #' @param filename name of biosig data file |
| 33 | #' @return Header (or Meta-) information of data file in JSON format |
| 34 | jsonHeader <- function(filename) { |
| 35 | result <- .Call("jsonHeader", filename) |
| 36 | return(result) |
| 37 | } |
| 38 | |
| 39 | # Usage: |
| 40 | # # read header information |
| 41 | # library(rjson) |
| 42 | # HDR = fromJSON(jsonHeader("../data/Newtest17-256.bdf")) |
| 43 | # |
| 44 | # # read data |
| 45 | # data = sload("../data/Newtest17-256.bdf") |
| 46 | # plot((1:nrow(data))/HDR$Samplingrate,data[,1],"l",xlab="time [s]",ylab=HDR$CHANNEL[[1]]$Label) |
| 47 |