Skip to content

Commit

Permalink
Correct colour maps in dose vis
Browse files Browse the repository at this point in the history
  • Loading branch information
pchlap committed Feb 22, 2023
1 parent 437d8ab commit e50dfc8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 13 additions & 3 deletions examples/dvh_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@
"dvh = calculate_dvh_for_labels(dose, structures)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dvh"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -146,13 +155,12 @@
"source": [
"# Reshape the DVH\n",
"plt_dvh = dvh\n",
"plt_dvh.set_index(\"label\")\n",
"plt_dvh.transpose()\n",
"plt_dvh = plt_dvh.set_index(\"label\")\n",
"plt_dvh = plt_dvh.iloc[:,3:].transpose()\n",
"\n",
"# Plot the DVH\n",
"fig, ax = plt.subplots()\n",
"plt_dvh.plot(ax=ax, kind=\"line\", colormap=plt.cm.get_cmap(\"viridis\"), legend=False)\n",
"plt_dvh.plot(ax=ax, kind=\"line\", colormap=plt.cm.get_cmap(\"rainbow\"), legend=False)\n",
"\n",
"# Add labels and show plot\n",
"plt.legend(loc='best')\n",
Expand Down Expand Up @@ -218,6 +226,8 @@
" d_cc_points=[10],\n",
" structure_for_limits=dose>5,\n",
" expansion_for_limits=40,\n",
" contour_cmap=plt.cm.get_cmap(\"rainbow\"),\n",
" dose_cmap=plt.cm.get_cmap(\"inferno\"),\n",
" title=\"TCGA_CV_5977 Dose Metrics\")"
]
},
Expand Down
9 changes: 6 additions & 3 deletions platipy/imaging/visualisation/dose.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def visualise_dose(
structure_for_limits=None,
expansion_for_limits=10,
title="",
contour_cmap=plt.cm.get_cmap("inferno"),
contour_cmap=plt.cm.get_cmap("rainbow"),
dose_cmap=plt.cm.get_cmap("inferno"),
structure_name_dict=None,
img_vis_kw=None,
):
Expand Down Expand Up @@ -86,6 +87,8 @@ def visualise_dose(
to 10.
title (str, optional): Title to display on visualisation. Defaults to "".
contour_cmap (plt.cm.colormap, optional): Matplotlib color map to use for contour colors.
Defaults to plt.cm.get_cmap("rainbow").
dose_cmap (plt.cm.colormap, optional): Matplotlib color map to use for dose colors.
Defaults to plt.cm.get_cmap("inferno").
structure_name_dict (dict, optional): Dictionary to map alternative structure names.
Defaults to None.
Expand Down Expand Up @@ -158,12 +161,12 @@ def visualise_dose(
vis.add_scalar_overlay(
dose,
discrete_levels=int(max_val / round_to_nearest),
colormap=contour_cmap,
colormap=dose_cmap,
alpha=0.5,
max_value=max_val,
name="Dose (Gy)",
)
vis.add_contour(structures, show_legend=False)
vis.add_contour(structures, show_legend=False, colormap=contour_cmap)

if structure_for_limits is not None:
vis.set_limits_from_label(structure_for_limits, expansion=expansion_for_limits)
Expand Down

0 comments on commit e50dfc8

Please sign in to comment.