File size: 2,800 Bytes
e83143a
 
 
 
66b5fa9
 
e83143a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66b5fa9
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import mahotas as mh
import pandas as pd
import plotly.express as px
import urllib.request
from skimage import io

# Define a list of medical conditions
conditions = [
    {"name": "Depression", "test_for": "Patient Health Questionnaire-9 (PHQ-9)"},
    {"name": "Anxiety", "test_for": "Generalized Anxiety Disorder-7 (GAD-7)"},
    {"name": "Diabetes", "test_for": "Hemoglobin A1C test"},
    {"name": "Hypertension", "test_for": "Blood pressure measurement"},
    {"name": "Asthma", "test_for": "Pulmonary function test"},
    {"name": "Cancer", "test_for": "Biopsy or imaging tests (e.g., CT scan, MRI)"},
    {"name": "Arthritis", "test_for": "X-ray, MRI, or ultrasound"},
    {"name": "Heart disease", "test_for": "Electrocardiogram (ECG)"},
    {"name": "Obesity", "test_for": "Body mass index (BMI)"},
    {"name": "Substance use disorder", "test_for": "Substance Abuse Subtle Screening Inventory (SASSI)"}
]

# Define a function to process images using Mahotas
def process_image(image):
    # Convert the image to grayscale
    grayscale_image = mh.colors.rgb2gray(image)
    # Apply a Gaussian filter to the image to reduce noise
    filtered_image = mh.gaussian_filter(grayscale_image, 4)
    # Threshold the image to create a binary image
    binary_image = filtered_image > mh.otsu(filtered_image)
    # Compute the connected components in the binary image
    labels, num_labels = mh.label(binary_image)
    # Compute the size of each connected component
    sizes = mh.labeled.labeled_size(labels)
    # Sort the sizes in descending order
    sorted_sizes = sorted(sizes, reverse=True)
    # Return the top 10 sizes
    return sorted_sizes[:10]

# Define the Streamlit app
def app():
    # Add a title to the app
    st.title("Mahotas Demo")

    # Add a sidebar to the app
    st.sidebar.title("Medical Conditions")
    selected_condition = st.sidebar.selectbox("Select a condition", [c["name"] for c in conditions])

    # Get the selected condition
    condition = next(c for c in conditions if c["name"] == selected_condition)

    # Display the selected condition
    st.header(condition["name"])
    st.write("Test for:", condition["test_for"])

    # Load an example medical image
    if selected_condition == "Depression":
        image_url = "https://i.imgur.com/kPQoD8C.jpg"
    elif selected_condition == "Anxiety":
        image_url = "https://i.imgur.com/ZWyKjJN.jpg"
    elif selected_condition == "Diabetes":
        image_url = "https://i.imgur.com/1gOEMO5.jpg"
    elif selected_condition == "Hypertension":
        image_url = "https://i.imgur.com/BoSUwio.jpg"
    elif selected_condition == "Asthma":
        image_url = "https://i.imgur.com/BLKjzJF.jpg"
    elif selected_condition == "Cancer":
        image_url = "https://i.imgur.com/nq3vV8