Skip to content

Latest commit

 

History

History
365 lines (280 loc) · 11.1 KB

INSTALL.org

File metadata and controls

365 lines (280 loc) · 11.1 KB

Setup and install

Prerequisites

Install the required applications and python packages your appropriate linux distribution package manager (or Pip for local python installations).

MASSIVE (Centos 6):

module load build atlas cuda/7.0  mrtrix3 fsl/5.0.8 dcmtk git boost python/2.7.8-gcc octave imagemagick mercurial matlab/r2014b
pip install --user argparse mahotus pyfft pyopencl pycuda reikna pydicom

On Debian/Ubuntu/LinuxMint:

sudo apt-get install python-setuptools python-dicom python-numpy python-tk dcmtk scipy
sudo pip install argparse mahotus pyfft pycuda pyopencl 

or Redhat/CentOS/Fedora:

sudo yum install python-setuptools numpy scipy python-tk dcmtk
sudo pip install pydicom argparse

Get the code

Pull the stable version from the MBI repository, using:

# hg clone ssh://hg@bitbucket.org/mbi-image/agilent2dicom Agilent2Dicom
# git clone ssh://carbon2.mbi.monash.edu.au:mbi-image/agilent2dicom Agilent2Dicom
git clone git@gitlab.erc.monash.edu.au:mbi-image/Agilent2Dicom.git 

On the Agilent 9.4T MR console, download the tar zipped bundle of the source code and unpack it. Add the Agilent2Dicom source path to the PATH environment variable (csh is the default shell, but also add the path in the bash user config file).

# wget https://bitbucket.org/mbi-image/agilent2dicom/get/default.tar.gz
# mkdir Agilent2Dicom
# tar zxvf default.tar.gz Agilent2Dicom/ 
# wget https://carbon2.mbi.monash.edu.au/mbi-image/Agilent2Dicom/repository/archive.zip
wget https://gitlab.erc.monash.edu.au/mbi-image/Agilent2Dicom/repository/archive.zip
unzip archive.zip
cd Agilent2Dicom.git
echo "export PATH=`pwd`:${PATH}" >> ~/.bashrc
echo "setenv PATH `pwd`:$PATH" >> ~/.cshrc

Check

Check your python installation for the required packages using the check.py script:

cd Agilent2Dicom
./check.py

Install Dicom3tools

Install dicom3tools from http://www.dclunie.com/dicom3tools.html into the Agilent2Dicom folder. The default settings for MBI’s Agilent 9.4T MR scanner are used below. The default UID root value ‘1.3.6.1.4.1’ is unique to the MBI Agilent 9.4T MR scanner and should be changed for other devices. The dependencies for compiling dicom3tools are imake, gcc and binutil-essentials.

On MASSIVE use:

module load imake gcc.  

On the Agilent console, use:

sudo yum install imake gcc binutil-essentials

Once the dependencies have been installed, begin by downloading the latest dicom3tools http://www.dclunie.com/dicom3tools/workinprogress/, adjust the config/site.p-def file for the appropriate settings. Follow the compile instructions below for installing on the Agilent console:

cd ~/src/    # On MASSIVE use cd ~/Monash016/eagerm/Agilent2Dicom
wget   http://www.dclunie.com/dicom3tools/workinprogress/dicom3tools_1.00.snapshot.20140306142442.tar.bz2
tar jxvf dicom3tools_1.00.snapshot.20140306142442.tar.bz2
cd dicom3tools_1.00.snapshot.20140306142442

sed -i 's/CLUNIE/MBIAGILENT/' config/site.p-def
./Configure
#            setenv IMAKEINCLUDE -I./config                              # only needed for tcsh
imake -I./config -DInstallInTopDir -DUseMBIAGILENT1ID -DDefaultUIDRoot=1.3.6.1.4.1
make World
make install                          # into ./bin
make install.man                      # into ./man
 

Install MRtrix

MRtrix source code and documentation: http://www.brain.org.au/software/mrtrix/.

For MRtrix stable version (0.2.12), follow instructions on http://jdtournier.github.io/mrtrix-0.2/install/unix.html. For first-time installation, install required dependencies: g++, python, gtkmm, gtkglext, libgsl & a working OpenGL environment

On debian:

sudo apt-get install g++ python libglib2.0-dev libgtk2.0-dev libglibmm-2.4-dev libgtkmm-2.4-dev libgtkglext1-dev libgsl0-dev libgl1-mesa-dev libglu1-mesa-dev

On MASSIVE:

