from-dicom.ipynb changed
"outputs": [],
"source": [
"import numpy as np\n",
- "import matplotlib.pyplot as plt\n",
- "import matplotlib.ticker"
+ "import matplotlib.pyplot as plt"
]
},
{
"import pymedphys"
]
},
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "#define formatter for colorbar\n",
- "class OOMFormatter(matplotlib.ticker.ScalarFormatter):\n",
- " def __init__(self, order=0, fformat=\"%1.1f\", offset=True, mathText=True):\n",
- " self.oom = order\n",
- " self.fformat = fformat\n",
- " matplotlib.ticker.ScalarFormatter.__init__(self,useOffset=offset,useMathText=mathText)\n",
- " def _set_order_of_magnitude(self):\n",
- " self.orderOfMagnitude = self.oom\n",
- " def _set_format(self, vmin=None, vmax=None):\n",
- " self.format = self.fformat\n",
- " if self._useMathText:\n",
- " self.format = r'$\\mathdefault{%s}$' % self.format"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
"for i, (eval_slice, ref_slice, diff, gamma_slice) in enumerate(zip(eval_slices, ref_slices, diffs, gamma_slices)): \n",
" fig, ax = plt.subplots(figsize=(13,10), nrows=2, ncols=2)\n",
" \n",
- " fig.suptitle('slice Z_{0}'.format(slice_start+i*5), fontsize=12)\n",
+ " fig.suptitle('Slice Z_{0}'.format(slice_start+i*5), fontsize=12)\n",
" c00 = ax[0,0].contourf(\n",
" x_eval, y_eval, eval_slice, 100, \n",
" vmin=0, vmax=max_ref_dose)\n",
" x_ref, y_ref, diff, 100, \n",
" vmin=-max_diff, vmax=max_diff, cmap=plt.get_cmap('seismic'))\n",
" ax[1,0].set_title(\"Dose difference\") \n",
- " fig.colorbar(c10, ax=ax[1,0], format = OOMFormatter(-2, mathText=False), label='[Dose Eval] - [Dose Ref] (Gy)')\n",
+ " cbar = fig.colorbar(c10, ax=ax[1,0], label='[Dose Eval] - [Dose Ref] (Gy)')\n",
+ " cbar.formatter.set_powerlimits((0, 0)) #use scientific notation\n",
" ax[1,0].invert_yaxis()\n",
" ax[1,0].set_xlabel('x (mm)')\n",
" ax[1,0].set_ylabel('y (mm)')\n",
" x_ref, y_ref, gamma_slice, 100, \n",
" vmin=0, vmax=2, cmap=plt.get_cmap('coolwarm'))\n",
" ax[1,1].set_title(\n",
- " f\"Local Gamma ({gamma_options['dose_percent_threshold']} % / {gamma_options['distance_mm_threshold']} mm)\") \n",
+ " f\"{gamma_norm_condition} ({gamma_options['dose_percent_threshold']} % / {gamma_options['distance_mm_threshold']} mm)\") \n",
" fig.colorbar(c11, ax=ax[1,1], label='gamma index')\n",
" ax[1,1].invert_yaxis()\n",
" ax[1,1].set_xlabel('x (mm)')\n",
