Astra curved detector#1729
Conversation
| # FIXME: if self.geometry.det_curvature_radius is None | ||
| # We can't use a single PyTorch transpose... | ||
| if self.geometry.det_curvature_radius is not None: | ||
| raise NotImplementedError("Curved detectors currently do not support pytorch") | ||
| self.transpose_tuple = (1,0) |
There was a problem hiding this comment.
This is the transpose issue. We store transpose info in transpose_tuple to be able to do the transpose at a later time. But for pytorch tensors a transpose can only swap the positions of two dimensions and not arbitrarily rearrange them like we need to do in this case. With two transposes we can get the correct format, but I'm not sure what the best way to store that information is.
I could make a transpose_tuple2 that only gets used for pytorch tensors and only if transpose_tuple2 != None but I'm not sure if this is a good solution, seems a little bit messy.
There was a problem hiding this comment.
I think permute_dims is now the preferred tool to use.
There was a problem hiding this comment.
I've managed to use permute_dims but as I'm unfamiliar with the standardized python array API I might be doing something weird.
There was a problem hiding this comment.
At a glance, it looks reasonable. Though, better use proj_space.array_namespace and store it in a variable, instead of repeatedly looking up proj_data.__array_namespace__.
There was a problem hiding this comment.
Do you think it matters enough that I should change it?
I don't know how expensive __array_namespace__ really is, but I expect that compared to the other operations in these functions I expect it to be negligible.
There was a problem hiding this comment.
Performance-wise the difference is likely negligible, but it's just a bit more structured.
|
There is a bug in this code that I will investigate tomorrow, but because creating pull request threads is down (https://www.githubstatus.com/) can't comment this on the affected line of code. On line 253 in astra_cuda.py: |
|
@NogginBops looks like |
|
I've seemingly fixed the issue. The issue was that the old permutation had order 2 which meant applying the same permutation again returned to the original shape, but the new permutation is order 3 which means applying the same permutation again does not return to the dimentions to the original order. The fix is to introduce explicitly specify the inverse permutation. |
|
@NogginBops sounds reasonable. Thanks a lot for your efforts! I don't see anything wrong with the code, but still need to do a bunch of testing before I can merge it. |
|
Well, this backprojection seems to suggest that at least the axes are correctly mapped:
detector_partition = odl.uniform_partition([-np.pi/8, -160], [np.pi/8, 160], [512, 512])
geometry = odl.applications.tomo.ConeBeamGeometry(
angle_partition, detector_partition, src_radius=200,
det_radius=200, det_curvature_radius=(400, None),
axis=[1, 0, 0])(everything else the same as in ray_trafo_cone_3d). What's strange is that I have to make the detector very "oversized" (so the projection of the actual phantom only takes up a small part of the data space, which would be rather inefficient). If not, then the backprojection comes out heavily cropped on the sides, even though the projection is still well within the detector area:
Not sure if this is because of some actual bug in the code, or I'm just interpreting the results wrong. |


This PR is based on #1634 but remade for odl 1.0.0.
This PR uses
cyl_cone_vecfrom ASTRA 2.4.0 to allow curved cone beam detectors.From #1634 there was a note about a off-by-half bug related to pixel centers that I'm not sure if it still applies.
There is also a FIXME in astra_cuda.py related to not being able to arbitrarily transposing pytorch tensors. Not sure what the best solution for that is, guidance is appreciated. :)This is fixed by usingpermute_dims.@leftaroundabout could you take a look at and see if you can see anything that is obviously wrong that I could fix? You can do a full review when you have time.