diff --git a/_images/index_28_0.png b/_images/index_28_0.png deleted file mode 100644 index d3c9f75..0000000 Binary files a/_images/index_28_0.png and /dev/null differ diff --git a/_images/index_44_0.png b/_images/index_44_0.png deleted file mode 100644 index bd2d6fd..0000000 Binary files a/_images/index_44_0.png and /dev/null differ diff --git a/_images/index_50_0.png b/_images/index_48_0.png similarity index 100% rename from _images/index_50_0.png rename to _images/index_48_0.png diff --git a/index.html b/index.html index 85c0f6b..a67b841 100644 --- a/index.html +++ b/index.html @@ -490,7 +490,7 @@
# Make figure of CSF/SC signal ratio from T2starw scan
@@ -535,12 +535,12 @@ 5 | Process anat/T2starw (GRE)data_stats = []
# Data storage for Plotly
-data_plotly = {}
+t2_data_plotly = {}
# Iterate over each subject and create a subplot
for i, subject in enumerate(subjects):
ax = axes[i]
- data_plotly[subject]={}
+ t2_data_plotly[subject]={}
for shim_mode in shim_modes:
# Initialize list to collect data for this shim method
method_data = []
@@ -571,7 +571,7 @@ 5 | Process anat/T2starw (GRE)# If there's data for this shim method, plot it and compute stats
if method_data:
- data_plotly[subject][shim_mode]=method_data
+ t2_data_plotly[subject][shim_mode]=method_data
# Plotting each file's data separately
for resampled_data in method_data:
@@ -583,7 +583,7 @@ 5 | Process anat/T2starw (GRE)sd_data = np.std(data_sc_csf_ratio)
data_stats.append([subject, shim_mode, mean_data, sd_data])
else:
- data_plotly[subject][shim_mode]=None
+ t2_data_plotly[subject][shim_mode]=None
# Set x-ticks and labels for the bottom subplot
if i == n_rows - 1: # Check if it's the last subplot
@@ -614,207 +614,6 @@ 5 | Process anat/T2starw (GRE)
-
-
# PYTHON CODE
-# Module imports
-
-# Base python
-import os
-from os import path
-from pathlib import Path
-
-# Graphical
-
-import plotly.graph_objs as go
-from IPython.display import display, HTML
-from plotly import __version__
-from plotly.offline import init_notebook_mode, iplot, plot
-config={
- 'showLink': False,
- 'displayModeBar': False,
- 'toImageButtonOptions': {
- 'format': 'png', # one of png, svg, jpeg, webp
- 'filename': 'custom_image',
- 'height': 2500,
- 'width': 500,
- 'scale': 2 # Multiply title/legend/axis/canvas sizes by this factor
- }
- }
-
-init_notebook_mode(connected=True)
-
-from plotly.subplots import make_subplots
-import plotly.graph_objects as go
-
-import seaborn as sns
-
-# Set the color palette
-pal=sns.color_palette("Set2")
-
-# Imports
-import warnings
-warnings.filterwarnings("ignore")
-
-## Setup for plots
-fig = make_subplots(rows=5, cols=1, vertical_spacing = 0.05,
- subplot_titles=(
- 'sub-01',
- 'sub-02',
- 'sub-03',
- 'sub-04',
- 'sub-05'))
-
-datasets={}
-data = []
-legend_bool = True
-for subject in subjects:
- index = 0
- datasets[subject]={}
- for shim_mode in shim_modes:
- datasets[subject][shim_mode]={}
- data=go.Line(
- x=x_grid,
- y=data_plotly[subject][shim_mode][0],
- name=shim_mode,
- legendgroup=shim_mode,
- line=dict(color='rgb'+str(pal[index])),
- showlegend=legend_bool
- )
-
- datasets[subject][shim_mode]=data
- index += 1
- legend_bool=False
-
-
-index = 1
-# For z-ordering
-for subject in subjects:
- for shim_mode in shim_modes:
- fig.add_trace(
- datasets[subject][shim_mode],
- row=index, col=1
- )
- index+=1
-
-
-index = 1
-for subject in subjects:
- fig.update_xaxes(
- type="linear",
- autorange=True,
- title='<b>Vertebral Levels</b>',
- showgrid=True,
- gridcolor='rgb(169,169,169)',
- tickvals=label_positions,
- ticktext=vertebral_levels,
- title_font_family="Times New Roman",
- title_font_size = 20,
- linecolor='black',
- linewidth=2,
- row=index, col=1
- )
- fig.update_yaxes(
- type="linear",
- title={
- 'text':'<b>CSF/Cord T<sub>2</sub><sup>*</sup>w signal ratio</b>',
- 'standoff':0
- },
- showgrid=True,
- gridcolor='rgb(169,169,169)',
- title_font_family="Times New Roman",
- title_font_size = 20,
- linecolor='black',
- linewidth=2,
- row=index, col=1
- )
- index+=1
-
-fig.update_layout(height=2000, width=500)
-fig.update_layout(legend=dict(
- yanchor="top",
- y=1.0,
- xanchor="left",
- x=0.01),
- legend_tracegroupgap=0,
-
-)
-
-
-#iplot(fig, filename = 'figure4a', config = config)
-plot(fig, filename = 'figure1a.html', config = config)
-display(HTML('figure1a.html'))
-
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/plotly/graph_objs/_deprecations.py:378: DeprecationWarning:
-
-plotly.graph_objs.Line is deprecated.
-Please replace it with one of the following more specific types
- - plotly.graph_objs.scatter.Line
- - plotly.graph_objs.layout.shape.Line
- - etc.
-
label_positions
-
array([0.07088123, 0.21264368, 0.3467433 , 0.46934866, 0.59386973,
- 0.74137931, 0.91187739])
-
vertebral_levels
-
['C3', 'C4', 'C5', 'C6', 'C7', 'T1', 'T2']
-
Perform statistics
Make figure of B1+ values along the spinal cord across shim methods
-# Go back to root data folder
os.chdir(os.path.join(path_data))
@@ -1045,12 +844,17 @@ 6 | Process fmap/TFL (flip angle maps)# Data storage for statistics
data_stats = []
+# Data storage for Plotly
+b1_data_plotly = {}
+
# Iterate over each subject and create a subplot
for i, subject in enumerate(subjects):
+
ax = axes[i]
os.chdir(os.path.join(path_data, subject, "fmap"))
-
+ b1_data_plotly[subject]={}
+
for shim_mode in shim_modes:
# Initialize list to collect data for this shim method
method_data = []
@@ -1075,12 +879,16 @@ 6 | Process fmap/TFL (flip angle maps)if method_data:
# Plotting each file's data separately
for resampled_data in method_data:
+ b1_data_plotly[subject][shim_mode]=resampled_data
ax.plot(x_grid, resampled_data, label=f"{shim_mode}", linewidth=line_width)
# Compute stats on the non-resampled data (to avoid interpolation errors)
mean_data = np.mean(wa_data)
sd_data = np.std(wa_data)
data_stats.append([subject, shim_mode, mean_data, sd_data])
+ else:
+ b1_data_plotly[subject][shim_mode]=None
+
# Set x-ticks and labels for the bottom subplot
if i == n_rows - 1: # Check if it's the last subplot
@@ -1111,9 +919,294 @@ 6 | Process fmap/TFL (flip angle maps)
# PYTHON CODE
+# Module imports
+
+# Base python
+import os
+from os import path
+from pathlib import Path
+
+# Graphical
+
+import plotly.graph_objs as go
+from IPython.display import display, HTML
+from plotly import __version__
+from plotly.offline import init_notebook_mode, iplot, plot
+config={
+ 'showLink': False,
+ 'displayModeBar': False,
+ 'toImageButtonOptions': {
+ 'format': 'png', # one of png, svg, jpeg, webp
+ 'filename': 'custom_image',
+ 'height': 2500,
+ 'width': 500,
+ 'scale': 2 # Multiply title/legend/axis/canvas sizes by this factor
+ }
+ }
+
+init_notebook_mode(connected=True)
+
+from plotly.subplots import make_subplots
+import plotly.graph_objects as go
+
+import seaborn as sns
+
+# Set the color palette
+pal=sns.color_palette()
+
+# Imports
+import warnings
+warnings.filterwarnings("ignore")
+
+## Setup for plots
+fig = make_subplots(rows=5, cols=2, vertical_spacing = 0.025,
+ subplot_titles=(
+ '<b>sub-01</b>',
+ '<b>sub-01</b>',
+ '<b>sub-02</b>',
+ '<b>sub-02</b>',
+ '<b>sub-03</b>',
+ '<b>sub-03</b>',
+ '<b>sub-04</b>',
+ '<b>sub-04</b>',
+ '<b>sub-05</b>',
+ '<b>sub-05</b>',))
+
+t2_datasets={}
+b1_datasets={}
+
+t2_data = []
+b1_data = []
+
+legend_bool = True
+for subject in subjects:
+ index = 0
+ t2_datasets[subject]={}
+ b1_datasets[subject]={}
+
+ for shim_mode in shim_modes:
+ t2_datasets[subject][shim_mode]={}
+ b1_datasets[subject][shim_mode]={}
+
+ t2_data=go.Line(
+ x=x_grid,
+ y=t2_data_plotly[subject][shim_mode][0],
+ name=shim_mode,
+ legendgroup=shim_mode,
+ line=dict(color='rgb'+str(pal[index]), width=3),
+ showlegend=False
+ )
+
+ b1_data=go.Line(
+ x=x_grid,
+ y=b1_data_plotly[subject][shim_mode],
+ name=shim_mode,
+ legendgroup=shim_mode,
+ line=dict(color='rgb'+str(pal[index]), width=3),
+ showlegend=legend_bool
+ )
+
+
+ t2_datasets[subject][shim_mode]=t2_data
+ b1_datasets[subject][shim_mode]=b1_data
+
+ index += 1
+ legend_bool=False
+
+
+index = 1
+# For z-ordering
+for subject in subjects:
+ for shim_mode in shim_modes:
+ fig.add_trace(
+ t2_datasets[subject][shim_mode],
+ row=index, col=1
+ )
+ fig.add_trace(
+ b1_datasets[subject][shim_mode],
+ row=index, col=2
+ )
+ index+=1
+
+
+index = 1
+for subject in subjects:
+ if index == 5:
+ x_title = '<b>Vertebral Levels</b>'
+ showticklabels=True
+ else:
+ x_title = None
+ showticklabels=False
+
+ fig.update_xaxes(
+ type="linear",
+ autorange=True,
+ title=x_title,
+ showgrid=True,
+ gridcolor='rgb(169,169,169)',
+ tickvals=label_positions,
+ ticktext=vertebral_levels,
+ showticklabels=showticklabels,
+ title_font_family="Times New Roman",
+ title_font_size = 20,
+ linecolor='black',
+ linewidth=2,
+ tickfont=dict(
+ family='Times New Roman',
+ size=16,
+ ),
+ row=index, col=1
+ )
+ if index == 1:
+ fig.update_yaxes(
+ type="linear",
+ title={
+ 'text':'<b>CSF/Cord T<sub>2</sub><sup>*</sup>w signal ratio</b>',
+ 'standoff':0
+ },
+ range=[1.05, 1.4],
+ showgrid=True,
+ gridcolor='rgb(169,169,169)',
+ title_font_family="Times New Roman",
+ title_font_size = 20,
+ linecolor='black',
+ linewidth=2,
+ tickfont=dict(
+ family='Times New Roman',
+ size=16,
+ ),
+ row=index, col=1
+ )
+ else:
+ fig.update_yaxes(
+ type="linear",
+ title={
+ 'text':'<b>CSF/Cord T<sub>2</sub><sup>*</sup>w signal ratio</b>',
+ 'standoff':0
+ },
+ showgrid=True,
+ gridcolor='rgb(169,169,169)',
+ title_font_family="Times New Roman",
+ title_font_size = 20,
+ linecolor='black',
+ linewidth=2,
+ tickfont=dict(
+ family='Times New Roman',
+ size=16,
+ ),
+ row=index, col=1
+ )
+
+ fig.update_xaxes(
+ type="linear",
+ autorange=True,
+ title=x_title,
+ showgrid=True,
+ gridcolor='rgb(169,169,169)',
+ tickvals=label_positions,
+ ticktext=vertebral_levels,
+ showticklabels=showticklabels,
+ title_font_family="Times New Roman",
+ title_font_size = 20,
+ linecolor='black',
+ linewidth=2,
+ tickfont=dict(
+ family='Times New Roman',
+ size=16,
+ ),
+ row=index, col=2
+ )
+ fig.update_yaxes(
+ type="linear",
+ title={
+ 'text':'<b>B<sub>1</sub><sup>+</sup> efficiency [nT/V]</b>',
+ 'standoff':0
+ },
+ showgrid=True,
+ gridcolor='rgb(169,169,169)',
+ title_font_family="Times New Roman",
+ title_font_size = 20,
+ linecolor='black',
+ linewidth=2,
+ tickfont=dict(
+ family='Times New Roman',
+ size=16,
+ ),
+ row=index, col=2
+ )
+
+ index+=1
+
+fig.update_layout(height=1800, width=900)
+fig.update_layout(legend=dict(
+ yanchor="top",
+ y=0.999,
+ xanchor="left",
+ x=0.01,
+ font=dict(
+ family='Times New Roman',
+ size=12
+ ),
+ bordercolor="Black",
+ borderwidth=1.5
+ ),
+ legend_tracegroupgap=0,
+ paper_bgcolor='rgb(255, 255, 255)',
+ plot_bgcolor='rgb(255, 255, 255)',
+
+)
+
+fig.update_annotations(font_size=22)
+
+#iplot(fig, filename = 'figure4a', config = config)
+plot(fig, filename = 'figure1.html', config = config)
+display(HTML('figure1.html'))
+
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/plotly/graph_objs/_deprecations.py:378: DeprecationWarning:
+
+plotly.graph_objs.Line is deprecated.
+Please replace it with one of the following more specific types
+ - plotly.graph_objs.scatter.Line
+ - plotly.graph_objs.layout.shape.Line
+ - etc.
+
Perform statistics