ants.ops.slice_image

slice_image(image, axis, idx, collapse_strategy=0)[source]

Slice an image.

Parameters:
  • axis (int) – Which axis.

  • idx (int) – Which slice number.

  • collapse_strategy (int) – Collapse strategy for sub-matrix: 0, 1, or 2. 0: collapse to sub-matrix if positive-definite. Otherwise throw an exception. Default. 1: Collapse to identity. 2: Collapse to sub-matrix if positive definite. Otherwise collapse to identity.

Example

>>> import ants
>>> mni = ants.image_read(ants.get_data('mni'))
>>> mni2 = ants.slice_image(mni, axis=1, idx=100)