Installing and running MIRACL
We provide instructions on how to install and run MIRACL using either of the following methods:
Important
Docker is our recommended method for running MIRACL on local machines and servers. We recommend Singularity to run MIRACL in a cluster environment (e.g. Compute Canada).
Attention
Support for installing MIRACL locally (i.e. on your host system directly without using Docker or Singularity) has been deprecated. Please use Docker or Singularity instead.
We provide a build script to automatically create a Docker image for you that can be run using Docker Compose. This method does not require a manual installation of MIRACL and works on Linux, macOS and Windows (using WSL 2).
Tip
This is our recommended method for running MIRACL on local machines and servers
Docker is well suited if you want to run MIRACL on a local machine or local server. If you need to run MIRACL on a cluster, see our instructions for installing Singularity. If you don’t have Docker installed on your computer, do that first. Make sure your installation includes Docker Compose as it is required to run the build script we provide. Note that Docker Compose is included as part of the Docker Desktop installation by default.
Getting started
First, it is important to understand how the container is built. There
is a base image in the docker folder that installs Python and
dependencies. Then the Dockerfile in the base of the repository
builds the mgoubran/miracl image from that base. When the build
happens, it cats the version.txt file in the repository to save a
versioned base, but then the build uses the tag revised-base-latest that
is always the latest base. The base container is built from this folder
and pushed manually, while the main container is built and pushed
automatically via the CircleCI Recipe. Thus, if you want to
update the base, you will need to see the README.md in that folder
and push new images.
Build MIRACL from scratch
This will build a Docker image of MIRACL based on
its latest version using our default naming scheme. For custom names and
specific versions see below for our Additional build options section.
Clone the MIRACL repo to your machine:
$ git clone https://www.github.com/mgoubran/MIRACL
$ cd MIRACL
Build the latest MIRACL image using the build script we provide:
$ ./build.sh
Error
Make sure that the script can be executed. If it can’t and you are
the owner of the file, use chmod u+x build.sh to make it
executable. Prefix with sudo if you are not the owner of the file
or change permissions for g and/or o.
Once the image has successfully been built, run the container using Docker Compose:
$ docker compose up -d
Note
Note that the Docker Compose syntax is different if
you installed it using the standalone method. Compose
standalone uses the -compose syntax instead of the current standard
syntax compose. The above command would thus be docker-compose up -d
when using Compose standalone.
The container is now running and ready to be used.
Using the container
Interactively shell inside:
$ docker exec -it miracl bash
Files that are saved while using MIRACL should be saved to
volumes mounted into the container in order to make them persistent. To
mount volumes, just add them to the docker-compose.yml in the base
directory under volumes.
Danger
Do not delete the volume that is already mounted which mounts
your .Xauthority! This is important for X11 to work correctly.
Example:
volumes:
- '/home/mgoubran/.Xauthority:/home/mgoubran/.Xauthority'
- '/home/mgoubran/mydata:/home/mgoubran/mydata'
Stopping the container
Exit your container and navigate to your MIRACL folder. Use Docker Compose to stop the container:
$ docker compose down
Note
Note that the Docker Compose syntax is different if
you installed it using the standalone method. Compose
standalone uses the -compose syntax instead of the current standard
syntax compose. The above command would thus be docker-compose up -d
when using Compose standalone.
Additional build options
Image and container naming
Naming is done automatically when using our build script which includes
a default naming scheme. By default, the image is named
mgoubran/miracl:latest and the container is tagged with miracl.
You can easily change the defaults if your usecase requires it by running our build script with the following options:
$ ./build -i <image_name> -c <container_name>
Options:
-i, Specify image name (default: mgroubran/miracl)
-c, Specify container name (default: miracl)
Example:
$ ./build -i josmann/miracl -c miracl_dev_version
Tip
Use ./build -h to show additional options
MIRACL versions
By default, Docker images will be built using the latest version of MIRACL. If you need to build a Docker image based on a specific version of MIRACL, do the following:
Clone the MIRACL repository and navigate to the MIRACL folder:
$ git clone https://www.github.com/mgoubran/MIRACL
$ cd MIRACL
Cloning the repository will download all tags/versions. List them with:
$ git tag -l
Example output:
v1.1.1
v2.2.1
v2.2.2
v2.2.3
v2.2.4
v2.2.5
Decide which tag/version of MIRACL you want to use and check it out as a new branch:
$ git checkout tags/<tag_name> -b <branch_name>
Example:
$ git checkout tags/v2.2.4 -b miracl_v2.2.4
If you are reverting to a version of MIRACL >=
2.2.4, you can build the image for your chosen version by running the build script with the-tflag:
$ ./build.sh -t
Note
If you want to build an image for a version of MIRACL <= 2.2.4
either follow the build instructions of the particular version or
download the latest build script using e.g. wget https://raw.githubusercontent.com/AICONSlab/MIRACL/master/build.sh
(overwrites current build script if present) and run it with the
-t flag.
From here you can follow our instructions for building MIRACL from scratch starting with
docker compose up -d. Our script will automatically detect the version of the branch you checked out and tag the image accordingly.
Unlike Docker, Singularity is well suited to run in a cluster environment (like Sherlock at Stanford or Compute Canada). We provide the latest version of MIRACL as a Singularity container that can be conveniently pulled from cloud storage.
Tip
This is our recommended method for running MIRACL in a SLURM cluster environment such as Compute Canada or Sherlock @ Stanford
Download container
First, log in to the cluster:
$ ssh -Y <username>@<cluster>
<cluster> could be sherlock.stanford.edu or
cedar.computecanada.ca for example
Once logged in, change the directory to your scratch space and pull (download) the Singularity container:
$ cd $SCRATCH
$ singularity pull miracl_latest.sif library://aiconslab/miracl/miracl:latest
Attention
singularity pull requires Singularity version 3.0.0
or higher. Please refer to our
Troubleshooting section
(“Can I build a Singularity container from the latest MIRACL
image on Docker Hub”) if you are using an older version of
Singularity.
Interaction
To shell into the container use:
$ singularity shell miracl_latest.sif bash
Use the -B flag to bind a data directory to the container:
$ singularity shell -B /data:/data miracl_latest.sif bash
See also
For running functions on clusters please check our Singularity tutorials for Compute Canada and Sherlock
The Windows Subsystem for Linux (WSL) creates an environment that allows users to run versions of Linux without having to set up a virtual machine or a different computer.
Important
Docker Desktop requires WSL version 1.1.3.0
or later to be installed and turned on. To check open a command prompt
in Windows (cmd) and type: wsl --status.
To install WSL, users can follow the instructions from Microsoft. More comprehensive instructions can be found here. Upgrading from WSL1 to WSL2 is recommended, due to WSL2’s benefits.
Warning
Support for installing MIRACL locally in the WSL has been
deprecated in version 2.2.6 of MIRACL.
Once the WSL has been installed you can proceed to install Docker.
Note
You may ignore the next step if you have a preferred, Docker enabled Linux distribution that is already installed in your WSL2.
Installing Docker on Windows
Download the Docker Desktop installer for Windows from here or from the release notes.
Double-click Docker Desktop Installer.exe to run the installer. By default, Docker Desktop is installed at
C:\Program Files\Docker\Docker.
Attention
By default, WSL2 should be used with Docker Desktop. However, if your Windows system supports WSL2 and Hyper-V, make sure to select the WSL2 option on the Configuration page when prompted.
Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
When the installation is successful, select
Closeto complete the installation process.
Tip
Technically, Docker can be run on the Windows command prompt. However, it is recommended to use Docker in a Linux distro installed in the WSL.
Open the WSL2 on Windows in a command prompt (
cmd). Check the drop down menu next to the tab for installed Linux versions or typewsl -l -v.`Ubuntu` is already installed: Select it from the drop down. An Ubuntu terminal will open in a new tab.
`Ubuntu` is not yet installed: Open the Microsoft Store and search for Ubuntu. Choose the version you want to install and click the
Getbutton to automatically install it on the WSL. Select the version you installed from the drop down next to the command prompt tab. An Ubuntu terminal will open in a new tab.
Open Docker Desktop and navigate to
Settings. In theGeneraltab check ifUse the WSL 2 based enginecheckbox is checked. Check it if it isn’t yet.Still in the
Settingsnavigate toResources>WSL integration. Enable the Ubuntu distribution that you want to use Docker with.Go back to the command prompt and open the Docker enabled Ubuntu distro in a new tab.
In the Linux terminal, type
docker run helloto check if Docker is working correctly.
Install MIRACL in the WSL2
Just follow our installation instructions for Docker to install MIRACL as a Docker container in the WSL2.
Hint
Follow the below steps if you want to install MIRACL in your WSL instance locally. If you prefer to use Docker to run MIRACL on Windows follow our installation instructions for Docker instead.
Warning
Support for this installation method has been discontinued starting
with version of 2.2.6 of MIRACL. Please use Docker
or Singularity instead.
Warning
THIS INSTALLATION METHOD HAS BEEN DEPRECATED!
Steps to setup/run MIRACL on a Linux/macOS machine:
$ git clone https://github.com/mgoubran/MIRACL.git miracl
Tip
Alternatively, you can download the zip file containg the repo and uncompress it
Next, change directories into the newly created miracl folder:
$ cd miracl
Create your virtual MIRACL environment and activate it:
Attention
To setup a virtual environment you need Anaconda for Python 2.7. It can be downloaded from their official website
$ conda create --name miracl python=3.7.4 pip
$ conda activate miracl
Install dependencies:
$ pip install -e .
ANTS & c3d
Next, download the depends folder from our
Dropbox link
and place it either inside the linux_depends or
mac_depends folder:
$ mv ~/Downloads/depends.zip miracl/.
$ cd miracl
$ unzip depends.zip
$ rm depends.zip
This folder contains compiled versions of ANTS and c3d for Linux or Mac OS. Before continuing, make sure to change the permissions.
This can be done by running:
$ chmod -R 755 <path/to/depends>/*
In order to run the pipeline, some symbolic links must be added to
access certain commands. Inside the miracl folder, run:
$ sudo ln -s <path/to/depends>/ants/antsRegistrationMIRACL.sh /usr/bin/ants_miracl_clar && chmod +x /usr/bin/ants_miracl_clar
$ sudo ln -s <path/to/depends>/ants/antsRegistrationMIRACL_MRI.sh /usr/bin/ants_miracl_mr && chmod +x /usr/bin/ants_miracl_mr
Make sure <path/to/depends> is replaced with the directory path
that leads to the depends directory.
Allen atlas
Place the atlases folder (which got downloaded together with the
depends folder) inside the miracl folder:
$ mv ~/Downloads/atlases.zip miracl/.
$ cd miracl
$ unzip atlases.zip
$ rm atlases.zip
This folder contains the Allen Atlas data needed for registration and connectivity analysis.
Fiji & FSL
Install Fiji & FSL
First, download Fiji/ImageJ from their offical website.
Then do:
$ cd depends
$ wget https://downloads.imagej.net/fiji/latest/fiji-linux64.zip
$ unzip fiji-linux64.zip
$ rm fiji-linux64.zip
Next, install additional plugins by going to Help -> Update and
clicking on the Manage update sites button.
Choose the following update sites:
3D ImageJ Suite: http://sites.imagej.net/Tboudier
Biomedgroup: https://sites.imagej.net/Biomedgroup
IJPB-plugins: http://sites.imagej.net/IJPB-plugins
Download FSL and install it:
$ wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py
$ sudo python fslinstaller.py
Visualization
For the visualization of nifti files and labels we recommend ITKSNAP or the nifti plugin for Fiji/ImageJ.
Diffusion Data
If you have diffusion MRI data download and install MRtrix3:
$ sudo apt-get install git g++ python python-numpy libeigen3-dev zlib1g-dev libqt4-opengl-dev libgl1-mesa-dev libfftw3-dev libtiff5-dev
$ git clone https://github.com/MRtrix3/mrtrix3.git
$ cd mrtrix3
$ ./configure
$ ./build
$ ./set_path
Deactivate
To end a MIRACL session, deactivate your virtual environment:
$ conda deactivate
Update MIRACL
To update MIRACL, navigate into your MIRACL base
folder (e.g. $ cd miracl) and run:
$ git pull
You should be good to go!