forked from yqx7150/IFR-Net-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IFR_Net_test.m
57 lines (56 loc) · 2.01 KB
/
IFR_Net_test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%% The is a test Code based on the method described in the following paper:
% IFR-Net: Iterative Feature Refinement Network for Compressed Sensing MRI
% Author: Yiling Liu, Qiegen Liu, Minghui Zhang, Qingxin Yang, Shanshan Wang and Dong Liang
% Date : 10/2019
% Version : 4.0
% The code and the algorithm are for non-comercial use only.
% Copyright 2019, Department of Electronic Information Engineering, Nanchang University.
%
% Input:
% M0: The corresponding ground truth image.
% mask: The undersampling pattern.
% y: Undersampled k-space.
% net: The trained net.
%
% Outputs:
% re_Loss: The loss of denoised image.
% rec_image: The reconstructed image.
clc; clear;close all;
%% add path
addpath('./layersfunction')
addpath('./mask')
addpath('./matconvnet')
addpath('./Test_data')
addpath('./Train_data')
addpath('./Train_output')
addpath('./util')
addpath(genpath(pwd))
vl_compilenn; % prepare for MatConvNet
%% Load trained network
load('./Train_output/net/net-radial30.mat')
% load('./Train_output/net/IFR-net-epoch-74.mat')
%% Load data
load('./test_data/knee02.mat')
M0 = abs(im2double(Img));
if (length(size(M0))>2); M0 = rgb2gray(M0); end
M0 = (M0 - min(M0(:)))/(max(M0(:)) - min(M0(:))); % normalization
%% Load mask
load mask_radial30.mat; mask = fftshift(mask);
%% Undersampling in the k-space
kspace_full = fft2(M0); % full K-space
y = (double(kspace_full)) .* mask;% undersampled K-space
data.test = y; % input
data.label = M0; % label
data.mask = mask; % undersampling pattern
%% reconstruction by IFR-Net
tic;
res = vl_simplenn_LYL_test(net, data); % reconstrution procedure
Time_Net_rec = toc;
rec_image = res(end-1).x;
%% evaluation
re_Loss = res(end).x;
re_PSNR = psnr(abs(rec_image) , abs(data.label)) ;
HFEN = norm(imfilter(abs(rec_image),fspecial('log',15,1.5)) - imfilter(data.label,fspecial('log',15,1.5)),'fro');
SSIM = cal_ssim(255*rec_image, 255*data.label, 0, 0 );
fprintf('IFR-Net reconstruction: NMSE %.4f, PSNR %.4f, HFEN %.4f, SSIM %.4f.\n2,',re_Loss, re_PSNR, HFEN, SSIM);
figure(22);imshow(abs(rec_image),[]);