CERN / TIGRE

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

Logic failure when disabling Wang weights #600

Closed twhitbread closed 1 month ago

twhitbread commented 1 month ago

Expected Behavior

In TIGRE\Python\tigre\algorithms\single_pass_algorithms.py, code was recently added (f0e91005ba2881e1a5e63eb744740ca0c01af6c8) to disable Wang weights if there is no detector offset. This should be able to handle fixed offsets and per-frame offsets.

Actual Behavior

For per-frame offsets (i.e. geo.offDetector is a 2xn array), it throws an error:

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I would recommend using np.any(geo.offDetector) or geo.offDetector.any()

Code to reproduce the problem (If applicable)

import numpy as np
import tigre
from tigre.utilities.Ax import Ax
from tigre.utilities.sample_loader import load_head_phantom

geo = tigre.geometry(mode='cone', default=True)

head = load_head_phantom(geo.nVoxel)
tigre.plotimg(head, slice=128)

angles = np.linspace(0, 2*np.pi, dtype=np.float32)
projections = Ax(head, geo, angles, 'interpolated')

imgFDK = tigre.algorithms.single_pass_algorithms.FDK(projections, geo, angles)

Specifications

AnderBiguri commented 1 month ago

Thanks @twhitbread , indeed a bug that I intreoduced by a too quick update. I'll fix :) missed the np.!

twhitbread commented 1 month ago

Thanks @AnderBiguri :)