Skip to content

Commit a796971

Browse files
committed
Integrate comments
Fix device check Change assert to raise ValueError
1 parent 5aa514c commit a796971

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

brainles_preprocessing/brain_extraction/synthstrip.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,18 @@ def _conform(self, input_nii: Nifti1Image) -> Nifti1Image:
7070
Args:
7171
input_nii (Nifti1Image): Input NIfTI image to conform.
7272
73+
Raises:
74+
ValueError: If the input NIfTI image does not have a valid affine.
75+
7376
Returns:
7477
A new NIfTI image with conformed shape and affine.
7578
"""
7679

7780
shape = np.array(input_nii.shape[:3])
7881
affine = input_nii.affine
7982

80-
assert affine is not None, "Input NIfTI image must have a valid affine."
83+
if affine is None:
84+
raise ValueError("Input NIfTI image must have a valid affine.")
8185

8286
# Get corner voxel centers in index coords
8387
corner_centers_ijk = (
@@ -181,7 +185,7 @@ def extract(
181185
device = torch.device(device) if isinstance(device, str) else device
182186
model = self._setup_model(device=device)
183187

184-
if device == "cpu" and num_threads > 0:
188+
if device.type == "cpu" and num_threads > 0:
185189
torch.set_num_threads(num_threads)
186190

187191
# normalize intensities

0 commit comments

Comments
 (0)