Update utils.py
Browse files
utils.py
CHANGED
|
@@ -13,6 +13,18 @@ import zipfile
|
|
| 13 |
import subprocess
|
| 14 |
import nibabel as nib
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
def convert_dicom_zip_to_nifti(zip_file):
|
| 17 |
"""
|
| 18 |
Takes a uploaded ZIP file containing DICOM files.
|
|
|
|
| 13 |
import subprocess
|
| 14 |
import nibabel as nib
|
| 15 |
|
| 16 |
+
SKIP_KEYWORDS = ["localizer", "scout", "loc"]
|
| 17 |
+
|
| 18 |
+
for nifti_file in sorted(nifti_files):
|
| 19 |
+
sequence_name = nifti_file.replace(".nii.gz", "")
|
| 20 |
+
|
| 21 |
+
# Skip localizer images
|
| 22 |
+
if any(skip in sequence_name.lower() for skip in SKIP_KEYWORDS):
|
| 23 |
+
print(f"Skipping localizer: {sequence_name}")
|
| 24 |
+
continue
|
| 25 |
+
|
| 26 |
+
nifti_path = os.path.join(nifti_dir, nifti_file)
|
| 27 |
+
|
| 28 |
def convert_dicom_zip_to_nifti(zip_file):
|
| 29 |
"""
|
| 30 |
Takes a uploaded ZIP file containing DICOM files.
|