生成已知体积变化的位移场
disptools的Python项目详细描述
显示工具
生成具有已知体积变化的位移场
此库提供实用程序来生成和操作具有已知体积更改的置换字段。它实现了三种基于搜索的变形场生成算法,以及一小部分实用功能,并通过CUDA实现提供了可选的GPU加速。
实现的三种算法称为:
- 梯度:梯度下降法(默认)。
- 贪心:在[1]中提出的贪心搜索方法
- 匹配:提出了一种体积匹配方法。该实现来自预测atrophysim工具
这个库是在simpleitk的基础上构建的,目的是为图像分析提供一组简单而强大的功能。存储为numpy数组的图像可以很容易地从和转换到simpleitk和itk图像对象。
文档
有关此软件包的完整文档,请访问https://martinopilia.com/disptools" rel="nofollow">https://martinopilia.com/disptools
快速示例
importSimpleITKassitkimportdisptools.displacementsasdspimportdisptools.drawingasdrw# Create an example Jacobian map# A spherical ROI with a Jacobian of 1.1 (expansion)jacobian=drw.create_sphere(10,40,fg_val=1.1,bg_val=1.0)# Create a binary mask for the ROImask=drw.create_sphere(10,40)>0# Generate the displacementdisplacement=dsp.displacement(jacobian,mask=mask)# Check the correctness of the result within the ROIerror=jacobian-dsp.jacobian(displacement)error=sitk.Mask(error,mask)
使用paraview对生成的位移字段进行三维渲染,并在roi中可视化jacobian上的错误:
此软件包在pypi上可用,既可以作为源分发版,也可以作为Windows预编译的二进制控制盘。您可以使用pip安装它
这个库是一个跨平台的Python3.5+包,带有编译的C扩展。python依赖项是: 构建依赖项是一个标准的C编译器(在Linux上使用GCC 8.2,在Windows 10上使用MingW-W64 7.2和MSVC 19进行测试),cmake,numpy 一些可选的依赖项仅对一组有限的功能是必需的,包应该在没有它们的情况下构建和运行: 以下生成标志由setup.py识别: 以-d开头的附加标志也被接受并直接传递给cmake 使用您喜爱的包管理器安装依赖项。例如,使用pip: 该软件包提供了一个基于setuptools的安装脚本。要安装库,请从项目根文件夹运行 它应该构建c扩展并安装python包。 首先,确保mingw、cmake和python已经安装,并且它们的可执行文件在您的路径中。
确保gcc工作正常: 确保库路径中存在库vcruntime140.dll。否则,请下载并将其放在c:\ users\yourname\appdata\local\programs\python\python3x\libs中(具体路径可能因设置而异)。 安装依赖项: 该软件是在麻省理工学院的许可下发布的。安装
python3 -m pip install disptools
从源代码生成
要求
生成选项
Windows(Visual Studio)和Linux
python3 -m pip install scikit-build numpy scipy SimpleITK
python3 setup.py install
窗口(明暗)
> gcc --version
gcc (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
defget_msvcr():"""Include the appropriate MSVC runtime library if Python was built with MSVC 7.0 or later. """msc_pos=sys.version.find('MSC v.')ifmsc_pos!=-1:msc_ver=sys.version[msc_pos+6:msc_pos+10]ifmsc_ver=='1300':# MSVC 7.0return['msvcr70']elifmsc_ver=='1310':# MSVC 7.1return['msvcr71']elifmsc_ver=='1400':# VS2005 / MSVC 8.0return['msvcr80']elifmsc_ver=='1500':# VS2008 / MSVC 9.0return['msvcr90']elifmsc_ver=='1600':# VS2010 / MSVC 10.0return['msvcr100']elifmsc_ver=='1700':# Visual Studio 2012 / Visual C++ 11.0return['msvcr110']elifmsc_ver=='1800':# Visual Studio 2013 / Visual C++ 12.0return['msvcr120']elifmsc_ver=='1900':# Visual Studio 2015 / Visual C++ 14.0# "msvcr140.dll no longer exists" http://blogs.msdn.com/b/vcblog/archive/2014/06/03/visual-studio-14-ctp.aspxreturn['vcruntime140']else:raiseValueError("Unknown MS Compiler version %s "%msc_ver)
> python -m pip install scikit-build numpy scipy SimpleITK
> cd C:\Users\yourname\disptools
> python setup.py setopt --command=build --option=compiler --set-value=mingw32
> python setup.py install
参考文献
许可证
推荐PyPI第三方库