Unverified Commit 0a3790a5 authored by Marmaduke Woodman's avatar Marmaduke Woodman Committed by GitHub

Merge pull request #25 from the-virtual-brain/tvb-2586-fix-matlab

Fixes for MATLAB API
parents 3b5c3d54 9d1fba5b
......@@ -7,11 +7,11 @@
tvb_setup
%% Build simulator
model = py.tvb.simulator.models.ReducedWongWang();
RWW = py.tvb_matlab.get_model('ReducedWongWang');
model = RWW();
coupling = py.tvb.simulator.coupling.Linear;
conn = py.tvb.datatypes.connectivity.Connectivity(...
pyargs('load_default', py.True));
noise = py.tvb.simulator.noise.Additive(pyargs('nsig', 1e-4));
conn = py.tvb.datatypes.connectivity.Connectivity.from_file();
noise = py.tvb.simulator.noise.Additive(pyargs('nsig', py.numpy.array({1e-4})));
sim = py.tvb.simulator.simulator.Simulator(pyargs(...
'integrator', py.tvb.simulator.integrators.HeunStochastic(...
......
......@@ -8,15 +8,18 @@ tvb_setup
%% Build simulator
% Create epileptor model.
model = py.tvb.simulator.models.Epileptor();
model = py.tvb.simulator.models.epileptor.Epileptor();
% Difference coupling between nodes' coupling variables
coupling = py.tvb.simulator.coupling.Difference(pyargs('a', 1e-3));
coupling = py.tvb.simulator.coupling.Difference(pyargs('a', py.numpy.array({1e-3})));
% 2 nodes, random connection weights, zero tract lengths
conn = py.tvb.datatypes.connectivity.Connectivity();
conn.weights = py.numpy.random.rand(2, 2);
conn.tract_lengths = py.numpy.zeros([2 2]);
p2 = py.int(2);
conn.weights = py.numpy.random.rand(p2, p2);
conn.tract_lengths = py.numpy.zeros({p2 p2});
conn.region_labels = py.numpy.array({'left' 'right'});
conn.centres = py.numpy.zeros({p2 py.int(3)});
% Noise per state variable
noise = py.tvb.simulator.noise.Additive(...
......@@ -33,14 +36,14 @@ sim = py.tvb.simulator.simulator.Simulator(pyargs(...
'model', model, ...
'coupling', coupling, ...
'connectivity', conn, ...
'monitors', monitor, ...
'monitors', py.list({monitor}), ...
'simulation_length', 5000));
% Perform internal configuration
configure(sim);
% Spatialize epileptor excitability
model.x0 = [-2.0, -1.6];
model.x0 = py.numpy.array([-2.0, -1.6]);
%% Run simulation
monitor_output = run(sim);
......
......@@ -87,7 +87,11 @@ def find_sys_mod_names(root, base):
def unsupport_module(modname):
h5py_path, = find_on_sys_path('h5py')
try:
h5py_path, = find_on_sys_path('h5py')
except ValueError as exc:
print('[TVB] cannot find TVB deps, maybe you have wrong Python interpreter?')
raise exc
h5py_mods = find_sys_mod_names(h5py_path, 'h5py')
sys.modules[modname] = UnsupportedModule(modname)
for submodname in h5py_mods:
......@@ -123,3 +127,13 @@ def run_sim_with_seed(sim, length, seed):
return sim.run(simulation_length=length, random_state=rstate)
except Exception as exc:
print('unable to run: %r' % (exc,))
def get_model(name):
"Return a model class for a name"
# This is required since models are now available in the top
# level model module via module property, which isn't invoked
# when MATLAB looks for stuff in that module, so this is a
# workaround to make it easy to find the model.
import tvb.simulator.models as models
return getattr(models, name)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment