import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
# TODO: deal with the issue that the plot doesn't regenerate (ie isn't alive)
# Unless the code is updated.
metable = pd.read_csv('https://docs.google.com/spreadsheets/d/1WERojJyxFoqcg_tndUm5Kj0H1UfUc9Ban0jFGGfPaBk/export?gid=0&format=csv',
                       header=0)
TEs = [metable.TE1.mean(), metable.TE2.mean(), metable.TE3.mean(), metable.TE4.mean(), metable.TE5.mean()]
TE_labels = ['TE1', 'TE2', 'TE3', 'TE4', 'TE5']
plt.bar([1, 2, 3, 4, 5], TEs)
plt.title('Echo Times', fontsize=18)
pub_count = metable.TE1.count()
plt.text(0.5,60, 'Average from {} studies'.format(pub_count))
plt.xlabel('Echo Number')
plt.ylabel('Echo Time (ms)')
plt.show()


plt.hist(metable.TR.to_numpy())
plt.title('Repetition Times', fontsize = 18)
plt.xlabel('Repetition Time (s)')
plt.ylabel('Count')
plt.show()


x_vox = metable.x.to_numpy()
y_vox = metable.y.to_numpy()
z_vox = metable.z.to_numpy()
plt.hist(np.nanmean([x_vox, y_vox, z_vox],0))
plt.title('Voxel Dimensions', fontsize = 18)
plt.xlabel('Average Voxel dimension (mm)')
plt.ylabel('Count')
plt.show()