Skip to content

(2022-10-19) Lab Notebook: TractSeg installation with Conda

Warning

This is as a Lab Notebook which describes how to solve a specific problem at a specific time. Please keep this in mind as you read and use the content. Please pay close attention to the date, version information and other details.

Lab Notebook --- Installing TractSeg on HPCC using Conda (2022-10-19)

TractSeg is a tool for fast and accurate white matter bundle segmentation from Diffusion MRI (see their GitHub page for further details). The program itself can be installed through pip, but requires a few dependencies, one of which, Mrtrix 3, may appear dauting at first because the link on the TractSeg page takes you to the source build instruction. However, Mrtrix 3 can be installed using Anaconda, which is recommened and enable by the developer (see here). Therefore, we are going to use Anacnoda for the whole install.

If you have not installed Anaconda in you home directory, see https://docs.icer.msu.edu/Using_conda/

Installing TractSeg

The code below will walk you through the process of creating a conda environment of TractSeg and install TactSeg in it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Begin by loading the loading the Conda module:

module purge
module load Conda/3

#After that is done, the following command should create a conda enviroment, activate it and install the dependencies:
conda create -n tractseg
conda activate tractseg
conda install -c mrtrix3 mrtrix3
conda install pytorch

# Now we can install TractSeg with pip
pip install TractSeg

#Finally, to test the install, try to get the help options for TractSeg:

TractSeg --help

Once you have completed the above steps, to run TractSeg in the future, do:

1
2
3
4
5
6
7
module purge
module load Conda/3

conda activate tractseg

# check
TractSeg --help

Install Optional Dependencies

TractSeg has a couple extra dependencies which can be installed if needed, but are not necessary. I've tested installing them but not their functionality in TractSeg as I am not sure where pip installs the TractSeg example files nor am I an expert on the software itself.

FSL

An FSL python install script can be found here with accompanying install information for Linux here. This script WILL try to install to /usr/local, so use the -d option to install in our home directory (i.e., fslinstaller.py -d /mnt/home/your_netid/something/fsl).

After finishing the install, you will need to take several setps that depdent on where you installed FSL. So first, let assume that the pathe to the directory you installed FSL in is something like "/mnt/home/your_netid/local/fsl" (replace this with whatever the real path is). To get FSL running you will need to do the following in command line, but PLEASE be careful with the export PATH command:

1
2
3
export FSLDIR=/mnt/home/your_netid/local/fsl                  # Set an environment variable for the program
source /mnt/home/your_netid/local/fsl/etc/fslconf/fslfsl.sh   # Source the config file
export PATH=$PATH:/mnt/home/your_netid/local/fslbin           # Add FSL to your path

After this you should be able to run FSL from the command line by running 'fsl'

If you are going to be using FSL alot, you can adde the above lines to your ~/.bashrc file, but agian, PLEASE be careful.

xvfb

Xvfb is a virtual frame buffer for X11 servers. It is library which should be able to bed installed via conda using:

1
conda install xorg-x11-server-xvfb-cos7-x86_64