def test_ones_JsenseRecon(self): img_shape = [6, 6] mps_shape = [4, 6, 6] img = np.ones(img_shape, dtype=np.complex) mps = sim.birdcage_maps(mps_shape) ksp = sp.fft(mps * img, axes=[-2, -1]) _app = app.JsenseRecon(ksp, mps_ker_width=6, ksp_calib_width=6) mps_rec = _app.run() npt.assert_allclose(mps, mps_rec, atol=1e-3, rtol=1e-3)
def process_slice(kspace, args, calib_method='jsense'): # get data dimensions nky, nkz, nechoes, ncoils = kspace.shape # ESPIRiT parameters nmaps = args.num_emaps calib_size = args.ncalib crop_value = args.crop_value if args.device is -1: device = sp.cpu_device else: device = sp.Device(args.device) # compute sensitivity maps (BART) #cmd = f'ecalib -d 0 -S -m {nmaps} -c {crop_value} -r {calib_size}' #maps = bart.bart(1, cmd, kspace[:,:,0,None,:]) #maps = np.reshape(maps, (nky, nkz, 1, ncoils, nmaps)) # compute sensitivity maps (SigPy) ksp = np.transpose(kspace[:, :, 0, :], [2, 1, 0]) if calib_method is 'espirit': maps = app.EspiritCalib(ksp, calib_width=calib_size, crop=crop_value, device=device, show_pbar=False).run() elif calib_method is 'jsense': maps = app.JsenseRecon(ksp, mps_ker_width=6, ksp_calib_width=calib_size, device=device, show_pbar=False).run() else: raise ValueError('%s calibration method not implemented...' % calib_method) maps = np.reshape(np.transpose(maps, [2, 1, 0]), (nky, nkz, 1, ncoils, nmaps)) # Convert everything to tensors kspace_tensor = cplx.to_tensor(kspace).unsqueeze(0) maps_tensor = cplx.to_tensor(maps).unsqueeze(0) # Do coil combination using sensitivity maps (PyTorch) A = T.SenseModel(maps_tensor) im_tensor = A(kspace_tensor, adjoint=True) # Convert tensor back to numpy array image = cplx.to_numpy(im_tensor.squeeze(0)) return image, maps