figsize=(6, 6), constrained_layout=True) dpls[trial_idx].plot(tmin=tmin, ax=axes[0], show=False) # Create an fixed-step tiling of frequencies from 20 to 100 Hz in steps of 1 Hz freqs = np.arange(20., 100., 1.) dpls[trial_idx].plot_tfr_morlet(freqs, n_cycles=7, tmin=tmin, ax=axes[1]) ############################################################################### # As a final exercise, let us try to re-run the simulation with a tonic bias # applied to the L5 Pyramidal cells. Notice that the oscillation waveform is # more regular, with less noise due to the fact that the tonic depolarization # dominates over the influence of the Poisson drive. By default, a tonic bias # is applied to the entire duration of the simulation. net.add_tonic_bias(cell_type='L5_pyramidal', amplitude=6.) dpls = simulate_dipole(net, n_trials=1) dpls[trial_idx].plot() ############################################################################### # Notice that the Layer 5 pyramidal neurons now fire nearly synchronously, # leading to a synchronous activation of the inhibitory basket neurons, # resulting in a low-latency IPSP back onto the pyramidal cells. The duration # of the IPSP is ~20 ms, after which the combined effect of the tonic bias and # Poisson drive is to bring the pyramidal cells back to firing threshold, # creating a ~50 Hz PING rhythm. This type of synchronous rhythm is sometimes # referred to as “strong” PING. net.cell_response.plot_spikes_raster() ###############################################################################
def test_tonic_biases(): """Test tonic biases.""" hnn_core_root = op.dirname(hnn_core.__file__) # default params params_fname = op.join(hnn_core_root, 'param', 'default.json') params = read_params(params_fname) net = Network(params, add_drives_from_params=True) with pytest.raises(ValueError, match=r'cell_type must be one of .*$'): net.add_tonic_bias(cell_type='name_nonexistent', amplitude=1.0, t0=0.0, tstop=4.0) with pytest.raises(ValueError, match='Duration of tonic input cannot be' ' negative'): net.add_tonic_bias(cell_type='L2_pyramidal', amplitude=1.0, t0=5.0, tstop=4.0) simulate_dipole(net, tstop=20.) net.external_biases = dict() with pytest.raises(ValueError, match='End time of tonic input cannot be' ' negative'): net.add_tonic_bias(cell_type='L2_pyramidal', amplitude=1.0, t0=5.0, tstop=-1.0) simulate_dipole(net, tstop=5.) with pytest.raises(ValueError, match='parameter may be missing'): params['Itonic_T_L2Pyr_soma'] = 5.0 net = Network(params, add_drives_from_params=True) params.update({ 'N_pyr_x': 3, 'N_pyr_y': 3, 'N_trials': 1, 'dipole_smooth_win': 5, 't_evprox_1': 5, 't_evdist_1': 10, 't_evprox_2': 20, # tonic inputs 'Itonic_A_L2Pyr_soma': 1.0, 'Itonic_t0_L2Pyr_soma': 5.0, 'Itonic_T_L2Pyr_soma': 15.0 }) # old API net = Network(params, add_drives_from_params=True) assert 'tonic' in net.external_biases assert 'L2_pyramidal' in net.external_biases['tonic'] # new API net = Network(params) net.add_tonic_bias(cell_type='L2_pyramidal', amplitude=1.0) assert 'tonic' in net.external_biases assert 'L5_pyramidal' not in net.external_biases['tonic'] assert net.external_biases['tonic']['L2_pyramidal']['t0'] == 0 with pytest.raises(ValueError, match=r'Tonic bias already defined for.*$'): net.add_tonic_bias(cell_type='L2_pyramidal', amplitude=1.0)