File size: 3,610 Bytes
631d564
 
 
291559f
631d564
 
 
 
 
 
 
 
291559f
 
 
 
631d564
 
 
 
291559f
 
 
 
 
 
 
631d564
 
291559f
 
 
 
 
 
 
631d564
 
291559f
 
 
 
 
 
 
 
631d564
 
 
 
291559f
 
631d564
 
 
 
 
 
 
291559f
 
 
631d564
 
 
 
291559f
 
 
631d564
 
 
 
 
 
291559f
631d564
 
 
 
 
 
 
 
 
 
291559f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import streamlit as st
import pandas as pd
import os
from glob import glob

# Function to get list of document IDs
def get_document_ids():
    # Assuming 'abc' is the folder containing documents
    document_ids = [file.split('_')[0] for file in os.listdir('abc') if file.endswith('.png')]
    return list(set(document_ids))

# Function to load image based on selected document ID and page number
def load_image(image_path, document_id, page_number):
    im_path = f"{image_path}{document_id}-{page_number-1}.png"
    if os.path.exists(im_path):
        return im_path
    else:
        return None

# Function to load dataframe based on selected document ID
def load_dataframe(auto_csv_path, document_id, page_number, cols):
    csv_path = glob(f'{auto_csv_path}*{document_id}*auto.csv')
    print(csv_path)
    if len(csv_path)>0:
        auto_df = pd.read_csv(csv_path[0])
        auto_df_page = auto_df[auto_df['Page#']==page_number][cols]
        return auto_df_page
    else:
        return None
    
def path_setting(inbound_df_path):
    auto_csv_path = 'PhaseData/Batch1/NLP_batch/'
    image_path = 'PhaseData/Data/output/images/'
    inbound_df = pd.read_csv(inbound_df_path)
    pif_list = list(inbound_df.pif_key.values)
    return pif_list, image_path, auto_csv_path

def main():
    inbound_df_path = 'inbound_issues_tempus_2_q2.csv'
    display_cols = ['Biomarker Name Source', 'Biomarker Test Type', 'NLP Result','NLP Value', 'NLP Variant', 
                    'Biomarker Test Result Value Numeric 1', 'Biomarker Test Result Value Unit 1', 
                    'Biomarker Test Result Value Numeric 2', 'Biomarker Test Result Value Unit 2', 
                    'Biomarker Test Threshold Value Numeric 1', 'Biomarker Test Threshold Value Unit1', 
                    'Biomarker Test Threshold Value Numeric 2', 'Biomarker Test Threshold Value Unit2']
    pif_list, image_path, auto_csv_path = path_setting(inbound_df_path)
    
    st.set_page_config(layout="wide")  # Set layout to wide

    # Slider to adjust the width of the columns
    col1_width = st.sidebar.slider("Width of First Column", 0.1, 10.0, 1.0, 0.1)
    col2_width = st.sidebar.slider("Width of Second Column", 0.1, 10.0, 6.5, 0.1)
    col3_width = st.sidebar.slider("Width of Third Column", 0.1, 10.0, 5.0, 0.1)

    # Divide the screen into three vertical panels with specified widths
    col1, col2, col3 = st.columns([col1_width, col2_width, col3_width])

    # Document Selection Panel
    with col1:
        st.write("### Document Selection")
        document_id = st.selectbox("Select Document ID", options=pif_list)
        pages = [int(i.split('-')[-1].split('.')[0]) for i in glob(f"{image_path}{document_id}*.png")]
        page_number = st.number_input("Page Number", min_value=1, max_value=len(pages), step=1, value=1)

    # Display Image Panel
    with col2:
        st.write("### Display Image")
        im_path = load_image(image_path, document_id, page_number)
        if im_path:
            st.image(im_path)
        else:
            st.write("Image not found")

    # Display DataFrame Panel
    with col3:
        st.write("### Display DataFrame")
        df = load_dataframe(auto_csv_path, document_id, page_number, display_cols)
        if df is not None:
            columns_to_display = st.multiselect("Select Columns to Display", df.columns)
            if len(columns_to_display) > 0:
                st.write(df[columns_to_display])
            else:
                st.write("No columns selected")
        else:
            st.write("DataFrame not found")

if __name__ == "__main__":
    main()