Skip to content

Installing ANTsR in Windows 10 (along with FSL, Rstudio, Freesurfer, etc).

dorianps edited this page Aug 24, 2020 · 58 revisions

UPDATE: please refer to the 2020 updated instructions for the installation of ANTsR on WSL2. The instructions on this page are from 2016 and may be outdated.


|
|
|
|

In August 2016, Windows 10 has enabled a full Ubuntu subsystem that enables bash and allows any kind of Linux packages to be installed. You can now have ANTsR, ANTs, FSL, Freesurfer directly on Windows 10.


Here are the instructions to get ANTsR running on Windows 10

This will work only if your Windows 10 is updated with the anniversary update (Aug 2016).

Enable the Linux subsystem on Windows 10

Follow the instructions here: https://msdn.microsoft.com/en-us/commandline/wsl/install_guide

Install R-base and git

You may need to disable antivirus software (Kaspersky, Avast, etc) to perform the next steps.

# quick way, but will install the older R 3.0.2
sudo apt-get update
sudo apt-get -y install r-base-core
# longer, but will install the most recent R (currently 3.3.1)
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list'
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base

Install ITKR and ANTsR

First, open R and install the dependencies:
(Note, installing so many packages will take a while)

install.packages(
c(
"Rcpp","magrittr","dplyr",
"abind",
"BGLR",
"caret",
"cluster",
"d3Network",
"DMwR",
"e1071",
"extremevalues",
"fastICA",
"fpc",
"glasso",
"glmnet",
"grid",
"igraph",
"knitr",
"lme4",
"magic",
"MASS",
"mFilter",
"misc3d",
"moments",
"nabor",
"pixmap",
"png",
"pracma",
"psych",
"randomForest",
"rgl",
"rmarkdown",
"robust",
"robustbase",
"RRedsvd",
"signal",
"sna",
"testthat",
"visreg",
"wmtsa")
)

Then exit R and install ANTsR:

sudo apt-get -y install git
sudo apt-get -y install cmake
git clone https://github.com/stnava/ITKR.git
git clone https://github.com/ANTsX/ANTsRCore.git
git clone https://github.com/ANTsX/ANTsR.git
sudo R CMD INSTALL ITKR
sudo R CMD INSTALL ANTsRCore
sudo R CMD INSTALL ANTsR

Voila! you now have ANTsR on Windows.

The Linux subsystem was designed as a command line tool. To enable using graphic interfaces (Rstudio, FSL, Freesurfer) you have to install an X-server in Windows (for example: Xming or vcXsrv. The above options are not great, the most accurate display I tried is MobaXterm. However, none of them is stable, at some point all crashed for me. But most neuroimaging software run ok.


Now you can install Rstudio:

sudo apt-get install gdebi-core
sudo apt-get install libxslt1-dev # library needed for rstudio
# get rstudio 64bit for Ubuntu at https://www.rstudio.com/products/rstudio/download/
wget -O rstudio.deb https://download1.rstudio.org/rstudio-1.0.153-amd64.deb
sudo gdebi rstudio.deb
rm rstudio.deb

UPDATE 2018-10-17: The new Rstudio v2 does not work anymore in Ubuntu WLS; the authors do not plan to support WLS. Maybe this will be resolved later, you can use any earlier version and should work.


And you can install FSL (see instructions).


And you can install Freesurfer (see instructions)

(To make sure freeview will work, get the nightly builds. The official release did not work for me.)


And you can install MRtrix (see instructions and this post)

MRtrix viewer (mrview) requires special drivers and will not work.


Finally, you can install ANTs

sudo apt-get install -y cmake-curses-gui ### install ccmake
git clone https://github.com/stnava/ANTs.git
mkdir antsbin
cd antsbin
ccmake ../ANTs
# in the ccmake display, type “c” (configure) twice, then type “g” (generate and exit)
make -j 4

Add ANTs to the path:

cp -R ${PWD}/../ANTs/Scripts/* $PWD/bin
echo "export ANTSPATH=$PWD/bin/" >> ~/.bashrc
echo "PATH=\${ANTSPATH}:\${PATH}" >> ~/.bashrc
source ~/.bashrc

So far I have tried the GUIs for fslview, freeview, rstudio, and R plots, all working, albeit showing warning and errors in command line. Sometimes RStudio starts but menus don't work, in which case I close and restart RStudio and all works better.