module load python/2.7.8-gcc qt/4.8.4 gcc/4.8.2 glew/1.10.0 glut gsl gtkglext zlib virtualgl/2.3.x pyqt4 git

On RedHat 6 (Agilent console does not have the appropriate repos - so look for rpms below and save to ~/src/):

sudo yum install -y gtkmm24 glibmm24 glib2-devel mesa-libGL-devel mesa-libGLw-devel freeglut-devel PyQt4-devel
sudo rpm -i  src/cairomm-devel-1.8.0-2.1.el6.x86_64.rpm \
src/dcmtk-3.6.0-7.fc16.src.rpm \
src/glibmm24-devel-2.22.1-1.el6.x86_64.rpm \
src/glibmm24-devel-2.45.3-1.fc23.i686.rpm \
src/gtkglext-1.0.6-1.el5.rf.x86_64.rpm \
src/gtkglext-devel-1.0.6-1.el5.rf.x86_64.rpm \
src/gtkmm24-devel-2.18.2-1.el6.x86_64.rpm \
src/libsigc++20-devel-2.2.4.2-1.el6.x86_64-1.rpm \
src/libsigc++20-devel-2.2.4.2-1.el6.x86_64.rpm \
src/pangomm-devel-2.26.0-1.el6.x86_64.rpm 

Simple compile procedure:

# 1. Go to NITRC.org and download package
# Unpack archive:
    tar xjf mrtrix-0.2.X.tar.bz2

# 2. Compile:
    cd mrtrix-0.2.X/
    ./build

# if there are compilation errors for pango_x_fonts*, add -lpangox-1.0 to build step

# 3. Install (as root):
    sudo ./build install
# this installs executables to /opt/mrtrix
# unfortunately the lib in /opt/mrtrix/lib is not linked to /usr/lib
# either add to LD_LIBRARY_PATH in bashrc or soft link it

For mrtrix3 built on MASSIVE:

git clone https://github.com/jdtournier/mrtrix3
cd mrtrix
export PYTHONPATH=/usr/local/pyqt4/4.11/lib/python2.7/site-packages:/usr/local/python/2.7.8-gcc/lib/python2.7/site-packages:/usr/local/python/2.7.8-gcc/lib/python2.7
export CFLAGS="-I/usr/include -DGLX_GLXEXT_PROTOTYPES"
python2.7 ./configure
python2.7 ./build

# Known error in the build process: run the gl_core command
 g++ -c -fPIC -march=native -DMRTRIX_WORD64 -DMRTRIX_USE_TR1 -Wall -Wno-unused-function -Wno-unused-parameter -O2 -DNDEBUG -Isrc -Icmd -Ilib -Icmd -I/usr/local/gsl/1.12-gcc/include -I/usr/include -DHAVE_INLINE -DGLX_GLXEXT_PROTOTYPES src/gui/opengl/gl_core_3_3.cpp -o src/gui/opengl/gl_core_3_3.o
# Then complete the build again
python2.7 ./build

# Optional: Install as root
 sudo python ./build install

Setup matlab third party packages

Non-local means filter

Read README file in NLmeans and compile vlfeat. MATLAB must be in PATH for vlfeat to compile correctly.

mkdir matlab/NLmeans;
cd matlab/NLmeans
git clone https://github.com/UB-TFG-TFM-1415/SS-DDLS.git
(cd SS-DDLS;patch -p1 ../SS-DDLS-patch.txt)
mv SS-DDLS/Code/Utils/MRIDenoisingPackage ./
rm -rf SS-DDLS
git clone https://github.com/vlfeat/vlfeat.git
cd vlfeat
make

Modified version of the MRIDenoising package are in matlab/NLmeans/MRIDenoisingModified.

To compile the mex files, run:

matlab -nodesktop -nosplash -r "cd matlab/NLmeans/MRIDenoisingModified;
mex -v -compatibleArrayDims COMPFLAGS='$COMPFLAGS -Ofast'  myODCT3d.cpp;
mex -v -compatibleArrayDims COMPFLAGS='$COMPFLAGS -Ofast'  myMBONLM3D.cpp;
mex -v -compatibleArrayDims COMPFLAGS='$COMPFLAGS -Ofast' myRINLM3d.cpp;
"

Copy of NIFTI package (mathworks)

cd matlab
zip_path=`curl http://www.mathworks.com.au/matlabcentral/fileexchange/8797-tools-for-nifti-and-analyze-image?download=true`
zip_path=` echo $zip_path | sed 's#<html><body>You are being <a href="\(.*\)">redirected</a>.</body></html>#\1#'`
wget $zip_path
mkdir NIFTI
cd NIFTI
unzip ../NIFTI*.zip  

