Neemah commited on
Commit
b3e0730
·
verified ·
1 Parent(s): 2dc49d3

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +6 -6
utils.py CHANGED
@@ -66,13 +66,15 @@ def convert_dicom_zip_to_nifti(zip_file):
66
 
67
  try:
68
  # Load the 3D volume
69
- img_nib = nib.load(nifti_path)
70
- img_nib = nib.as_closest_canonical(img_nib)
71
- volume = img_nib.get_fdata()
72
 
73
  # Extract middle axial slice
74
  mid = volume.shape[2] // 2
75
- slice_2d = volume[:, :, mid]
 
 
 
76
 
77
  # Normalize to 0-255
78
  s_min, s_max = slice_2d.min(), slice_2d.max()
@@ -80,8 +82,6 @@ def convert_dicom_zip_to_nifti(zip_file):
80
  continue
81
 
82
  normalized = (slice_2d - s_min) / (s_max - s_min) * 255
83
- # Rotate to correct display orientation
84
- slice_2d_rotated = np.rot90(normalized)
85
 
86
  image = Image.fromarray(
87
  slice_2d_rotated.astype(np.uint8)
 
66
 
67
  try:
68
  # Load the 3D volume
69
+ img = nib.as_closest_canonical(nifti_path)
70
+ volume = img.get_fdata()
 
71
 
72
  # Extract middle axial slice
73
  mid = volume.shape[2] // 2
74
+ slice_2d = volume[:, :, mid
75
+
76
+ # Rotate to correct display orientation
77
+ slice_2d = np.rot90(slice_2d)
78
 
79
  # Normalize to 0-255
80
  s_min, s_max = slice_2d.min(), slice_2d.max()
 
82
  continue
83
 
84
  normalized = (slice_2d - s_min) / (s_max - s_min) * 255
 
 
85
 
86
  image = Image.fromarray(
87
  slice_2d_rotated.astype(np.uint8)