pytomography

Installation

1.conda create -n pytomography_env -c conda-forge libparallelproj parallelproj pytorch cupy cudatoolkit=11.8

注意可能会因为CUDA版本问题而报错,最好在创建虚拟环境的时候设置好版本

python -c "import parallelproj" 检验是否成功,并且可以测试官方案例

2. pip install pytomography

接下来按照官方案例去跑即可

Load data

1.加载scanner的参数

2.加载listmode数据

Set parameter

# Specify object space for reconstruction
object_meta = ObjectMeta(
    dr=(1,1,1), #mm
    shape=(240,240,240) #voxels
)
# Get projection space metadata from PET geometry information dictionary
proj_meta = PETLMProjMeta(
    detector_ids = detector_ids, # list of all detected event detector ID pairs
    info = info
    # weights_sensitivity=normalization_weights
    )
psf_transform = GaussianFilter(3.25) # gaussian blurring
# Create system matrix
system_matrix = PETLMSystemMatrix(
    object_meta,
    proj_meta,
    obj2obj_transforms = [psf_transform],
    # attenuation_map = atten_map,
    # N_splits=8,
)
# Create likelihood. For listmode reconstruction, projections don't need to be provided, since all detection events are stored in proj_meta
likelihood = PoissonLogLikelihood(
    system_matrix
)
# Initialize reconstruction algorithm
recon_algorithm = OSEM(likelihood)
# Reconstruct
recon_primaryonly = recon_algorithm(n_iters=50, n_subsets=1)

可视化成像结果

vmax = 0.5
fig, ax = plt.subplots(1,3,figsize=(12,4))
plt.subplot(131)
plt.pcolormesh(recon_primaryonly[120,16:-16].cpu().T, cmap='gray', shading='gouraud', vmax=vmax)
plt.axis('off')
plt.subplot(132)
plt.pcolormesh(recon_primaryonly[16:-16,120].cpu().T, cmap='gray', shading='gouraud', vmax=vmax)
plt.axis('off')
plt.subplot(133)
plt.pcolormesh(recon_primaryonly[:,:,120].cpu().T, cmap='gray', shading='gouraud', vmax=vmax)
plt.axis('off')
fig.tight_layout()
plt.show()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值