Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

KrisThielemans
Copy link
Collaborator

@KrisThielemans KrisThielemans commented Feb 14, 2021

Adds supports for https://github.com/gschramm/parallelproj

Current status is that CMake is set-up, and the skeleton for the projectors exist. Now we have to call them...

These are based on the NiftyPET work and currently follow a similar strategy of
doing the whole projection upfront

The code runs, but actually doesn't do any projections yet
@KrisThielemans
Copy link
Collaborator Author

@gschramm, @AnderBiguri, @gfardell, @paskino I've created the PR now as it is now set-up (once gschramm/parallelproj#3 is set-up).

Of course, Travis doesn't really test this, as it won't have parallelproj. It'd be easy enough to add it I guess.

@KrisThielemans
Copy link
Collaborator Author

The next step is to get required geometric info. This more or less corresponds to

  • Filling a Bin with the relevant segment/view etc
  • Calling proj_data_info.get_LOR() with a LORAs2Points object
  • Finding the relation between voxel and bin coordinate systems (still a bit messy at the moment pending Prepare for origin shift 2020 #618).

@KrisThielemans
Copy link
Collaborator Author

I might have done the backprojection now for OpenMP. Forward projection should be trivial.

A test with non-TOF backprojection of the NEMA acquired on the Signa:
top: parallelproj, bottom: STIR's default ray-tracing
image
(I have no idea if we expect the interesting effects at the edge of the FOV).

Execution time on my HP Firefly laptop (8 cores, STIR will default to using 7) inside an Ubuntu VM.

  • parallelproj:
    • real 1m10
    • user 5m18
  • STIR projmatrix using raytracing
    • real 0m49
    • user 4m32

There seems to be a few seconds overhead in creating the arrays with the coordinates. That doesn't matter now, but of course would when doing GPU stuff. (We can easily change this to do it only once during set_up, such that for a reconstruction, that overhead becomes negligible).

@gschramm
Copy link
Contributor

the edge effect is a bug that i hope to fix soon. it is because the start and end points lie within the image volume and I step through all planes of the volume instead of only considering planes between the start and end points.
I hope to get that fixed by next week

@AnderBiguri
Copy link
Collaborator

AnderBiguri commented Feb 17, 2021

Good to hear this is progressing!

parallelproj:
real 1m10
user 5m18

This is about 2 orders of magnitude slower than the cuda code (the real part). Is the STIR overhead for LORs that large?

the edge effect is a bug that i hope to fix soon. it is because the start and end points lie within the image volume and I step through all planes of the volume instead of only considering planes between the start and end points.
I hope to get that fixed by next week

Should be just having an if conditions to crop the "start" and "end" of the ray in these chuncks of code, right?
https://github.com/gschramm/parallelproj/blob/master/cuda/src/joseph3d_fwd_cuda.cu#L128-L129

@KrisThielemans
Copy link
Collaborator Author

This is about 2 orders of magnitude slower than the cuda code (the real part). Is the STIR overhead for LORs that large?

Timings above are for the non-CUDA OpenMP code! STIR-LOR overhead is probably ~4s (and most of that would be a once-only operation). It would be easy to OpenMP that bit. It can be further optimised, but that'll be more work.

@KrisThielemans
Copy link
Collaborator Author

I suggest to create an issue at parallelproj for the start/end code, and discuss there.

@gschramm
Copy link
Contributor

new issue is parallelproj created:
gschramm/parallelproj#5 (comment)

This seems to work now. Actual code for geometry will need to be
moved to separate file for re-use by the forward projector.
@KrisThielemans
Copy link
Collaborator Author

seems that I had forgotten to push my last commit that I used to obtain the above results. I've done it now.

forward_project and back_project utilities will now check
if the parsing failed and exit with an error message
(as opposed to seg-faulting).
- change test framework to allow passing a projector-pair file
- add sample projector-pair files
- run test_OSMAPOSL with parallelproj projectors
@KrisThielemans
Copy link
Collaborator Author

@gschramm @AnderBiguri @paskino I have now a version that works fine on CPU with a minimal test (some manual tests are fine as well). I have also pushed a short commit to use the GPU code if parallelproj was built with it. (Currently I cannot switch back to the non-GPU code in that case, but maybe that doesn't matter).

I'd very much appreciate it if someone with a GPU and CUDA could try this. Essentially,

cmake -Dparallelproj_DIR=/where/ever/install/lib/cmake whateverotherSTIRoptions /where/ever/source/STIR
make -j8
ctest

you could save yourself some time if you'd say

ctest -R test_OS

as that's currently the only one with the projector.

If that works, it'll be easy to test on other data as well (just change the projector pair)

Also made _proj_data_info_sptr member in Forward/BackProjectorByBin
protected as opposed to private.
@KrisThielemans KrisThielemans marked this pull request as ready for review February 21, 2021 15:19
@KrisThielemans
Copy link
Collaborator Author

This is ready now, as soon as somebody tests the CUDA projector.

@KrisThielemans
Copy link
Collaborator Author

We should now remove the fill(0) before forward projection. See gschramm/parallelproj#7 (comment)

without it, anyone finding STIR will get linking errors to target
parallelproj::parallelproj_c (or cuda)
parallelproj now no longer accumulates, so disabling the fill.
@KrisThielemans
Copy link
Collaborator Author

KrisThielemans commented Feb 23, 2021

Example result of forward projection of a very crude mu-map of the NEMA phantom (54x54x127) with the Siemens mMR span=11 template (data is at https://github.com/SyneRBI/SIRF_data/blob/0e5ac5978e76017d741d2cc4ae8d188e09f9f7c2/examples/PET/mMR/)
top is parallelproj, bottom is ray-tracing.

seg 0:
image
seg -5:
image

This is as expected as the Joseph projector interpolates, while ray-tracing (Siddon) is more sensitive to discretisation (which why we have the number of tangential LORs option, the above is with the default 1).

(This phantom is centered, so I cannot see the difference between segment +5 and -5, but the underlying code to determine geometry is the same)

@KrisThielemans KrisThielemans merged commit 882c261 into UCL:master Feb 23, 2021
@KrisThielemans KrisThielemans deleted the parallelproj branch February 23, 2021 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants