Exemple #1
0
def import_surface_rm(project_id, conn_gid):
    # Import surface and region mapping from tvb_data berlin subjects (68 regions)
    rm_file = try_get_absolute_path("tvb_data", "berlinSubjects/DH_20120806/DH_20120806_RegionMapping.txt")
    surface_zip_file = try_get_absolute_path("tvb_data", "berlinSubjects/DH_20120806/DH_20120806_Surface_Cortex.zip")

    surface_importer = ABCAdapter.build_adapter_from_class(ZIPSurfaceImporter)
    surface_imp_model = ZIPSurfaceImporterModel()
    surface_imp_model.uploaded = surface_zip_file
    surface_imp_operation = fire_operation(project_id, surface_importer, surface_imp_model)
    surface_imp_operation = wait_to_finish(surface_imp_operation)

    surface_gid = dao.get_results_for_operation(surface_imp_operation.id)[0].gid
    rm_importer = ABCAdapter.build_adapter_from_class(RegionMappingImporter)
    rm_imp_model = RegionMappingImporterModel()
    rm_imp_model.mapping_file = rm_file
    rm_imp_model.surface = surface_gid
    rm_imp_model.connectivity = conn_gid
    rm_import_operation = fire_operation(project_id, rm_importer, rm_imp_model)
    wait_to_finish(rm_import_operation)
Exemple #2
0
    def import_surface_zip(user, project, zip_path, surface_type, zero_based=True, same_process=True):

        count = dao.count_datatypes(project.id, SurfaceIndex)

        view_model = ZIPSurfaceImporterModel()
        view_model.uploaded = zip_path
        view_model.should_center = True
        view_model.zero_based_triangles = zero_based
        view_model.surface_type = surface_type
        TestFactory.launch_importer(ZIPSurfaceImporter, view_model, user, project, same_process)

        return TestFactory._assert_one_more_datatype(project, SurfaceIndex, count)
Exemple #3
0
def launch_operation_examples(tvb_client_instance):
    logger.info("Requesting projects for logged user")
    projects_of_user = tvb_client_instance.get_project_list()
    assert len(projects_of_user) > 0
    logger.info("TVB has {} projects for this user".format(len(projects_of_user)))

    project_gid = projects_of_user[0].gid

    # --- Launch operations to import a Connectivity, a Surface and a RegionMapping ---

    logger.info("Importing a connectivity from ZIP...")
    zip_connectivity_importer_model = ZIPConnectivityImporterModel()
    zip_connectivity_importer_model.uploaded = compute_tvb_data_path('connectivity', 'connectivity_96.zip')
    zip_connectivity_importer_model.normalization = 'region'
    operation_gid = tvb_client_instance.launch_operation(project_gid, ZIPConnectivityImporter,
                                                         zip_connectivity_importer_model)
    monitor_operation(tvb_client_instance, operation_gid)

    logger.info("Get the result of connectivity import...")
    connectivity_dto = tvb_client_instance.get_operation_results(operation_gid)[0]

    logger.info("Importing a surface from ZIP...")
    zip_surface_importer_model = ZIPSurfaceImporterModel()
    zip_surface_importer_model.uploaded = compute_tvb_data_path('surfaceData', 'cortex_16384.zip')
    zip_surface_importer_model.surface_type = CORTICAL
    zip_surface_importer_model.should_center = False
    operation_gid = tvb_client_instance.launch_operation(project_gid, ZIPSurfaceImporter, zip_surface_importer_model)
    monitor_operation(tvb_client_instance, operation_gid)

    logger.info("Get the result of surface import...")
    surface_dto = tvb_client_instance.get_operation_results(operation_gid)[0]

    logger.info("Importing a region mapping...")
    rm_importer_model = RegionMappingImporterModel()
    rm_importer_model.mapping_file = compute_tvb_data_path('regionMapping', 'regionMapping_16k_76.txt')
    rm_importer_model.connectivity = connectivity_dto.gid
    rm_importer_model.surface = surface_dto.gid
    operation_gid = tvb_client_instance.launch_operation(project_gid, RegionMappingImporter, rm_importer_model)
    monitor_operation(tvb_client_instance, operation_gid)

    logger.info("Get the result of region mapping import...")
    region_mapping_dto = tvb_client_instance.get_operation_results(operation_gid)[0]

    # --- Load the region mapping together with references information in 3 different ways ---

    logger.info("1.Download and load the region mapping with all its references...")
    region_mapping_complete = tvb_client_instance.load_datatype_with_full_references(region_mapping_dto.gid,
                                                                                     tvb_client_instance.temp_folder)
    logger.info("1.This region mapping is linked to a connectivity with GID={} and number_of_regions={}".format(
        region_mapping_complete.connectivity.gid, region_mapping_complete.connectivity.number_of_regions))

    logger.info("2.Download and load the region mapping with only GIDs for its references...")
    region_mapping_with_links = tvb_client_instance.load_datatype_with_links(region_mapping_dto.gid,
                                                                             tvb_client_instance.temp_folder)
    logger.info("2.This region mapping is linked to a connectivity with GID={}".format(
        region_mapping_with_links.connectivity.gid))

    logger.info("3.Only download the region mapping on client machine...")
    region_mapping_path = tvb_client_instance.retrieve_datatype(region_mapping_dto.gid, tvb_client_instance.temp_folder)

    logger.info("3.Load the region mapping that was already downloaded on client machine...")
    local_region_mapping_with_links = tvb_client_instance.load_datatype_from_file(region_mapping_path)
    logger.info("3.This region mapping is linked to a connectivity with GID={}".format(
        local_region_mapping_with_links.connectivity.gid))

    # --- Launch operation to run a Degree Analyzer over the Connectivity ---

    bct_model = BaseBCTModel()
    bct_model.connectivity = connectivity_dto.gid
    operation_gid = tvb_client_instance.launch_operation(project_gid, Degree, bct_model)
    monitor_operation(tvb_client_instance, operation_gid)

    logger.info("Get the result of BCT...")
    bct_dto = tvb_client_instance.get_operation_results(operation_gid)[0]
    logger.info("The resulted BCT has GID={}".format(bct_dto.gid))
