forked from crocodoyle/deep-mri-qc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataviz.py
77 lines (49 loc) · 1.66 KB
/
dataviz.py
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
73
74
75
76
77
import h5py
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import nibabel as nib
workdir = '/data1/data/deepqc/'
from vis.utils import utils
from keras import activations
import imageio
import os
def gif_my_brain(input_file):
t1_image = nib.load(input_file).get_data()
print(t1_image.shape)
plt.imshow(t1_image[:, int(t1_image.shape[1]/2), :], cmap='gray')
plt.tight_layout()
plt.axis('off')
plt.savefig('E:/brains/andrew.png')
x_range, y_range, z_range = t1_image.shape
for y in range(y_range):
plt.imshow(t1_image[:, int(y), :], cmap='gray')
plt.axis('off')
plt.savefig('E:/brains/andrew/' + str(y) + '.png', bbox_inches='tight')
images = []
for y in range(202, 56, -1):
images.append(imageio.imread('E:/brains/andrew/' + str(y) + '.png'))
for y in range(56, 202):
images.append(imageio.imread('E:/brains/andrew/' + str(y) + '.png'))
imageio.mimsave('E:/brains/andrew/andrew.gif', images)
def rename_abide(input_path, output_path):
for file in os.listdir(input_path):
print(file)
tokens = file.split('+')
id = tokens[1]
print(id)
os.rename(input_path + file, output_path + id[2:] + '.mnc')
def visualize_fail_regions():
pass
if __name__ == '__main__':
gif_my_brain('E:/brains/andrew_mri_nov_2015.nii.gz')
# rename_abide('E:/abide1/natives/', 'E:/abide1/abide/')
# f = h5py.File(workdir + 'deepqc.hdf5')
#
# images = f['MRI']
#
# for i, image in enumerate(images):
# filename = workdir + str(i) + '.png'
#
# plt.imshow(image[96, ...])
# plt.savefig(filename)