js3611 / Deep-MRI-Reconstruction

Deep Cascade of Convolutional Neural Networks for MR Image Reconstruction: Implementation & Demo
Other
322 stars 104 forks source link

incorrect when calling undersampling mask in 2D case #1

Closed PotatoThanh closed 6 years ago

PotatoThanh commented 7 years ago
ZJL0517 commented 6 years ago

Hello, can you provide the test code for reconstruction, thank you very much!

PotatoThanh commented 6 years ago

@jerrold1988 I haven't changed anything in the source code. I just tried to run main_2d.py and I got an error when the code calls cs.cartesian_mask(...) but cartesian_mask(...) has different params.

ZJL0517 commented 6 years ago

@PotatoThanh Hi, I have adjust the code main_2d.py correctly, do you know how to use the trained model to reconstruct the new mri image? I study the deep learning recently.

PotatoThanh commented 6 years ago

Thanks for asking. I'm training new model with my brain and cardiac data. You should write the code for reload trained model using Lasagne that I already did it in my own code.

with np.load('model.npz') as f:
    param_values = [f['arr_%d' % i] for i in range(len(f.files))]
    lasagne.layers.set_all_param_values(net, param_values)

vis = []
test_err = 0
base_psnr = 0
test_psnr = 0
test_batches = 0
for im in iterate_minibatch(test, batch_size, shuffle=False):
    im_und, k_und, mask, im_gnd = prep_input(im)

    err, pred = val_fn(im_und, mask, k_und, im_gnd)
    test_err += err
    for im_i, und_i, pred_i in zip(im,
                                   from_lasagne_format(im_und),
                                   from_lasagne_format(pred)):
        base_psnr += complex_psnr(im_i, und_i, peak='max')
        test_psnr += complex_psnr(im_i, pred_i, peak='max')
    test_batches += 1

    if save_fig and test_batches % save_every == 0:
        vis.append((im[0],
                    from_lasagne_format(pred)[0],
                    from_lasagne_format(im_und)[0],
                    from_lasagne_format(mask, mask=True)[0]))

    if args.debug and test_batches == 20:
        break

t_end = time.time()
test_err /= test_batches
base_psnr /= (test_batches * batch_size)
test_psnr /= (test_batches * batch_size)
js3611 commented 6 years ago

Hi all,

PotatoThanh,

  1. Thanks for pointing it out. When I added the dynamic reconstruction part, I also updated the sampling mask generator. I forgot to change the code for the 2d version.
  2. I also added in the demo where you can load pretrained weights.

jerrold1988

As PotatoThanh mentioned, you need to load the pretrained weights as he mentioned. At the moment the demo code is for training and testing. You should be able to modify the code to run the model on new image dataset.

Best,

Jo