def launch(self, view_model): # type: (ConnectivityAnnotationsViewModel) -> dict annotations_index = self.load_entity_by_gid(view_model.annotations_index) if view_model.connectivity_index is None: connectivity_index = self.load_entity_by_gid(annotations_index.connectivity_gid) else: connectivity_index = self.load_entity_by_gid(view_model.connectivity_index) if view_model.region_mapping_index is None: region_map = dao.get_generic_entity(RegionMappingIndex, connectivity_index.gid, 'connectivity_gid') if len(region_map) < 1: raise LaunchException( "Can not launch this viewer unless we have at least a RegionMapping for the current Connectivity!") region_mapping_index = region_map[0] else: region_mapping_index = self.load_entity_by_gid(view_model.region_mapping_index) boundary_url = SurfaceURLGenerator.get_url_for_region_boundaries(region_mapping_index.surface_gid, region_mapping_index.gid, self.stored_adapter.id) surface_index = self.load_entity_by_gid(region_mapping_index.surface_gid) surface_h5 = h5.h5_file_for_index(surface_index) assert isinstance(surface_h5, SurfaceH5) url_vertices_pick, url_normals_pick, url_triangles_pick = SurfaceURLGenerator.get_urls_for_pick_rendering( surface_h5) url_vertices, url_normals, _, url_triangles, url_region_map = SurfaceURLGenerator.get_urls_for_rendering( surface_h5, region_mapping_index.gid) params = dict(title="Connectivity Annotations Visualizer", baseUrl=TvbProfile.current.web.BASE_URL, annotationsTreeUrl=URLGenerator.build_url(self.stored_adapter.id, 'tree_json', view_model.annotations_index), urlTriangleToRegion=URLGenerator.build_url(self.stored_adapter.id, "get_triangles_mapping", region_mapping_index.gid), urlActivationPatterns=URLGenerator.paths2url(view_model.annotations_index, "get_activation_patterns"), minValue=0, maxValue=connectivity_index.number_of_regions - 1, urlColors=json.dumps(url_region_map), urlVerticesPick=json.dumps(url_vertices_pick), urlTrianglesPick=json.dumps(url_triangles_pick), urlNormalsPick=json.dumps(url_normals_pick), brainCenter=json.dumps(surface_h5.center()), urlVertices=json.dumps(url_vertices), urlTriangles=json.dumps(url_triangles), urlNormals=json.dumps(url_normals), urlRegionBoundaries=boundary_url) return self.build_display_result("annotations/annotations_view", params, pages={"controlPage": "annotations/annotations_controls"})
def launch(self, view_model): """Construct data for visualization and launch it.""" connectivity = self.load_traited_by_gid(view_model.connectivity) pars = { "labels": json.dumps(connectivity.region_labels.tolist()), "url_base": URLGenerator.paths2url(view_model.connectivity, attribute_name="weights", flatten="True") } return self.build_display_result("connectivity_edge_bundle/view", pars)