<commit_before>from __future__ import print_function
from __future__ import division
import tigre
import copy
import tigre.algorithms as algs
import numpy as np
import tigre.algorithms as algs
import time
import sys
from tigre.demos.Test_data import data_loader
from matplotlib import pyplot as plt
from tigre.utilities.Measure_Quality import Measure_Quality
#geo1 = tigre.geometry(mode='cone', high_quality=False, default=True)
geo = tigre.geometry(mode='cone', nVoxel=np.array([256,256,256]),default=True)
geo.dDetector = np.array([0.8, 0.8])*2               # size of each pixel            (mm)
geo.sDetector = geo.dDetector * geo.nDetector

niter = 10
nangles = 100
angles = np.linspace(0, 2 * np.pi, nangles, dtype=np.float32)
#head = np.load('src_img_cubic_256.npy') #data_loader.load_head_phantom(geo.nVoxel)
head = data_loader.load_head_phantom(geo.nVoxel)
proj = tigre.Ax(head,geo,angles)
fdkout = algs.fdk(proj,geo,angles)
sirtout = algs.ossart(proj,geo,angles,20,blocksize=20)
# 'RMSE'
# 'MSSIM'
# 'SSD'
# 'UQI'
print('RMSE fdk:')
print(Measure_Quality(fdkout,head,['nRMSE']))

print('RMSE ossart')
print(Measure_Quality(sirtout,head,['nRMSE']))
plt.subplot(211)
plt.imshow(fdkout[geo.nVoxel[0]//2])
plt.subplot(212)
plt.imshow(sirtout[geo.nVoxel[0]//2])
plt.colorbar()
plt.show()
# print(proj.shape)
# plt.imshow(proj[50])
# plt.show()<commit_msg>Tidy up example.py<commit_after>from __future__ import print_function
from __future__ import division
import numpy as np
from matplotlib import pyplot as plt
import tigre
import tigre.algorithms as algs
from tigre.demos.Test_data import data_loader
from tigre.utilities.Measure_Quality import Measure_Quality

# Geometry
#geo1 = tigre.geometry(mode='cone', high_quality=False, default=True)
geo = tigre.geometry(mode='cone', nVoxel=np.array([256,256,256]), default=True)
geo.dDetector = np.array([0.8, 0.8])*2               # size of each pixel            (mm)
geo.sDetector = geo.dDetector * geo.nDetector
# print(geo)

nangles = 100
angles = np.linspace(0, 2 * np.pi, nangles, endpoint=False, dtype=np.float32)

# Prepare projection data
#head = np.load('src_img_cubic_256.npy')
head = data_loader.load_head_phantom(geo.nVoxel)
proj = tigre.Ax(head,geo,angles)

# Reconstruct
niter = 20
fdkout = algs.fdk(proj,geo,angles)
sirtout = algs.ossart(proj,geo,angles,niter,blocksize=20)

# Measure Quality
# 'RMSE', 'MSSIM', 'SSD', 'UQI'
print('RMSE fdk:')
print(Measure_Quality(fdkout,head,['nRMSE']))
print('RMSE ossart')
print(Measure_Quality(sirtout,head,['nRMSE']))

# Plot
fig, axes=plt.subplots(3, 2)
axes[0, 0].set_title('FDK')
axes[0, 0].imshow(fdkout[geo.nVoxel[0]//2])
axes[1, 0].imshow(fdkout[:, geo.nVoxel[1]//2, :])
axes[2, 0].imshow(fdkout[:, :, geo.nVoxel[2]//2])
axes[0, 1].set_title('OS-SART')
axes[0, 1].imshow(sirtout[geo.nVoxel[0]//2])
axes[1, 1].imshow(sirtout[:, geo.nVoxel[1]//2, :])
axes[2, 1].imshow(sirtout[:, :, geo.nVoxel[2]//2])
plt.show()
# tigre.plotProj(proj)
# tigre.plotImg(fdkout)
{'fraction_non_alphanumeric': 0.16195286195286196, 'fraction_numerical': 0.03434343434343434, 'mean_word_length': 5.974178403755869, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3552172', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1224, 'n_words': 218}