dataset['name'])

                    # evaluation
                    ssim_patient = mriutils.ssim(output, target)
                    rmse_patient = mriutils.rmse(output, target)
                    ssim_eval_dataset.append(ssim_patient)
                    rmse_eval_dataset.append(rmse_patient)

                    print("    Patient {:d}: {:8.4f} {:8.4f}".format(
                        patient, rmse_patient, ssim_patient))

                    output_path = '%s/%s/%d/' % (eval_output_dir,
                                                 dataset['name'], patient)
                    mriutils.saveAsMat(
                        output,
                        '%s/vn-%d.mat' % (output_path, epoch),
                        'result_vn',
                        mat_dict={'normalization': np.asarray(normalization)})
                    mriutils.saveAsMat(
                        target, (output_path, epoch),
                        '%s/reference.mat',
                        'reference',
                        mat_dict={'normalization': np.asarray(normalization)})
                    mriutils.saveAsMat(
                        input0, (output_path, epoch),
                        '%s/zero_filling.mat',
                        'result_zf',
                        mat_dict={'normalization': np.asarray(normalization)})

                print("  Dataset {:s}: {:8.4f} {:8.4f}".format(
                    dataset['name'], np.mean(rmse_eval_dataset),
            u_i = u_i * norm  # renormalize
            u_volume.append(u_i)

        # postprocessing
        u_volume = mriutils.postprocess(np.asarray(u_volume),
                                        data_config['dataset']['name'])
        time_reco = time.time() - eval_start_time
        print('reconstruction of {} image took {:f}s'.format(
            u_volume.shape, time_reco))

        print('saving reconstructed image to "{}"'.format(output_name))
        # save mat file
        patient_id = '%s-p%d' % (data_config['dataset']['name'],
                                 data_config['dataset']['patient'])
        mriutils.saveAsMat(u_volume,
                           '%s-vn-%s' % (output_name, patient_id),
                           'result_vn',
                           mat_dict={'normalization': np.asarray(norm)})

        # enhance volume
        v_min, v_max = mriutils.getContrastStretchingLimits(
            np.abs(u_volume), saturated_pixel=0.002)
        volume_enhanced = mriutils.normalize(np.abs(u_volume),
                                             v_min=v_min,
                                             v_max=v_max)

        # save pngs
        for i in range(1, num_slices + 1):
            mriutils.imsave(volume_enhanced[i - 1],
                            '%s-vn-%s-sl%d.png' % (output_name, patient_id, i))
        ssim_zf = mriutils.ssim(zf_volume, target_volume)

        print(
            "Zero filling: RMSE={:.4f} SSIM={:.4f}  VN: RMSE={:.4f} SSIM={:.4f}"
            .format(rmse_zf, ssim_zf, rmse_vn, ssim_vn))

        time_reco = time.time() - eval_start_time
        print('reconstruction of {} image took {:f}s'.format(
            u_volume.shape, time_reco))

        print('saving reconstructed image to "{}"'.format(output_name))
        # save mat files
        patient_id = '%s-p%d' % (data_config['dataset']['name'],
                                 data_config['dataset']['patient'])
        mriutils.saveAsMat(u_volume,
                           '%s-vn-%s' % (output_name, patient_id),
                           'result_vn',
                           mat_dict={'normalization': np.asarray(norm)})
        mriutils.saveAsMat(zf_volume,
                           '%s-zf-%s' % (output_name, patient_id),
                           'result_zf',
                           mat_dict={'normalization': np.asarray(norm)})
        mriutils.saveAsMat(target_volume,
                           '%s-ref-%s' % (output_name, patient_id),
                           'reference',
                           mat_dict={'normalization': np.asarray(norm)})

        # enhance image with same parameters for all images
        v_min, v_max = mriutils.getContrastStretchingLimits(
            np.abs(target_volume), saturated_pixel=0.002)
        target_enhanced = mriutils.normalize(np.abs(target_volume),
                                             v_min=v_min,