def setup_method(self): oscillator = models.Generic2dOscillator() white_matter = connectivity.Connectivity.from_file( 'connectivity_%d.zip' % (self.n_regions, )) white_matter.speed = numpy.array([self.speed]) white_matter_coupling = coupling.Difference(a=self.coupling_a) heunint = integrators.HeunStochastic( dt=2**-4, noise=noise.Additive(nsig=numpy.array([ 2**-10, ]))) mons = ( monitors.EEG.from_file(period=self.period), monitors.MEG.from_file(period=self.period), monitors.iEEG.from_file(period=self.period), ) local_coupling_strength = numpy.array([2**-10]) region_mapping = RegionMapping.from_file('regionMapping_16k_%d.txt' % (self.n_regions, )) default_cortex = Cortex(region_mapping_data=region_mapping, load_default=True) default_cortex.coupling_strength = local_coupling_strength self.sim = simulator.Simulator(model=oscillator, connectivity=white_matter, coupling=white_matter_coupling, integrator=heunint, monitors=mons, surface=default_cortex) self.sim.configure()
def configure(self, dt=2**-3, model=models.Generic2dOscillator, speed=4.0, coupling_strength=0.00042, method="HeunDeterministic", surface_sim=False, default_connectivity=True): """ Create an instance of the Simulator class, by default use the generic plane oscillator local dynamic model and the deterministic version of Heun's method for the numerical integration. """ self.method = method if default_connectivity: white_matter = connectivity.Connectivity(load_default=True) # NOTE: This is the default region mapping should consider changing the name. region_mapping = RegionMapping.from_file( source_file= "cortex_reg13/region_mapping/o52r00_irp2008_hemisphere_both_subcortical_false_regions_74.txt.bz2" ) else: white_matter = connectivity.Connectivity.from_file( source_file="connectivity_190.zip") region_mapping = RegionMapping.from_file( source_file= "cortex_reg13/region_mapping/o52r00_irp2008_hemisphere_both_subcortical_true_regions_190.txt.bz2" ) white_matter_coupling = coupling.Linear(a=coupling_strength) white_matter.speed = speed dynamics = model() if method[-10:] == "Stochastic": hisss = noise.Additive(nsig=numpy.array([2**-11])) integrator = eval("integrators." + method + "(dt=dt, noise=hisss)") else: integrator = eval("integrators." + method + "(dt=dt)") if surface_sim: local_coupling_strength = numpy.array([2**-10]) default_cortex = Cortex(load_default=True, region_mapping_data=region_mapping) default_cortex.coupling_strength = local_coupling_strength default_cortex.local_connectivity = LocalConnectivity( load_default=default_connectivity, surface=default_cortex) else: default_cortex = None # Order of monitors determines order of returned values. self.sim = simulator.Simulator(model=dynamics, connectivity=white_matter, coupling=white_matter_coupling, integrator=integrator, monitors=self.monitors, surface=default_cortex) self.sim.configure()
def test_assign_complex_attr(self): """ Test scientific methods are executed """ default_cortex = Cortex(load_file="cortex_16384.zip") default_cortex.coupling_strength = 0.0121 assert default_cortex.local_connectivity is None # default_cortex.local_connectivity = surfaces.LocalConnectivity(cutoff=2, surface=default_cortex) # default_cortex.compute_local_connectivity() # self.assertTrue(default_cortex.local_connectivity is not None) default_lc = LocalConnectivity( cutoff=2, load_file="local_connectivity_16384.mat") other_cortex = Cortex(local_connectivity=default_lc) assert other_cortex.local_connectivity is not None
def configure(self, dt=2 ** -3, model=models.Generic2dOscillator, speed=4.0, coupling_strength=0.00042, method="HeunDeterministic", surface_sim=False, default_connectivity=True): """ Create an instance of the Simulator class, by default use the generic plane oscillator local dynamic model and the deterministic version of Heun's method for the numerical integration. """ self.method = method if default_connectivity: white_matter = Connectivity(load_file="connectivity_76.zip") region_mapping = RegionMapping(load_file="regionMapping_16k_76.txt") else: white_matter = Connectivity(load_file="connectivity_192.zip") region_mapping = RegionMapping(load_file="regionMapping_16k_192.txt") white_matter_coupling = coupling.Linear(a=coupling_strength) white_matter.speed = speed dynamics = model() if method[-10:] == "Stochastic": hisss = noise.Additive(nsig=numpy.array([2 ** -11])) integrator = eval("integrators." + method + "(dt=dt, noise=hisss)") else: integrator = eval("integrators." + method + "(dt=dt)") if surface_sim: local_coupling_strength = numpy.array([2 ** -10]) default_cortex = Cortex(region_mapping_data=region_mapping, load_file="cortex_16384.zip") default_cortex.coupling_strength = local_coupling_strength default_cortex.local_connectivity = LocalConnectivity(load_file="local_connectivity_16384.mat") else: default_cortex = None # Order of monitors determines order of returned values. self.sim = simulator.Simulator(model=dynamics, connectivity=white_matter, coupling=white_matter_coupling, integrator=integrator, monitors=self.monitors, surface=default_cortex) self.sim.configure()
def setup_method(self): oscillator = models.Generic2dOscillator() white_matter = connectivity.Connectivity(load_file='connectivity_' + str(self.n_regions) + '.zip') white_matter.speed = numpy.array([self.speed]) white_matter_coupling = coupling.Difference(a=self.coupling_a) heunint = integrators.HeunStochastic( dt=2**-4, noise=noise.Additive(nsig=numpy.array([ 2**-10, ]))) mons = ( monitors.EEG(projection=ProjectionMatrix( load_file='projection_eeg_65_surface_16k.npy'), sensors=SensorsEEG(load_file="eeg_brainstorm_65.txt"), period=self.period), monitors.MEG( projection=ProjectionMatrix( load_file='projection_meg_276_surface_16k.npy'), sensors=SensorsMEG(load_file='meg_brainstorm_276.txt'), period=self.period), monitors.iEEG(projection=ProjectionMatrix( load_file='projection_seeg_588_surface_16k.npy'), sensors=SensorsInternal(load_file='seeg_588.txt'), period=self.period), ) local_coupling_strength = numpy.array([2**-10]) region_mapping = RegionMapping(load_file='regionMapping_16k_' + str(self.n_regions) + '.txt') default_cortex = Cortex( region_mapping_data=region_mapping, load_file="cortex_16384.zip" ) #region_mapping_file="regionMapping_16k_192.txt") default_cortex.coupling_strength = local_coupling_strength self.sim = simulator.Simulator(model=oscillator, connectivity=white_matter, coupling=white_matter_coupling, integrator=heunint, monitors=mons, surface=default_cortex) self.sim.configure()
#Bundle them what_to_watch = (mon_tavg, mon_savg, mon_eeg) #Initialise a surface: #First define the function describing the "local" connectivity. grey_matter = LocalConnectivity(cutoff=40.0) grey_matter.equation.parameters['sigma'] = 10.0 grey_matter.equation.parameters['amp'] = 1.0 #then a scaling factor, to adjust the strength of the local connectivity local_coupling_strength = numpy.array([-0.0115]) #finally, create a default cortex that includes the custom local connectivity. default_cortex = Cortex(load_default=True) default_cortex.local_connectivity = grey_matter default_cortex.coupling_strength = local_coupling_strength #Initialise Simulator -- Model, Connectivity, Integrator, Monitors, and surface. sim = simulator.Simulator(model=oscillator, connectivity=white_matter, integrator=heunint, monitors=what_to_watch, surface=default_cortex) sim.configure() LOG.info("Starting simulation...") #Perform the simulation tavg_data = [] tavg_time = [] savg_data = [] savg_time = []