Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -69,6 +69,14 @@ def convert_dicom_to_png(dicom_data, output_dir, index):
|
|
69 |
f.write(img_buffer.read())
|
70 |
return output_path
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
if uploaded_zip_file is not None:
|
73 |
try:
|
74 |
install_dependencies()
|
@@ -85,9 +93,8 @@ if uploaded_zip_file is not None:
|
|
85 |
with zipfile.ZipFile(uploaded_zip_file, "r") as zip_ref:
|
86 |
zip_ref.extractall(temp_dir)
|
87 |
|
88 |
-
#
|
89 |
-
dicom_files =
|
90 |
-
dicom_files.sort() # Sort the files
|
91 |
|
92 |
if len(dicom_files) == 0:
|
93 |
st.error("No DICOM files found in the ZIP archive.")
|
|
|
69 |
f.write(img_buffer.read())
|
70 |
return output_path
|
71 |
|
72 |
+
def find_dicom_files(directory):
|
73 |
+
dicom_files = []
|
74 |
+
for root, _, files in os.walk(directory):
|
75 |
+
for file in files:
|
76 |
+
if file.endswith(".dcm"):
|
77 |
+
dicom_files.append(os.path.join(root, file))
|
78 |
+
return dicom_files
|
79 |
+
|
80 |
if uploaded_zip_file is not None:
|
81 |
try:
|
82 |
install_dependencies()
|
|
|
93 |
with zipfile.ZipFile(uploaded_zip_file, "r") as zip_ref:
|
94 |
zip_ref.extractall(temp_dir)
|
95 |
|
96 |
+
# Find DICOM files in the directory, including subdirectories
|
97 |
+
dicom_files = find_dicom_files(temp_dir)
|
|
|
98 |
|
99 |
if len(dicom_files) == 0:
|
100 |
st.error("No DICOM files found in the ZIP archive.")
|