File: readFidFile-functions.R

package info (click to toggle)
r-cran-readbrukerflexdata 1.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,240 kB
  • sloc: sh: 13; makefile: 4
file content (49 lines) | stat: -rw-r--r-- 1,755 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Copyright 2010-2012 Sebastian Gibb
## <mail@sebastiangibb.de>
##
## This file is part of readBrukerFlexData for R and related languages.
##
## readBrukerFlexData is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## readBrukerFlexData is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with readBrukerFlexData. If not, see <https://www.gnu.org/licenses/>

#' Reads binary fid file.
#'
#' This function reads a binary fid file. A fid file contains intensities for
#' all measured time points.
#'
#'
#' @param fidFile \code{character} path to fid file e.g.
#'  Pankreas_HB_L_061019_A10/0_a19/1/1SLin/fid
#' @param nIntensities number of data entries
#'  (total count; get from acqu file)
#' @param endian endianness of the fid file
#'  (\sQuote{little} or \sQuote{big}; default: \sQuote{little})
#'
#' @return
#'  A vector of intensity values.
#' @seealso
#'  \code{\link[readBrukerFlexData]{.readAcquFile}},
#'  \code{\link[readBrukerFlexData]{readBrukerFlexFile}}
#' @keywords internal IO
#' @rdname readFidFile
#'
.readFidFile <- function(fidFile, nIntensities, endian="little") {
  if (!file.exists(fidFile)) {
    stop("File ", sQuote(fidFile), " doesn't exists!")
  }

  con <- file(fidFile, "rb")
  on.exit(close(con))
  as.double(readBin(con, integer(), n=nIntensities, size=4L, endian=endian))
}