8000 How to set angle for Sparse-view Fanbeam CT simulation · Issue #149 · LLNL/LEAP · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

How to set angle for Sparse-view Fanbeam CT simulation #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GreameLee opened this issue Feb 19, 2025 · 2 comments
Open

How to set angle for Sparse-view Fanbeam CT simulation #149

GreameLee opened this issue Feb 19, 2025 · 2 comments

Comments

@GreameLee
Copy link

Hello, Kyle,
I am simulating a sparse-view fan-beam CT image. Given an clear CT image, I first do forward to get the sinogram and then use FBP to get its reconstructed image. Here is the code:

import sys
import os
import time
import numpy as np
from leapctype import *
import matplotlib.pyplot as plt
leapct = tomographicModels()
leapct.about()

numCols = 821
numAngles = 150   # 984 views for 360 degree, 150 views for 55 degree
print(numAngles)
start_angle = 0
end_angle = start_angle + 360
angles = np.linspace(start_angle, end_angle, numAngles, dtype=np.float32)

pixelSizex = 1.09
pixelSizey = 0.8224 * 1097 / 821

numZ = 1
numY = 256
numX = 256

numRows = 1
numCols, pixelSize, pixelSize, 0.5*(numRows-1), 0.5*(numCols-1), leapct.setAngleArray(numAngles, 360.0), 1100, 1400)
leapct.set_fanbeam(numAngles, numRows, numCols, pixelSizex, pixelSizey, 0.5*(numRows-1), 0.5*(numCols-1), angles, 625.61, 1097)
leapct.set_default_volume()

leapct.set_volume(numX, numY, numZ, voxelWidth=None, voxelHeight=None, offsetX=None, offsetY=None, offsetZ=None)
leapct.print_parameters()

g = leapct.allocateProjections() # shape is numAngles, numRows, numCols
f = leapct.allocateVolume()

img = np.load('xcat_test.npy')
f = 255*img[None,:,:].astype(np.float32)

startTime = time.time()
leapct.project(g,f)
print('Forward Projection Elapsed Time: ' + str(time.time()-startTime))

plt
plt.imshow(np.squeeze(g), cmap='gray')
plt.savefig('sinogram')

f[:] = 0.0
startTime = time.time()
leapct.FBP(g,f)
print('Reconstruction Elapsed Time: ' + str(time.time()-startTime))

plt.imshow(np.squeeze(f[f.shape[0]//2,:,:]), cmap='gray')

f.shape 

The total number of projections is 984 and I want to set the angle start 0 to 360 degree. But the fbp.png is much clearer than what I expected.
I feel confused about why I did not see a parameter that I should set the total number of projections
Looking forward to your reply.

@GreameLee
Copy link
Author

I guess for my case 984 views represent 360 degree, so if I want to use 55 views from 984 views, I should set the numangles = 55*360//984≈20?

@kylechampley
Copy link
Collaborator

I'm not sure I follow the math from your last post, but the reason you don't see any artifacts is that your volume is very low resolution. You have numX = 256 and numAngles = 150. Those numbers are pretty close. I wouldn't expect to see big artifacts until numAngles < numX/10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0