跳转到主要内容

用于CUDA加速3D反卷积的Python封装

项目描述

pyCUDAdecon

本包提供了cudaDecon的Python封装和便利函数,它是加速的Richardson Lucy反卷积算法的CUDA/C++实现1

  • CUDA加速反卷积,具有一些减少伪影的特征。
  • 具有插值以保持PSF和数据体积之间体素大小独立的径向平均OTF生成
  • 3D直方图,旋转,一般仿射变换
  • CUDA基于的相机校正,用于sCMOS伪影校正

安装

conda包包括Windows和Linux所需的前编译库。请参阅GPU驱动程序要求以下

conda install -c conda-forge pycudadecon

不支持macOS

📖   文档

GPU要求

本软件需要兼容CUDA的NVIDIA GPU。底层cudadecon库针对不同版本的CUDA工具包进行了编译。所需的CUDA库已包含在conda发行版中,因此您无需单独安装CUDA工具包。如果您需要,可以根据自己的需求选择CUDA版本,但请注意,CUDA工具包的不同版本有不同的GPU驱动程序要求。

要指定特定的cudatoolkit版本,按照以下方式进行安装(例如,要使用cudatoolkit=10.2):

conda install -c conda-forge pycudadecon cudatoolkit=10.2
CUDA Linux驱动程序 Windows驱动程序
10.2 ≥ 440.33 ≥ 441.22
11.0 ≥ 450.36.06 ≥ 451.22
11.1 ≥ 455.23 ≥ 456.38
11.2 ≥ 460.27.03 ≥ 460.82

如果您遇到问题,请随时提交问题并描述您的设置。

用法

pycudadecon.decon()函数设计用于处理大多数基本应用。

from pycudadecon import decon

# pass filenames of an image and a PSF
result = decon('/path/to/3D_image.tif', '/path/to/3D_psf.tif')

# decon also accepts numpy arrays
result = decon(img_array, psf_array)

# the image source can also be a sequence of arrays or paths
result = decon([img_array, '/path/to/3D_image.tif'], psf_array)

# see docstrings for additional parameter options

为了更精确的控制,您可能希望使用pycudadecon.make_otf()将PSF转换为OTF文件,然后使用pycudadecon.RLContext上下文管理器设置GPU以用于pycudadecon.rl_decon()函数。请注意,在相同上下文中处理的每个图像都必须具有相同的输入形状。

from pycudadecon import RLContext, rl_decon
from glob import glob
import tifffile

image_folder = '/path/to/some_images/'
imlist = glob(image_folder + '*488*.tif')
otf_path = '/path/to/pregenerated_otf.tif'

with tifffile.TiffFile(imlist[0]) as tf:
    imshape = tf.series[0].shape

with RLContext(imshape, otf_path, dz) as ctx:
    for impath in imlist:
        image = tifffile.imread(impath)
        result = rl_decon(image, ctx.out_shape)
        # do something with result...

如果您有一个3D PSF体积,pycudadecon.TemporaryOTF上下文管理器简化了临时OTF的生成...

 # continuing with the variables from the previous example...
 psf_path = "/path/to/psf_3D.tif"
 with TemporaryOTF(psf) as otf:
     with RLContext(imshape, otf.path, dz) as ctx:
         for impath in imlist:
             image = tifffile.imread(impath)
             result = rl_decon(image, ctx.out_shape)
             # do something with result...

... 这段代码基本上就是pycudadecon.decon()函数所做的,增加了一些额外的便利。

这些函数都有许多选项,接受多个关键字参数。请参阅文档以获取有关各自函数的更多信息。

有关仿射变换、体积旋转和平移(典型于使用舞台扫描获取的轻片体积)的示例和信息,请参阅仿射变换文档


1 D.S.C. Biggs和M. Andrews,加速迭代图像恢复算法,应用光学,第36卷,第8期,1997年。https://doi.org/10.1364/AO.36.001766

项目详情


下载文件

下载适合您平台的文件。如果您不确定要选择哪个,请了解更多关于安装包的信息。

源分布

pycudadecon-0.5.1.tar.gz (52.4 MB 查看散列)

上传时间

构建分布

pycudadecon-0.5.1-py3-none-any.whl (22.9 kB 查看散列)

上传时间 Python 3

由以下支持