Skip to content

Commit 822b719

Browse files
committed
modules/resample_benchmark.ipynb
Signed-off-by: Wenqi Li <[email protected]>
1 parent eaf509d commit 822b719

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

modules/resample_benchmark.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
" ),\n",
216216
" monai.transforms.ScaleIntensityd(keys=[\"img\"])\n",
217217
" ])\n",
218-
" monai_transformed = transform({\"img\": monai_img})[\"img\"].transpose((1, 2, 0))\n",
218+
" monai_transformed = transform({\"img\": monai_img})[\"img\"].permute((1, 2, 0))\n",
219219
"\n",
220220
" # sitk transform\n",
221221
" sitk_img = sitk.ReadImage(img_path)\n",
@@ -285,7 +285,7 @@
285285
"\n",
286286
"# Generate random samples inside the image, we will obtain the intensity/color values at these points.\n",
287287
"num_samples = 10\n",
288-
"physical_points = np.array([np.random.randint(monai_img.shape[1:]) for _ in range(10)], dtype=np.float) # (10, 2)\n"
288+
"physical_points = np.array([np.random.randint(monai_img.shape[1:]) for _ in range(10)], dtype=float) # (10, 2)\n"
289289
]
290290
},
291291
{
@@ -322,7 +322,7 @@
322322
"# initialise ddf as a zero matrix\n",
323323
"ddf = torch.zeros(2, height, width).to(torch.float) # (2, H, W)\n",
324324
"# add displacement of y coordinate to sampled locations\n",
325-
"for i, pnt in enumerate(physical_points.astype(np.long)):\n",
325+
"for i, pnt in enumerate(physical_points.astype(int)):\n",
326326
" ddf[0, pnt[0], pnt[1]] += i\n",
327327
"\n",
328328
"# initialise warp layer\n",
@@ -360,7 +360,7 @@
360360
"sitk_displacement_img = sitk.Image([width, height], sitk.sitkVectorFloat64, sitk_img.GetDimension())\n",
361361
"# add displacement of y coordinate to sampled locations\n",
362362
"for i, pnt in enumerate(physical_points):\n",
363-
" sitk_displacement_img[int(pnt[1]), int(pnt[0])] = np.array([0, i], dtype=np.float)\n",
363+
" sitk_displacement_img[int(pnt[1]), int(pnt[0])] = np.array([0, i], dtype=float)\n",
364364
"\n",
365365
"# select linear interpolater to match `bilinear` mode in MONAI\n",
366366
"interpolator_enum = sitk.sitkLinear\n",
@@ -420,7 +420,7 @@
420420
}
421421
],
422422
"source": [
423-
"for _, pnt in enumerate(physical_points.astype(np.long)):\n",
423+
"for _, pnt in enumerate(physical_points.astype(int)):\n",
424424
" print(f\"at location {pnt}: original intensity {monai_img[:, pnt[0], pnt[1]]} \" +\n",
425425
" f\"resampled to {monai_resample[:, pnt[0], pnt[1]]} by MONAI and {sitk_resample[pnt[0], pnt[1]]} by SITK\")"
426426
]
@@ -449,7 +449,7 @@
449449
"source": [
450450
"img = monai.transforms.LoadImaged(keys=\"img\")({\"img\": f\"{root_dir}/mri.nii\"})[\"img\"]\n",
451451
"# W, H, D -> D, H, W\n",
452-
"img = img.transpose((2, 1, 0))"
452+
"img = img.permute((2, 1, 0))"
453453
]
454454
},
455455
{
@@ -689,7 +689,7 @@
689689
"name": "python",
690690
"nbconvert_exporter": "python",
691691
"pygments_lexer": "ipython3",
692-
"version": "3.8.12"
692+
"version": "3.8.0"
693693
},
694694
"widgets": {
695695
"application/vnd.jupyter.widget-state+json": {

0 commit comments

Comments
 (0)