Example #1
0
 def test_data(self):
   w = BDFWriter(psychic.find_data_path('sine-256Hz-test.bdf'),
         header=self.header)
   w.write(self.d)
   w.close()
   d2 = load_bdf(psychic.find_data_path('sine-256Hz-test.bdf'))
   np.testing.assert_allclose(self.d.data, d2.data, atol=0.05)
Example #2
0
  def test_save(self):
    d = load_bdf(psychic.find_data_path('sine-256Hz.bdf'))
    save_bdf(d, psychic.find_data_path('sine-256Hz-test.bdf'))
    d2 = load_bdf(psychic.find_data_path('sine-256Hz-test.bdf'))

    self.assertEqual(d.feat_lab, d2.feat_lab)
    np.testing.assert_allclose(d.data, d2.data, atol=0.0001)
    np.testing.assert_allclose(d.labels, d2.labels)
    np.testing.assert_allclose(d.ids, d2.ids)
Example #3
0
  def test_header(self):
    w = BDFWriter(psychic.find_data_path('sine-256Hz-test.bdf'),
          header=self.header)
    w.write(self.d)
    w.close()
    with open(psychic.find_data_path('sine-256Hz.bdf'), "rb") as f:
      file1 = f.read()

    with open(psychic.find_data_path('sine-256Hz-test.bdf'), "rb") as f:
      file2 = f.read()

    header_length = 4608
    self.assertEqual(file1[:header_length], file2[:header_length])
Example #4
0
  def test_header_types(self):
    # Test using a DataSet for header values
    w = BDFWriter(psychic.find_data_path('sine-256Hz-test.bdf'),
          dataset=self.d)
    w.write(self.d)
    w.close()
    r = BDFReader(psychic.find_data_path('sine-256Hz-test.bdf'))
    np.testing.assert_array_equal(r.header['n_samples_per_record'], 256)

    # Test specifying a sample_rate and num_samples for header values
    w = BDFWriter(psychic.find_data_path('sine-256Hz-test.bdf'),
          sample_rate=256, num_channels=self.d.nfeatures)
    w.write(self.d)
    w.close()
    r = BDFReader(psychic.find_data_path('sine-256Hz-test.bdf'))
    np.testing.assert_array_equal(r.header['n_samples_per_record'], 256)
Example #5
0
  def test_load(self):
    d = load_bdf(psychic.find_data_path('sine-256Hz.bdf'))

    # test labels
    targets = [['A%d' % (i + 1) for i in range(16)]]
    self.assertEqual(d.feat_lab, targets)
    self.assertEqual(d.cl_lab, ['class254', 'class255'])

    # test ids ~ time
    self.assertAlmostEqual(d.ids[0, 256 + 1], 1, 2)

    # test dims
    self.assertEqual(d.nfeatures, 16)
    self.assertEqual(d.ninstances, 60 * 256)
    
    self.assertEqual(d.extra, {})
Example #6
0
 def setUp(self):
   self.d = load_bdf(psychic.find_data_path('sine-256Hz.bdf'))
   r = BDFReader(psychic.find_data_path('sine-256Hz.bdf'))
   self.header = r.header
   r.close()
Example #7
0
 def setUp(self):
   self.bdf = BDFReader(open(psychic.find_data_path('sine-256Hz.bdf'), 'rb'))
Example #8
0
import psychic
import golem
from matplotlib import pyplot as plt

trials = golem.DataSet.load(psychic.find_data_path('priming-trials.dat'))
trials = psychic.nodes.Baseline((-0.2, 0)).train_apply(trials, trials)
psychic.plot_erp(trials.lix[['Fz', 'Cz', 'Pz'], :, :], fwer=None)
plt.savefig('plot_erp.png')

erp = psychic.nodes.ERP().apply(trials)
psychic.plot_erp(erp.lix[['Fz', 'Cz', 'Pz'], :, :])
plt.savefig('plot_erp_erp.png')