Spaces:
Sleeping
Sleeping
hlnicholls
commited on
Commit
•
e69525e
1
Parent(s):
3684fcf
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,7 @@ import matplotlib.pyplot as plt
|
|
4 |
import os
|
5 |
|
6 |
# Set up the Streamlit app title
|
7 |
-
st.title("
|
8 |
-
|
9 |
|
10 |
# Directory paths where DICOM files are stored
|
11 |
single_image_directory = "00002067/"
|
@@ -23,16 +22,20 @@ def get_slice_location(dicom_file):
|
|
23 |
else:
|
24 |
return 0 # Default to 0 if neither tag is available
|
25 |
|
|
|
|
|
|
|
|
|
26 |
# Display the single DICOM image from the first folder
|
27 |
-
st.header("Single DICOM Image
|
28 |
|
29 |
# Check if the directory exists
|
30 |
if os.path.exists(single_image_directory):
|
31 |
-
# Get
|
32 |
-
single_image_files = [os.path.join(single_image_directory, f) for f in os.listdir(single_image_directory) if
|
33 |
|
34 |
if single_image_files:
|
35 |
-
# Read and display the
|
36 |
ds = pydicom.dcmread(single_image_files[0])
|
37 |
single_image = ds.pixel_array
|
38 |
|
@@ -47,12 +50,12 @@ else:
|
|
47 |
st.write("Directory 00002067 does not exist.")
|
48 |
|
49 |
# Display the multiple DICOM images from the second folder using a slider
|
50 |
-
st.header("Browse Multiple DICOM Images
|
51 |
|
52 |
# Check if the directory exists
|
53 |
if os.path.exists(multiple_images_directory):
|
54 |
-
# Get
|
55 |
-
multiple_image_files = [os.path.join(multiple_images_directory, f) for f in os.listdir(multiple_images_directory) if
|
56 |
|
57 |
if multiple_image_files:
|
58 |
# Sort DICOM files by slice location or image position
|
|
|
4 |
import os
|
5 |
|
6 |
# Set up the Streamlit app title
|
7 |
+
st.title("DICOM Viewer for CBCT Scans")
|
|
|
8 |
|
9 |
# Directory paths where DICOM files are stored
|
10 |
single_image_directory = "00002067/"
|
|
|
22 |
else:
|
23 |
return 0 # Default to 0 if neither tag is available
|
24 |
|
25 |
+
# Debug: List contents of the directories
|
26 |
+
st.write("Contents of directory 00002067:", os.listdir(single_image_directory))
|
27 |
+
st.write("Contents of directory 00007FA6:", os.listdir(multiple_images_directory))
|
28 |
+
|
29 |
# Display the single DICOM image from the first folder
|
30 |
+
st.header("Single DICOM Image")
|
31 |
|
32 |
# Check if the directory exists
|
33 |
if os.path.exists(single_image_directory):
|
34 |
+
# Get all files in the single_image_directory (no extension filtering)
|
35 |
+
single_image_files = [os.path.join(single_image_directory, f) for f in os.listdir(single_image_directory) if os.path.isfile(os.path.join(single_image_directory, f))]
|
36 |
|
37 |
if single_image_files:
|
38 |
+
# Read and display the first DICOM image found
|
39 |
ds = pydicom.dcmread(single_image_files[0])
|
40 |
single_image = ds.pixel_array
|
41 |
|
|
|
50 |
st.write("Directory 00002067 does not exist.")
|
51 |
|
52 |
# Display the multiple DICOM images from the second folder using a slider
|
53 |
+
st.header("Browse Multiple DICOM Images")
|
54 |
|
55 |
# Check if the directory exists
|
56 |
if os.path.exists(multiple_images_directory):
|
57 |
+
# Get all files in the multiple_images_directory (no extension filtering)
|
58 |
+
multiple_image_files = [os.path.join(multiple_images_directory, f) for f in os.listdir(multiple_images_directory) if os.path.isfile(os.path.join(multiple_images_directory, f))]
|
59 |
|
60 |
if multiple_image_files:
|
61 |
# Sort DICOM files by slice location or image position
|