Esempio n. 1
0
def _run_reco(args):
    # Read input data
    kspace_data, trajectory, noise, data_par, coils = read_data(
        pathtofile=args.pathtofile,
        undersampling_factor=args.undersampling_factor)
    # Setup parameters
    parameter = setup_parameter_dict(args.configfile,
                                     rawdata=kspace_data,
                                     trajectory=trajectory,
                                     data_par=data_par)

    # Decorrelate Coil channels if noise scan is present
    kspace_data, coils = _decor_noise(data=kspace_data,
                                      noise=noise,
                                      par=parameter["Data"],
                                      coils=coils)

    # Get coil sensitivities in the parameter dict
    estimate_coil_sensitivities(kspace_data,
                                trajectory,
                                parameter,
                                coils=coils)
    # Save coils if not present
    _save_coil_(pathtofile=args.pathtofile,
                undersampling_factor=args.undersampling_factor,
                par=parameter["Data"])

    # Get operator
    MRImagingOperator = linop.MRIImagingModel(parameter, trajectory)
    cgs = solver.CGReco(data_par=parameter["Data"],
                        optimizer_par=parameter["Optimizer"])
    print("Starting reconstruction...")
    cgs.set_operator(MRImagingOperator)
    # Start reconstruction
    # Data needs to be multiplied with the sqrt of dense_cor to assure that
    # forward and adjoint application of the NUFFT is adjoint with each other.
    # dens_cor itself is saved in the par dict as the sqrt.
    recon_result, residuals = cgs.optimize(data=kspace_data *
                                           parameter["FFT"]["dens_cor"])

    # Single Coil images after FFT
    single_coil_images = cgs.operator.NUFFT.adjoint(
        kspace_data * parameter["FFT"]["dens_cor"])

    # Store results
    save_to_file(recon_result, residuals, single_coil_images,
                 parameter["Data"], args)
Esempio n. 2
0
    def setUp(self):
        parser = tmpArgs()
        parser.streamed = False
        parser.devices = [0]
        parser.use_GPU = True

        par = {}
        setupPar(par)

        self.op = linop.MRIImagingModel(par, par["traj"])

        self.opinfwd = (np.random.randn(par["Data"]["image_dim"],
                                        par["Data"]["image_dim"]) +
                        1j * np.random.randn(par["Data"]["image_dim"],
                                             par["Data"]["image_dim"]))
        self.opinadj = (
            np.random.randn(par["Data"]["num_coils"], par["Data"]["num_proj"],
                            par["Data"]["num_reads"]) + 1j *
            np.random.randn(par["Data"]["num_coils"], par["Data"]["num_proj"],
                            par["Data"]["num_reads"]))

        self.opinfwd = self.opinfwd.astype(DTYPE)
        self.opinadj = self.opinadj.astype(DTYPE)