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))
'%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, v_max=v_max) u_i_enhanced = mriutils.normalize(np.abs(u_volume), v_min=v_min, v_max=v_max) zf_enhanced = mriutils.normalize(np.abs(zf_volume), v_min=v_min, v_max=v_max) # save pngs for i in range(1, num_slices + 1): mriutils.imsave(u_i_enhanced[i - 1], '%s-vn-%s-sl%d.png' % (output_name, patient_id, i)) mriutils.imsave( target_enhanced[i - 1], '%s-ref-%s-sl%d.png' % (output_name, patient_id, i)) mriutils.imsave(zf_enhanced[i - 1], '%s-zf-%s-sl%d.png' % (output_name, patient_id, i))
print('start reconstruction') eval_start_time = time.time() feed_dict, norm = data.get_test_feed_dict( data_config['dataset'], data_config['dataset']['patient'], data_config['dataset']['slice'], return_norm=True) # get the reconstruction, re-normalize and postprocesss it u_i = sess.run(u_op, feed_dict=feed_dict)[0] u_i = u_i * norm # renormalize u_i = mriutils.postprocess(u_i, data_config['dataset']['name']) time_reco = time.time() - eval_start_time print('reconstruction of {} image took {:f}s'.format( u_i.shape, time_reco)) print('saving reconstructed image to "{}"'.format(output_name)) # save mat file patient_id = '%s-p%d-sl%d' % (data_config['dataset']['name'], data_config['dataset']['patient'], data_config['dataset']['slice']) mriutils.saveAsMat(u_i, '%s-vn-%s.mat' % (output_name, patient_id), 'result_vn', mat_dict={'normalization': np.asarray(norm)}) # enhance image and save as png u_i_enhanced = mriutils.contrastStretching(np.abs(u_i), 0.002) mriutils.imsave(u_i_enhanced, '%s-vn-%s.png' % (output_name, patient_id))
print('reconstruction of {} image took {:f}s'.format(u_i.shape, time_reco)) print('saving reconstructed image to "{}"'.format(output_name)) # save mat files patient_id = '%s-p%d-sl%d' % (data_config['dataset']['name'], data_config['dataset']['patient'], data_config['dataset']['slice']) mriutils.saveAsMat(u_i, '%s-vn-%s' % (output_name, patient_id), 'result_vn', mat_dict={'normalization': np.asarray(norm)}) mriutils.saveAsMat(zero_filling, '%s-zf-%s' % (output_name, patient_id), 'result_zf', mat_dict={'normalization': np.asarray(norm)}) mriutils.saveAsMat(target, '%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), saturated_pixel=0.002) target_enhanced = mriutils.normalize(np.abs(target), v_min=v_min, v_max=v_max) u_i_enhanced = mriutils.normalize(np.abs(u_i), v_min=v_min, v_max=v_max) zf_enhanced = mriutils.normalize(np.abs(zero_filling), v_min=v_min, v_max=v_max) # save pngs mriutils.imsave(u_i_enhanced, '%s-vn-%s.png' % (output_name, patient_id)) mriutils.imsave(target_enhanced, '%s-ref-%s.png' % (output_name, patient_id)) mriutils.imsave(zf_enhanced, '%s-zf-%s.png' % (output_name, patient_id))