コード例 #1
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_names_base(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper)
     wrap.addFeature("bandPower", 0, bandLimits={"band1":(3,4),
                                                 "band2":(10,20)})
     
     featureName="bandPower(0,){'bandLimits': {'band1': (3, 4), 'band2': (10, 20)}}"
     self.assertEqual(list(wrap.featuresNames())[0], featureName)
コード例 #2
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_names_noargs(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper)
     wrap.addFeature("bandPower", 0, bandLimits={"band1":(3,4),
                                                 "band2":(10,20)},
                     hideArgs=True)
     
     featureName="bandPower"
     self.assertEqual(list(wrap.featuresNames())[0], featureName)
コード例 #3
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_add_features_errors(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper[::128])
     
     with self.assertRaises(ValueError) as _:
         wrap.addFeatures([("synchronizationLikelihood",[(0,3)]),])
     
     with self.assertRaises(AttributeError) as _:
         wrap.addFeatures("PFD")
コード例 #4
0
 def test_branches(self):
     helpers.CSVHelper(self.test_file_name,
                       sampleRate=128,
                       ICA=True,
                       lowpass=24,
                       highpass=2,
                       normalize=True)
     h = helpers.Helper(self.test_data)
     len(h)
コード例 #5
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_segmentation(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper[::128], label="test",
                            segmentation=[(("0","2"),"l1"), 
                                          ((384,512),"l2")])
     
     wrap.addFeature("bandPower", 0)
     
     label = wrap.getAllFeatures()["segment_label"]
     
     self.assertEqual(label[0], "l1")
     self.assertEqual(label[1], "l1")
     self.assertEqual(label[3], "l2")
コード例 #6
0
    def test_channels_names(self):
        h = helpers.CSVHelper(self.test_file_name,
                              windowSize=64,
                              names=["F1", "F2", "F3", "F4", "F5"],
                              selectedSignals=["F1", "F3"])

        self.assertListEqual(h.getNames(), ["F1", "F3"])
        self.assertListEqual(h.getNames([1]), ["F3"])

        # Not sure if this should be allowed, but it will be keeped by the
        # moment.
        h.selectSignals([1, 0, "F1"])
        self.assertListEqual(h.getNames(), ["F3", "F1", "F1"])
コード例 #7
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_custom_features_params(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper[::128])
     
     wrap.addCustomFeature(lambda x, y: np.linalg.norm(x-y, ord=2), 
                           channels=[0,1,2], twoChannels=True,
                           name="norm")
     
     f1 = wrap.getAllFeatures()
     
     wrap = wrapper.Wrapper(helper[::128])
     wrap.addCustomFeature(lambda x, y, *args, **kwargs: np.linalg.norm(x-y, *args, **kwargs), 
                     channels=[0,1,2], twoChannels=True,
                     name="norm" ,customKwargs={"ord":2})
     f2 = wrap.getAllFeatures()
     
     pd.testing.assert_frame_equal(f1, f2, check_names = False)    
コード例 #8
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_all_features_progress(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper[::16], showProgress=True,
                            segmentation=[(("0","2"), "l1"),
                                          (("6","10"), "l2")],
                            onlySegments=True)
     
     wrap.addFeature("bandPower", 0)
     wrap.addFeature.DFA([1,2])
     wrap.addFeature.HFD(kMax=8)
     wrap.addFeatures([("synchronizationLikelihood",[],{}),
                       "PFD"])
     wrap.addCustomFeature(np.mean)
     wrap.addCustomFeature(lambda x, y: np.linalg.norm(x-y), 
                           channels=[0,1,2], twoChannels=True)
     
     features = wrap.getAllFeatures()
コード例 #9
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_segmentation_only_segments(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper[::128], label="test",
                            segmentation=[(("0","2"),"l1"), 
                                          ((384,512),"l2"),
                                          (("6","8"), "l3")],
                            onlySegments = True)
     
     wrap.addFeature("bandPower", 0)
     
     features = wrap.getAllFeatures()
     label = features["segment_label"]
     
     self.assertEqual(label[0], "l1")
     self.assertEqual(label[1], "l1")
     self.assertEqual(label[3], "l2")
     self.assertEqual(label[6], "l3")
     self.assertEqual(label[7], "l3")
コード例 #10
0
ファイル: test_wrapper.py プロジェクト: Xiul109/eeglib
 def test_wrapper_all_features_stored(self):
     helper = helpers.CSVHelper(self.test_file_name, sampleRate=128)
     wrap = wrapper.Wrapper(helper[::128])
     
     wrap.addFeature("bandPower", 0)
     wrap.addFeature.DFA([1,2])
     wrap.addFeature.HFD(kMax=8)
     wrap.addFeatures([("synchronizationLikelihood",[(0,3)],{}),
                       "PFD"])
     wrap.addCustomFeature(np.mean)
     wrap.addCustomFeature(lambda x, y: np.linalg.norm(x-y), 
                           channels=[0,1,2], twoChannels=True)
     
     features = wrap.getAllFeatures()
     stored = wrap.getStoredFeatures()
     
     pd.testing.assert_frame_equal(features, stored)
     pd.testing.assert_series_equal(features.iloc[-1], wrap.getFeatures().drop(wrap._indexName),
                                    check_names=False)
コード例 #11
0
    def test_CSVHelperNames(self):
        h = helpers.CSVHelper(self.test_file_name, sampleRate=128)
        self.assertListEqual(h.getNames(), ["C1", "C2", "C3", "C4", "C5"])

        h = helpers.CSVHelper(self.test_file_noname, sampleRate=128)
        self.assertListEqual(h.getNames(), ["0", "1", "2", "3", "4"])
コード例 #12
0
from eeglib import wrapper, helpers

helper = helpers.CSVHelper("fake_EEG_signal.csv", windowSize=128)

wrap = wrapper.Wrapper(helper)

wrap.addFeature.HFD()
wrap.addFeature.DFT()
wrap.addFeature.synchronizationLikelihood()

features = wrap.getAllFeatures()