forked from Rimehdaoudi/Tumour-Segmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplay.py
More file actions
72 lines (62 loc) · 2.37 KB
/
Display.py
File metadata and controls
72 lines (62 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Import the required libraries.
import matplotlib.pyplot as plt
from nilearn import plotting
# Create the Image Display class.
class ImageDisplay(object):
# Class Constructor.
def __init__(self, ImageDirectory=" ", MaskDirectory=" "):
self.imageDir = ImageDirectory
self.maskDir = MaskDirectory
# Basic anatomical plot of the three image planes.
def anatomicalPlot(self, image):
plotting.plot_anat(
image,
cut_coords=[0, 0, 0],
draw_cross=False,
annotate=False
)
plotting.plot_anat(
image,
cut_coords=(-10, 0, 0),
draw_cross=False,
annotate=False
)
plotting.show()
# Overlay the image mask with the original image.
def overlayMask(self, image, mask):
plotting.plot_roi(
mask,
image,
cut_coords=[0, 0, 0],
annotate=False,
draw_cross=False
)
plotting.show()
# Create the function to display a single image.
def displayImages(self, dataFile, numImages, startSlice, incSlices):
fig, ax = plt.subplots(1, numImages, figsize=[18, 6])
self.img = self.image.loadImage(self.imageDir + dataFile)
self.imageData = self.img.get_fdata()
# Loop through the parameter range.
for i in range(numImages):
ax[i].imshow(self.imageData[startSlice, :, :], 'gray')
ax[i].set_xticks([])
ax[i].set_yticks([])
ax[i].set_title('Slice number: {}'.format(startSlice), color='r')
startSlice += incSlices
# Show the images.
fig.subplots_adjust(wspace=0, hspace=0)
plt.show()
# Copy of previous function but intakes a resampled image object.
def displayResampledImage(self, image, numImages, startSlice, incSlices):
fig, ax = plt.subplots(1, numImages, figsize=[18, 6])
# Loop through the parameter range.
for i in range(numImages):
ax[i].imshow(image[startSlice, :, :], 'gray')
ax[i].set_xticks([])
ax[i].set_yticks([])
ax[i].set_title('Slice number: {}'.format(startSlice), color='r')
startSlice += incSlices
# Show the images.
fig.subplots_adjust(wspace=0, hspace=0)
plt.show()