Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -124,7 +124,7 @@ def extract_middle_slices(nifti_path, output_image_path, slice_size=180, center=
|
|
124 |
|
125 |
# Compute or reuse the center of mass
|
126 |
if center is None:
|
127 |
-
com = center_of_mass(
|
128 |
center = np.round(com).astype(int)
|
129 |
|
130 |
# Define half the slice size
|
@@ -151,9 +151,9 @@ def extract_middle_slices(nifti_path, output_image_path, slice_size=180, center=
|
|
151 |
return padded_slice
|
152 |
|
153 |
# Extract slices
|
154 |
-
axial_slice = extract_2d_slice(
|
155 |
-
coronal_slice = extract_2d_slice(
|
156 |
-
sagittal_slice = extract_2d_slice(
|
157 |
|
158 |
# Apply rotations
|
159 |
axial_slice = np.rot90(axial_slice, k=-1)
|
|
|
124 |
|
125 |
# Compute or reuse the center of mass
|
126 |
if center is None:
|
127 |
+
com = center_of_mass(resampled_data > 0)
|
128 |
center = np.round(com).astype(int)
|
129 |
|
130 |
# Define half the slice size
|
|
|
151 |
return padded_slice
|
152 |
|
153 |
# Extract slices
|
154 |
+
axial_slice = extract_2d_slice(resampled_data, center, axis=2)
|
155 |
+
coronal_slice = extract_2d_slice(resampled_data, center, axis=1)
|
156 |
+
sagittal_slice = extract_2d_slice(resampled_data, center, axis=0)
|
157 |
|
158 |
# Apply rotations
|
159 |
axial_slice = np.rot90(axial_slice, k=-1)
|