Skip to content

Commit

Permalink
remove all but one reference to postproc
Browse files Browse the repository at this point in the history
  • Loading branch information
cjayb authored and ntolley committed Jun 25, 2021
1 parent 92f7354 commit 50f3c7a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doc/whats_new.rst
Expand Up @@ -57,7 +57,7 @@ API

- Replace parameter `T` with `tstop` in :func:`~hnn_core.Network.add_tonic_bias` and :func:`~hnn_core.Cell.create_tonic_bias` to be more consistent with other functions and improve readability, by `Kenneth Loi`_ in `#354 <https://github.com/jonescompneurolab/hnn-core/pull/354>`_

- Set `postproc` argument in :func:`~hnn_core.dipole.simulate_dipole` to `False` by default, whereby user should explicitly smooth and scale resulting dipoles, by `Christopher Bailey`_ in `#372 <https://github.com/jonescompneurolab/hnn-core/pull/372>`_
- Deprecated `postproc` argument in :func:`~hnn_core.dipole.simulate_dipole`, whereby user should explicitly smooth and scale resulting dipoles, by `Christopher Bailey`_ in `#372 <https://github.com/jonescompneurolab/hnn-core/pull/372>`_

.. _0.1:

Expand Down
16 changes: 10 additions & 6 deletions examples/howto/plot_connectivity.py
Expand Up @@ -57,9 +57,7 @@
# Data recorded during simulations are stored under
# :class:`~hnn_core.Cell_Response`. Spiking activity can be visualized after
# a simulation is using :meth:`~hnn_core.Cell_Response.plot_spikes_raster`
# Note that in the current example, we apply smoothing and scaling to the
# dipoles as defined in the parameter file (``postproc=True``).
dpl_erp = simulate_dipole(net_erp, n_trials=1, postproc=True)
dpl_erp = simulate_dipole(net_erp, n_trials=1)
net_erp.cell_response.plot_spikes_raster()

###############################################################################
Expand Down Expand Up @@ -97,14 +95,14 @@ def get_network(probability=1.0):


net_all = get_network()
dpl_all = simulate_dipole(net_all, n_trials=1, postproc=True)
dpl_all = simulate_dipole(net_all, n_trials=1)

###############################################################################
# We can additionally use the ``probability`` argument to create a sparse
# connectivity pattern instead of all-to-all. Let's try creating the same
# network with a 10% chance of cells connecting to each other.
net_sparse = get_network(probability=0.1)
dpl_sparse = simulate_dipole(net_sparse, n_trials=1, postproc=True)
dpl_sparse = simulate_dipole(net_sparse, n_trials=1)

###############################################################################
# With the previous connection pattern there appears to be synchronous rhythmic
Expand Down Expand Up @@ -138,7 +136,13 @@ def get_network(probability=1.0):
from hnn_core.viz import plot_dipole
fig, axes = plt.subplots(2, 1, sharex=True, figsize=(6, 6),
constrained_layout=True)
dpls = [dpl_erp[0], dpl_all[0], dpl_sparse[0]]

window_len = 30 # ms
scaling_factor = 3000
dpls = [dpl_erp[0].smooth(window_len).scale(scaling_factor),
dpl_all[0].smooth(window_len).scale(scaling_factor),
dpl_sparse[0].smooth(window_len).scale(scaling_factor)]

plot_dipole(dpls, ax=axes[0], layer='agg', show=False)
axes[0].legend(['Default', 'Custom All', 'Custom Sparse'])
net_erp.cell_response.plot_spikes_hist(
Expand Down
12 changes: 7 additions & 5 deletions examples/workflows/plot_simulate_gamma.py
Expand Up @@ -51,9 +51,9 @@
location='proximal', synaptic_delays=synaptic_delays, seedcore=1079)

###############################################################################
# Note that in the current example, we apply smoothing and scaling to the
# dipoles as defined in the parameter file (``postproc=True``).
dpls = simulate_dipole(net, postproc=True)
dpls = simulate_dipole(net)
scaling_factor = 30000
dpls = [dpl.scale(scaling_factor) for dpl in dpls] # scale in place

###############################################################################
# Take a look at how different cell types respond to the exogenous drive. Note
Expand Down Expand Up @@ -91,7 +91,8 @@
# 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, postproc=True)
dpls = simulate_dipole(net, n_trials=1)
dpls = [dpl.scale(scaling_factor) for dpl in dpls] # scale in place

dpls[trial_idx].plot()

Expand All @@ -118,7 +119,8 @@
# refactory period between L5 pyramidal cell spikes and increase the PING
# frequency from ~50 to ~65 Hz.
net.cell_types['L5_pyramidal'].p_syn['gabaa']['tau2'] = 2
dpls = simulate_dipole(net, n_trials=1, postproc=True)
dpls = simulate_dipole(net, n_trials=1)
dpls = [dpl.scale(scaling_factor) for dpl in dpls] # scale in place

fig, axes = plt.subplots(3, 1, sharex=True, figsize=(6, 6),
constrained_layout=True)
Expand Down
2 changes: 1 addition & 1 deletion hnn_core/tests/conftest.py
Expand Up @@ -74,7 +74,7 @@ def pytest_runtest_setup(item):
def run_hnn_core_fixture():
def _run_hnn_core_fixture(backend=None, n_procs=None, n_jobs=1,
reduced=False, record_vsoma=False,
record_isoma=False, postproc=True,
record_isoma=False, postproc=False,
electrode_array=None):
hnn_core_root = op.dirname(hnn_core.__file__)

Expand Down
12 changes: 10 additions & 2 deletions hnn_core/tests/test_dipole.py
Expand Up @@ -26,8 +26,16 @@ def test_dipole(tmpdir, run_hnn_core_fixture):
dipole = Dipole(times, data)
dipole._baseline_renormalize(params['N_pyr_x'], params['N_pyr_y'])
dipole._convert_fAm_to_nAm()

# test smoothing and scaling
dipole_raw = dipole.copy()
dipole.scale(params['dipole_scalefctr'])
dipole.smooth(window_len=params['dipole_smooth_win'])
with pytest.raises(AssertionError):
assert_allclose(dipole.data['agg'], dipole_raw.data['agg'])
assert_allclose(dipole.data['agg'],
(params['dipole_scalefctr'] * dipole_raw.smooth(
params['dipole_smooth_win']).data['agg']))

dipole.plot(show=False)
plot_dipole([dipole, dipole], show=False)
Expand All @@ -48,10 +56,10 @@ def test_dipole(tmpdir, run_hnn_core_fixture):
"average of 2 trials"):
dipole_avg = average_dipoles([dipole_avg, dipole_read])

# test postproc
# XXX all below to be deprecated in 0.3
dpls_raw, net = run_hnn_core_fixture(backend='joblib', n_jobs=1,
reduced=True, record_isoma=True,
record_vsoma=True, postproc=False)
record_vsoma=True)
# test deprecation of postproc
with pytest.warns(DeprecationWarning,
match='The postproc-argument is deprecated'):
Expand Down
2 changes: 1 addition & 1 deletion hnn_core/tests/test_parallel_backends.py
Expand Up @@ -157,7 +157,7 @@ def test_compare_hnn_core(self, run_hnn_core_fixture, backend, n_jobs=1):
dpl_master = loadtxt('dpl.txt')

dpls, net = run_hnn_core_fixture(backend=backend)
dpl = dpls[0]
dpl = dpls[0].smooth(30).scale(3000)

# write the dipole to a file and compare
fname = './dpl2.txt'
Expand Down

0 comments on commit 50f3c7a

Please sign in to comment.