Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ANTs binaries to solve slow processing in some systems #2642

Merged
merged 10 commits into from
May 22, 2020

Conversation

jcohenadad
Copy link
Member

@jcohenadad jcohenadad commented Mar 24, 2020

When running it in some systems, motion correction is very slow. The solution was to re-build ANTs binaries on Ubuntu 16.04 and OSX. Fixes #947

In this PR, we also take the opportunity to review the various distros that cause problems with some of the Python's libraries, causing problems such as #2523.

TODO:

  • Update binaries for Linux CentOS and OSX
  • Check if Linux binaries work on CentOS
  • Update call to ants function with SamplingStrategy=None, for reproducibility

Compatibility of new Linux binaries (compiled on Ubuntu 16.04) with CentOS:

CentOS8 --> OK

CentOS6 --> FAIL
./isct_antsRegistration: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.11' not found (required by ./isct_antsRegistration)
./isct_antsRegistration: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by ./isct_antsRegistration)

Compatibility of Python's libraries

CentOS8 --> OK

CentOS6 --> FAIL
SCT info:
- version: git-master-266bfc88d6eb6e96a2c2f1ec88c2e185c6f88e09
- path: /sct
OS: linux (Linux-4.9.184-linuxkit-x86_64-with-centos-6.10-Final)
CPU cores: Available: 8, Used by SCT: 8
RAM: MemTotal:        2046268 kB
total       used       free     shared    buffers     cached
Mem:          1998       1651        346          0         71       1138
-/+ buffers/cache:        441       1556
Swap:         1023          1       1022
Check Python executable.............................[OK]
  Using bundled python 3.6.10 |Anaconda, Inc.| (default, Jan  7 2020, 21:14:29) 
[GCC 7.3.0] at /sct/python/envs/venv_sct/bin/python
Check if data are installed.........................[OK]
Check if numpy is installed.........................[OK] (1.18.2)
Check if cryptography is installed..................[OK] (2.8)
Check if dipy is installed..........................[OK] (1.1.1)
Check if futures is installed.......................[OK]
Check if h5py is installed..........................[OK] (2.10.0)
Check if Keras (2.1.5) is installed.................[FAIL]
Traceback (most recent call last):
  File "/sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/sct/python/envs/venv_sct/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/sct/python/envs/venv_sct/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
Check if matplotlib is installed....................[OK] (3.2.1)
Check if nibabel is installed.......................[OK] (3.0.2)
Check if pandas is installed........................[OK] (1.0.3)
Check if psutil is installed........................[OK] (5.7.0)
Check if pyqt5 (5.11.3) is installed................[FAIL]
/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /sct/python/envs/venv_sct/lib/python3.6/site-packages/PyQt5/QtCore.so)
Check if pytest is installed........................[OK] (5.4.1)
Check if pytest-cov is installed....................[OK] (2.8.1)
Check if raven is installed.........................[OK]
Check if requests is installed......................[OK] (2.23.0)
Check if scipy is installed.........................[OK] (1.4.1)
Check if scikit-image is installed..................[OK] (0.16.2)
Check if scikit-learn is installed..................[OK] (0.22.2.post1)
Check if tensorflow (1.5.0) is installed............[FAIL]
Traceback (most recent call last):
  File "/sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/sct/python/envs/venv_sct/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/sct/python/envs/venv_sct/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /sct/python/envs/venv_sct/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)

testing

data + syntax:

sct_download_data -d sct_example_data
cd sct_example_data/mt
sct_register_multimodal -i mt1.nii.gz -d mt0.nii.gz -param step=1,type=im,algo=slicereg,iter=50 -v 2

before merging

Please run batch_processing.sh and report output numbers, as done for each release or PRs that likely impact those numbers. If numbers are different it would be nice to report it with the label "compatibility API/breakage"

Depends on: #2699, and #2690.

@jcohenadad jcohenadad changed the title Updated ANTs binaries to address slow processing in some systems Updated ANTs binaries to solve slow processing in some systems Mar 24, 2020
@kousu
Copy link
Contributor

kousu commented Mar 27, 2020

In response to the further report I've rebuilt the Linux binaries with static linking:

git clone --depth 1 https://github.com/ANTsX/ANTs
mkdir antsbin
cd antsbin
cmake -DCMAKE_EXE_LINKER_FLAGS "-static" ../ANTs  # this flag is what makes the binaries static
make -j 4   # my machine only has 4 cores

The files ended up in ANTS-build/Examples (not in bin/ like ./install/compile_ants.py suggests) so I'm a bit confused.

$ ldd antsbin/ANTS-build/Examples/{ants{ApplyTransforms,Registration,SliceRegularizedRegistration},ComposeMultiTransform}
antsbin/ANTS-build/Examples/antsApplyTransforms:
	not a dynamic executable
antsbin/ANTS-build/Examples/antsRegistration:
	not a dynamic executable
antsbin/ANTS-build/Examples/antsSliceRegularizedRegistration:
	not a dynamic executable
antsbin/ANTS-build/Examples/ComposeMultiTransform:
	not a dynamic executable

It took over 2 hours to build all of ANTs, and I did it twice to make sure I'd done it right. There is a way to only build the programs we need, but so much of the build time was from ANTs compiling the ITK and VTK libraries from source and I doubt that can be avoided without also reworking its build script.

Anyway, my binaries are at https://osf.io/r59va. I will ask our user to give them a try :)


By the way, I did not include any of {isct_dice_coefficient,isct_propseg,isct_spine_detect,isct_train_svm} because those files weren't actually rebuilt in the version from https://osf.io/568y4/; you can check by comparing file hashes from that upload against a fresh SCT install:

From @jcohenadad's upload at https://osf.io/568y4/:

$ sha256sum isct_*
d293e1a805539b68a51721e888b740ae05a460664352edfb122aebb9ef2abdcb  isct_antsApplyTransforms
4cf5a3774e00ba508a9f417d90b4ac4b547a4d2fa82288238274fb66f4fc9766  isct_antsRegistration
2c635337b1ad9cafa8f41d93cbb3c7d715f5ebce5405d502b8511bc8b2a13149  isct_antsSliceRegularizedRegistration
2f9edf9e401f24e893209e6b7b9466f1e734a5bf1e291e8429bbe79a2dcdd72f  isct_ComposeMultiTransform
58d0487d37d7c994f2a6fa3820d715de4852f63d554be9f0177ebb900234f623  isct_dice_coefficient
270fb99132d91c3f890caec28efbb8c314857a9e4c843ddd9c7fab3dcb241218  isct_propseg
d8dd029bb9c76d979e2edacbcf04e44d34e5c10d7efdabd2831a11f3bdd903be  isct_spine_detect
699d42b6dd10430af664f63fd1d2105a8a42c46bae83f86e082435f3932cc439  isct_train_svm

And from https://osf.io/bt58d/:

