SimpleElastix
SimpleElastix copied to clipboard
Error while installing SimpleElastix on Windows.
I am trying to install SimpleElstix on Windows (in a Conda environment) but I am not able to solve this error.
I tried to look for _SimpleITK.pyd but I can't find it anywhere. Tried doing this but it didn't work. Is there a possible fix for this? Also, this is my first time posting an issue on GitHub so please ask for anything that is required to solve this.
Hello,
I've had issues compiling SimpleElastix on Windows as well but did get there eventually. I wrote down some steps I had to take (a few months back) to get there. Not sure everything still applies, but here's a brain dump.
Do let me know if some things don't make sense, I'll try to come back to this comment and clean things up. I needed to compile SimpleElastix to use with Valis.
Follow the cmake instructions
https://simpleelastix.readthedocs.io/GettingStarted.html
Note: Maybe my build directory wasn't where it was supposed to be, so let me know if I need to change the paths below.
git clone https://github.com/SuperElastix/SimpleElastix cd SimpleElastix mkdir build cd build
Launch miniconda, then activate the right environment We’re doing step 3 of the instructions instead of opening Visual Studio…
Then this in the valis_37 environment %comspec% /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
cmake -DWRAP_JAVA:BOOL=OFF -DWRAP_LUA:BOOL=OFF -DWRAP_R:BOOL=OFF -DWRAP_RUBY:BOOL=OFF -DWRAP_TCL:BOOL=OFF -DSimpleITK_PYTHON_USE_VIRTUALENV:BOOL=OFF ../SuperBuild
msbuild ALL_BUILD.vcxproj /p:Configuration=Release
C:\Projects\SimpleElastix\SuperBuild\SuperBuild.cmake – Add the Git protocol lines:
enable_language(C)
enable_language(CXX)
#-----------------------------------------------------------------------------
# Git protocol
#-----------------------------------------------------------------------------
# As of March 15 2022, Github requires https
set(git_protocol "https")
#-----------------------------------------------------------------------------
# Platform check
#-----------------------------------------------------------------------------
When compilation fails, go fix the error. A search pointed to opj_includes.h (The one from OpenJPEG):
https://github.com/InsightSoftwareConsortium/ITK/issues/1967
From the thread: @dzenanz Thanks for your info and help. I tried to apply a patch for ../Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h as below. It can build pass. Thank you very much.
EZ: search replace lrintf and replace by obj_lrintf (two places). In vim: %s/long\ lrintf(/long\ obj_lrintf(/g
diff --git a/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h b/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
index e75a220d4d..60d185e233 100644
--- a/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
+++ b/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
@@ -92,7 +92,7 @@ Most compilers implement their own version of this keyword ...
/* MSVC 64bits doesn't support _asm */
#if !defined(_WIN64)
-static INLINE long lrintf(float f){
+static INLINE long opj_lrintf(float f){
int i;
_asm{
@@ -103,7 +103,7 @@ static INLINE long lrintf(float f){
return i;
}
#else
-static INLINE long lrintf(float x){
+static INLINE long opj_lrintf(float x){
long r;
if (x>=0.f)
{
… and potentially need to pip install --upgrade virtualenv
Installation, check this:
Still under the valis environment,
cd SimpleITK-build/Wrapping/Python python Packaging\setup.py install
https://github.com/SuperElastix/SimpleElastix/issues/366 https://github.com/SuperElastix/SimpleElastix/issues/233
From the threads: For all those who have this issue, all I did was copy _SimpleITK.pyd from the ...\Python\ directory to ...\Python\Packaging. This seems to have fixed it. I also ran a registration and it seems to work!
Test if it’s all been installed properly and working
Import SimpleITK as sitk elastixImageFilter = sitk.ElastixImageFilter()
Note If you have an error, maybe you already have sitk installed with pip, so need to uninstall it. Only keep the one you just built!!
pip uninstall simpleitk
Here we can find an appropriate version of libvips compiled for windows (64 bit)…
https://github.com/libvips/build-win64-mxe