Skip to article frontmatterSkip to article content
# Prepare Python environment

import scipy.io as sio
from pathlib import Path

data_dir = Path("../../../data/02-T1-03-MP2RAGE")
data_file = "fig1.mat"

#Load either archived or generated plot variables
mat_contents = sio.loadmat(data_dir / data_file)

T1matrix = mat_contents["T1matrix"]
B1_vector = mat_contents["B1_vector"][0]
MP2RAGE_vector = mat_contents["MP2RAGE_vector"][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)

# 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.

trace5 = go.Heatmap(x = MP2RAGE_vector,
                   y = B1_vector,
                   z=T1matrix,
                   zmin=0,
                   zmax=5,
                   colorscale='Portland',
                   xaxis='x2',
                   yaxis='y2',
                   visible=True,
                   name = 'T1 values (ms)')

data=[trace5]

layout = dict(
    width=560,
    height=345,
    margin = dict(
                t=40,
                r=50,
                b=50,
                l=80),
    annotations=[
         dict(
            x=-0.14,
            y=0.5,
            showarrow=False,
            text='B<sub>1</sub> values',
            font=dict(
                family='Times New Roman',
                size=22
            ),
            textangle=-90,
            xref='paper',
            yref='paper'
        ),
          dict(
            x=0.5,
            y=-0.2,
            showarrow=False,
            text='S<sub>MP2RAGE</sub> values',
            font=dict(
                family='Times New Roman',
                size=22
            ),
            xref='paper',
            yref='paper'
        ),
        dict(
            x=0.5,
            y=1.15,
            showarrow=False,
            text='Lookup Table',
            font=dict(
                family='Times New Roman',
                size=26
            ),
            xref='paper',
            yref='paper'
        ),
        dict(
            x=1.17,
            y=1.15,
            showarrow=False,
            text='T<sub>1</sub> (ms)',
            font=dict(
                family='Times New Roman',
                size=20
            ),
            xref='paper',
            yref='paper'
        ),
    ],
    xaxis = dict(range = [0,1], autorange = False,
             showgrid = False, zeroline = False, showticklabels = False,
             ticks = '', domain=[0, 0.5]),
    yaxis = dict(range = [0,1], autorange = False,
             showgrid = False, zeroline = False, showticklabels = False,
             ticks = '', domain=[0, 1]),
    showlegend = False,
    autosize = False,
)


fig = dict(data=data, layout=layout)

iplot(fig, filename = 'basic-heatmap', config = config)
Loading...