def add_shape(self, shape, scale): if self.handle is None: raise error('cannot add shapes to uninitialised image') handle = pystir.cSTIR_addShape\ (self.handle, self.voxels, shape.handle, scale) _check_status(handle) pystir.deleteDataHandle(handle)
def initialise\ (self, arg1, arg2 = 0, arg3 = 0, arg4 = 1, arg5 = 1, arg6 = 1, \ arg7 = 0, arg8 = 0, arg9 = 0): if type(arg1) == type((0,0,0)): dim = arg1 if arg2 == 0: vsize = (1, 1, 1) origin = (0, 0, 0) else: vsize = arg2 if arg3 == 0: origin = (0, 0, 0) else: origin = arg3 else: dim = (arg1, arg2, arg3) vsize = (arg4, arg5, arg6) origin = (arg7, arg8, arg9) if self.handle is not None: pystir.deleteDataHandle(self.handle) if self.voxels is not None: pystir.deleteDataHandle(self.voxels) self.handle = None self.voxels = pystir.cSTIR_voxels3DF\ (dim[0], dim[1], dim[2], \ vsize[0], vsize[1], vsize[2], \ origin[0], origin[1], origin[2]) _check_status(self.voxels) self.handle = pystir.cSTIR_imageFromVoxels(self.voxels) _check_status(self.handle)
def read_from_file(self, filename): if self.handle is not None: pystir.deleteDataHandle(self.handle) if self.voxels is not None: pystir.deleteDataHandle(self.voxels) self.handle = pystir.cSTIR_objectFromFile('Image', filename) _check_status(self.handle)
def diff_from(self, image): handle = pystir.cSTIR_imagesDifference\ (self.handle, image.handle, self.rimsize) _check_status(handle) diff = pystir.doubleDataFromHandle(handle) pystir.deleteDataHandle(handle) return diff
def get_gradient_plus_sensitivity_no_penalty(self, image, subset): grad = Image() pystir.deleteDataHandle(grad.handle) grad.handle = pystir.cSTIR_objectiveFunctionGradientNotDivided\ (self.handle, image.handle, subset) _check_status(grad.handle) return grad
def __del__(self): if self.handle is not None: pystir.cSTIR_deleteObject(self.handle) if self.templ is not None: pystir.deleteDataHandle(self.templ) if self.image is not None: pystir.cSTIR_deleteObject(self.image)
def forward(self, image, filename = ''): if self.templ is None: raise error('forward projection failed: setup not done') ad = AcquisitionData() ad.handle = pystir.cSTIR_acquisitionModelForward\ (self.handle, filename, self.templ, image.handle) _check_status(ad.handle) if len(filename) > 0: pystir.deleteDataHandle(ad.handle) ad.handle = pystir.cSTIR_objectFromFile('AcquisitionData', filename) return ad
def backward(self, ad, image = None): if self.image is None: raise error('backward projection failed: setup not done') update = Image() if update.handle is not None: pystir.deleteDataHandle(update.handle) if image is None: update.handle = pystir.cSTIR_acquisitionModelBackward\ (self.handle, ad.handle, self.image) else: update.handle = pystir.cSTIR_acquisitionModelBackward\ (self.handle, ad.handle, image.handle) _check_status(update.handle) return update
def set_up(self, image): handle = pystir.cSTIR_setupReconstruction(self.handle, image.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def set_up(self): handle = pystir.cSTIR_setupObject\ ('GeneralisedObjectiveFunction', self.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def _float_par(handle, set, par): h = pystir.cSTIR_parameter(handle, set, par) _check_status(h) value = pystir.floatDataFromHandle(h) pystir.deleteDataHandle(h) return value
def set_up(self, image): handle = pystir.cSTIR_setupObjectiveFunction(self.handle, image.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def set_up(self): handle = pystir.cSTIR_setupObject('GeneralisedPrior', self.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def apply(self, image): handle = pystir.cSTIR_applyDataProcessor\ (self.handle, image.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def _set_float_par(handle, set, par, value): h = pystir.floatDataHandle(value) _setParameter(handle, set, par, h) pystir.deleteDataHandle(h)
def get_gradient(self, image): grad = Image() pystir.deleteDataHandle(grad.handle) grad.handle = pystir.cSTIR_priorGradient(self.handle, image.handle) _check_status(grad.handle) return grad
def _set_char_par(handle, set, par, value): h = pystir.charDataHandle(value) _setParameter(handle, set, par, h) pystir.deleteDataHandle(h)
def reconstruct(self, image): handle = pystir.cSTIR_runReconstruction(self.handle, image.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def _setParameter(hs, set, par, hv): h = pystir.cSTIR_setParameter(hs, set, par, hv) _check_status(h) pystir.deleteDataHandle(h)
def __del__(self): if self.handle is not None: pystir.deleteDataHandle(self.handle)
def gradient(self, image, subset): grad = Image() pystir.deleteDataHandle(grad.handle) grad.handle = pystir.cSTIR_gradient(self.handle, image.handle, subset) _check_status(grad.handle) return grad
def get_subset_sensitivity(self, subset): ss = Image() pystir.deleteDataHandle(ss.handle) ss.handle = pystir.cSTIR_subsetSensitivity(self.handle, subset) _check_status(ss.handle) return ss
def update(self, image): handle = pystir.cSTIR_updateReconstruction(self.handle, image.handle) _check_status(handle) pystir.deleteDataHandle(handle)
def __del__(self): pystir.deleteDataHandle(self.handle)