示例#1
0
 def search_clusters(self, data):
     """This function performs the search for significant clusters. 
        Uses a class from eegpy.stats.cluster
     """
     plotid = 0
     for i_ch in range(data[0].shape[2]):
         for i_b in range(data[0].shape[3]):
             #print i_ch,i_b
             cs_data = [d[:, :, i_ch, i_b].T for d in data]
             #print len(cs_data), [csd.shape for csd in cs_data]
             fs, sct, scp, ct, cp = ClusterSearch1d(
                 cs_data, num_surrogates=self._num_surrogates).search()
             #print "CPM: fs.shape=",fs.shape
             #print ct, cp
             for i_c in range(len(sct)):
                 self._clusters.append((i_ch, i_b, sct[i_c], scp[i_c]))
             #Do plot if significant cluster found
             if len(sct) > 0:
                 #print "CPM: fs.shape=",fs.shape, fs.dtype
                 #print "CPM: fs[499:510]", fs[498:510]
                 p.plot(np.array(fs))
                 p.title("Channel %i, band %i" % (i_ch, i_b))
                 for cluster in sct:
                     p.axvspan(cluster[0], cluster[1], color="y", alpha=0.2)
                 p.savefig("/tmp/fbpm%03d.png" % plotid)
                 plotid += 1
                 p.clf()
示例#2
0
 def test_DataWithNoClusterFindNoCluster(self):
     #arange
     cl1d = ClusterSearch1d(self.data_without_cluster, num_surrogates=100)
     #act
     results = cl1d.search()
     #assert
     assert len(results[1]) == 0
     assert results[4].min() > 0.01
示例#3
0
 def test_DataWithOneClusterFindOneCluster(self):
     #arange
     cl1d = ClusterSearch1d(self.data_with_one_cluster, num_surrogates=100)
     #act
     results = cl1d.search()
     cluster = results[1][0]
     #assert
     assert len(results[1]) == 1
     assert cluster[0] > 40
     assert cluster[1] < 60
示例#4
0
 def search_clusters(self, data):
     """This function performs the search for significant clusters. 
        Uses a class from eegpy.stats.cluster
     """
     plotid = 0
     print data[0].shape
     for i_ch in range(data[0].shape[2]):
         for i_b in range(data[0].shape[3]):
             #print i_ch,i_b
             cs_data = [d[:, :, i_ch, i_b].T for d in data]
             #print len(cs_data), [csd.shape for csd in cs_data]
             fs, sct, scp, ct, cp = ClusterSearch1d(
                 cs_data, num_surrogates=self._num_surrogates).search()
             #print "CPM: fs.shape=",fs.shape
             #print ct, cp
             for i_c in range(len(sct)):
                 self._clusters.append((i_ch, i_b, sct[i_c], scp[i_c]))
示例#5
0
 def test_Cluster1dForNegativeNumberOfSurrogates(self):
     cl1d = ClusterSearch1d(self.data_with_one_cluster[0],
                            num_surrogates=-10)
示例#6
0
 def test_Cluster1dForZeroSurrogates(self):
     cl1d = ClusterSearch1d(self.data_with_one_cluster[0], num_surrogates=0)
示例#7
0
 def test_Cluster1dFor1dArrays(self):
     data = [d[:, 0] for d in self.data_with_one_cluster]
     cl1d = ClusterSearch1d(data)
示例#8
0
 def test_Cluster1dForArrayListNotAList(self):
     data = self.data_with_one_cluster[0]
     cl1d = ClusterSearch1d(data)