def test_place_pwlin_id(self): # Single branch, discontiguous segments. s0p = A.mpoint(0, 0, 0, 10) s0d = A.mpoint(1, 0, 0, 10) s1p = A.mpoint(3, 0, 0, 10) s1d = A.mpoint(4, 0, 0, 10) tree = A.segment_tree() i = tree.append(A.mnpos, s0p, s0d, 1) tree.append(i, s1p, s1d, 2) m = A.morphology(tree) place = A.place_pwlin(m) L0 = place.at(A.location(0, 0)) L0s = place.all_at(A.location(0, 0)) self.assertEqual(s0p, L0) self.assertEqual([s0p], L0s) Lhalf = place.at(A.location(0, 0.5)) Lhalfs = place.all_at(A.location(0, 0.5)) self.assertTrue(s0d == Lhalf or s1p == Lhalf) self.assertTrue([s0d, s1p] == Lhalfs) Chalf = [(s.prox, s.dist) for s in place.segments([A.cable(0, 0., 0.5)])] self.assertEqual([(s0p, s0d)], Chalf) Chalf_all = [(s.prox, s.dist) for s in place.all_segments([A.cable(0, 0., 0.5)])] self.assertEqual([(s0p, s0d), (s1p, s1p)], Chalf_all)
def make_cable_cell(morphology, clamp_location): # number of CVs per branch cvs_per_branch = 3 # Label dictionary defs = {} labels = arbor.label_dict(defs) # decor decor = arbor.decor() # set initial voltage, temperature, axial resistivity, membrane capacitance decor.set_property( Vm=-65, # Initial membrane voltage (mV) tempK=300, # Temperature (Kelvin) rL=10000, # Axial resistivity (Ω cm) cm=0.01, # Membrane capacitance (F/m**2) ) # set passive mechanism all over # passive mech w. leak reversal potential (mV) pas = arbor.mechanism('pas/e=-65') pas.set('g', 0.0001) # leak conductivity (S/cm2) decor.paint('(all)', arbor.density(pas)) # set number of CVs per branch policy = arbor.cv_policy_fixed_per_branch(cvs_per_branch) decor.discretization(policy) # place sinusoid input current iclamp = arbor.iclamp( 5, # stimulation onset (ms) 1E8, # stimulation duration (ms) -0.001, # stimulation amplitude (nA) frequency=0.1, # stimulation frequency (kHz) phase=0) # stimulation phase) decor.place(str(clamp_location), iclamp, '"iclamp"') # create ``arbor.place_pwlin`` object p = arbor.place_pwlin(morphology) # create cell and set properties cell = arbor.cable_cell(morphology, labels, decor) return p, cell
def test_place_pwlin_isometry(self): # Single branch, discontiguous segments. s0p = A.mpoint(0, 0, 0, 10) s0d = A.mpoint(1, 0, 0, 10) s1p = A.mpoint(3, 0, 0, 10) s1d = A.mpoint(4, 0, 0, 10) tree = A.segment_tree() i = tree.append(A.mnpos, s0p, s0d, 1) tree.append(i, s1p, s1d, 2) m = A.morphology(tree) iso = A.isometry.translate(2, 3, 4) place = A.place_pwlin(m, iso) x0p = iso(s0p) x0d = iso(s0d) x1p = iso(s1p) x1d = iso(s1d) L0 = place.at(A.location(0, 0)) L0s = place.all_at(A.location(0, 0)) self.assertEqual(x0p, L0) self.assertEqual([x0p], L0s) Lhalf = place.at(A.location(0, 0.5)) Lhalfs = place.all_at(A.location(0, 0.5)) self.assertTrue(x0d == Lhalf or x1p == Lhalf) self.assertTrue([x0d, x1p] == Lhalfs) Chalf = [(s.prox, s.dist) for s in place.segments([A.cable(0, 0., 0.5)])] self.assertEqual([(x0p, x0d)], Chalf) Chalf_all = [(s.prox, s.dist) for s in place.all_segments([A.cable(0, 0., 0.5)])] self.assertEqual([(x0p, x0d), (x1p, x1p)], Chalf_all)
V_m_samples = V_m_samples[:, np.r_[True, inds]] V_m_meta = np.array(V_m_meta)[inds].tolist() # note: the cables comprising the metadata for each probe # should be the same, as well as the reported sample times. assert V_m_meta == I_m_meta assert (V_m_samples[:, 0] == I_m_samples[:, 0]).all() # prep recorded data for plotting time = V_m_samples[:, 0] V_m = V_m_samples[:, 1:].T I_m = I_m_samples[:, 1:].T I_c = I_c_samples[:, 1:].T # gather geometry of CVs and assign segments to each CV p = arbor.place_pwlin(morphology) x, y, z, d = [np.array([], dtype=float).reshape((0, 2))] * 4 CV_ind = np.array([], dtype=int) # tracks which CV owns segment for i, m in enumerate(I_m_meta): segs = p.segments([m]) for j, seg in enumerate(segs): x = np.row_stack([x, [seg.prox.x, seg.dist.x]]) y = np.row_stack([y, [seg.prox.y, seg.dist.y]]) z = np.row_stack([z, [seg.prox.z, seg.dist.z]]) d = np.row_stack([d, [seg.prox.radius * 2, seg.dist.radius * 2]]) CV_ind = np.r_[CV_ind, i] ############################################################################### # compute extracellular potential using segment information ############################################################################### cell_geometry = lfpykit.CellGeometry(x=x, y=y, z=z, d=d)