def test_distance_map_1d(self): b, w, nelecs = self.b, self.w, self.nelecs arg_sets = itools.product(b, w, nelecs) for bb, ww, n in arg_sets: a = randint(1, n + 1, size=n) em = ElectrodeMap(a) if ww and bb and em.values.size > 1: dm = em.distance_map(ww, bb) self.assertIsNotNone(dm) else: self.assertRaises(ValueError, em.distance_map, ww, bb)
def test_distance_map_2d(self): nshanks = randint(2, 8) b, w, nelecs = self.b, np.zeros_like(self.b), self.nelecs arg_sets = itools.product(b, w, nelecs, [nshanks]) for bb, ww, n, nsh in arg_sets: a = randint(1, n + 1, size=(n, nsh)) em = ElectrodeMap(a) if ww and bb: dm = em.distance_map(ww, bb) self.assertIsNotNone(dm) else: self.assertRaises(AssertionError, em.distance_map, ww, bb) self.assertIsNotNone(em)
class TestDistanceMapWithCrossCorrelation(TestCase): def setUp(self): sp = create_spike_df() thr = sp.threshold(4 * sp.std()) clr = sp.clear_refrac(thr) binned = sp.bin(clr, binsize=10) self.xc = sp.xcorr(binned, maxlags=10) rawmap = np.array([1, 3, 2, 6, 7, 4, 8, 5, 13, 10, 12, 9, 14, 16, 11, 15]).reshape(4, 4) self.elecmap = ElectrodeMap(rawmap) self.dm = self.elecmap.distance_map(50, 125) def test_set_index(self): xcc = self.xc.T.set_index(self.dm, append=True).T lag0_tmp = xcc.ix[0].dropna().sortlevel(level=4) lag0 = lag0_tmp.reset_index(level=range(5), drop=True) self.assertIsNotNone(lag0)