Skip to content

Commit

Permalink
ENH: change random seed for each trial
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmainak committed May 14, 2019
1 parent ade7bb1 commit 48dd967
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/plot_simulate_evoked.py
Expand Up @@ -35,7 +35,7 @@
# Now let's simulate the dipole
# You can simulate multiple trials in parallel by using n_jobs > 1
net = Network(params)
dpls = simulate_dipole(net, n_jobs=1, n_trials=2)
dpls = simulate_dipole(net, n_jobs=3, n_trials=3)

###############################################################################
# and then plot it
Expand Down
7 changes: 5 additions & 2 deletions mne_neuron/dipole.py
Expand Up @@ -16,13 +16,16 @@ def _hammfilt(x, winsz):
return convolve(x, win, 'same')


def _simulate_single_trial(params):
def _simulate_single_trial(params, trial_idx):
"""Simulate one trial."""
from .parallel import rank, pc, cvode
from .network import Network

from neuron import h
h.load_file("stdrun.hoc")

if trial_idx != 1:
params['prng_*'] = trial_idx
net = Network(params, n_jobs=1)

# global variables, should be node-independent
Expand Down Expand Up @@ -114,7 +117,7 @@ def simulate_dipole(net, n_trials=1, n_jobs=1):
The dipole object or list of dipole objects if n_trials > 1
"""
parallel, myfunc = _parallel_func(_simulate_single_trial, n_jobs=n_jobs)
dpl = parallel(myfunc(net.params) for _ in range(n_trials))
dpl = parallel(myfunc(net.params, idx) for idx in range(n_trials))

return dpl

Expand Down

0 comments on commit 48dd967

Please sign in to comment.