Adrit Rao commited on
Commit
e9f7fd2
1 Parent(s): 3318510

Add application file

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -1,4 +1,27 @@
1
  import streamlit as st
 
 
2
 
3
- x = st.slider('Select a value')
4
- st.write(x, 'squared is', x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import pydicom
3
+ import matplotlib.pyplot as plt
4
 
5
+ # Streamlit app title
6
+ st.title("DICOM Image Viewer")
7
+
8
+ # Upload a DICOM file
9
+ uploaded_file = st.file_uploader("Upload a DICOM file", type=["dcm"])
10
+
11
+ if uploaded_file is not None:
12
+ try:
13
+ # Read the uploaded DICOM file
14
+ dicom_data = pydicom.dcmread(uploaded_file)
15
+
16
+ # Display the DICOM image
17
+ plt.imshow(dicom_data.pixel_array, cmap=plt.cm.bone)
18
+ plt.axis("off")
19
+ plt.title("DICOM Image")
20
+ plt.tight_layout()
21
+
22
+ # Show the image in the Streamlit app
23
+ st.pyplot(plt)
24
+ except Exception as e:
25
+ st.error(f"Error: {str(e)}")
26
+
27
+ st.write("Upload a DICOM file to view the image.")