def test_assign_complex_attr(self): """ Test scientific methods are executed """ default_cortex = surfaces.Cortex.from_file() default_cortex.coupling_strength = 0.0121 self.assertTrue(default_cortex.local_connectivity is None) grey_matter = surfaces.LocalConnectivity(load_default=True, surface=default_cortex, cutoff=2) default_cortex.local_connectivity = grey_matter default_cortex.compute_local_connectivity() self.assertTrue(default_cortex.local_connectivity is not None)
def test_assign_complex_attr(self): """ Test scientific methods are executed """ local_coupling_strength = 0.0121 grey_matter = surfaces.LocalConnectivity(cutoff=10.0) default_cortex = surfaces.Cortex(coupling_strength=local_coupling_strength) #self.assertTrue(default_cortex.local_connectivity is None) default_cortex.local_connectivity = grey_matter #default_cortex.region_average = default_cortex.region_mapping default_cortex.compute_local_connectivity() self.assertTrue(default_cortex.local_connectivity is not None)
def cdata2local_connectivity(local_connectivity_data, meta, storage_path, expected_length=0): """ From a CData entry in CFF, create LocalConnectivity entity. """ ##### expected_length = cortex.region_mapping.shape[0] tmpdir = os.path.join( gettempdir(), local_connectivity_data.parent_cfile.get_unique_cff_name()) LOG.debug("Using temporary folder for Local Connectivity import: " + tmpdir) _zipfile = ZipFile(local_connectivity_data.parent_cfile.src, 'r', ZIP_DEFLATED) local_connectivity_path = _zipfile.extract(local_connectivity_data.src, tmpdir) gid = dao.get_last_data_with_uid(meta[constants.KEY_SURFACE_UID], surfaces.CorticalSurface) surface_data = ABCAdapter.load_entity_by_gid(gid) local_connectivity = surfaces.LocalConnectivity() local_connectivity.storage_path = storage_path local_connectivity_data = read_matlab_data(local_connectivity_path, constants.DATA_NAME_LOCAL_CONN) if local_connectivity_data.shape[0] < expected_length: padding = sparse.csc_matrix( (local_connectivity_data.shape[0], expected_length - local_connectivity_data.shape[0])) local_connectivity_data = sparse.hstack( [local_connectivity_data, padding]) padding = sparse.csc_matrix( (expected_length - local_connectivity_data.shape[0], local_connectivity_data.shape[1])) local_connectivity_data = sparse.vstack( [local_connectivity_data, padding]) local_connectivity.equation = None local_connectivity.matrix = local_connectivity_data local_connectivity.surface = surface_data uid = meta[constants.KEY_UID] if constants.KEY_UID in meta else None if os.path.isdir(tmpdir): shutil.rmtree(tmpdir) return local_connectivity, uid
def test_cortexdata(self): dt = surfaces.Cortex() ## Initialize Local Connectivity, to avoid long computation time. reader = readers.File(folder_path="surfaces/cortex_reg13") dt.local_connectivity = surfaces.LocalConnectivity() dt.local_connectivity.matrix = reader.read_data("nearest_neighbour.mat", "LocalCoupling") dt.configure() summary_info = dt.summary_info self.assertTrue(abs(summary_info['Region area, maximum (mm:math:`^2`)'] - 9119.4540365252615) < 0.00000001) self.assertTrue(abs(summary_info['Region area, mean (mm:math:`^2`)'] - 3366.2542250541251) < 0.00000001) self.assertTrue(abs(summary_info['Region area, minimum (mm:math:`^2`)'] - 366.48271886512993) < 0.00000001) self.assertEqual(dt.get_data_shape('vertices'), (16384, 3)) self.assertEqual(dt.get_data_shape('vertex_normals'), (16384, 3)) self.assertEqual(dt.get_data_shape('triangles'), (32760, 3))
def test_cortexdata(self): dt = surfaces.Cortex(load_default=True) self.assertTrue(isinstance(dt, surfaces.Cortex)) self.assertTrue(dt.region_mapping is not None) ## Initialize Local Connectivity, to avoid long computation time. dt.local_connectivity = surfaces.LocalConnectivity(load_default=True) dt.configure() summary_info = dt.summary_info self.assertTrue( abs(summary_info['Region area, maximum (mm:math:`^2`)'] - 9119.4540365252615) < 0.00000001) self.assertTrue( abs(summary_info['Region area, mean (mm:math:`^2`)'] - 3366.2542250541251) < 0.00000001) self.assertTrue( abs(summary_info['Region area, minimum (mm:math:`^2`)'] - 366.48271886512993) < 0.00000001) self.assertEqual(dt.get_data_shape('vertices'), (16384, 3)) self.assertEqual(dt.get_data_shape('vertex_normals'), (16384, 3)) self.assertEqual(dt.get_data_shape('triangles'), (32760, 3))
def test_localconnectivity(self): dt = surfaces.LocalConnectivity() self.assertTrue(dt.surface is None)
#Initialise an Integrator heunint = integrators.HeunDeterministic(dt=2**-4) #Initialise some Monitors with period in physical time mon_tavg = monitors.TemporalAverage(period=2**-2) mon_savg = monitors.SpatialAverage(period=2**-2) mon_eeg = monitors.EEG(period=2**-2) #Bundle them what_to_watch = (mon_tavg, mon_savg, mon_eeg) #Initialise a surface local_coupling_strength = numpy.array([0.0121]) grey_matter = surfaces.LocalConnectivity(equation=equations.Gaussian(), cutoff=60.0) grey_matter.equation.parameters['sigma'] = 10.0 grey_matter.equation.parameters['amp'] = 0.0 default_cortex = surfaces.Cortex(local_connectivity=grey_matter, coupling_strength=local_coupling_strength) #Define the stimulus eqn_t = equations.Gaussian() eqn_t.parameters["amp"] = 0.0 eqn_t.parameters["midpoint"] = 8.0 eqn_x = equations.Gaussian() eqn_x.parameters["amp"] = -0.0625 eqn_x.parameters["sigma"] = 28.0