def kSpaceFill(self, vol): (ns, _, nx) = vol.shape ny = self.fill_size fill_vol = N.zeros((ns,ny,nx), N.complex64) for s in range(ns): embedIm(vol[s], fill_vol[s], self.fill_rows, 0) return fill_vol.astype(vol.dtype)
def imageFromFill2D(self, slice): (_, nx) = slice.shape ny = self.fill_size fill_slice = N.zeros((ny,nx), N.complex128) embedIm(slice, fill_slice, self.fill_rows, 0) fill_slice[:] = ifft2d(fill_slice) return fill_slice
def run(self, image): (nv, ns, ny, nx) = image.tdim and image.shape or (1, ) + image.shape old_shape = image.shape new_shape = list(old_shape) new_shape[-2:] = [ny * 2, nx * 2] # pixel size will go down image.jsize, image.isize = (image.jsize / 2., image.isize / 2.) image.resize(new_shape) #b points to the "old data" inside the resized array, shaped the old way b = N.reshape(image[:].flat[0:N.product(old_shape)], old_shape) for vol in (nv - N.arange(nv) - 1): for sl in (ns - N.arange(ns) - 1): if (sl == 0 and vol == 0): continue # be careful in case it's a 3d array slicer = image.tdim and (vol, sl) or (sl, ) # put old slicer into new one cornered at (ny/2, nx/2) embedIm(b[slicer], image[slicer], ny / 2, nx / 2) #do last slice with permanent copy, or else b gets zero'd b = N.reshape(image[:].flatten()[0:ny * nx], (ny, nx)).copy() final_slicer = image.tdim and (0, 0) or (0, ) embedIm(b, image[final_slicer], ny / 2, nx / 2) image.setData(image[:])
def run(self, image): (nv, ns, ny, nx) = image.tdim and image.shape or (1,) + image.shape old_shape = image.shape new_shape = list(old_shape) new_shape[-2:] = [ny*2, nx*2] # pixel size will go down image.jsize, image.isize = (image.jsize/2., image.isize/2.) image.resize(new_shape) #b points to the "old data" inside the resized array, shaped the old way b = N.reshape(image[:].flat[0:N.product(old_shape)], old_shape) for vol in (nv - N.arange(nv) - 1): for sl in (ns - N.arange(ns) - 1): if(sl == 0 and vol == 0): continue # be careful in case it's a 3d array slicer = image.tdim and (vol,sl) or (sl,) # put old slicer into new one cornered at (ny/2, nx/2) embedIm(b[slicer], image[slicer], ny/2, nx/2) #do last slice with permanent copy, or else b gets zero'd b = N.reshape(image[:].flatten()[0:ny*nx], (ny,nx)).copy() final_slicer = image.tdim and (0,0) or (0,) embedIm(b, image[final_slicer], ny/2, nx/2) image.setData(image[:])