Get the spatial shape of `img`. Args: img: an ITK image object loaded from an image file.
(self, img)
| 352 | return affine |
| 353 | |
| 354 | def _get_spatial_shape(self, img): |
| 355 | """ |
| 356 | Get the spatial shape of `img`. |
| 357 | |
| 358 | Args: |
| 359 | img: an ITK image object loaded from an image file. |
| 360 | |
| 361 | """ |
| 362 | sr = itk.array_from_matrix(img.GetDirection()).shape[0] |
| 363 | sr = max(min(sr, 3), 1) |
| 364 | _size = list(itk.size(img)) |
| 365 | if isinstance(self.channel_dim, int): |
| 366 | _size.pop(self.channel_dim) |
| 367 | return np.asarray(_size[:sr]) |
| 368 | |
| 369 | def _get_array_data(self, img): |
| 370 | """ |