Skip to content
neured edited this page Jan 5, 2019 · 55 revisions

How to Process MRI Images:

  1. Beginner's Guide to Command Line Interface
  2. More about the Command Line Interface
  3. NITRC, a source for neuroimaging software and data.
  4. Before you begin
    • Computer setup and Applications
  5. Preprocessing and processing images
  6. Hippocampus Segmentation

Before You Begin

Neuroimaging computing is generally done on Linux or macOS. You may need to be logged in as root to install many of these programs, depending on the permissions of the directory on which you are installing. The following are specifics about operating systems I currently use to run neuroimaging analyses:

macOS (10.12+)

In order to have access to root user you have to directly enable the option, for instructions refer to this page here. You can also install a number of tools using the command line with superuser access: sudo. If you are on a university or company managed computer, it's a good idea to talk with your IT administrator before installing any software (if you have administrator access).

Before installing any neuroimaging software, there are some tools you should make sure are on your computer first.

XCode Command Line Tools

You should install the XCode Command Line Tools before beginning any of these other tasks. Probably the easiest way to install these tools is to run the following command

git --version

If you don't have the command line tools installed it will prompt you to install them (requires admin access). You can also install XCode if you wish. I often use it when I'm writing scripts but there are many other options. The version of XCode will vary, depending on your OS version. Read more about XCode.

Git

If you ran the command listed above, you have git installed. You can also visit this link for more instructions, including for other operating systems.

Text/Code Editor

While you can use TextEdit that's built into macOS, it has limitations because it is a pure text editor. It is fast and lightweight though so I use it for most of my quick work. Many people use Vim but it has a steep learning curve and is not user-friendly. I don't recommend it to novices.

One cross-platform option is Atom. Installation instructions for the Mac are here. While this has more features than you'll need for simple Bash scripting (we'll cover that later), it gives you a solid platform to work on.

There are many other options so explore a little to see which editor fits you and your needs. To find options perform a web search for code editor.

Pip

Pip is a package manager for Python.

On macOS you can install it like this in Terminal

easy_install pip

Or, you might need to run it with administrator privileges

sudo easy_install pip

We will use this to install some neuroimaging software.

Homebrew

Homebrew is a general package manager for the command line in macOS. It allows some software to be easily installed and updated (it's essentially a command line version of the App Store).

Install it like this by pasting and running this in Terminal

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then you are ready to install applications/packages you might need.

Don't do this now but here's an example of how it is used to install.

brew install eigen (this is a dependency if you install MRtrix).

Then later, if you want to make sure applications and packages are up-to-date you can run the following commands.

brew update && brew upgrade

If you want to make sure a particular package does not upgrade (could be important to make neuroimaging reproducible and even valid), you can "pin" it.

brew pin mrtrix3

Windows 10

With the Windows Subsystem for Linux activated and Ubuntu installed you can use many common MRI applications. If you are using Windows it may be easier to log in as the Administrator for all of these downloads. If you are using a managed computer, you will likely need your IT administrator to install any software.

Notes Regarding Windows

Some imaging programs (MANGO, dcm2nii, mricron, and some functions of ANTs) can be installed onto Windows easily but you will quickly find barriers between programs. The neuroimaging community likes to run things on Linux or macOS (although SPM runs well on Windows so many people who do only fMRI research use Windows). If you are interested in having these programs on your own computer I suggest a free installation of Linux. Ubuntu, Mint, Debian, CentOS, and others work well. Ubuntu is quite easy to use and learn. If you aren't fully committed to using just Linux you can run it in a Virtual Machine or partition your drive to dual boot, which allows you to run Linux or Windows upon restarting your computer each time. NeuroDebian is a VM that can be installed and run without too much difficulty. I won't reproduce the installation instructions here.

Another option mentioned previously is with Windows 10 and the Windows Subsystem for Linux. Follow those instructions to get this useful tool installed. Once you enable the WSL, you can easily install your Linux distribution of choice. There are some limitations to the WSL relative to a "pure" installation of Linux but it gives access to a number of the tools previously unusable in Windows. Windows Subsystem for Linux Documentation

Recommended MRI and Useful Software