Package mvpa :: Package misc :: Package bv :: Module base

[hide private]
[frames] | no frames]

# Source Code for Module mvpa.misc.bv.base

     1  # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
     2  # vi: set ft=python sts=4 ts=4 sw=4 et:
     3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
     4  #
     5  #   See COPYING file distributed along with the PyMVPA package for the
     6  #   copyright and license terms.
     7  #
     8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
     9  """Tiny snippets to interface with FSL easily."""
    10
    11  __docformat__ = 'restructuredtext'
    12
    13  from mvpa.misc.io import ColumnData
    14
    15  if __debug__:
    16      from mvpa.base import debug
    17
    18
    19 -class BrainVoyagerRTC(ColumnData):
    20      """IO helper to read BrainVoyager RTC files.
    21
    22      This is a textfile format that is used to specify stimulation
    23      protocols for data analysis in BrainVoyager. It looks like
    24
    25      FileVersion:     2
    26      Type:            DesignMatrix
    27      NrOfPredictors:  4
    28      NrOfDataPoints:  147
    29
    30      "fm_l_60dB" "fm_r_60dB" "fm_l_80dB" "fm_r_80dB"
    31      0.000000 0.000000 0.000000 0.000000
    32      0.000000 0.000000 0.000000 0.000000
    33      0.000000 0.000000 0.000000 0.000000
    34
    35      Data is always read as `float` and header is actually ignored
    36      """
    37 -    def __init__(self, source):
    38          """Read and write BrainVoyager RTC files.
    39
    40          :Parameter:
    41            source: filename of an RTC file
    42          """
    43          # init data from known format
    44          ColumnData.__init__(self, source, header=True,
    45                              sep=None, headersep='"', dtype=float, skiplines=5)
    46
    47
    48 -    def toarray(self):
    49          """Returns the data as an array
    50          """
    51          import numpy as N
    52
    53          # return as array with time axis first
    54          return N.array([self[i] for i in self._header_order],
    55                         dtype='float').T
    56