hlnicholls commited on
Commit
3e69fcb
1 Parent(s): 4e44c6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -24,7 +24,7 @@ def get_slice_location(dicom_file):
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 from 00002067")
28
 
29
  # Check if the directory exists
30
  if os.path.exists(single_image_directory):
@@ -47,7 +47,7 @@ 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 with slider")
51
 
52
  # Check if the directory exists
53
  if os.path.exists(multiple_images_directory):
@@ -74,7 +74,7 @@ if os.path.exists(multiple_images_directory):
74
  st.pyplot(fig)
75
 
76
  # Automatic image display section
77
- st.header("Automatic Image Display - view animated images (click start)")
78
  placeholder = st.empty() # Placeholder for the images
79
 
80
  # Initialize session state for animation control
@@ -95,6 +95,13 @@ if os.path.exists(multiple_images_directory):
95
  if st.button("Resume Animation"):
96
  st.session_state.animation_running = True
97
 
 
 
 
 
 
 
 
98
  # Run the animation loop if running
99
  if st.session_state.animation_running:
100
  while st.session_state.animation_running and st.session_state.current_index < len(dicom_images):
 
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 from folder 00002067")
28
 
29
  # Check if the directory exists
30
  if os.path.exists(single_image_directory):
 
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 from 00007FA6")
51
 
52
  # Check if the directory exists
53
  if os.path.exists(multiple_images_directory):
 
74
  st.pyplot(fig)
75
 
76
  # Automatic image display section
77
+ st.header("Automatic Image Display (click start)")
78
  placeholder = st.empty() # Placeholder for the images
79
 
80
  # Initialize session state for animation control
 
95
  if st.button("Resume Animation"):
96
  st.session_state.animation_running = True
97
 
98
+ # Display the current image based on the state
99
+ with placeholder:
100
+ fig, ax = plt.subplots()
101
+ ax.imshow(dicom_images[st.session_state.current_index], cmap='gray')
102
+ ax.axis('off')
103
+ st.pyplot(fig)
104
+
105
  # Run the animation loop if running
106
  if st.session_state.animation_running:
107
  while st.session_state.animation_running and st.session_state.current_index < len(dicom_images):