Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.y_shift_voxel_range is not None:
ty = np.random.uniform(-self.y_shift_voxel_range, self.y_shift_voxel_range)
if self.z_shift_voxel_range is not None:
tz = np.random.uniform(-self.z_shift_voxel_range, self.z_shift_voxel_range)
transforms.append(shift_voxels(tx, ty, tz))
final_transform = apply_offset(combine_transforms(transforms), x, y, z)
voxelgrid = apply_transform(voxelgrid, final_transform, channel_axis, fill_mode=self.fill_mode, cval=self.cval)
if self.x_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, x_axis)
if self.y_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, y_axis)
if self.z_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, z_axis)
return voxelgrid
final_transform = apply_offset(combine_transforms(transforms), x, y, z)
voxelgrid = apply_transform(voxelgrid, final_transform, channel_axis, fill_mode=self.fill_mode, cval=self.cval)
if self.x_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, x_axis)
if self.y_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, y_axis)
if self.z_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, z_axis)
return voxelgrid
if self.z_shift_voxel_range is not None:
tz = np.random.uniform(-self.z_shift_voxel_range, self.z_shift_voxel_range)
transforms.append(shift_voxels(tx, ty, tz))
final_transform = apply_offset(combine_transforms(transforms), x, y, z)
voxelgrid = apply_transform(voxelgrid, final_transform, channel_axis, fill_mode=self.fill_mode, cval=self.cval)
if self.x_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, x_axis)
if self.y_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, y_axis)
if self.z_flip:
if np.random.random() < 0.5:
voxelgrid = flip_axis(voxelgrid, z_axis)
return voxelgrid