# Prepare Python environment
import scipy.io as sio
import numpy as np
from pathlib import Path
data_dir = Path("../../../data/06-MT-03-MTsat")
data_file = "sim2.mat"
#Load either archived or generated plot variables
mat_contents = sio.loadmat(data_dir / data_file)
Mz_after = np.squeeze(mat_contents["Mz_after"])
delta_Mz_T1relax = np.squeeze(mat_contents["delta_Mz_T1relax"])
Mz_before = np.squeeze(mat_contents["Mz_before"])
M0_remainingTR_free = np.squeeze(mat_contents["M0_remainingTR_free"])
delta_Mz_T1relax_remaining = np.squeeze(mat_contents["delta_Mz_T1relax_remaining"])
x=np.arange(1,len(Mz_before)+1)
y1 = (1-(Mz_after)/Mz_before)*100
y2 = (1-(Mz_after-delta_Mz_T1relax)/Mz_before)*100
# Plot Figure 1
# Module imports
import matplotlib.pyplot as plt
import plotly as py
import plotly.graph_objs as go
import numpy as np
from plotly import __version__
from plotly.subplots import make_subplots
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
config={'showLink': False, 'displayModeBar': False}
init_notebook_mode(connected=True)
# PYTHON CODE
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.
## Setup for plots
fig = make_subplots(rows=1, cols=1, horizontal_spacing = 0.1)
fig.add_trace(
go.Scatter(
x=x,
y=y1,
hoverinfo = 'y',
visible=True,
name='MTsat before T1 correction'
)
)
fig.add_trace(
go.Scatter(
x=x,
y=y2,
hoverinfo = 'y',
visible=True,
name='MTsat after T1 correction'
)
)
layout = go.Layout(
width=600,
height=500,
margin=go.layout.Margin(
l=60,
r=30,
b=60,
t=60,
),
legend={
"x": 0.3,
"y": 0.9,
"xref": "paper",
"yref": "paper",
},
xaxis=dict(
showgrid=True,
gridcolor='rgb(169,169,169)',
linecolor='black',
linewidth=2,
title='Repetition #'
),
yaxis=dict(
showgrid=True,
gridcolor='rgb(169,169,169)',
linecolor='black',
linewidth=2,
title="\"MTsat\" (%)"
),
)
fig.update_layout(layout)
iplot(fig, filename = 'fig4.html', config = config)
Loading...