esmrmb-educational/plotComparativeTimes.py

39 lines
1.2 KiB
Python
Raw Normal View History

2024-06-25 13:59:36 +00:00
import scipy.io as sio
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.gridspec as gridspec
import matplotlib.cm as cm
from mpl_toolkits.axes_grid1 import make_axes_locatable
imagesPath=['T2_CPMG','T2_APCPMG', 'T2_APCP', 'T2_CP', 'T1']
sliceRep = 12
vmin = 0
vmax = 200
nMaps = len(imagesPath)
fig = plt.figure(figsize=(1, 5), dpi=500)
gs1 = gridspec.GridSpec(1, nMaps)
gs1.update(wspace=0.020, hspace=0.020)
for i in range(nMaps):
if 'T1' in imagesPath[i]:
mat_data = sio.loadmat(imagesPath[i]+'.mat')
data = mat_data['t1map']
print(data.shape)
else:
mat_data = sio.loadmat(imagesPath[i]+'.mat')
data = mat_data['t2map']
print(data.shape)
ax1 = plt.subplot(gs1[i])
ax1.set_xticklabels([])
ax1.set_yticklabels([])
ax1.set_aspect('equal')
dataAux = data[sliceRep, :, :]
imgPlot = ax1.imshow(abs(dataAux),vmin=vmin, vmax=vmax)
ax1.axis('off')
ax1.set_title(imagesPath[i], fontsize=4)
cbar_ax = fig.add_axes([0.92, 0.35, 0.01, 0.30])
norm = plt.Normalize(vmin=vmin, vmax=vmax)
cbar = plt.colorbar(cm.ScalarMappable(norm=norm, cmap=cm.viridis), cax=cbar_ax)
cbar.set_label('Time [ms]', fontsize=2)
cbar.ax.tick_params(labelsize=2)
plt.show()