From 7b7a940988d7a64cebfdfc34c35575e002a99129 Mon Sep 17 00:00:00 2001 From: eigenvivek Date: Tue, 28 May 2024 15:00:50 -0400 Subject: [PATCH] Make Siddon work with a different source for each ray --- diffdrr/renderers.py | 2 +- notebooks/api/01_renderers.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/diffdrr/renderers.py b/diffdrr/renderers.py index 3848c8f7d..3b23f185e 100644 --- a/diffdrr/renderers.py +++ b/diffdrr/renderers.py @@ -115,7 +115,7 @@ def _get_voxel(alpha, source, target, volume, origin, spacing, dims, maxidx, eps def _get_index(alpha, source, target, origin, spacing, dims, maxidx, eps): sdd = target - source + eps - idxs = source.unsqueeze(1) + alpha.unsqueeze(-1) * sdd.unsqueeze(2) + idxs = source.unsqueeze(2) + alpha.unsqueeze(-1) * sdd.unsqueeze(2) idxs = (idxs - origin) / spacing idxs = idxs.floor() # Conversion to long makes nan->-inf, so temporarily replace them with 0 diff --git a/notebooks/api/01_renderers.ipynb b/notebooks/api/01_renderers.ipynb index 94b639d7c..870b8e312 100644 --- a/notebooks/api/01_renderers.ipynb +++ b/notebooks/api/01_renderers.ipynb @@ -224,7 +224,7 @@ "\n", "def _get_index(alpha, source, target, origin, spacing, dims, maxidx, eps):\n", " sdd = target - source + eps\n", - " idxs = source.unsqueeze(1) + alpha.unsqueeze(-1) * sdd.unsqueeze(2)\n", + " idxs = source.unsqueeze(2) + alpha.unsqueeze(-1) * sdd.unsqueeze(2)\n", " idxs = (idxs - origin) / spacing\n", " idxs = idxs.floor()\n", " # Conversion to long makes nan->-inf, so temporarily replace them with 0\n",