Skip to content

Commit

Permalink
Use more descriptive boolean variables
Browse files Browse the repository at this point in the history
  • Loading branch information
fepegar committed Oct 11, 2018
1 parent 3b91e25 commit b15bedb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions niftynet/layer/rand_spatial_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,21 @@ def _get_sigma(self, zoom):
sigma = np.sqrt(variance)
return sigma

def _apply_transformation(self, image, interp_order=3, antialiasing=True):
def _apply_transformation(self, image, interp_order=3, smooth=True):
if interp_order < 0:
return image
assert self._rand_zoom is not None
full_zoom = np.array(self._rand_zoom)
while len(full_zoom) < image.ndim:
full_zoom = np.hstack((full_zoom, [1.0]))
smooth = all(full_zoom[:3] < 1) # perform smoothing if undersampling
if smooth:
is_undersampling = all(full_zoom[:3] < 1)
run_antialiasing_filter = smooth and is_undersampling
if run_antialiasing_filter:
sigma = self._get_sigma(full_zoom[:3])
if image.ndim == 4:
output = []
for mod in range(image.shape[-1]):
if smooth and antialiasing:
if run_antialiasing_filter:
original_resolution = ndi.gaussian_filter(
image[..., mod], sigma)
else:
Expand All @@ -69,7 +70,7 @@ def _apply_transformation(self, image, interp_order=3, antialiasing=True):
output.append(scaled[..., np.newaxis])
return np.concatenate(output, axis=-1)
elif image.ndim == 3:
if smooth and antialiasing:
if run_antialiasing_filter:
original_resolution = ndi.gaussian_filter(
image, sigma)
else:
Expand Down

0 comments on commit b15bedb

Please sign in to comment.