Exemple #4
0
    logger.info("Launching connectivity uploading operation...")
    operation_gid = tvb_client.launch_operation(project_gid, ZIPConnectivityImporter, connectivity_view_model)

    while True:
        status = tvb_client.get_operation_status(operation_gid)
        if status in [STATUS_FINISHED, STATUS_CANCELED, STATUS_ERROR]:
            break
        time.sleep(5)
    logger.info("The connectivity uploading has finished with status: {}".format(status))

    logger.info("Requesting the result of the connectivity uploading...")
    connectivity_result = tvb_client.get_operation_results(operation_gid)[0]

    logger.info("Preparing a surface H5 file...")
    surface_view_model = ZIPSurfaceImporterModel()
    surface_zip_path = os.path.join(os.path.dirname(tvb_data.__file__), 'surfaceData', 'cortex_16384.zip')
    surface_view_model.uploaded = surface_zip_path
    surface_view_model.surface_type = "Cortical Surface"
    surface_view_model.should_center = False

    logger.info("Launching surface uploading operation...")
    operation_gid = tvb_client.launch_operation(project_gid, ZIPSurfaceImporter, surface_view_model)

    while True:
        status = tvb_client.get_operation_status(operation_gid)
        if status in [STATUS_FINISHED, STATUS_CANCELED, STATUS_ERROR]:
            break
        time.sleep(5)
    logger.info("The surface uploading has finished with status: {}".format(status))
Exemple #5
0
    # --- Launch operations to import a Connectivity, a Surface and a RegionMapping ---

    logger.info("Importing a connectivity from ZIP...")
    zip_connectivity_importer_model = ZIPConnectivityImporterModel()
    zip_connectivity_importer_model.uploaded = compute_tvb_data_path(
        'connectivity', 'connectivity_96.zip')
    zip_connectivity_importer_model.normalization = 'region'
    operation_gid = tvb_client.launch_operation(
        project_gid, ZIPConnectivityImporter, zip_connectivity_importer_model)
    monitor_operation(tvb_client, operation_gid)

    logger.info("Get the result of connectivity import...")
    connectivity_dto = tvb_client.get_operation_results(operation_gid)[0]

    logger.info("Importing a surface from ZIP...")
    zip_surface_importer_model = ZIPSurfaceImporterModel()
    zip_surface_importer_model.uploaded = compute_tvb_data_path(
        'surfaceData', 'cortex_16384.zip')
    zip_surface_importer_model.surface_type = CORTICAL
    zip_surface_importer_model.should_center = False
    operation_gid = tvb_client.launch_operation(project_gid,
                                                ZIPSurfaceImporter,
                                                zip_surface_importer_model)
    monitor_operation(tvb_client, operation_gid)

    logger.info("Get the result of surface import...")
    surface_dto = tvb_client.get_operation_results(operation_gid)[0]

    logger.info("Importing a region mapping...")
    rm_importer_model = RegionMappingImporterModel()
    rm_importer_model.mapping_file = compute_tvb_data_path(