SyneRBI / SIRF

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

ImageData.read_from_file unexpected #548

Closed KrisThielemans closed 3 years ago

KrisThielemans commented 4 years ago
im=sirf.STIR.ImageData.read_from_file("myfile.hv")

TypeError: unbound method read_from_file() must be called with ImageData instance as first argument (got str instance instead)

It seems that syntax is

im=pet.ImageData
im=im.read_from_file("myfile.hv")

(could work with any image constructed). To me, that's surprising. I would have expected read_from_file to be a static method.

It's possible that we don't need this function at all, as it would be equivalent to

im=pet.ImageData("myfile.hv")

@evgueni-ovtchinnikov @rijobro Opinions?

Presumably it's the same for AcquisitionData or GadgetronImageData

evgueni-ovtchinnikov commented 4 years ago

Actually, read_from_file does not return:

    def read_from_file(self, filename):
        '''Read data from file.

        Replaces the current content of the object.
        '''
        if self.handle is not None:
            pyiutil.deleteDataHandle(self.handle)
        self.handle = pystir.cSTIR_objectFromFile('Image', filename)
        check_status(self.handle)

So, im=im.read_from_file("myfile.hv") would result in im being None. No idea why we have it.

KrisThielemans commented 4 years ago

Possibly might be useful if we would ever be able to discover which "engine" can read an image?

KrisThielemans commented 4 years ago

Let's remove it. (will have to be in CHANGES.md)

Please check if it's used anywhere (including SIRF-exercises) though.

evgueni-ovtchinnikov commented 3 years ago

There is hardly any harm in having read_from_file, whereas removing it would unnecessarily hit those who use it already.