Exemple #1
0
    def test_cut_epochs(self):
        triggers = [100, 200, 300, 400, 500, 600, 700, 800, 900]
        rawdata = np.random.randn(5, 1000)
        rawcopy = rawdata.copy()

        start, stop = -10, 50
        x = datatools.cut_segments(rawdata, triggers, start, stop)
        self.assertTrue(np.all(rawdata == rawcopy))
        self.assertEqual(x.shape,
                         (len(triggers), rawdata.shape[0], stop - start))

        # test if it works with float indices
        start, stop = -10.0, 50.0
        x = datatools.cut_segments(rawdata, triggers, start, stop)
        self.assertEqual(x.shape,
                         (len(triggers), x.shape[1], int(stop) - int(start)))

        self.assertRaises(ValueError, datatools.cut_segments, rawdata,
                          triggers, 0, 10.001)
        self.assertRaises(ValueError, datatools.cut_segments, rawdata,
                          triggers, -10.1, 50)

        for it in range(len(triggers)):
            a = rawdata[:, triggers[it] + start:triggers[it] + stop]
            b = x[it, :, :]
            self.assertTrue(np.all(a == b))
Exemple #2
0
    def test_cut_epochs(self):
        triggers = [100, 200, 300, 400, 500, 600, 700, 800, 900]
        rawdata = np.random.randn(5, 1000)
        rawcopy = rawdata.copy()

        start, stop = -10, 50
        x = datatools.cut_segments(rawdata, triggers, start, stop)
        self.assertTrue(np.all(rawdata == rawcopy))
        self.assertEqual(x.shape, (len(triggers), rawdata.shape[0], stop - start))

        # test if it works with float indices
        start, stop = -10.0, 50.0
        x = datatools.cut_segments(rawdata, triggers, start, stop)
        self.assertEqual(x.shape, (len(triggers), x.shape[1], int(stop) - int(start)))

        self.assertRaises(ValueError, datatools.cut_segments,
                          rawdata, triggers, 0, 10.001)
        self.assertRaises(ValueError, datatools.cut_segments,
                          rawdata, triggers, -10.1, 50)

        for it in range(len(triggers)):
            a = rawdata[:, triggers[it] + start: triggers[it] + stop]
            b = x[it, :, :]
            self.assertTrue(np.all(a == b))
    def test_cut_epochs(self):
        triggers = [100, 200, 300, 400, 500, 600, 700, 800, 900]
        rawdata = np.random.randn(1000, 5)
        rawcopy = rawdata.copy()

        start = -10
        stop = 50

        x = datatools.cut_segments(rawdata, triggers, -10, 50)

        self.assertTrue(np.all(rawdata == rawcopy))
        self.assertEqual(x.shape, (stop - start, x.shape[1], len(triggers)))

        for it in range(len(triggers)):
            a = rawdata[triggers[it] + start: triggers[it] + stop, :]
            b = x[:, :, it]
            self.assertTrue(np.all(a == b))
Exemple #4
0
    def test_cut_epochs(self):
        triggers = [100, 200, 300, 400, 500, 600, 700, 800, 900]
        rawdata = np.random.randn(1000, 5)
        rawcopy = rawdata.copy()

        start = -10
        stop = 50

        x = datatools.cut_segments(rawdata, triggers, -10, 50)

        self.assertTrue(np.all(rawdata == rawcopy))
        self.assertEqual(x.shape, (stop - start, x.shape[1], len(triggers)))

        for it in range(len(triggers)):
            a = rawdata[triggers[it] + start:triggers[it] + stop, :]
            b = x[:, :, it]
            self.assertTrue(np.all(a == b))
Exemple #5
0
raweeg = midata.eeg.T
triggers = midata.triggers
classes = midata.classes
fs = midata.samplerate
locs = midata.locations


# Set random seed for repeatable results
np.random.seed(42)


# Prepare data
#
# Here we cut out segments from 3s to 4s after each trigger. This is right in
# the middle of the motor imagery period.
data = cut_segments(raweeg, triggers, 3 * fs, 4 * fs)

m = 4  # number of sources to estimate
h = 66  # number of lags for whiteness test

i = 0
for p in [22, 33]:
    i += 1
    print("Model order:", p)

    print("    Performing CSPVARICA")
    var = scot.backend["var"](p)
    result = cspvarica(data, var, classes, m)

    if result.a.is_stable():
        s = ""
Exemple #6
0
midata = fetch("mi")[0]

raweeg = midata["eeg"]
triggers = midata["triggers"]
classes = midata["labels"]
fs = midata["fs"]
locs = midata["locations"]

# Set random seed for repeatable results
np.random.seed(42)

# Prepare data
#
# Here we cut out segments from 3s to 4s after each trigger. This is right in
# the middle of the motor imagery period.
data = cut_segments(raweeg, triggers, 3 * fs, 4 * fs)

m = 4  # number of sources to estimate
h = 66  # number of lags for whiteness test

i = 0
for p in [22, 33]:
    i += 1
    print('Model order:', p)

    print('    Performing CSPVARICA')
    var = scot.backend['var'](p)
    result = cspvarica(data, var, classes, m)

    if result.a.is_stable():
        s = ''