[Optional] Scipy install from source

Read this first: http://www.scipy.org/scipylib/building/linux.html

  1. Download ATLAS and Lapack

ATLAS link: http://sourceforge.net/projects/math-atlas/files/latest/download?source=files Lapack link: http://www.netlib.org/lapack/lapack-3.5.0.tgz

  1. Prerequistites for ATLAS and Lapack

The Agilent workstation is a RHEL 6. Use `yum groupinstall “Developmental Tools”` to enable more features if you want more recent packages (e.g. atlas-devel, lapack-devel, PyQt4-devel) required to install numpy and scipy from source.

  1. Install Numpy scipy prerequisites
pip install --user Tempita
pip install --user cython
  1. ATLAS and lapack compilation

Read http://www.scipy.org/scipylib/building/linux.html#building-atlas

tar zxvf ATLAS-3.11.30
cd ATLAS-3.11.30/ATLAS
mkdir ATLAS_LINUX
cd ATLAS_LINUX
sudo /usr/bin/cpufreq-selector -g performance
../configure -Fa alg -fPIC --with-netlib-lapack-tarfile=$HOME/src/lapack-3.5.0.tgz
## This will take some time
make
cd lib
make shared
make ptshared
sudo make install
## when finished, reset the cpu throttling
sudo /usr/bin/cpufreq-selector -g ondemand

[Obsolete]

sudo yum install --upgrade python
cd ~/src
export LAPACK_SRC=/home/vnmr1/src/lapack-3.5.0/SRC/
   wget http://www.netlib.org/lapack/lapack-3.5.0.tgz 
   tar zxvf lapack-3.5.0.tgz && cd lapack-3.5.0
   cp make.inc.example make.inc 
   sed -i -e 's/^OPTS\(.*\)/OPTS \1 -m64 -fPIC/' -e 's/^NOOPT\(.*\)/NOOPT \1 -m64 -fPIC/' make.inc

   make 
   make -C BLAS/SRC
   
#   ln -s blas_LINUX.a libblas.a
#   ln -s lapack_LINUX.a liblapack.a
#   ln -s tmglib_LINUX.a libtmglib.a

export BLAS_SRC=/home/vnmr1/src/lapack-3.5.0/BLAS/SRC
export ATLAS=/home/vnmr1/src/ATLAS_3.11.30/ATLAS
export LD_LIBRARY_PATH=$HOME/src/lapack-3.5.0:$LD_LIBRARY_PATH
export PYTHONPATH=~/.local/lib/python2.6/site-packages:/usr/lib64/python2.6/site-packages:/usr/lib/python2.6/site-packages

pip install --user --force-reinstall --upgrade numpy
pip install --user --force-reinstall --upgrade scipy
python -c 'import numpy;numpy.test()
python -c 'import scipy;scipy.test()'
  1. Compile Numpy and Scipy.

Use shared or threaded atlas in compilation. Numpy from pip is fine (1.9.2) but scipy needs to come from the git repo.

cd ~/src
git clone https://github.com/scipy/scipy.git
cd scipy
export ATLAS=/usr/local/atlas/lib/libsatlas.so
export LAPACK=/usr/local/atlas/lib/liblapack.a
export BLAS=/usr/local/atlas/lib/libcblas.a
pip install --user --force-reinstall --upgrade numpy
python setup.py install --user

python -c 'import numpy; numpy.show_config()'
python -c 'import numpy;numpy.test()'
python -c 'import scipy;scipy.test()'
  1. Testing
#!/usr/bin/env python                                                           
import numpy
import sys
import timeit

try:
    import numpy.core._dotblas
    print 'FAST BLAS'
except ImportError:
    print 'slow blas'

print "version:", numpy.__version__
print "maxint:", sys.maxint
print

x = numpy.random.random((1000,1000))

setup = "import numpy; x = numpy.random.random((1000,1000))"
count = 5

t = timeit.Timer("numpy.dot(x, x.T)", setup=setup)
print "dot:", t.timeit(count)/count, "sec"
#!/usr/bin/env python                                                           
import timeit


setup = "import numpy;\
        import scipy.linalg as linalg;\
        x = numpy.random.random((1000,1000));\
        z = numpy.dot(x, x.T)"
count = 5

t = timeit.Timer("linalg.cholesky(z, lower=True)", setup=setup)
print "cholesky:", t.timeit(count)/count, "sec"

t = timeit.Timer("linalg.svd(z)", setup=setup)
print "svd:", t.timeit(count)/count, "sec"