Exemplo n.º 1
0
def recons_pysap_3D(image, samples_loc, **kwargs):

    linear_op = pyWavelet3(wavelet_name="bior6.8",
                           nb_scale=4)
    fourier_op = NFFT3(samples=samples_loc, shape=image.shape)
    kspace_obs = fourier_op.op(image)
    gradient_op_cd = Gradient_pMRI(data=kspace_obs,
                                   fourier_op=fourier_op)

    x_final, transform, cost = condat_3D(
                                        gradient_op=gradient_op_cd,
                                        linear_op=linear_op,
                                        **kwargs)

    return x_final.data, cost
Exemplo n.º 2
0
    'name': 'Db4',
    'sp3d_name': 'BiOrthogonalTransform3D',
    'filter_id': 2
}, {
    'name': 'Bior35',
    'sp3d_name': 'BiOrthogonalTransform3D',
    'filter_id': 12
}, {
    'name': 'Bior44',
    'sp3d_name': 'BiOrthogonalTransform3D',
    'filter_id': 13
}]

obj_wt_pwt = [{
    'name': 'pwt_' + ite,
    'wt': pyWavelet3(wavelet_name=ite, nb_scale=nb_scale)
} for ite in list_pwt]

obj_wt_sp3d = [{
    'name':
    'sp3d_' + ite['name'],
    'wt':
    Wavelet2(wavelet_name=ite['sp3d_name'],
             nb_scale=nb_scale - 1,
             **{'type_of_filters': ite['filter_id']})
} for ite in list_sp3d]

# This is a list of wavelets, each item is a dic containing a key 'name' and a
# key 'wt' containing the object of the wt
obj_wt = obj_wt_pwt + obj_wt_sp3d
#                           in range(Il.shape[0])])

kspace_data = loadmat('/volatile/bsarthou/datas/XP_pysap/data_N320_sos_vds_nc1139/datavalues.mat')['datavalues']
kspace_data = np.moveaxis(kspace_data, -1, 0)
print(kspace_data.shape)
#############################################################################
# FISTA optimization
# ------------------
#
# We now want to refine the zero order solution using a FISTA optimization.
# Here no cost function is set, and the optimization will reach the
# maximum number of iterations. Fill free to play with this parameter.

# Start the FISTA reconstruction
max_iter = 200
linear_op = pyWavelet3(wavelet_name="sym8",
                       nb_scale=3)

# fourier_op = NFFT3(samples=samples,
#                    shape=(128, 128, 128))
fourier_op = NUFFT(samples=samples, shape=(152, 152, 104), platform='gpu')

print('Generate the zero order solution')

rec_0 = np.asarray([fourier_op.adj_op(kspace_data[l, :]) for l in range(32)])
imshow3D(np.squeeze(np.sqrt(np.sum(np.abs(rec_0)**2, axis=0))),
         display=True)

gradient_op = Gradient_pMRI(data=kspace_data,
                            fourier_op=fourier_op,
                            linear_op=linear_op,
                            S=Smaps)
Exemplo n.º 4
0
    'name': 'Bior44',
    'sp3d_name': 'BiOrthogonalTransform3D',
    'filter_id': 13
}]

# Load input data
filename = '/volatile/bsarthou/datas/' \
            'meas_MID14_gre_800um_iso_128x128x128_FID24.mat'
Iref = loadmat(filename)['ref']

for (i, pwt_name) in enumerate(list_pwt):
    for (j, dic) in enumerate(list_sp3d):
        print('Pywavelet:', pwt_name)
        time_pwt_trans, time_pwt_recons, error_pwt = [], [], []
        for k in range(R):
            linear_op = pyWavelet3(wavelet_name=pwt_name, nb_scale=nb_scale)
            start = time.clock()
            coeffs = linear_op.op(Iref)
            mid = time.clock()
            recons1 = linear_op.adj_op(coeffs)
            end = time.clock()
            time_pwt_trans.append(mid - start)
            time_pwt_recons.append(end - mid)
            error_pwt.append(np.abs((Iref - recons1).mean()))
            # print('Trans time:', mid - start, 'Recons time:', end - mid)

        print('{}: Trans, recons, error=({},{}, {})'.format(
            pwt_name, np.mean(time_pwt_trans), np.mean(time_pwt_recons),
            np.mean(error_pwt)))

        wt_type = dic['sp3d_name']