Spaces:
Sleeping
Sleeping
add
Browse files- app.py +8 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -3,8 +3,8 @@ import nibabel as nib
|
|
3 |
import pydicom
|
4 |
import os
|
5 |
|
6 |
-
def convert(input):
|
7 |
-
# if linux
|
8 |
path = input.name
|
9 |
print("Zip file path:", path)
|
10 |
|
@@ -20,6 +20,12 @@ def convert(input):
|
|
20 |
assert [f.endswith('.dcm') for f in dicom_files], 'Dicom folder must contain only .dcm files'
|
21 |
|
22 |
print("This is the list of files in the folder:", os.listdir(path))
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
gr.Interface(
|
|
|
3 |
import pydicom
|
4 |
import os
|
5 |
|
6 |
+
def convert(input):
|
7 |
+
# if linux
|
8 |
path = input.name
|
9 |
print("Zip file path:", path)
|
10 |
|
|
|
20 |
assert [f.endswith('.dcm') for f in dicom_files], 'Dicom folder must contain only .dcm files'
|
21 |
|
22 |
print("This is the list of files in the folder:", os.listdir(path))
|
23 |
+
# create an output file that has the same name as the input file but with a .nii.gz extension
|
24 |
+
output_file = os.path.join(path, os.path.basename(path) + '.nii.gz')
|
25 |
+
dicom2nifti.dicom_series_to_nifti(path, output_file, reorient_nifti=True)
|
26 |
+
print("Nifti file path:", output_file)
|
27 |
+
|
28 |
+
return output_file
|
29 |
|
30 |
|
31 |
gr.Interface(
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
nibabel
|
2 |
gradio
|
3 |
pydicom
|
|
|
|
1 |
nibabel
|
2 |
gradio
|
3 |
pydicom
|
4 |
+
dicom2nifti
|