$ sha256sum ~/sct_4.2.2/bin/isct_*
a0e71e546304325c74afbe01e17554aab38185d6c4e8cdb083c1f58014d1ab79  /home/ubuntu/sct_4.2.2/bin/isct_antsApplyTransforms
e67d31a2269cdd833da435ae0db81812cf84f44319d21b50d0d4546ab368be48  /home/ubuntu/sct_4.2.2/bin/isct_antsRegistration
baa1a7482ea2e9be4f6e76dcc0dfed7fd43046879e2e501e6c5ea43dc5b76015  /home/ubuntu/sct_4.2.2/bin/isct_antsSliceRegularizedRegistration
820b9bcddc452554af0d375ee540a26311b82bd910e1e3d9bfd788d40dd844bd  /home/ubuntu/sct_4.2.2/bin/isct_check_detection
5b2f76ddabd88147384e07778013219995abe27a4215a0e53f5220b007b07073  /home/ubuntu/sct_4.2.2/bin/isct_ComposeMultiTransform
95502833d4e3b364df6230f6b3962cfb4293f462e73bf1bbd8c9a4db42af3b5d  /home/ubuntu/sct_4.2.2/bin/isct_convert_binary_to_trilinear
58d0487d37d7c994f2a6fa3820d715de4852f63d554be9f0177ebb900234f623  /home/ubuntu/sct_4.2.2/bin/isct_dice_coefficient
8c63312ad5516f844bc008b17697d9df06978b82288e97b0b4f8949b5421a964  /home/ubuntu/sct_4.2.2/bin/isct_get_fractional_volume
109798d59106d5e63810ec356782aeae48a3ea2a2c25cafe7ccd3fcc07c565a0  /home/ubuntu/sct_4.2.2/bin/isct_minc2volume-viewer
270fb99132d91c3f890caec28efbb8c314857a9e4c843ddd9c7fab3dcb241218  /home/ubuntu/sct_4.2.2/bin/isct_propseg
d8dd029bb9c76d979e2edacbcf04e44d34e5c10d7efdabd2831a11f3bdd903be  /home/ubuntu/sct_4.2.2/bin/isct_spine_detect
2c9917ac500d5aed40fbc595ad0d82a55d323b5533901f77a62a848a30bf5362  /home/ubuntu/sct_4.2.2/bin/isct_test_ants
699d42b6dd10430af664f63fd1d2105a8a42c46bae83f86e082435f3932cc439  /home/ubuntu/sct_4.2.2/bin/isct_train_svm
4fec04718cd7f6ae6dd96396d9e216875015515204f446b64e8545e82947ec48  /home/ubuntu/sct_4.2.2/bin/isct_warpmovie_generator

You can see that these hashes haven't changed:

58d0487d37d7c994f2a6fa3820d715de4852f63d554be9f0177ebb900234f623  isct_dice_coefficient
270fb99132d91c3f890caec28efbb8c314857a9e4c843ddd9c7fab3dcb241218  isct_propseg
d8dd029bb9c76d979e2edacbcf04e44d34e5c10d7efdabd2831a11f3bdd903be  isct_spine_detect
699d42b6dd10430af664f63fd1d2105a8a42c46bae83f86e082435f3932cc439  isct_train_svm

@jcohenadad
Copy link
Member Author

By the way, I did not include any of {isct_dice_coefficient,isct_propseg,isct_spine_detect,isct_train_svm} because those files weren't actually rebuilt in the version from https://osf.io/568y4/; you can check by comparing file hashes from that upload against a fresh SCT install:

good decision-- there was no issue with these files so i decided to not recompile them.

@kousu
Copy link
Contributor

kousu commented Mar 27, 2020

Where do train_svm and the others come from? They will eventually need the same treatment.

@kousu
Copy link
Contributor

kousu commented Mar 27, 2020

I said this on Slack but for the record I don't think static building is a good long term solution to being cross-platform. Libraries only form one part of a platform; there's many other details like syscalls and endianness and word sizes to account for. The most reliable way to build for a particular platform is to build on that platform -- notwithstanding recent advances in cross-compiling that have made this easier but still not trivial.

I am trying to prototype a cross-platform builder at kousu/ANTs#1. If I get it working, we should be able to cover all versions of Linux, OS X and Windows with the same build script, and have it done online where the whole team can watch the progress.

@jcohenadad
Copy link
Member Author

Where do train_svm and the others come from? They will eventually need the same treatment.

Ah! great question. I've just added a new page on the wiki: https://github.com/neuropoly/spinalcordtoolbox/wiki/Compile-binaries

kousu added a commit that referenced this pull request Apr 20, 2020
These binaries were built via a Github Workflow.
The Linux binaries were built on centos7, which is the oldest Linux that
ANTS will still compile on. The MacOS binaries were built on the Github
MacOS VMs.
The other binaries were copied unchanged from the previous binaries.

For full details see Github PR #2642
@kousu kousu force-pushed the jca/947-new-ants-binaries branch from 2774180 to 371dcac Compare April 20, 2020 20:10
@kousu
Copy link
Contributor

kousu commented Apr 20, 2020

I've updated the PR with new binaries, that are compiled properly, to the best of my knowledge. I made them using Github's CI, which makes them reproducible and conveniently downloadable.

I still had to do a bunch of manual work to get them packed and distributed; that can be automated in a later PR.

The ANTS binaries included in the updated links are from

The Linux build was done on centos7, even though my build script actually did a build for several distros. I've tried them (using Docker) on Ubuntu 14.04 through 18.04, Arch, and centos 7 and 8. They run everywhere. I learned this trick from python which considers "linux" binaries to be something built on centos 5, 6 or 7 with minimal dependencies -- basically just libc and everything else statically linked in -- which the ANTS programs are. The idea is that centos changes the slowest and forward-compatibility is easier than backwards-compatibility.

I haven't tested their numerical stability; I haven't discovered how to do that directly, but hopefully the tests in batch_processing.sh will be able to tell us if anything changed drastically.

This also has a couple of commits of related clean-up.

TODO:

  • rebuild binaries from ANTS master branch
  • repack binaries
  • upload to OSF.io
  • temporarily remove the neuropoly mirror links (until I get write access to that mirror)
  • fix the typo in sct_download_data's first OSF link
    • it doesn't work and falls back to neuropoly
  • binaries_debian -> binaries_linux and binaries_centos -> binaries_centos6
  • repair sct_run's auto-download on centos6
    • if this was ever working it wasn't now; probably this code never got exercised because ./install_sct made sure it never had to be run
  • upload to neuropoly OSF account; update mirror links
  • upload to neuropoly OSF account; update mirror links
  • upload to www.neuro.polymtl.ca; update mirror links
  • investigate and sct_dmri_moco output change
How The Files Were Built

First I got into SCT's venv and made an empty workspace:

(base) $ conda activate sct_venv
(sct_venv) $ mkdir -p ci-build/steps/pr0; cd ci-build/steps/pr0;

I found the latest binary URLs in the source code:

https://github.com/neuropoly/spinalcordtoolbox/blob/be4f8e9890bfc0ba141a8961d21bc8a12c5c979b/scripts/sct_download_data.py#L103-L108

and then downloaded them directly.
I need these because the ANTS programs are only part of what's in our binary packages and I need to preserve the other parts unchanged
( TODO: split to genuinely separate packages that can be versioned separately )

(sct_venv) [kousu@requiem pr0]$ curl -JLO https://osf.io/bt58d/?action=download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   459  100   459    0     0   1153      0 --:--:-- --:--:-- --:--:--  1153
100 77.3M  100 77.3M    0     0  3521k      0  0:00:22  0:00:22 --:--:-- 3775k
curl: Saved to filename '20190930_sct_binaries_linux.tar.gz'

(sct_venv) [kousu@requiem pr0]$ curl -JLO https://osf.io/msjb5/?action=download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   459  100   459    0     0   1550      0 --:--:-- --:--:-- --:--:--  1545
100 52.9M  100 52.9M    0     0  3225k      0  0:00:16  0:00:16 --:--:-- 3595k
curl: Saved to filename '20190930_sct_binaries_osx.tar.gz'

Do the same for my build:

(sct_venv) [kousu@requiem pr0]$ curl -JLO https://github.com/kousu/ANTs/releases/download/refs%2Fpull%2F5%2Fmerge-82250525/sct-apps_centos7.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   636  100   636    0     0   2231      0 --:--:-- --:--:-- --:--:--  2231
100 31.7M  100 31.7M    0     0  3333k      0  0:00:09  0:00:09 --:--:-- 3734k
curl: Saved to filename 'sct-apps_centos7.tar.gz'

(sct_venv) [kousu@requiem pr0]$ curl -JLO https://github.com/kousu/ANTs/releases/download/refs%2Fpull%2F5%2Fmerge-82250525/sct-apps_macos-latest.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   641  100   641    0     0   4748      0 --:--:-- --:--:-- --:--:--  4748
100 36.7M  100 36.7M    0     0  3343k      0  0:00:11  0:00:11 --:--:-- 3592k
curl: Saved to filename 'sct-apps_macos-latest.tar.gz'

Now I have these packages to merge:

