mirror of
https://gitlab.tugraz.at/ibi/projects/julia-pfitzer/esmrmb-educational.git
synced 2024-11-24 18:42:26 +00:00
52 lines
No EOL
1.5 KiB
Python
52 lines
No EOL
1.5 KiB
Python
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
|
|
|
|
# Map
|
|
rawName = 'T2_CPMG.mat'
|
|
mat_data_0=sio.loadmat(rawName)
|
|
if 'T1' in rawName:
|
|
tmap = mat_data_0['t1map']
|
|
else:
|
|
tmap = mat_data_0['t2map']
|
|
print(np.min(tmap))
|
|
print(np.max(tmap))
|
|
vmin = 0
|
|
vmax = 200
|
|
|
|
def multiSlicePlot(data,nRow, nCol, nSlrep, vmin, vmax, sliceInit = 0):
|
|
"""""
|
|
data = imageMatrix3D [sl,ph,rd]
|
|
nRow, nCol dimensions of the multislicePlot
|
|
nSlRep = number of slices to represent
|
|
sliceInit = slice in wihich we start representing
|
|
"""""
|
|
images = []
|
|
fig = plt.figure(figsize=(nRow, nCol), dpi=500)
|
|
gs1 = gridspec.GridSpec(nRow, nCol)
|
|
gs1.update(wspace=0.020, hspace=0.020) # set the spacing between axes.
|
|
for i in range(nSlrep):
|
|
ii = i + sliceInit
|
|
# print(ii)
|
|
ax1 = plt.subplot(gs1[i])
|
|
# plt.axis('off')
|
|
ax1.set_xticklabels([])
|
|
ax1.set_yticklabels([])
|
|
ax1.set_aspect('equal')
|
|
dataAux = data[int(ii), :, :]
|
|
imgPlot = ax1.imshow(dataAux,vmin=vmin, vmax=vmax)
|
|
images.append(imgPlot)
|
|
ax1.axis('off')
|
|
return fig
|
|
|
|
fig = multiSlicePlot(tmap,3,6,16,vmin,vmax,0)
|
|
|
|
cbar_ax = fig.add_axes([0.92, 0.15, 0.01, 0.7])
|
|
norm = plt.Normalize(vmin=vmin, vmax=vmax)
|
|
cbar = plt.colorbar(cm.ScalarMappable(norm=norm, cmap=cm.viridis), cax=cbar_ax)
|
|
cbar.set_label(rawName+ '[ms]', fontsize=2)
|
|
cbar.ax.tick_params(labelsize=2)
|
|
plt.show() |