Neemah commited on
Commit
cafb0db
·
verified ·
1 Parent(s): 37eb66c

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +8 -12
utils.py CHANGED
@@ -13,18 +13,6 @@ import zipfile
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.
@@ -32,6 +20,8 @@ def convert_dicom_zip_to_nifti(zip_file):
32
  Returns list of (sequence_name, PIL Image) tuples.
33
  """
34
 
 
 
35
  # Step 1: Setup temp directories
36
  unique_id = uuid.uuid4().hex
37
  tmp_dir = f"/tmp/dicom_{unique_id}"
@@ -66,6 +56,12 @@ def convert_dicom_zip_to_nifti(zip_file):
66
 
67
  for nifti_file in sorted(nifti_files):
68
  sequence_name = nifti_file.replace(".nii.gz", "")
 
 
 
 
 
 
69
  nifti_path = os.path.join(nifti_dir, nifti_file)
70
 
71
  try:
 
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.
 
20
  Returns list of (sequence_name, PIL Image) tuples.
21
  """
22
 
23
+ SKIP_KEYWORDS = ["localizer", "scout", "loc"]
24
+
25
  # Step 1: Setup temp directories
26
  unique_id = uuid.uuid4().hex
27
  tmp_dir = f"/tmp/dicom_{unique_id}"
 
56
 
57
  for nifti_file in sorted(nifti_files):
58
  sequence_name = nifti_file.replace(".nii.gz", "")
59
+
60
+ # Skip localizer images
61
+ if any(skip in sequence_name.lower() for skip in SKIP_KEYWORDS):
62
+ print(f"Skipping localizer: {sequence_name}")
63
+ continue
64
+
65
  nifti_path = os.path.join(nifti_dir, nifti_file)
66
 
67
  try: