making expanded masks
"import getpass\n",
"import functools\n",
"\n",
+ "import numpy as np\n",
+ "\n",
"import pydicom\n",
"\n",
"import segments"
"metadata": {},
"outputs": [],
"source": [
- "from pymedphys._experimental.autosegmentation import pipeline"
+ "from pymedphys._experimental.autosegmentation import pipeline, mask"
]
},
{
"# contours_by_ct_uid"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "expansion = 4\n",
+ "\n",
+ "_, _, ct_size = mask.get_grid(dcm_ct)\n",
+ "ct_size = tuple(np.array(ct_size) * expansion)\n",
+ "ct_size"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"contours_on_this_slice = contours_by_ct_uid[ct_uid].keys()\n",
- "contours_on_this_slice"
+ "\n",
+ "masks = dict()\n",
+ "\n",
+ "for structure in structures_to_learn:\n",
+ " if structure in contours_on_this_slice:\n",
+ " masks[structure] = mask.calculate_expanded_mask(\n",
+ " contours_by_ct_uid[ct_uid][structure],\n",
+ " dcm_ct, expansion\n",
+ " )\n",
+ " else:\n",
+ " masks[structure] = np.zeros(ct_size).astype(bool)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "masks"
]
},
{
