dosma.core.numpy_routines.stack¶
- dosma.core.numpy_routines.stack(xs, axis: int = - 1)[source]¶
Stack medical images across non-spatial dimensions.
Images will be auto-oriented to the orientation of the first medical volume.
- Parameters
xs (array-like[MedicalVolume]) – 1D array-like of aligned medical images to stack.
axis (int, optional) – Axis to stack along.
- Returns
The stacked medical image.
- Return type
Note
Unlike NumPy, the default stacking axis is
-1.Note
Headers are not set unless all inputs have headers of the same shape. This functionality may change in the future.
Examples
>>> mv = dm.MedicalVolume([[[0,1,2,3]]], affine=np.eye(4)) >>> np.stack([mv, mv], axis=-1) # Stacks along last axis. MedicalVolume(volume=[[[[0 0], [1 1], [2 2], [3 3]]]])