Beispiel #1
0
    def __init__(self, nfft, win_step):
        def tfc(x):
            return np.array([spectrogram(x[ci, :], nfft, win_step) for ci in range(x.shape[0])])

        BaseNode.__init__(self)
        self.nfft, self.win_step = nfft, win_step
        self.n = ApplyOverInstances(tfc)
Beispiel #2
0
 def __init__(self, nodes, tr_splitter=copy_splitter, 
   te_splitter=copy_splitter, combiner=average_combiner):
   BaseNode.__init__(self)
   assert isinstance(nodes, list)
   self.nodes = nodes 
   self.tr_splitter = tr_splitter
   self.te_splitter = te_splitter
   self.combiner = combiner
Beispiel #3
0
 def __init__(self, isi=10, reest=0.5):
     """
 Define a SlowSphering node, with inter-stimulus interval isi in seconds
 which is reestimated every reest seconds.
 """
     self.isi = isi
     self.reest = reest
     BaseNode.__init__(self)
Beispiel #4
0
 def __init__(self, statistic, min_nfeatures=0, threshold=-np.inf):
   '''
   Construct a feature filter that keeps min_nfeatures, or all featurs
   that score higher than treshold using the statistic function.
   '''
   BaseNode.__init__(self)
   self.statf = statistic
   self.min_nfeatures = min_nfeatures
   self.threshold = threshold
Beispiel #5
0
 def __init__(self, mdict, heog='hEOG', veog='vEOG', reog='rEOG',
              keep_eog=True, eeg=None):
     assert sorted(mdict.values()) == ['blink', 'down', 'left', 'right', 'up']
     BaseNode.__init__(self)
     self.heog = heog
     self.veog = veog
     self.reog = reog
     self.mdict = mdict
     self.keep_eog = keep_eog
     self.eeg = eeg
Beispiel #6
0
    def __init__(self, classes=(0,1), reg=0.2, peak_ch=None, time_range=None, spatial_only=False):
        BaseNode.__init__(self)
        assert type(classes) == int or len(classes) == 2
        self.classes = classes
        self.reg = reg
        self.peak_ch=peak_ch

        assert time_range is None or len(time_range) == 2,\
            'Time range should be specified as (begin, end)'

        self.time_range = time_range
        self.spatial_only = spatial_only
Beispiel #7
0
  def __init__(self, c=np.logspace(-3, 5, 10), kernel=None, **params):
    BaseNode.__init__(self)
    self.c = np.atleast_1d(c)
    self.c_star = np.nan
    self.kernel = kernel
    self.kernel_params = params
    self.nfolds = 5

    if 'C' in params.keys():
      warnings.warn(
        "The SVM's C-parameter has been replaced with a lowercase c.",
        DeprecationWarning)
      self.c = np.atleast_1d(params['C'])
Beispiel #8
0
 def __init__(self, alpha=.0, beta=.3, cov_f=lw_cov):
   '''
   Regularized Discriminant Analysis, Alpaydin, p.98, Eq. 5.29:
   S_i^{'} = \alpha \sigma^2I + \beta S + (1 - \alpha - \beta)S_i
   
   alpha = beta = 0 results in a quadratic classfier,
   alpha = 0, beta = 1 results in a linear classifier,
   alpha = 1, beta = 0 results in a nearest mean classifier.
   '''
   BaseNode.__init__(self)
   self.alpha = float(alpha)
   self.beta = float(beta)
   self.cov_f = cov_f
Beispiel #9
0
    def __init__(self, template, shrinkage='oas', center=True):
        BaseNode.__init__(self)
        self.template = template
        self.template = np.atleast_2d(template)
        self.center = center

        if center:
            self.template -= self.template.mean()

        if shrinkage == 'oas':
            self.cov = OAS
        elif shrinkage == 'lw':
            self.cov = LedoitWolf
        elif shrinkage == 'none':
            self.cov = EmpiricalCovariance
        elif type(shrinkage) == float or type(shrinkage) == int:
            self.cov = ShrunkCovariance(shrinkage=shrinkage)
Beispiel #10
0
    def __init__(
        self,
        eeg=[],
        eog=None,
        bads=None,
        ref=[],
        bipolar=None,
        heog=None,
        veog=None,
        calc_reog=False,
        drop=None,
        drop_ref=False,
    ):
        BaseNode.__init__(self)

        assert eeg is None or hasattr(eeg, "__iter__"), "Parameter eeg should either be None or a list"
        assert eog is None or hasattr(eog, "__iter__"), "Parameter eog should either be None or a list"
        assert bads is None or hasattr(bads, "__iter__"), "Parameter bads should either be None or a list"
        assert ref is None or hasattr(ref, "__iter__"), "Parameter ref should either be None or a list"
        assert bipolar is None or type(bipolar) == dict, "Parameter bipolar should either be None or a dictionary"
        if bipolar is not None:
            for channels in bipolar.values():
                assert len(channels) == 2, "Bipolar channels should be a " "dictionary containing tuples as " "values"
        assert heog is None or (
            hasattr(heog, "__iter__") and len(heog) == 2
        ), "Parameter heog should either be None or a tuple"
        assert veog is None or (
            hasattr(veog, "__iter__") and len(veog) == 2
        ), "Parameter veog should either be None or a tuple"

        self.eeg = eeg
        self.eog = None if eog == [] else eog
        self.bads = None if bads == [] else bads
        self.ref = ref
        self.bipolar = None if bipolar == {} else bipolar
        self.heog = heog
        self.veog = veog
        self.calc_reog = calc_reog
        self.drop = None if drop == [] else drop
        self.drop_ref = drop_ref
Beispiel #11
0
 def __init__(self, class_i, node):
   BaseNode.__init__(self)
   self.class_i = class_i
   self.node = node
Beispiel #12
0
 def __init__(self, nodes, critic):
   BaseNode.__init__(self)
   self.nodes = list(nodes)
   self.critic = critic
Beispiel #13
0
 def __init__(self, W, ftype=None, preserve_feat_lab=False):
   BaseNode.__init__(self)
   self.W = W
   self.ftype = ftype
   self.preserve_feat_lab = preserve_feat_lab
Beispiel #14
0
 def __init__(self, rt):
     BaseNode.__init__(self)
     self.rt = rt
Beispiel #15
0
 def __init__(self, retain=.95, ndims=None, cov_f=lw_cov):
   BaseNode.__init__(self)
   self.retain = float(retain)
   self.ndims = ndims
   self.cov_f = cov_f
Beispiel #16
0
 def __init__(self, nodes):
     BaseNode.__init__(self)
     self.nodes = list(nodes)
Beispiel #17
0
 def __init__(self, binary_node):
   BaseNode.__init__(self)
   self.binary_node = binary_node
Beispiel #18
0
 def __init__(self, cia, cib, node):
   BaseNode.__init__(self)
   self.cia = cia
   self.cib = cib
   self.node = node
Beispiel #19
0
 def __init__(self, win_size, win_step, ref_point=.5):
   BaseNode.__init__(self)
   self.win_size = win_size
   self.win_step = win_step
   self.ref_frame = ref_point * self.win_size
Beispiel #20
0
 def __init__(self, mapping):
   BaseNode.__init__(self)
   self.mapping = mapping