ahendriksen/tomosipo

Easy way of subset operators?

Closed this issue · 2 comments

Hey!

I am trying to use tomosipo with pytorch integration, just for context.

If I decide to try to have some subset operations for algorithms (e.g. for SART/OS-anything/stochastic-anything), is there a way to do subsaple the operator itself? The only way I can think of doing it right now is to have a list of operators, each for each angle subset I need. This seems a tiny bit verbose, but perhaps the only way?

Hi Ander,

What you propose to do (an operator per angle subset) is indeed the easiest way achieve what you want in tomosipo. I have avoided adding any APIs to index an operator directly, as there isn't really an intuitive way to do this in six dimensions and would surely lead to errors.

The following doesn't seem too bad though?

import torch 
import tomosipo as ts

# Create geometries
vg = ts.volume(shape=32)
pg = ts.parallel(angles=48, shape=32)

A_full = ts.operator(vg, pg)

# Create sub-geometries
As = [ts.operator(vg, pg_angle) for pg_angle in pg]
# or
As = [ts.operator(vg, pg[i]) for i in range(pg.num_angles)]

# Forward projection:
x = torch.zeros(A_full.domain_shape)
y = torch.zeros(A_full.range_shape)
for i, A in enumerate(As):
  y[:, i] = A(x).squeeze()

I hope this helps!

Hi @ahendriksen yeah absolutely, its not a terrible alternative. That should work fantastically. Thanks!