CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
563 stars 186 forks source link

Support masking backprojection #434

Open eliyash opened 1 year ago

eliyash commented 1 year ago

Use cases

How should it work IMO A mask per sinogram's image or one for all images in the sinogram. the mask values should not be backprojected into the volume, and the pixel should not be considered in the diff calculation

Additional context mask implementation in astra: https://www.astra-toolbox.com/docs/misc.html

hope it make sense, Thanks!

AnderBiguri commented 1 year ago

@eliyash fair point! The best way to impement this in TIGRE is likely not touching the backprojector, and instead just allowing the algorithms to mask the output of the fp/bp in MATLAB/Python itself, not unlike the detector offset weights are implemented. Ultimately a zero in the detector is the same as "not backprojecting".

Its likely the most efficient way, as otherwise more memory needs to be passed (the mask) to CUDA, and this overhead of reading the mask is likely larger than just backprojecting zeroes and masking the output of forward projections at the algorithm level.

In any case, great suggestion. I won't be able to implement it anytime soon, but if you feel like it, I can guide you doing it so, it's quite a simple thing, but many algorithms need to be updated.

eliyash commented 1 year ago

@AnderBiguri thanks for the (fast) response!

I do feel like it, although I am unsure when I will be able to allocate the time for it. Can you give me general guidance on how should I do it?

AnderBiguri commented 1 year ago

@eliyash absolutely!

Its not too hard. say, given SART.

1- Make it an optional parameter, i.e. let parse_inputs take an optional parameter for e.g. 'image_mask' or 'sinogram_mask'. These values can be initialized to the scalar 1. 2- Everytime the algorithm uses Ax() multiply the output by the mask, similarly for Atb().

I think a priori that would work.