Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions notebooks/advanced_topics/ct_seg_to_tensors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install -q \"idc-index>=0.13\" \"highdicom>=0.28\" torch matplotlib"
"%pip install -q \"idc-index>=0.13\" \"highdicom>=0.29\" torch matplotlib"
]
},
{
Expand Down Expand Up @@ -233,11 +233,7 @@
" instead if you want a single label map in which each voxel holds a segment number.)\n",
"- `.match_geometry(ct_volume)` rearranges the mask volume so that it lies on exactly the same voxel grid as the\n",
" CT. This only pads, crops, flips, and/or permutes the array; it never interpolates, and it raises an error if the two\n",
" volumes cannot be aligned.\n",
"\n",
"We pass `tol=1e-4` (in units of voxels) to `match_geometry()` because the SEG files in this collection store\n",
"positions and pixel spacing with fewer decimal places than the CT files, so the two grids differ by a tiny\n",
"rounding error."
" volumes cannot be aligned."
]
},
{
Expand All @@ -247,7 +243,7 @@
"metadata": {},
"outputs": [],
"source": [
"mask_volume = seg.get_volume(combine_segments=False).match_geometry(ct_volume, tol=1e-4)\n",
"mask_volume = seg.get_volume(combine_segments=False).match_geometry(ct_volume)\n",
"\n",
"print(\"CT shape: \", ct_volume.shape)\n",
"print(\"Mask shape:\", mask_volume.shape)"
Expand Down Expand Up @@ -339,7 +335,7 @@
" dtype=np.float32,\n",
" )\n",
" seg = hd.seg.segread(seg_file)\n",
" mask_volume = seg.get_volume(combine_segments=False).match_geometry(ct_volume, tol=1e-4)\n",
" mask_volume = seg.get_volume(combine_segments=False).match_geometry(ct_volume)\n",
"\n",
" image = torch.from_numpy(ct_volume.array).unsqueeze(0)\n",
" masks = torch.from_numpy(mask_volume.array).permute(3, 0, 1, 2)\n",
Expand Down
Loading