Skip to content

Commit

Permalink
Merge pull request #47 from gschramm/tof_chunk_bugfix
Browse files Browse the repository at this point in the history
BUGFIX: correct chunking of TOF sinogram projection in python interface
  • Loading branch information
gschramm authored Jan 19, 2024
2 parents a081237 + 1d9f5e9 commit 2c57567
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.7.1 (January 19, 2024)
- BUGFIX: correct bug in the "chunking" of TOF sinogram projections in the python interface

## 1.7.0 (January 15, 2024)
- update of documentation
- addition of more examples
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "1.7.0"
"version": "1.7.1"
}
4 changes: 2 additions & 2 deletions python/parallelproj/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ def joseph3d_fwd_tof_sino(
d_img,
np.asarray(img_origin, dtype=np.float32),
np.asarray(voxsize, dtype=np.float32),
img_fwd.ravel()[ic[i] : (ic[i + 1])],
img_fwd.ravel()[ntofbins*ic[i] : ntofbins*(ic[i + 1])],
ic[i + 1] - ic[i],
np.asarray(img.shape, dtype=np.int32),
np.float32(tofbin_width),
Expand Down Expand Up @@ -935,7 +935,7 @@ def joseph3d_back_tof_sino(
d_back_img,
np.asarray(img_origin, dtype=np.float32),
np.asarray(voxsize, dtype=np.float32),
np.asarray(img_fwd, dtype=np.float32).ravel()[ic[i] : ic[i + 1]],
np.asarray(img_fwd, dtype=np.float32).ravel()[ntofbins*ic[i] : ntofbins*ic[i + 1]],
ic[i + 1] - ic[i],
np.asarray(back_img.shape, dtype=np.int32),
np.float32(tofbin_width),
Expand Down
6 changes: 3 additions & 3 deletions test/parallelproj/test_nontof_joseph.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_fwd(
xstart = vstart * voxel_size + img_origin
xend = vend * voxel_size + img_origin

img_fwd = parallelproj.joseph3d_fwd(xstart, xend, img, img_origin, voxel_size)
img_fwd = parallelproj.joseph3d_fwd(xstart, xend, img, img_origin, voxel_size, num_chunks=3)

# setup the expected values for the projection
expected_projections = xp.zeros_like(img_fwd, device=dev)
Expand Down Expand Up @@ -153,12 +153,12 @@ def test_adjointness(
xend[:, 2] = R * costheta

# forward project
img_fwd = parallelproj.joseph3d_fwd(xstart, xend, img, img_origin, voxel_size)
img_fwd = parallelproj.joseph3d_fwd(xstart, xend, img, img_origin, voxel_size, num_chunks=3)

# backward project
sino = xp.asarray(np.random.rand(*img_fwd.shape), dtype=xp.float32, device=dev)
back_img = parallelproj.joseph3d_back(
xstart, xend, img.shape, img_origin, voxel_size, sino
xstart, xend, img.shape, img_origin, voxel_size, sino, num_chunks=5
)

ip_a = float(xp.sum((back_img * img)))
Expand Down
3 changes: 3 additions & 0 deletions test/parallelproj/test_toflm_joseph.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_tof_lm_fwd(
tofcenter_offset,
nsigmas,
tof_bin,
num_chunks=3
)

# check if sum of the projection is correct (should be equal to the voxel
Expand Down Expand Up @@ -237,6 +238,7 @@ def test_adjointness(
tofcenter_offset,
nsigmas,
tof_bin,
num_chunks=7
)

# backward project
Expand All @@ -254,6 +256,7 @@ def test_adjointness(
tofcenter_offset,
nsigmas,
tof_bin,
num_chunks=11
)

ip_a = float(xp.sum(back_img * img))
Expand Down
3 changes: 3 additions & 0 deletions test/parallelproj/test_tofsino_joseph.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def test_tof_sino_fwd(
tofcenter_offset,
nsigmas,
num_tof_bins,
num_chunks=3,
)

# check if sum of the projection is correct (should be equal to the voxel
Expand Down Expand Up @@ -196,6 +197,7 @@ def test_adjointness(
tofcenter_offset,
nsigmas,
num_tof_bins,
num_chunks=3,
)

# backward project
Expand All @@ -212,6 +214,7 @@ def test_adjointness(
tofcenter_offset,
nsigmas,
num_tof_bins,
num_chunks=5,
)

ip_a = float(xp.sum((back_img * img)))
Expand Down

0 comments on commit 2c57567

Please sign in to comment.