PALM installation#

Use these instructions to install PALM and enable its use with either MATLAB or Octave. These instructions were written for PALM version alpha-1.1.2.

1. Download PALM#

To install PALM for use with QuNex, we recommend to generate a folder PALM within $TOOLS directory, and either download or clone the current version of PALM from in this directory. If you are planning to support the use of PALM with both MATLAB and Octave, we recommend creating two copies of the PALM distribution with different names, e.g.:

$TOOLS/PALM/palm-alpha112m      # to use with MATLAB
$TOOLS/PALM/palm-alpha112o      # to use with Octave

2. Set up PALM#

Open $TOOLS/PALM/palm-alpha112m/palm and/or $TOOLS/PALM/palm-alpha112o in a text editor and set up the following variables:

# To use with MATLAB
MATLABPATH=<path to your MATLAB installation>

# To use with Octave
OCTAVEPATH=<path to your Octave installation>

3. Compile mex files#

We have found that for use with MATLAB, no compilation of mex files was required; however, to work with Octave additional steps had to be taken. In all the following steps, $PALMPATH refers to the location of the PALM distribution, e.g. $TOOLS/PALM/palm-alpha112o.

Compile @file_array mex files:

cd $PALMPATH/fileio/@file_array/private

mv file2mat.m x_file2mat.m
mv init.m x_init.m
mv mat2file.m x_mat2file.m

In our experience the last three lines were necessary, as Octave was loading the .m files instead of the compiled .mex files even when the latter were present. The same strategy of masking the .m files is employed in the following steps.

Compile @gifti mex files:

cd $PALMPATH/fileio/@gifti/private

mv zstream.m x_zstream.m

Compile @nifti mex files:

cd $PALMPATH/fileio/@nifti/private
mkoctfile --mex nifti_stats.c nifti_stats_mex.c -O

mv nifti_stats.m x_nifti_stats.m

Compile @xmltree mex files:

cd $PALMPATH/fileio/@xmltree/private
cp $PALMPATH/fileio/@file_array/private/Makefile.var .
cp $PALMPATH/fileio/@file_array/private/ .
sed -i -e 's|include ../../src/Makefile.var|include Makefile.var|g' Makefile

mv xml_findstr.m x_xml_findstr.m

4. Edit

To make sure that QuNex 'sees' the correct PALM installation, edit the following segment of the $TOOLS/qunex/env/ file so that PALMDIR variable in references the PALM installation that matches with the PALM WHICH_TO_RUN variable set in step 2.:

# ------------------------------------------------------------------------------
# -- Running matlab vs. octave
# ------------------------------------------------------------------------------

if [ "$USEOCTAVE" == "TRUE" ]; then
    if [[ ${OctaveTest} == "fail" ]]; then 
        reho " ===> ERROR: Cannot setup Octave because module test failed."
         ln -s `which octave` ${OCTAVEDIR}/octave > /dev/null 2>&1
         export OCTAVEPKGDIR
         export OCTAVEDIR
         export OCTAVEBINDIR
         cyaneho " ---> Setting up Octave "; echo ""
         QUNEXMCOMMAND='octave -q --no-init-file --eval'
         if [ ! -e ~/.octaverc ]; then
             cp ${QUNEXPATH}/qx_library/.octaverc ~/.octaverc
         export LD_LIBRARY_PATH=/usr/lib64/hdf5/:${LD_LIBRARY_PATH} > /dev/null 2>&1
         if [[ -z ${PALMDIR} ]]; then PALMDIR="${TOOLS}/palm/palm-latest-o"; fi
    # if [[ ${MatlabTest} == "fail" ]]; then
    #     reho " ===> ERROR: Cannot setup Matlab because module test failed."
    # else

         cyaneho " ---> Setting up Matlab "; echo ""
         QUNEXMCOMMAND='matlab -nodisplay -nosplash -r'
         if [[ -z ${PALMDIR} ]]; then PALMDIR="${TOOLS}/palm/palm-latest-m"; fi
    # fi
# -- Use the following command to run .m code in MATLAB