(sct_venv) [kousu@requiem pr0]$ ls
20190930_sct_binaries_linux.tar.gz  20190930_sct_binaries_osx.tar.gz  sct-apps_centos7.tar.gz  sct-apps_macos-latest.tar.gz
(sct_venv) [kousu@requiem pr0]$ mkdir binaries_linux
(sct_venv) [kousu@requiem pr0]$ tar -zxvf 20190930_sct_binaries_linux.tar.gz -C binaries_linux/
./._isct_ComposeMultiTransform
isct_ComposeMultiTransform
./._isct_antsApplyTransforms
isct_antsApplyTransforms
./._isct_antsRegistration
isct_antsRegistration
./._isct_antsSliceRegularizedRegistration
isct_antsSliceRegularizedRegistration
./._isct_dice_coefficient
isct_dice_coefficient
./._isct_propseg
isct_propseg
./._isct_spine_detect
isct_spine_detect
./._isct_train_svm
isct_train_svm
(sct_venv) [kousu@requiem pr0]$ rm binaries_linux/._*  # clean up OS X junk

(sct_venv) [kousu@requiem pr0]$ mkdir binaries_osx
(sct_venv) [kousu@requiem pr0]$ tar -zxvf 20190930_sct_binaries_osx.tar.gz -C binaries_osx
./._isct_ComposeMultiTransform
isct_ComposeMultiTransform
./._isct_antsApplyTransforms
isct_antsApplyTransforms
./._isct_antsRegistration
isct_antsRegistration
./._isct_antsSliceRegularizedRegistration
isct_antsSliceRegularizedRegistration
./._isct_dice_coefficient
isct_dice_coefficient
./._isct_propseg
isct_propseg
./._isct_spine_detect
isct_spine_detect
./._isct_train_svm
isct_train_svm
(sct_venv) [kousu@requiem pr0]$ rm binaries_osx/._* # clean up OS X junk

Here's the unpacked 2019-09-30 version:

(sct_venv) [kousu@requiem pr0]$ ls -la binaries_*
binaries_linux:
total 255848
drwxr-xr-x 2 kousu kousu     4096 Apr 20 15:11 .
drwxr-xr-x 4 kousu kousu     4096 Apr 20 15:11 ..
-rwxr-xr-x 1 kousu kousu 25822904 Feb 23  2016 isct_antsApplyTransforms
-rwxr-xr-x 1 kousu kousu 55473440 Feb 23  2016 isct_antsRegistration
-rwxr-xr-x 1 kousu kousu 22498406 Feb 23  2016 isct_antsSliceRegularizedRegistration
-rwxr-xr-x 1 kousu kousu 20405723 Feb 23  2016 isct_ComposeMultiTransform
-rwxr-xr-x 1 kousu kousu 10439872 Mar  2  2016 isct_dice_coefficient
-rwxr-xr-x 1 kousu kousu 20504754 Jul  5  2016 isct_propseg
-rwxr-xr-x 1 kousu kousu 53186384 Apr  9  2017 isct_spine_detect
-rwxr-xr-x 1 kousu kousu 53331105 Dec  4  2018 isct_train_svm

binaries_osx:
total 181012
drwxr-xr-x 2 kousu kousu     4096 Apr 20 15:12 .
drwxr-xr-x 4 kousu kousu     4096 Apr 20 15:11 ..
-rwxr-xr-x 1 kousu kousu 22997288 Feb 19  2017 isct_antsApplyTransforms
-rwxr-xr-x 1 kousu kousu 48900148 Feb 19  2017 isct_antsRegistration
-rwxr-xr-x 1 kousu kousu 20655276 Feb 23  2016 isct_antsSliceRegularizedRegistration
-rwxr-xr-x 1 kousu kousu 18287896 Feb 19  2017 isct_ComposeMultiTransform
-rwxr-xr-x 1 kousu kousu  9589820 Mar  2  2016 isct_dice_coefficient
-rwxr-xr-x 1 kousu kousu 36514576 Sep 18  2016 isct_propseg
-rwxr-xr-x 1 kousu kousu 14071264 Apr 12  2017 isct_spine_detect
-rwxr-xr-x 1 kousu kousu 14090052 Apr 12  2017 isct_train_svm
(sct_venv) [kousu@requiem pr0]$ tar -zxvf sct-apps_centos7.tar.gz -C binaries_linux/ --strip-components=1 # --strip-components removes the sct-apps/ part
sct-apps/
sct-apps/isct_antsApplyTransforms
sct-apps/isct_antsRegistration
sct-apps/isct_ComposeMultiTransform
sct-apps/isct_antsSliceRegularizedRegistration
(sct_venv) [kousu@requiem pr0]$ tar -zxvf sct-apps_macos-latest.tar.gz -C binaries_osx/ --strip-components=1
sct-apps/isct_antsApplyTransforms
sct-apps/isct_antsSliceRegularizedRegistration
sct-apps/isct_antsRegistration
sct-apps/isct_ComposeMultiTransform

Now here's what our package looks like, notice that the dates have been updated:

(sct_venv) [kousu@requiem pr0]$ ls -l binaries_*
binaries_linux:
total 246396
-rwxr-xr-x 1 kousu kousu 28630112 Apr 19 15:08 isct_antsApplyTransforms
-rwxr-xr-x 1 kousu kousu 44594624 Apr 19 15:08 isct_antsRegistration
-rwxr-xr-x 1 kousu kousu 21435952 Apr 19 15:08 isct_antsSliceRegularizedRegistration
-rwxr-xr-x 1 kousu kousu 19880216 Apr 19 15:08 isct_ComposeMultiTransform
-rwxr-xr-x 1 kousu kousu 10439872 Mar  2  2016 isct_dice_coefficient
-rwxr-xr-x 1 kousu kousu 20504754 Jul  5  2016 isct_propseg
-rwxr-xr-x 1 kousu kousu 53186384 Apr  9  2017 isct_spine_detect
-rwxr-xr-x 1 kousu kousu 53331105 Dec  4  2018 isct_train_svm

