PET图像重建MELM算法

import numpy as np
import torch
import torch as th
import torch.nn as nn


from torch_radon import ParallelBeam



def performMLEM_radon(image, data, iters=50):
    """
    Perform MLEM using radon transform for PET image reconstruction.

    Parameters:
    image : 2D numpy array
        Initial guess for the image.
    data : 2D numpy array
        Sinogram data (projection data).
    theta : 1D numpy array
        Projection angles (in degrees).
    iters : int
        Number of iterations.

    Returns:
    guess : 2D numpy array
        Reconstructed image.
    """
    data = data.cuda()
    image = image.cuda()
    if len(image.shape)==4:
        b,c,h,w = image.shape
    elif len(image.shape)==2:
        h,w = image.shape
    elif len(image.shape)==3:
        raise ValueError("input shape is wrong")
    assert h == w ,"input pet image has wrong shape"
    pbeam = ParallelBeam(h,np.linspace(0, np.pi, h, endpoint=False))
    guess = torch.ones_like(image)
    ones = torch.ones_like(image)
    for i in range(iters):
        # Forward projection (radon transform)
        projection = pbeam.forward(guess)

        # Ratio of measured data to projection
        ratio = data / (projection + 1e-10)

        # Backprojection (filtered backprojection)
        backprojection = pbeam.backward(ratio)

        # Sensitivity (backprojection of ones)
        sensitivity = pbeam.backward(ones)

        # Update guess
        guess = guess * (backprojection / (sensitivity + 1e-10))

        # Optional: print or log progress
        # print(np.linalg.norm(radon(guess, theta=theta, circle=True) - data))
        # print(i)

    return guess

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值