Accepts an 3D numpy array and shows median slices in all three planes :param img_numpy:
(img_numpy, return_views=False)
| 4 | |
| 5 | |
| 6 | def show_mid_slice(img_numpy, return_views=False): |
| 7 | """ |
| 8 | Accepts an 3D numpy array and shows median slices in all three planes |
| 9 | :param img_numpy: |
| 10 | """ |
| 11 | assert img_numpy.ndim == 3, "please provide a 3d numpy image" |
| 12 | n_i, n_j, n_k = img_numpy.shape |
| 13 | |
| 14 | # saggital |
| 15 | center_i1 = int((n_i - 1) / 2) |
| 16 | # transversecreate_2d_views |
| 17 | center_j1 = int((n_j - 1) / 2) |
| 18 | # axial slice |
| 19 | center_k1 = int((n_k - 1) / 2) |
| 20 | |
| 21 | if return_views == False: |
| 22 | show_slices([img_numpy[center_i1, :, :], |
| 23 | img_numpy[:, center_j1, :], |
| 24 | img_numpy[:, :, center_k1]]) |
| 25 | else: |
| 26 | return (img_numpy[center_i1, :, :], |
| 27 | img_numpy[:, center_j1, :], |
| 28 | img_numpy[:, :, center_k1]) |
| 29 | |
| 30 | |
| 31 | def show_slices(slices): |
no test coverage detected