nuf_ob = MriSenseNufft(im_size=(nx, nx), smap=smapT).to(dtype) nuf_ob = nuf_ob.to(gpu) adjnuf_ob = AdjMriSenseNufft(im_size=(nx, nx), smap=smapT).to(dtype) adjnuf_ob = adjnuf_ob.to(gpu) d2 = sio.loadmat('/Shared/lss_jcb/abdul/prashant_cardiac_data/Data/ktraj.mat') ktraj = np.asarray(d2['ktraj']) ktraj = ktraj.astype(np.complex64) ktraj = np.transpose(ktraj, (2, 1, 0)) / nx ktraj = ktraj[0:NF] ktraj = np.reshape(ktraj, (1, NF * nintl * nx)) * 2 * np.pi #dcf=np.abs(ktraj) ktraj = np.stack((np.real(ktraj), np.imag(ktraj)), axis=1) dcf = calculate_radial_dcomp_pytorch(nuf_ob, adjnuf_ob, torch.tensor(ktraj).cuda()) dcf = torch.tensor(dcf).unsqueeze(0).unsqueeze(0) #dcf=dcf.repeat(nbasis,nch,2,1) dcf = dcf.repeat(1, 1, 2, 1) ktraj = np.tile(ktraj, (nbasis, 1, 1)) ktrajT = torch.tensor(ktraj).to(dtype) cc = torch.zeros((1, 1, 2, nx, nx)).cuda() cc[0, 0, :, 255, 255] = 1 #cc[0,0,:,236,247]=1 tr = ktrajT[0].unsqueeze(0) dd = nuf_ob(cc, tr.cuda()) ee1 = adjnuf_ob(dd * dcf.cuda(), tr.cuda()) dcf = dcf / ee1[0, 0, 0, 255, 255]
adjnuf_ob = adjnuf_ob.to(gpu) #real_mat, imag_mat = precomp_sparse_mats(ktrajT, adjnuf_ob) #interp_mats = {'real_interp_mats': real_mat, 'imag_interp_mats': imag_mat} nufft_ob1 = MriSenseNufft(im_size=im_size, smap=smapT2).to(dtype) nufft_ob1 = nufft_ob1.to(gpu) nufft_ob = MriSenseNufft(im_size=im_size, smap=smapT).to(dtype) nufft_ob = nufft_ob.to(gpu) adjnufft_ob = AdjMriSenseNufft(im_size=im_size, smap=smapT).to(dtype) adjnufft_ob = adjnufft_ob.to(gpu) #nufft_ob = MriSenseNufft(smap=smapT,im_size=im_size).to(dtype) #adjnufft_ob = AdjMriSenseNufft(smap=smapT,im_size=im_size ).to(dtype) #At=lambda x: adjnufft_ob(x*dcfT,ktrajT,interp_mats) #A=lambda x: nufft_ob(x,ktrajT,interp_mats) dcfT = calculate_radial_dcomp_pytorch(nufft_ob, adjnufft_ob, ktrajT) kdataT = nufft_ob1(atbT, ktrajT1) kdataT = kdataT.permute(1, 2, 0, 3) atb = torch.zeros((nbasis, im_size[0], im_size[1])) kdataT = torch.reshape(kdataT, (1, nch, 2, NF, nintl * nkpts)) kdataT = kdataT.permute(3, 0, 1, 2, 4) kdataT = torch.reshape(kdataT, (NF, 1 * nch * 2 * nintl * nkpts)) temp = torch.matmul(VT, kdataT) temp = torch.reshape(temp, (nbasis, NF, 1, nch, 2, nintl * nkpts)) temp = temp.permute(0, 2, 3, 4, 1, 5) temp = torch.reshape(temp, (nbasis, nch, 2, NF * nintl * nkpts)) atb = adjnufft_ob(temp, ktrajT) #ktb=nufft_ob(atb,ktrajT)