# Prepare Python environment
import scipy.io as sio
from pathlib import Path
data_dir = Path("../../../data/02-T1-03-MP2RAGE")
data_file = "fig2.mat"
#Load either archived or generated plot variables
mat_contents = sio.loadmat(data_dir / data_file)
T1_map = mat_contents["T1_map"]
S_INV1 = mat_contents["S_INV1"]
S_INV2 = mat_contents["S_INV2"]
B1map = mat_contents["B1map"]
xAxis = mat_contents["xAxis"][0]
yAxis = mat_contents["yAxis"][0]
## Plot
# PYTHON CODE
# Module imports
import matplotlib.pyplot as plt
import chart_studio.plotly as py
import plotly.graph_objs as go
import numpy as np
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
config={'showLink': False, 'displayModeBar': False}
init_notebook_mode(connected=True)
# The polling here is to ensure that plotly.js has already been loaded before
# setting display alignment in order to avoid a race condition.
trace1 = go.Heatmap(x = xAxis,
y = yAxis,
z=S_INV1,
colorscale='Gray',
showscale = False,
visible=False,
name = 'Signal')
trace2 = go.Heatmap(x = xAxis,
y = yAxis,
z=S_INV2,
colorscale='Gray',
showscale = False,
visible=False,
name = 'Signal')
trace3 = go.Heatmap(x = xAxis,
y = yAxis,
z=B1map,
zmin=-0.5,
zmax=0.5,
colorscale='RdBu',
showscale = False,
visible=True,
name = 'S_MP2RAGE')
trace5 = go.Heatmap(x = xAxis,
y = yAxis,
z=T1_map,
zmin=0.0,
zmax=5000,
colorscale='Portland',
xaxis='x2',
yaxis='y2',
visible=True,
name = 'T1 values (ms)')
data=[trace1, trace2, trace3, trace5]
updatemenus = list([
dict(active=2,
x = 0.09,
xanchor = 'left',
y = -0.15,
yanchor = 'bottom',
direction = 'up',
font=dict(
family='Times New Roman',
size=16
),
buttons=list([
dict(label = 'S<sub>INV1</sub>',
method = 'update',
args = [{'visible': [True, False, False, True]},
]),
dict(label = 'S<sub>INV2</sub>',
method = 'update',
args = [{'visible': [False, True, False, True]},
]),
dict(label = 'S<sub>MP2RAGE</sub>',
method = 'update',
args = [{'visible': [False, False, True, True]},
])
])
)
])
layout = dict(
width=560,
height=345,
margin = dict(
t=40,
r=50,
b=10,
l=50),
annotations=[
dict(
x=0.055,
y=1.15,
showarrow=False,
text='Input Data',
font=dict(
family='Times New Roman',
size=26
),
xref='paper',
yref='paper'
),
dict(
x=0.6,
y=1.15,
showarrow=False,
text='T<sub>1</sub> map',
font=dict(
family='Times New Roman',
size=26
),
xref='paper',
yref='paper'
),
dict(
x=1.22,
y=1.15,
showarrow=False,
text='T<sub>1</sub> (ms)',
font=dict(
family='Times New Roman',
size=26
),
xref='paper',
yref='paper'
),
],
xaxis = dict(range = [0,206], autorange = False,
showgrid = False, zeroline = False, showticklabels = False,
ticks = '', domain=[0, 0.58]),
yaxis = dict(range = [0,215], autorange = False,
showgrid = False, zeroline = False, showticklabels = False,
ticks = '', domain=[0, 1]),
xaxis2 = dict(range = [0,206], autorange = False,
showgrid = False, zeroline = False, showticklabels = False,
ticks = '', domain=[0.40, 0.98]),
yaxis2 = dict(range = [0,215], autorange = False,
showgrid = False, zeroline = False, showticklabels = False,
ticks = '', domain=[0, 1], anchor='x2'),
showlegend = False,
autosize = False,
updatemenus=updatemenus
)
fig = dict(data=data, layout=layout)
iplot(fig, filename = 'basic-heatmap', config = config)
Loading...