binaries_osx:
total 197892
-rwxr-xr-x 1 kousu kousu 32203680 Apr 19 14:44 isct_antsApplyTransforms
-rwxr-xr-x 1 kousu kousu 48876288 Apr 19 14:44 isct_antsRegistration
-rwxr-xr-x 1 kousu kousu 24320568 Apr 19 14:44 isct_antsSliceRegularizedRegistration
-rwxr-xr-x 1 kousu kousu 22713500 Apr 19 14:44 isct_ComposeMultiTransform
-rwxr-xr-x 1 kousu kousu  9589820 Mar  2  2016 isct_dice_coefficient
-rwxr-xr-x 1 kousu kousu 36514576 Sep 18  2016 isct_propseg
-rwxr-xr-x 1 kousu kousu 14071264 Apr 12  2017 isct_spine_detect
-rwxr-xr-x 1 kousu kousu 14090052 Apr 12  2017 isct_train_svm
(sct_venv) [kousu@requiem pr0]$ (cd binaries_^C
(sct_venv) [kousu@requiem pr0]$ tar -czvf 20200420_sct_binaries_linux.tar.gz -C binaries_linux/ .
./
./isct_dice_coefficient
./isct_antsRegistration
./isct_spine_detect
./isct_ComposeMultiTransform
./isct_train_svm
./isct_propseg
./isct_antsSliceRegularizedRegistration
./isct_antsApplyTransforms
(sct_venv) [kousu@requiem pr0]$ tar -czvf 20200420_sct_binaries_osx.tar.gz -C binaries_osx/ .
./
./isct_dice_coefficient
./isct_antsRegistration
./isct_spine_detect
./isct_ComposeMultiTransform
./isct_train_svm
./isct_propseg
./isct_antsSliceRegularizedRegistration
./isct_antsApplyTransforms

Verify that they are sensible:

(sct_venv) [kousu@requiem pr0]$ file binaries_osx/*
binaries_osx/isct_antsApplyTransforms:              Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_antsRegistration:                 Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_antsSliceRegularizedRegistration: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_ComposeMultiTransform:            Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_dice_coefficient:                 Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_propseg:                          Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_spine_detect:                     Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>
binaries_osx/isct_train_svm:                        Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>

(sct_venv) [kousu@requiem pr0]$ file binaries_linux/*
binaries_linux/isct_antsApplyTransforms:              ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=c686966ea8dd8e3a988d16280f2e38fa296e790e, not stripped
binaries_linux/isct_antsRegistration:                 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=6f3599eea5cbc9a948e17fa04878f734720fece2, not stripped
binaries_linux/isct_antsSliceRegularizedRegistration: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d6c747d23eba23f505eacb496d8b83c1f94309fc, not stripped
binaries_linux/isct_ComposeMultiTransform:            ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=8a4af131564ccb97849a781070d20da341067a18, not stripped
binaries_linux/isct_dice_coefficient:                 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.26, BuildID[sha1]=93c84d5f0e5738268540ff6e54c6c451700c84f8, not stripped
binaries_linux/isct_propseg:                          ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.26, BuildID[sha1]=188ddc39bb9128b483753a9f38209118ca6d4e4a, not stripped
binaries_linux/isct_spine_detect:                     ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=07c7ef9e98d498ed2e94794719880d205a93360a, with debug_info, not stripped
binaries_linux/isct_train_svm:                        ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=fd7a4f4bba3027c1e40bbf15723bbc8da55e1de5, with debug_info, not stripped

(sct_venv) [kousu@requiem pr0]$ binaries_linux/isct_antsApplyTransforms 

COMMAND: 
     antsApplyTransforms
          antsApplyTransforms, applied to an input image, transforms it according to a 
          reference image and a transform (or a set of transforms). 
[...]

Finally, repack them:

(sct_venv) [kousu@requiem pr0]$ tar -czvf 20200420_sct_binaries_osx.tar.gz -C binaries_osx/ .
./
./isct_dice_coefficient
./isct_antsRegistration
./isct_spine_detect
./isct_ComposeMultiTransform
./isct_train_svm
./isct_propseg
./isct_antsSliceRegularizedRegistration
./isct_antsApplyTransforms
(sct_venv) [kousu@requiem pr0]$ tar -czvf 20200420_sct_binaries_linux.tar.gz -C binaries_linux/ .
./
./isct_dice_coefficient
./isct_antsRegistration
./isct_spine_detect
./isct_ComposeMultiTransform
./isct_train_svm
./isct_propseg
./isct_antsSliceRegularizedRegistration
./isct_antsApplyTransforms
(sct_venv) [kousu@requiem pr0]$ sha256sum 20200420_sct_binaries_*  # checksums, for reference
53398c90470e37c37f2f3b1dcfe1bfb302e814fef8bfd3ec815b71c0e150b2f3  20200420_sct_binaries_linux.tar.gz
9a43dddbda12d41c6d6d97031f766490234815076d871ae97c24502a675f0beb  20200420_sct_binaries_osx.tar.gz

@kousu
Copy link
Contributor

kousu commented Apr 20, 2020

I didn't set the permissions on OSF.io right. Reopening to retrigger Travis.

@kousu kousu closed this Apr 20, 2020
@kousu kousu reopened this Apr 20, 2020
@kousu kousu force-pushed the jca/947-new-ants-binaries branch from e951d06 to 597ef72 Compare April 20, 2020 21:09
@kousu kousu self-assigned this Apr 21, 2020
@kousu
Copy link
Contributor

kousu commented Apr 21, 2020

Drat. On Linux and OS X 10.14 all the tests passed but for testing/test_sct_dmri_moco.py. It's giving these errors:

Motion parameters do not match: results: [-0.010882712730616006, -0.04405528824327014, -0.04405528824327014, -0.04405528824327014, -0.08666746070626345, -0.08666746070626345, -0.08666746070626345] ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
--> FAILED

Motion parameters do not match: results: [-0.034467963776350176, 0.013834994483032048, 0.013834994483032048, 0.013834994483032048, -0.017412266132292232, -0.017412266132292232, -0.017412266132292232] ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]
--> FAILED

Exception caught:
itk::ExceptionObject (0x342f620)
Location: "unknown"
File: /__w/ANTs/ANTs/antsbin/staging/include/ITK-5.1/itkMattesMutualInformationImageToImageMetricv4.hxx
Line: 312
Description: itk::ERROR: MattesMutualInformationImageToImageMetricv4(0x33f5e80): Joint PDF summed to zero

1 and 2 are, I'm guessing, a numerical stability issue (maybe we should be using np.testing.assert_approx_equal?), but 3 looks more serious. I'll have to look into these.

Checking sct_dmri_moco..............................�[0m[�[91mFAIL�[0m]�[0m
   
   ====================================================================================================
   sct_dmri_moco -i dmri/dmri.nii.gz -bvec dmri/bvecs.txt -g 3 -x nn -ofolder dmri_test1 -r 0
   ====================================================================================================
   
   
   --
   Spinal Cord Toolbox (git-HEAD-ac15dc262d6cf9fafcfe28491cf6eaae02991813)
   
   Merge within groups:   0%|                              | 0/2 [00:00<?, ?iter/s]
   Merge within groups: 100%|██████████████████████| 2/2 [00:00<00:00, 87.99iter/s]
   Z=0/0:   0%|                                            | 0/1 [00:00<?, ?iter/s]
   Z=0/0: 100%|████████████████████████████████████| 1/1 [00:00<00:00,  4.18iter/s]
   Z=0/0: 100%|████████████████████████████████████| 1/1 [00:00<00:00,  4.17iter/s]
   Z=0/0:   0%|                                            | 0/2 [00:00<?, ?iter/s]
   Z=0/0:  50%|██████████████████                  | 1/2 [00:00<00:00,  3.67iter/s]
   Z=0/0: 100%|████████████████████████████████████| 2/2 [00:00<00:00,  3.66iter/s]
   Z=0/0: 100%|████████████████████████████████████| 2/2 [00:00<00:00,  3.64iter/s]
   Z=0/0:   0%|                                            | 0/7 [00:00<?, ?iter/s]
   Z=0/0:  29%|██████████▎                         | 2/7 [00:00<00:00, 13.15iter/s]
   Z=0/0:  57%|████████████████████▌               | 4/7 [00:00<00:00, 13.28iter/s]
   Z=0/0:  86%|██████████████████████████████▊     | 6/7 [00:00<00:00, 11.92iter/s]
   Z=0/0: 100%|████████████████████████████████████| 7/7 [00:00<00:00, 11.92iter/s]
   
   Input parameters:
   Input file ............ dmri/dmri.nii.gz
   Group size ............ 3
   
   Create temporary folder (/tmp/sct-20200420214312.588651-moco-c1gjrv6n)...
   
   Copying input data to tmp folder and convert to nii...
   sct_convert -i dmri/dmri.nii.gz -o /tmp/sct-20200420214312.588651-moco-c1gjrv6n/data.nii
   
   Get dimensions of data...
   40 x 42 x 5
   
   Data orientation: RPI
   Treated as axial
   
   Set suffix of transformation file name, which depends on the orientation:
   Orientation is axial, suffix is 'Warp.nii.gz'. The estimated transformation is a 3D warping field, which is composed of a stack of 2D Tx-Ty transformations
   
   Identify b=0 and DWI images...
   Number of b=0: 1 [0]
   Number of DWI: 6 [1, 2, 3, 4, 5, 6]
   
   Split along T dimension...
   
   Merge and average b=0 data...
   
   Merge across groups...
   
   -------------------------------------------------------------------------------
   Estimating motion on b=0 images...
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ b0.nii
   Reference file ........ data_T0000.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. estimate_and_apply
   Mask  .................
   Output mat folder ..... mat_b0groups
   
   Data dimensions:
   40 x 42 x 5 x 1
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   
   -------------------------------------------------------------------------------
   Estimating motion across groups...
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ datasub-groups.nii
   Reference file ........ datasub_0_mean.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. estimate_and_apply
   Mask  .................
   Output mat folder ..... mat_groups
   
   Data dimensions:
   40 x 42 x 5 x 2
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   
   -------------------------------------------------------------------------------
   Apply moco
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ data.nii
   Reference file ........ datasub_0_mean.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. apply
   Mask  .................
   Output mat folder ..... mat_final/
   
   Data dimensions:
   40 x 42 x 5 x 7
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   sct_convert -i /tmp/sct-20200420214312.588651-moco-c1gjrv6n/data_moco.nii -o /tmp/sct-20200420214314.187829-dmri_separate-2vskdszy/dmri.nii
   
   File created: /tmp/sct-20200420214312.588651-moco-c1gjrv6n/data_moco_b0.nii
   File created: /tmp/sct-20200420214312.588651-moco-c1gjrv6n/data_moco_dwi.nii
   File created: /tmp/sct-20200420214312.588651-moco-c1gjrv6n/data_moco_b0_mean.nii
   File created: /tmp/sct-20200420214312.588651-moco-c1gjrv6n/data_moco_dwi_mean.nii
   Extract motion parameters...
   
   Generate output files...
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test1/dmri_moco.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test1/dmri_moco_b0_mean.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test1/dmri_moco_dwi_mean.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test1/moco_params_x.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test1/moco_params_y.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test1/moco_params.tsv
   
   Finished! Elapsed time: 5s
   
   ====================================================================================================
   INTEGRITY TESTING
   ====================================================================================================
   
   
   Motion parameters do not match:   results: [-0.010882712730616006, -0.04405528824327014, -0.04405528824327014, -0.04405528824327014, -0.08666746070626345, -0.08666746070626345, -0.08666746070626345]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
   --> FAILED
   
   ====================================================================================================
   sct_dmri_moco -i dmri/dmri.nii.gz -bvec dmri/bvecs.txt -g 3 -m dmri/mask.nii -ofolder dmri_test2 -r 0
   ====================================================================================================
   
   
   --
   Spinal Cord Toolbox (git-HEAD-ac15dc262d6cf9fafcfe28491cf6eaae02991813)
   
   Merge within groups:   0%|                              | 0/2 [00:00<?, ?iter/s]
   Merge within groups: 100%|██████████████████████| 2/2 [00:00<00:00, 91.00iter/s]
   Z=0/0:   0%|                                            | 0/1 [00:00<?, ?iter/s]
   Z=0/0: 100%|████████████████████████████████████| 1/1 [00:00<00:00,  3.83iter/s]
   Z=0/0: 100%|███████████████████████████████���████| 1/1 [00:00<00:00,  3.82iter/s]
   Z=0/0:   0%|                                            | 0/2 [00:00<?, ?iter/s]
   Z=0/0:  50%|██████████████████                  | 1/2 [00:00<00:00,  4.30iter/s]
   Z=0/0: 100%|████████████████████████████████████| 2/2 [00:00<00:00,  4.23iter/s]
   Z=0/0: 100%|████████████████████████████████████| 2/2 [00:00<00:00,  4.19iter/s]
   Z=0/0:   0%|                                            | 0/7 [00:00<?, ?iter/s]
   Z=0/0:  29%|██████████▎                         | 2/7 [00:00<00:00, 11.31iter/s]
   Z=0/0:  57%|████████████████████▌               | 4/7 [00:00<00:00, 10.90iter/s]
   Z=0/0:  86%|██████████████████████████████▊     | 6/7 [00:00<00:00, 11.24iter/s]
   Z=0/0: 100%|████████████████████████████████████| 7/7 [00:00<00:00, 11.27iter/s]
   
   Input parameters:
   Input file ............ dmri/dmri.nii.gz
   Group size ............ 3
   
   Create temporary folder (/tmp/sct-20200420214318.905951-moco-f3sjoib5)...
   
   Copying input data to tmp folder and convert to nii...
   sct_convert -i dmri/dmri.nii.gz -o /tmp/sct-20200420214318.905951-moco-f3sjoib5/data.nii
   sct_convert -i dmri/mask.nii -o /tmp/sct-20200420214318.905951-moco-f3sjoib5/mask.nii
   
   Get dimensions of data...
   40 x 42 x 5
   
   Data orientation: RPI
   Treated as axial
   
   Set suffix of transformation file name, which depends on the orientation:
   Orientation is axial, suffix is 'Warp.nii.gz'. The estimated transformation is a 3D warping field, which is composed of a stack of 2D Tx-Ty transformations
   
   Identify b=0 and DWI images...
   Number of b=0: 1 [0]
   Number of DWI: 6 [1, 2, 3, 4, 5, 6]
   
   Split along T dimension...
   
   Merge and average b=0 data...
   
   Merge across groups...
   
   -------------------------------------------------------------------------------
   Estimating motion on b=0 images...
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ b0.nii
   Reference file ........ data_T0000.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. estimate_and_apply
   Mask  ................. mask.nii
   Output mat folder ..... mat_b0groups
   
   Data dimensions:
   40 x 42 x 5 x 1
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   
   -------------------------------------------------------------------------------
   Estimating motion across groups...
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ datasub-groups.nii
   Reference file ........ datasub_0_mean.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. estimate_and_apply
   Mask  ................. mask.nii
   Output mat folder ..... mat_groups
   
   Data dimensions:
   40 x 42 x 5 x 2
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   
   -------------------------------------------------------------------------------
   Apply moco
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ data.nii
   Reference file ........ datasub_0_mean.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. apply
   Mask  ................. mask.nii
   Output mat folder ..... mat_final/
   
   Data dimensions:
   40 x 42 x 5 x 7
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   sct_convert -i /tmp/sct-20200420214318.905951-moco-f3sjoib5/data_moco.nii -o /tmp/sct-20200420214320.538001-dmri_separate-i_ig2dz_/dmri.nii
   
   File created: /tmp/sct-20200420214318.905951-moco-f3sjoib5/data_moco_b0.nii
   File created: /tmp/sct-20200420214318.905951-moco-f3sjoib5/data_moco_dwi.nii
   File created: /tmp/sct-20200420214318.905951-moco-f3sjoib5/data_moco_b0_mean.nii
   File created: /tmp/sct-20200420214318.905951-moco-f3sjoib5/data_moco_dwi_mean.nii
   Extract motion parameters...
   
   Generate output files...
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test2/dmri_moco.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test2/dmri_moco_b0_mean.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test2/dmri_moco_dwi_mean.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test2/moco_params_x.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test2/moco_params_y.nii.gz
   File created: /home/travis/build/neuropoly/spinalcordtoolbox/sct_testing_data/dmri_test2/moco_params.tsv
   
   Finished! Elapsed time: 5s
   
   ====================================================================================================
   INTEGRITY TESTING
   ====================================================================================================
   
   
   Motion parameters do not match:   results: [-0.034467963776350176, 0.013834994483032048, 0.013834994483032048, 0.013834994483032048, -0.017412266132292232, -0.017412266132292232, -0.017412266132292232]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]
   --> FAILED
   
   ====================================================================================================
   sct_dmri_moco -i dmri/dmri_AIL_crop.nii -bvec dmri/bvecs.txt -x nn -ofolder dmri_test3 -r 0
   ====================================================================================================
   
   
   --
   Spinal Cord Toolbox (git-HEAD-ac15dc262d6cf9fafcfe28491cf6eaae02991813)
   
   Merge within groups:   0%|                              | 0/6 [00:00<?, ?iter/s]
   Merge within groups: 100%|█████████████████████| 6/6 [00:00<00:00, 144.16iter/s]
   Z=0/2:   0%|                                            | 0/1 [00:00<?, ?iter/s]
   Z=0/2: 100%|████████████████████████████████████| 1/1 [00:00<00:00, 13.18iter/s]
   Z=1/2:   0%|                                            | 0/1 [00:00<?, ?iter/s]
   Z=1/2: 100%|████████████████████████████████████| 1/1 [00:00<00:00, 12.34iter/s]
   Z=2/2:   0%|                                            | 0/1 [00:00<?, ?iter/s]
   Z=2/2: 100%|████████████████████████████████████| 1/1 [00:00<00:00, 12.94iter/s]
   Z=0/2:   0%|                                            | 0/6 [00:00<?, ?iter/s]
   Z=0/2:  33%|████████████                        | 2/6 [00:00<00:00, 12.65iter/s]
   Z=0/2:  33%|████████████                        | 2/6 [00:00<00:00,  4.35iter/s]
   
   Input parameters:
   Input file ............ dmri/dmri_AIL_crop.nii
   Group size ............ 3
   
   Create temporary folder (/tmp/sct-20200420214325.254755-moco-nsacx89a)...
   
   Copying input data to tmp folder and convert to nii...
   sct_convert -i dmri/dmri_AIL_crop.nii -o /tmp/sct-20200420214325.254755-moco-nsacx89a/data.nii
   
   Get dimensions of data...
   42 x 5 x 3
   
   Data orientation: AIL
   Treated as sagittal
   
   Set suffix of transformation file name, which depends on the orientation:
   Orientation is sagittal, suffix is '0GenericAffine.mat'. The image is split across the R-L direction, and the estimated transformation is a 2D affine transfo.
   For sagittal data group_size should be one for more robustness. Forcing group_size=1.
   
   Identify b=0 and DWI images...
   Number of b=0: 1 [0]
   Number of DWI: 6 [1, 2, 3, 4, 5, 6]
   
   Split along T dimension...
   
   Merge and average b=0 data...
   
   Merge across groups...
   
   -------------------------------------------------------------------------------
   Estimating motion on b=0 images...
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ b0.nii
   Reference file ........ data_T0000.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. estimate_and_apply
   Mask  .................
   Output mat folder ..... mat_b0groups
   
   Data dimensions:
   42 x 5 x 3 x 1
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   
   -------------------------------------------------------------------------------
   Estimating motion across groups...
   -------------------------------------------------------------------------------
   
   Input parameters:
   Input file ............ datasub-groups.nii
   Reference file ........ datasub_0_mean.nii.gz
   Polynomial degree ..... 2
   Smoothing kernel ...... 1
   Gradient step ......... 1
   Metric ................ MI
   Sampling .............. 0.2
   Todo .................. estimate_and_apply
   Mask  .................
   Output mat folder ..... mat_groups
   
   Data dimensions:
   42 x 5 x 3 x 6
   
   Copy file_target to a temporary file...
   
   Register. Loop across Z (note: there is only one Z if orientation is axial)
   Traceback (most recent call last):
   File "/home/travis/build/neuropoly/spinalcordtoolbox/scripts/sct_dmri_moco.py", line 155, in <module>
   main()
   File "/home/travis/build/neuropoly/spinalcordtoolbox/scripts/sct_dmri_moco.py", line 150, in main
   moco_wrapper(param)
   File "/home/travis/build/neuropoly/spinalcordtoolbox/spinalcordtoolbox/moco.py", line 329, in moco_wrapper
   file_mat_datasub_group, _ = moco(param_moco)
   File "/home/travis/build/neuropoly/spinalcordtoolbox/spinalcordtoolbox/moco.py", line 607, in moco
   file_data_splitZ_splitT_moco[it], im_mask=input_mask)
   File "/home/travis/build/neuropoly/spinalcordtoolbox/spinalcordtoolbox/moco.py", line 734, in register
   status, output = sct.run(cmd, verbose=1 if param.verbose == 2 else 0, **kw)
   File "/home/travis/build/neuropoly/spinalcordtoolbox/scripts/sct_utils.py", line 313, in run
   raise RunError(output)
   sct_utils.RunError: All_Command_lines_OK
   Using double precision for computations.
   number of levels = 1
   fixed image: /tmp/sct-20200420214325.254755-moco-nsacx89a/target_Z0000.nii.gz
   moving image: /tmp/sct-20200420214325.254755-moco-nsacx89a/datasub-groups_Z0000_T0002.nii
   Dimension = 2
   Number of stages = 1
   Use Histogram Matching false
   Winsorize image intensities false
   Lower quantile = 0
   Upper quantile = 1
   Stage 1 State
   Image metric = Mattes
   Fixed image = Image (0x33dfef0)
   RTTI typeinfo:   itk::Image<double, 2u>
   Reference Count: 2
   Modified Time: 714
   Debug: Off
   Object Name:
   Observers:
   none
   Source: (none)
   Source output name: (none)
   Release Data: Off
   Data Released: False
   Global Release Data: Off
   PipelineMTime: 0
   UpdateMTime: 498
   RealTimeStamp: 0 seconds
   LargestPossibleRegion:
   Dimension: 2
   Index: [0, 0]
   Size: [42, 5]
   BufferedRegion:
   Dimension: 2
   Index: [0, 0]
   Size: [42, 5]
   RequestedRegion:
   Dimension: 2
   Index: [0, 0]
   Size: [42, 5]
   Spacing: [0.841346, 17.5]
   Origin: [7.78414, -17.0887]
   Direction:
   1 0
   0 1
   
   IndexToPointMatrix:
   0.841346 0
   0 17.5
   
   PointToIndexMatrix:
   1.18857 0
   0 0.0571429
   
   Inverse Direction:
   1 0
   0 1
   
   PixelContainer:
   ImportImageContainer (0x33dcfe0)
   RTTI typeinfo:   itk::ImportImageContainer<unsigned long, double>
   Reference Count: 1
   Modified Time: 495
   Debug: Off
   Object Name:
   Observers:
   none
   Pointer: 0x3401940
   Container manages memory: true
   Size: 210
   Capacity: 210
   
   Moving image = Image (0x33fafe0)
   RTTI typeinfo:   itk::Image<double, 2u>
   Reference Count: 2
   Modified Time: 715
   Debug: Off
   Object Name:
   Observers:
   none
   Source: (none)
   Source output name: (none)
   Release Data: Off
   Data Released: False
   Global Release Data: Off
   PipelineMTime: 0
   UpdateMTime: 712
   RealTimeStamp: 0 seconds
   LargestPossibleRegion:
   Dimension: 2
   Index: [0, 0]
   Size: [42, 5]
   BufferedRegion:
   Dimension: 2
   Index: [0, 0]
   Size: [42, 5]
   RequestedRegion:
   Dimension: 2
   Index: [0, 0]
   Size: [42, 5]
   Spacing: [0.841346, 17.5]
   Origin: [7.78414, -17.0887]
   Direction:
   1 0
   0 1
   
   IndexToPointMatrix:
   0.841346 0
   0 17.5
   
   PointToIndexMatrix:
   1.18857 0
   0 0.0571429
   
   Inverse Direction:
   1 0
   0 1
   
   PixelContainer:
   ImportImageContainer (0x33f5d20)
   RTTI typeinfo:   itk::ImportImageContainer<unsigned long, double>
   Reference Count: 1
   Modified Time: 709
   Debug: Off
   Object Name:
   Observers:
   none
   Pointer: 0x3405110
   Container manages memory: true
   Size: 210
   Capacity: 210
   
   Weighting = 1
   Sampling strategy = regular
   Number of bins = 16
   Radius = 4
   Sampling percentage  = 0.2
   Transform = Affine
   Gradient step = 1
   Update field sigma (voxel space) = 0
   Total field sigma (voxel space) = 0
   Update field time sigma = 0
   Total field time sigma  = 0
   Number of time indices = 0
   Number of time point samples = 0
   Registration using 1 total stages.
   
   Stage 0
   iterations = 10
   convergence threshold = 1e-06
   convergence window size = 10
   number of levels = 1
   using the Mattes MI metric (number of bins = 16, weight = 1)
   Shrink factors (level 1 out of 1): [1, 1]
   smoothing sigmas per level: [1]
   regular sampling (percentage = 0.2)
   
   *** Running AffineTransform registration ***
   
   DIAGNOSTIC,Iteration,metricValue,convergenceValue,ITERATION_TIME_INDEX,SINCE_LAST
   2DIAGNOSTIC,     1, -8.039992058313e-01, 1.797693134862e+308, 2.7559e-03, 2.7559e-03,
   2DIAGNOSTIC,     2, -8.223745472540e-01, 1.797693134862e+308, 3.2439e-03, 4.8804e-04,
   Exception caught:
   itk::ExceptionObject (0x342f620)
   Location: "unknown"
   File: /__w/ANTs/ANTs/antsbin/staging/include/ITK-5.1/itkMattesMutualInformationImageToImageMetricv4.hxx
   Line: 312
   Description: itk::ERROR: MattesMutualInformationImageToImageMetricv4(0x33f5e80): Joint PDF summed to zero
   
   
   Elapsed time (stage 0): 7.1611e-03
   
   
   Total elapsed time: 1.0438e-02

On OS X 10.13 and 10.12 it's failing with

dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin

Referenced from: /Users/travis/build/neuropoly/spinalcordtoolbox/bin/isct_antsRegistration (which was built for Mac OS X 10.15)

which apparently is fixable by recompiling with -mmacosx-version-min=10.12

kousu added a commit that referenced this pull request Apr 21, 2020
These binaries were built via a Github Workflow.
The Linux binaries were built on centos7, which is the oldest Linux that
ANTS will still compile on. The MacOS binaries were built on the Github
MacOS VMs.
The other binaries were copied unchanged from the previous binaries.

For full details see Github PR #2642
@kousu kousu force-pushed the jca/947-new-ants-binaries branch from ac15dc2 to 982767b Compare April 21, 2020 03:11
kousu added a commit that referenced this pull request Apr 21, 2020
These binaries were built via a Github Workflow.
The Linux binaries were built on centos7, which is the oldest Linux that
ANTS will still compile on. The MacOS binaries were built on the Github
MacOS VMs.
The other binaries were copied unchanged from the previous binaries.

For full details see Github PR #2642
@kousu kousu force-pushed the jca/947-new-ants-binaries branch 2 times, most recently from 9715e96 to acfb78a Compare April 21, 2020 03:18
@jcohenadad
Copy link
Member Author

1 and 2 are, I'm guessing, a numerical stability issue (maybe we should be using np.testing.assert_approx_equal?)

hum, the GT and results are quite different (some rows have sign differences). I would like to visually inspect the quality of the registration with these new binaries.

but 3 looks more serious. I'll have to look into these.

this is likely related to a lack of overlap between the source and dest. Again, possibly related to poor registration performance, which we need to assess visually. Do you experience this issue in all OSs? (except OSX 10.13 and 10.12 as you mentioned)

@kousu kousu mentioned this pull request Apr 21, 2020
40 tasks
@kousu
Copy link
Contributor

kousu commented Apr 21, 2020

The mismatch with "ground truth" could be due to changes in ANTs that tweaked the default parameters and randomized some others: ANTsX/ANTs#976. We could try in particular setting the sampling density to "full" and seeing if that repairs the issue.

@kousu
Copy link
Contributor

kousu commented Apr 22, 2020

Excellent, compiling the Mac build with -mmacosx-version-min=10.12 fixed the OS X build. It's still failing the integration tests, but now at least the OS X build is failing at the same point as the Linux builds:

Ubuntu 18.04

  Motion parameters do not match:   results: [0.001664092494639746, -0.052920862625080285, -0.052920862625080285, -0.052920862625080285, -0.2257613850742729, -0.2257613850742729, -0.2257613850742729]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
  Motion parameters do not match:   results: [0.032052003358640134, 0.0068744765056173674, 0.0068744765056173674, 0.0068744765056173674, -0.07596243866297632, -0.07596243866297632, -0.07596243866297632]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]

Ubuntu 16.04

  Motion parameters do not match:   results: [-0.013541630278093918, -0.011518132887323774, -0.011518132887323774, -0.011518132887323774, -0.04690899238704347, -0.04690899238704347, -0.04690899238704347]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
  Motion parameters do not match:   results: [0.029374258585575318, 0.020856222472389163, 0.020856222472389163, 0.020856222472389163, -0.11087420513286224, -0.11087420513286224, -0.11087420513286224]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]

Ubuntu 14.04

  Motion parameters do not match:   results: [-0.040230370960009414, 0.0013478728039622468, 0.0013478728039622468, 0.0013478728039622468, -0.10606732453438424, -0.10606732453438424, -0.10606732453438424]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
  Motion parameters do not match:   results: [-0.006092110980101495, 0.04504416247354683, 0.04504416247354683, 0.04504416247354683, -0.02216491176283384, -0.02216491176283384, -0.02216491176283384]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]

OS X 10.14

  Motion parameters do not match:   results: [-0.006966916534123157, -0.060083993896399686, -0.060083993896399686, -0.060083993896399686, -0.07030610277505607, -0.07030610277505607, -0.07030610277505607]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
  Motion parameters do not match:   results: [0.0097079526180611, -0.020379057795583574, -0.020379057795583574, -0.020379057795583574, -0.08478784788357245, -0.08478784788357245, -0.08478784788357245]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]

OS X 10.13

  Motion parameters do not match:   results: [-0.017505457874581153, -0.027057153635299255, -0.027057153635299255, -0.027057153635299255, -0.08347904858281012, -0.08347904858281012, -0.08347904858281012]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
  Motion parameters do not match:   results: [0.0334527246747129, 0.005702617221833961, 0.005702617221833961, 0.005702617221833961, -0.0383357763404959, -0.0383357763404959, -0.0383357763404959]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]

OS X 10.12

  Motion parameters do not match:   results: [-0.01878847923924063, -0.046631266616712005, -0.046631266616712005, -0.046631266616712005, -0.11948982479820885, -0.11948982479820885, -0.11948982479820885]  ground truth: [-0.02831688588348093, 0.010687867678295859, 0.010687867678295859, 0.010687867678295859, -0.09037059326262416, -0.09037059326262416, -0.09037059326262416]
  Motion parameters do not match:   results: [0.003482137372097327, -0.011689143072851493, -0.011689143072851493, -0.011689143072851493, -0.06997484760074749, -0.06997484760074749, -0.06997484760074749]  ground truth: [0.01895501218220765, 0.013237532481722523, 0.013237532481722523, 0.013237532481722523, -0.051536337647226205, -0.051536337647226205, -0.051536337647226205]

It's notable that the results change between each OS, though they are similar; I suspect this is actually that the results changing each run due to the randomization. When this run is done I'll trigger a re-run and record the results again. and then we will be able to see that, probably, the new results come out similarly but not identically.

@kousu kousu closed this Apr 22, 2020
kousu added a commit that referenced this pull request May 11, 2020
These binaries were built via a Github Workflow.
The Linux binaries were built on centos7, which is the oldest Linux that
ANTS will still compile on. The MacOS binaries were built on the Github
MacOS VMs.
The other binaries were copied unchanged from the previous binaries.

For full details see Github PR #2642 and Issue #2669.
kousu added a commit that referenced this pull request May 11, 2020
Upon upgrading our ANTS build we found that motion correction was no
longer deterministic (#2642 (comment)).

The ANTS maintainers suggested setting samplingStrategy=None
(ANTsX/ANTs#976 (comment))
to get deterministic output, but they also warned that this will induce
a variance-for-bias tradeoff:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTsR#210 (comment)
* Thévenaz, P., Bierlaire, M., & Unser, M. (2008).
  Halt on sampling for image registration based on mutual information.
  Sampling Theory in Signal and Image Processing, 7(2).
  <http://bigwww.epfl.ch/preprints/thevenaz0602p.pdf>

Because we are hard-coding the sampling rate I removed it from ParamMoco
entirely. If we want to support it properly we would have to pass
.sampling_strategy and .sampling_percentage separately.
kousu added a commit that referenced this pull request May 11, 2020
This is also to make the output deterministic, at the cost of running slow.

It turned out that using dense sampling wasn't enough; there was still some
numerical instability that came from the order of addition:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues#variance-due-to-floating-point-precision-errors

For some reason it only appeared on OS X, and only about 10% of the time, and never on Linux.
I [showed](#2642 (comment))
that the instability in isct_antsSliceRegularizedRegistration did exist on Linux, so something
still unknown about how we call it was hiding it there.

This was actually supposed to be in place already but the code had atrophied,
so all this does is fix it up.

See:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTs#444 (comment)
* ANTsX/ANTsR#210 (comment)
@kousu kousu force-pushed the jca/947-new-ants-binaries branch from 016882d to ea2ddb1 Compare May 11, 2020 17:14
kousu added 5 commits May 17, 2020 01:08
Previously we treated linux as two kinds of beasts: Debian and CentOS 6.
But we conflated Debian with all other linuxes, so really it was "linux"
and "centos6".

Going forward, I want to do builds the way PyPI does with manylinux [1]:
the oldest CentOS is considered linux full stop. With my recent rebuild,
that is CentOS 7. Update the package name to emphasize this clearly.

I picked CentOS 7 because that's the oldest version that ANTS will build
on, but I'm temporarily keeping a special case for CentOS 6 for the next
~6 months until it end-of-lifes.

[1] https://github.com/pypa/manylinux
These binaries were built via a Github Workflow.
The Linux binaries were built on centos7, which is the oldest Linux that
ANTS will still compile on. The MacOS binaries were built on the Github
MacOS VMs.
The other binaries were copied unchanged from the previous binaries.

For full details see Github PR #2642 and Issue #2669.
Upon upgrading our ANTS build we found that motion correction was no
longer deterministic (#2642 (comment)).

The ANTS maintainers suggested setting samplingStrategy=None
(ANTsX/ANTs#976 (comment))
to get deterministic output, but they also warned that this will induce
a variance-for-bias tradeoff:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTsR#210 (comment)
* Thévenaz, P., Bierlaire, M., & Unser, M. (2008).
  Halt on sampling for image registration based on mutual information.
  Sampling Theory in Signal and Image Processing, 7(2).
  <http://bigwww.epfl.ch/preprints/thevenaz0602p.pdf>

Because we are hard-coding the sampling rate I removed it from ParamMoco
entirely. If we want to support it properly we would have to pass
.sampling_strategy and .sampling_percentage separately.
This is also to make the output deterministic, at the cost of running slow.

It turned out that using dense sampling wasn't enough; there was still some
numerical instability that came from the order of addition:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues#variance-due-to-floating-point-precision-errors

For some reason it only appeared on OS X, and only about 10% of the time, and never on Linux.
I [showed](#2642 (comment))
that the instability in isct_antsSliceRegularizedRegistration did exist on Linux, so something
still unknown about how we call it was hiding it there.

This was actually supposed to be in place already but the code had atrophied,
so all this does is fix it up.

See:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTs#444 (comment)
* ANTsX/ANTsR#210 (comment)
In updating antsSliceRegularizedRegistration, and its samplingStrategy
to get the new version to be as deterministic as the 2016 version,
the estimates it gives on the test data have shifted. This updates the
snapshots we had of the values to the new values.

I am unsure if this is right. Maybe the old estimates were better?
@kousu kousu force-pushed the jca/947-new-ants-binaries branch from ea2ddb1 to d2c63fa Compare May 17, 2020 05:09
kousu and others added 3 commits May 17, 2020 01:22
Upon upgrading our ANTS build we found that motion correction was no
longer deterministic (#2642 (comment)).

The ANTS maintainers suggested setting samplingStrategy=None
(ANTsX/ANTs#976 (comment))
to get deterministic output, but they also warned that this will induce
a variance-for-bias tradeoff:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTsR#210 (comment)
* Thévenaz, P., Bierlaire, M., & Unser, M. (2008).
  Halt on sampling for image registration based on mutual information.
  Sampling Theory in Signal and Image Processing, 7(2).
  <http://bigwww.epfl.ch/preprints/thevenaz0602p.pdf>

I think ideally moco.py would thinly wrap antsRegistration, and
expose both .sampling_strategy and .sampling_percentage directly,
but until now we've always hardcoded 'samplingStrategy=Regular'
so in the interest of not rocking the boat too much all I did
was add a 'sampling=None' case, *and set it as the default*

Updated version re feedback: #2642 (comment)
@jcohenadad
Copy link
Member Author

jcohenadad commented May 21, 2020

Performance/eyeballing comparisons:

Macbook pro

git-master-6f0c8271d9bf842a61d1325732ec997c74d9aac3

Duration: ~18min
t2/CSA:          73.87711295363036
mt/MTR(WM):      54.42047766880533
t2s/CSA_GM:      12.487834828856178
t2s/CSA_WM:      64.93830702088246
dmri/FA(CST_r):  0.779941706962691
dmri/FA(CST_l):  0.7821467799429508

git-jca/947-new-ants-binaries-4ea484182fd7a7f334ff946f28fd1715ae385ade

Duration: ~23min
t2/CSA:          73.87711295363036
mt/MTR(WM):      54.41472824752352
t2s/CSA_GM:      12.487834828856178
t2s/CSA_WM:      64.93830702088246
dmri/FA(CST_r):  0.7756557400652291
dmri/FA(CST_l):  0.7801552114214262

Visual inspection of the registrations (for moco, template registration and inter-modal registration): I see negligible differences.

Ubuntu (joplin)

git-master-6f0c8271d9bf842a61d1325732ec997c74d9aac3

Duration: ~1h12min
t2/CSA:          73.87711295363036
mt/MTR(WM):      54.4207170412509
t2s/CSA_GM:      12.487834828856178
t2s/CSA_WM:      64.93830702088246
dmri/FA(CST_r):  0.7801012192793303
dmri/FA(CST_l):  0.7821539042653485

git-jca/947-new-ants-binaries-4ea484182fd7a7f334ff946f28fd1715ae385ade

Duration: ~20min --> WOHOOOOOO!!!! 🎉
t2/CSA:          73.87711295363036
mt/MTR(WM):      54.41533709156575
t2s/CSA_GM:      12.487834828856178
t2s/CSA_WM:      64.93830702088246
dmri/FA(CST_r):  0.7756557415994955 --> "ALMOST" the same as OSX 🎉
dmri/FA(CST_l):  0.7801552123851562

awesome fix @kousu! Can we merge?

Copy link
Contributor

@kousu kousu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please. 🚀

@jcohenadad jcohenadad merged commit fb64a61 into master May 22, 2020
jcohenadad pushed a commit that referenced this pull request May 22, 2020
These binaries were built via a Github Workflow.
The Linux binaries were built on centos7, which is the oldest Linux that
ANTS will still compile on. The MacOS binaries were built on the Github
MacOS VMs.
The other binaries were copied unchanged from the previous binaries.

For full details see Github PR #2642 and Issue #2669.
jcohenadad pushed a commit that referenced this pull request May 22, 2020
Upon upgrading our ANTS build we found that motion correction was no
longer deterministic (#2642 (comment)).

The ANTS maintainers suggested setting samplingStrategy=None
(ANTsX/ANTs#976 (comment))
to get deterministic output, but they also warned that this will induce
a variance-for-bias tradeoff:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTsR#210 (comment)
* Thévenaz, P., Bierlaire, M., & Unser, M. (2008).
  Halt on sampling for image registration based on mutual information.
  Sampling Theory in Signal and Image Processing, 7(2).
  <http://bigwww.epfl.ch/preprints/thevenaz0602p.pdf>

Because we are hard-coding the sampling rate I removed it from ParamMoco
entirely. If we want to support it properly we would have to pass
.sampling_strategy and .sampling_percentage separately.
jcohenadad pushed a commit that referenced this pull request May 22, 2020
This is also to make the output deterministic, at the cost of running slow.

It turned out that using dense sampling wasn't enough; there was still some
numerical instability that came from the order of addition:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues#variance-due-to-floating-point-precision-errors

For some reason it only appeared on OS X, and only about 10% of the time, and never on Linux.
I [showed](#2642 (comment))
that the instability in isct_antsSliceRegularizedRegistration did exist on Linux, so something
still unknown about how we call it was hiding it there.

This was actually supposed to be in place already but the code had atrophied,
so all this does is fix it up.

See:

* https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
* ANTsX/ANTs#444 (comment)
* ANTsX/ANTsR#210 (comment)
@jcohenadad jcohenadad deleted the jca/947-new-ants-binaries branch May 22, 2020 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installation category: install_sct or pip/setup.py priority:HIGH sct_dmri_moco context: sct_fmri_moco context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sct_fmri_moco and sct_dmri_moco are slow
4 participants