MCPcopy
hub / github.com/black0017/MedicalZooPytorch / show_mid_slice

Function show_mid_slice

lib/visual3D_temp/viz_2d.py:6–28  ·  view source on GitHub ↗

Accepts an 3D numpy array and shows median slices in all three planes :param img_numpy:

(img_numpy, return_views=False)

Source from the content-addressed store, hash-verified

4
5
6def 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
31def show_slices(slices):

Callers 3

create_2d_viewsFunction · 0.85

Calls 1

show_slicesFunction · 0.85

Tested by

no test coverage detected