hlnicholls commited on
Commit
474642c
1 Parent(s): 35f8a58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -6,8 +6,18 @@ import os
6
  # Set up the Streamlit app title
7
  st.title("DICOM Viewer for CBCT Scans")
8
 
9
- # Directory where DICOM files are stored in the repository
10
- dicom_directory = "./dicom_files/"
 
 
 
 
 
 
 
 
 
 
11
 
12
  # Function to get the slice location or image position for sorting
13
  def get_slice_location(dicom_file):
@@ -21,7 +31,7 @@ def get_slice_location(dicom_file):
21
  else:
22
  return 0 # Default to 0 if neither tag is available
23
 
24
- # Read all DICOM files from the directory
25
  dicom_files = [os.path.join(dicom_directory, f) for f in os.listdir(dicom_directory) if f.endswith('.dcm')]
26
 
27
  if dicom_files:
@@ -35,11 +45,4 @@ if dicom_files:
35
  st.sidebar.header("Image Slider")
36
  image_index = st.sidebar.slider("Select Image Index", 0, len(dicom_images) - 1, 0)
37
 
38
- # Display the selected DICOM image
39
- st.header(f"Displaying Image {image_index + 1} of {len(dicom_images)}")
40
- fig, ax = plt.subplots()
41
- ax.imshow(dicom_images[image_index], cmap='gray')
42
- ax.axis('off')
43
- st.pyplot(fig)
44
- else:
45
- st.write("No DICOM files found in the directory. Please check the folder and try again.")
 
6
  # Set up the Streamlit app title
7
  st.title("DICOM Viewer for CBCT Scans")
8
 
9
+ # Directories where DICOM files are stored
10
+ dicom_directories = {
11
+ "00002067": "./00002067/",
12
+ "00007FA6": "./00007FA6/"
13
+ }
14
+
15
+ # Sidebar for selecting DICOM folder
16
+ st.sidebar.header("Select DICOM Folder")
17
+ selected_folder = st.sidebar.selectbox("Choose a folder to view DICOM files", list(dicom_directories.keys()))
18
+
19
+ # Get the selected directory path
20
+ dicom_directory = dicom_directories[selected_folder]
21
 
22
  # Function to get the slice location or image position for sorting
23
  def get_slice_location(dicom_file):
 
31
  else:
32
  return 0 # Default to 0 if neither tag is available
33
 
34
+ # Get list of DICOM files in the selected directory
35
  dicom_files = [os.path.join(dicom_directory, f) for f in os.listdir(dicom_directory) if f.endswith('.dcm')]
36
 
37
  if dicom_files:
 
45
  st.sidebar.header("Image Slider")
46
  image_index = st.sidebar.slider("Select Image Index", 0, len(dicom_images) - 1, 0)
47
 
48
+ #