Skip to content

Commit

Permalink
SheppLogan example
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigovimieiro committed Aug 27, 2021
1 parent 566a4be commit 4628ab3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
65 changes: 65 additions & 0 deletions pydbt/demos/shepp_logan_phantom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 30 13:49:27 2020
@author: Rodrigo
"""

#%%
import matplotlib.pyplot as plt
import numpy as np
import sys

sys.path.insert(1,'../')

from parameterSettings import geometry_settings

from functions.initialConfig import initialConfig
from functions.phantoms import phantom3d

from functions.projectionDD import projectionDD

from functions.FBP import FDK as FBP


#%% Call function for initial configurations

libFiles = initialConfig()

#%% Create a DBT geometry

geo = geometry_settings()
geo.SheppLogan()

#%% Gen Phantom

sheppLogan = phantom3d(n=geo.nx)
sheppLogan = sheppLogan[:,:,np.round(np.linspace(0,geo.nx-1,geo.nz)).astype(np.int32)]

#%% Project Phantom

print("Starting projection...")

proj = projectionDD(sheppLogan, geo, libFiles)

plt.figure()
plt.title('Projected volume')
plt.imshow(proj[:,:,4] , cmap=plt.get_cmap('gist_gray'))

#%% Set specific recon parameters

nIter = [2]; # Number of iterations (SIRT)
filterType = 'FBP'; # Filter type: 'BP', 'FBP'
cutoff = 0.75; # Percentage until cut off frequency (FBP)

#%%

print("Starting reconstruction...")

# ## Uncomment to use ##
vol = FBP(proj, geo, filterType, cutoff, libFiles)

plt.figure()
plt.title('Reconstructed slice')
plt.imshow(vol[:,:,64] , cmap=plt.get_cmap('gist_gray'))
7 changes: 6 additions & 1 deletion pydbt/functions/initialConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def findLibraries(workDir):
buildDir = workDir / '../build'

if not(buildDir.exists() and buildDir.is_dir()):
raise ValueError('Cannot find the build folder. Make sure to run the setup.py or follow the instructions on the package Github.')

buildDir = workDir / '../../build'

if not(buildDir.exists() and buildDir.is_dir()):

raise ValueError('Cannot find the build folder. Make sure to run the setup.py or follow the instructions on the package Github.')

libDir = []

Expand Down

0 comments on commit 4628ab3

Please sign in to comment.