编译ANTsPy

1. 网址:https://github.com/ANTsX/ANTsPy

2. ITK下载脚本,避免自动删除已下载的:

 17 itkgit=https://github.com/InsightSoftwareConsortium/ITK.git
 18 itktag=v5.3rc03 # update ITK tag 10/2/2020
 19 # if there is a directory but no git, remove it
 20 if [[ -d itksource ]]; then
 21     echo "zc1"
 22     # if [[ ! -d itksource/.git ]]; then
 23     #     rm -rf itksource/
 24     # fi
 25 fi
 26 # if no directory, clone ITK in `itksource` dir
 27 if [[ ! -d itksource ]]; then
 28     echo "zc2"
 29     # git clone $itkgit itksource
 30 fi
 31 cd itksource
 32 if [[ -d .git ]]; then
 33     echo "zc3"
 34     # git checkout master;
 35     # git checkout $itktag
 36     # commented by zc
 37     # rm -rf .git
 38 fi
 39 # go back to main dir
 40 cd ../

3. setup.py, 设置-DITK_DIR=ITK的ITKConfig.cmake所在目录,添加cmake多线程

119     def build_extension(self, ext):
120         setup_py_dir = os.path.dirname(os.path.realpath(__file__))
121         extdir = os.path.join(setup_py_dir, "ants", "lib")
122 
123         cmake_args = [
124             "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
125             "-DPYTHON_EXECUTABLE=" + sys.executable,
126             "-DCMAKE_BUILD_TYPE=Release",
127             "-DITK_DIR={}".format(os.getenv("ITK_DIR")),
128         ]
129 
130         cfg = "Release"
131         build_args = ["--config", cfg]
176         print("cmake "+"--build "+" . " + ' '.join( build_args))
177         subprocess.check_call(
178             ["cmake", "--build", ".", "--parallel", "10", ] + build_args, cwd=self.build_temp
179         )

4. conda环境中安装新版GCC

https://stackoverflow.com/questions/72540359/glibcxx-3-4-30-not-found-for-librosa-in-conda-virtual-environment-after-tryin

conda install -c conda-forge gcc=12.1.0

 

5. ANTspy安装成功。安装python依赖库

1 conda install -c conda-forge numpy scipy scikit-learn nibabel pandas statsmodels pillow matplotlib scikit-image webcolors
2 conda install -c plotly plotly

 

posted @ 2022-09-24 12:10  imoon22  阅读(74)  评论(0编辑  收藏  举报