def from_file(source_file="connectivity_76.zip", instance=None): if instance is None: result = Connectivity() else: result = instance source_full_path = try_get_absolute_path("tvb_data.connectivity", source_file) if source_file.endswith(".h5"): reader = H5Reader(source_full_path) result.weights = reader.read_field("weights") result.centres = reader.read_field("centres") result.region_labels = reader.read_field("region_labels") result.orientations = reader.read_optional_field("orientations") result.cortical = reader.read_optional_field("cortical") result.hemispheres = reader.read_field("hemispheres") result.areas = reader.read_optional_field("areas") result.tract_lengths = reader.read_field("tract_lengths") else: reader = ZipReader(source_full_path) result.weights = reader.read_array_from_file("weights") result.centres = reader.read_array_from_file("centres", use_cols=(1, 2, 3)) result.region_labels = reader.read_array_from_file("centres", dtype=numpy.str, use_cols=(0,)) result.orientations = reader.read_optional_array_from_file("average_orientations") result.cortical = reader.read_optional_array_from_file("cortical", dtype=numpy.bool) result.hemispheres = reader.read_optional_array_from_file("hemispheres", dtype=numpy.bool) result.areas = reader.read_optional_array_from_file("areas") result.tract_lengths = reader.read_array_from_file("tract_lengths") return result
def from_file(source_file="nonexistent.zip", instance=None): ''' Borrowed from connectivity.Connectivity - copied here and modified to match filesnames of Berlin connectivity .txts in connectivity.zip (ie orientation.txt rather than average_orientations.txt) :param source_file: :param instance: :return: Connectivity object from source_file. ''' if instance is None: result = connectivity.Connectivity() else: result = instance source_full_path = try_get_absolute_path("tvb_data.connectivity", source_file) reader = ZipReader(source_full_path) result.areas = reader.read_array_from_file("area") result.region_labels = reader.read_array_from_file("centres", dtype=numpy.str, use_cols=(0,)) result.centres = reader.read_array_from_file("centres", use_cols=(1, 2, 3)) result.cortical = reader.read_array_from_file("cortical", dtype=numpy.bool) result.hemispheres = reader.read_array_from_file("hemisphere", dtype=numpy.bool) result.orientations = reader.read_array_from_file("orientation") result.tract_lengths = reader.read_array_from_file("tract") result.weights = reader.read_array_from_file("weights") return result
def from_file(cls, source_file="cortex_16384.zip"): """Construct a Surface from source_file.""" result = cls() source_full_path = try_get_absolute_path("tvb_data.surfaceData", source_file) reader = ZipReader(source_full_path) result.vertices = reader.read_array_from_file("vertices.txt") result.vertex_normals = reader.read_array_from_file("normals.txt") result.triangles = reader.read_array_from_file("triangles.txt", dtype=numpy.int32) return result
def from_file(cls, source_file=os.path.join("cortex_reg13", "surface_cortex_reg13.zip"), instance=None): """ Construct a Surface from source_file. """ if instance is None: result = cls() else: result = instance source_full_path = try_get_absolute_path("tvb_data.surfaceData", source_file) reader = ZipReader(source_full_path) result.vertices = reader.read_array_from_file("vertices.txt") result.vertex_normals = reader.read_array_from_file("normals.txt") result.triangles = reader.read_array_from_file("triangles.txt", dtype=numpy.int32) return result
def from_file(source_file="connectivity_76.zip", instance=None): source_full_path = try_get_absolute_path("tvb_data.connectivity", source_file) if source_file.endswith(".h5"): reader = H5Reader(source_full_path) weights = reader.read_field("weights") centres = reader.read_field("centres") region_labels = reader.read_field("region_labels") orientations = reader.read_optional_field("orientations") cortical = reader.read_optional_field("cortical") hemispheres = reader.read_field("hemispheres") areas = reader.read_optional_field("areas") tract_lengths = reader.read_field("tract_lengths") else: reader = ZipReader(source_full_path) weights = reader.read_array_from_file("weights") if reader.has_file_like("centres"): centres = reader.read_array_from_file("centres", use_cols=(1, 2, 3)) region_labels = reader.read_array_from_file("centres", dtype=numpy.str, use_cols=(0, )) else: centres = reader.read_array_from_file("centers", use_cols=(1, 2, 3)) region_labels = reader.read_array_from_file("centers", dtype=numpy.str, use_cols=(0, )) orientations = reader.read_optional_array_from_file( "average_orientations") cortical = reader.read_optional_array_from_file("cortical", dtype=numpy.bool) hemispheres = reader.read_optional_array_from_file( "hemispheres", dtype=numpy.bool) areas = reader.read_optional_array_from_file("areas") tract_lengths = reader.read_array_from_file("tract_lengths") return weights, centres, region_labels, orientations, cortical, hemispheres, areas, tract_lengths