[Python] How to load image data with JupyterLab in UBK-RAP

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have buied a project which contains fundus images in UK-Biobank. And I want to load them in UKB-RAP with JupyterLab so that I can use the images to do my work. How to achieve it?

    For example, I know the entity is participant, I know the name is p21015_i0_a0, I know the eid is 1234567, and I know the folder_path is Assessment centre/Eye measures/Retinal optical coherence tomography. How to load it to JupyterLab?

    The JupyterLab is provided by "DNAnexus Platform", I want to load image from UKB to it.

    Some informations about p21015_i0_a0 are attached, maybe useful. [​IMG]

    [​IMG]

    Additionally, I know a way to load phenotype data, as follows. But how to load bulk(image) data with JupyterLab?

    #Step 1. Get the file containing all available data-fields in your Dataset by running the following command:
    import dxpy
    import subprocess

    # Automatically discover dispensed dataset ID and load the dataset
    dispensed_dataset_id = dxpy.find_one_data_object(typename='Dataset', name='app*.dataset', folder='/', name_mode='glob')['id']

    # Get project ID
    project_id = dxpy.find_one_project()["id"]
    dataset = (':').join([project_id, dispensed_dataset_id])

    cmd = ["dx", "extract_dataset", dataset, "-ddd", "--delimiter", ","]
    subprocess.check_call(cmd)
    #The above command will generate 3 *.csv files, and the *.dataset.data_dictionary.csv file contains full information about all available data-fields (the field names are in the second column).


    #Step 2. Collect all data-field names of interest, and write them into a variable field_names_protein. Here is an example collecting all proteins.
    import os
    import glob

    path = os.getcwd()

    data_dict_csv = glob.glob(os.path.join(path, "*.data_dictionary.csv"))[0]
    data_dict_df = pd.read_csv(data_dict_csv)
    data_dict_df.head()

    field_names = list(
    data_dict_df.loc[data_dict_df["entity"] == "olink_instance_0", "name"].values
    )

    field_names_str = [f"olink_instance_0.{f}" for f in field_names]
    field_names_protein = ",".join(field_names_str)


    #Step 3. Extract the data using dx extract_dataset command.
    cmd = ['dx',
    'extract_dataset',
    dataset,
    '--fields',
    field_names_protein,
    '--delimiter',
    ',',
    '--output',
    <filename.csv>,
    ]
    subprocess.check_call(cmd)


    Any suggestions will be useful for me. Thanks. :)

    Continue reading...

Compartilhe esta Página