dosma.core.numpy_routines.clip¶
- dosma.core.numpy_routines.clip(x, x_min, x_max, **kwargs)[source]¶
Clip the values in the array.
Same as applying
numpy.clip()onx.volume. Only one ofx_minorx_maxcan beNone.- Parameters
x (MedicalVolume) – Medical image to clip.
x_min (array-like or
MedicalVolume) – Minimum value. IfNone, clipping is not performed on this edge.x_max (array-like or
MedicalVolume) – Maximum value. IfNone, clipping is not performed on this edge.kwargs – Optional keyword arguments, see
numpy.clip().
- Returns
The clipped medical image.
- Return type
Note
The
outpositional argument is not currently supported.Examples
>>> mv = MedicalVolume([[[0,1,2,3,4,5,6,7,8,9]]], affine=np.eye(4)) >>> np.clip(mv, 1, 5) # Clip values between [1, 5] MedicalVolume(volume=[[[1 1 2 3 4 5 5 5 5 5]]]) >>> np.clip(mv, x_max=5) # Clip values between (-inf, 5] MedicalVolume(volume=[[[0 1 2 3 4 5 5 5 5 5]]])