Closed PotatoThanh closed 6 years ago
Hello, can you provide the test code for reconstruction, thank you very much!
@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.
@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.
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)
Hi all,
PotatoThanh,
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
dummy_mask = cs.cartesian_mask((500, Nx, Ny), gauss_ivar, sample_high_freq=True, sample_centre=True, sample_n=8)
cartesian_mask(shape, acc, sample_n=10, centred=False)