mirror of
https://gitlab.tugraz.at/ibi/projects/julia-pfitzer/esmrmb-educational.git
synced 2024-11-22 01:32:24 +00:00
46 lines
1.4 KiB
Python
46 lines
1.4 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
|
||
|
|
||
|
# PD
|
||
|
mat_data_0=sio.loadmat('PD.mat')
|
||
|
img = mat_data_0['image3D']
|
||
|
vmin = np.min(np.abs(img))
|
||
|
vmax = np.max(np.abs(img))
|
||
|
|
||
|
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(np.abs(img),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('PD [a.u.]', fontsize=2)
|
||
|
cbar.ax.tick_params(labelsize=2)
|
||
|
plt.show()
|