From dcf1883b0e5bcd30223f35bf0de56fe96ab135a0 Mon Sep 17 00:00:00 2001 From: Coldly Date: Tue, 1 Apr 2025 17:59:20 +0800 Subject: [PATCH 1/2] Modify and update the code related to the PICCS algorithm module. --- Common/CUDA/PICCS.cu | 16 +++--- Common/CUDA/PICCS.hpp | 2 +- Python/setup.py | 21 +++++++- .../tigre/algorithms/iterative_recon_alg.py | 6 +++ Python/tigre/algorithms/pocs_algorithms.py | 13 ++++- .../tigre/utilities/cuda_interface/_PICCS.pyx | 50 +++++++++++++++++++ 6 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 Python/tigre/utilities/cuda_interface/_PICCS.pyx diff --git a/Common/CUDA/PICCS.cu b/Common/CUDA/PICCS.cu index 481ede08..0ddae170 100644 --- a/Common/CUDA/PICCS.cu +++ b/Common/CUDA/PICCS.cu @@ -54,7 +54,7 @@ Codes : https://github.com/CERN/TIGRE #define MAXTHREADS 1024 #include "PICCS.hpp" - +#include "gpuUtils.hpp" @@ -114,17 +114,21 @@ do { \ unsigned long size2d = rows*cols; unsigned long long idx = z * size2d + y * cols + x; - float uidx = u[idx]; + // float uidx = u[idx]; + float uidx = 0; if ( z - 1 >= 0 && z= 0 && y= 0 && y= 0 && x= 0 && x src.shape[0] + size_img[1]= src.shape[1] + size_img[2]= src.shape[2] + + cdef float* c_imgout = malloc(size_img[0] *size_img[1] *size_img[2]* sizeof(float)) + + cdef long imgsize[3] + imgsize[0] = size_img[2] + imgsize[1] = size_img[1] + imgsize[2] = size_img[0] + + src = np.ascontiguousarray(src) + prior = np.ascontiguousarray(prior) + + cdef float* c_src = src.data + cdef float* c_prior = prior.data + cdef np.npy_intp c_maxiter = maxiter + cuda_raise_errors(piccs_tv(c_src, c_prior, c_imgout, alpha, ratio, imgsize, c_maxiter, c_gpuids[0])) + imgout = np.PyArray_SimpleNewFromData(3, size_img, np.NPY_FLOAT32, c_imgout) + PyArray_ENABLEFLAGS(imgout, np.NPY_OWNDATA) + + return imgout From 7a37a9e3cfb0e96924eeaef17d820e0159d85043 Mon Sep 17 00:00:00 2001 From: Coldly Date: Tue, 1 Apr 2025 21:10:42 +0800 Subject: [PATCH 2/2] little change in the PICCS module --- Python/tigre/algorithms/iterative_recon_alg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/tigre/algorithms/iterative_recon_alg.py b/Python/tigre/algorithms/iterative_recon_alg.py index a3e01b14..560ce3db 100644 --- a/Python/tigre/algorithms/iterative_recon_alg.py +++ b/Python/tigre/algorithms/iterative_recon_alg.py @@ -356,7 +356,7 @@ def minimizeAwTV(self, res_prev, dtvg): self.gpuids = GpuIds() return AwminTV(res_prev, dtvg, self.numiter_tv, self.delta, self.gpuids) - def PICCS_TV(self, res_prev, res_prior, dtvg, ratio): + def PICCS(self, res_prev, res_prior, dtvg, ratio): if self.gpuids is None: self.gpuids = GpuIds() return PICCS(res_prev, res_prior, dtvg, ratio, self.numiter_tv, self.gpuids)