SyneRBI / SIRF

Main repository for the CCP SynerBI software
http://www.ccpsynerbi.ac.uk
Other
58 stars 29 forks source link

SeparableGaussianImageFilter has no attribute `input` #814

Closed AnderBiguri closed 3 years ago

AnderBiguri commented 3 years ago
filt=stir.SeparableGaussianImageFilter()
filt.set_fwhms([6,6,6])
filt.set_up(image)
image=filt.process()

errors as:

Traceback (most recent call last):
  File "/home/anderbiguri/Documents/MATLAB/GE/DWB-PET-WIP/Dyamic_PET_simulation/dynamic_recon.py", line 188, in <module>
    attn_image=filt.process()
  File "/home/anderbiguri/SIRF/build/INSTALL/python/sirf/STIR.py", line 607, in process
    if self.input is None:
AttributeError: 'SeparableGaussianImageFilter' object has no attribute 'input'

Solution is easy, give process() the input as argument. But given that set_up requires an image, should we either set it up as self.input, or instead, just improve the check in process with something like hasattr(self,"input")?

(happy to do a PR, just let me know which option you prefer)

evgueni-ovtchinnikov commented 3 years ago

The error message is confusing because I forgot at the time of writing that in Python base class properties are not inherited and did not initialize self.input to None in the derived class. If I did, the error message would be perfectly clear: 'input image not set'.

Fixed now.