Introduction

  • Everything should work on Linux (at least for Debian-based distros but if you want a tuto for other distros (i.e Arch-based) I will definetely be happy to help.
  • Some things might defer on Mac OS but if you install Homebrew it will definitely be easier.
  • I assume your folder names are in english but if they are in another language (i.e. french) you will have to change certain commands (e.g. “Downloads” become “Telechargements”).

Linux / Unix

First thing will be to get you hands on a Linux distribution, I myself use and recommend Pop!_OS, but we will assume you are on Ubuntu (anyhow any Debian-based distribution should work as well). You can choose to only have one main OS Ubuntu, Pop!_OS) or to dual boot Windows/Linux, or to dual boot Mac/Linux.

But if you are reluctant to dual boot Linux I really recommend you start by installing a NeuroDebian virtual machine. It’s really simple to install (and to remove if you don’t like it), with that you can be up and running in an hour! link to their video tutorial

Octave OR Matlab via UniGe

1.a Install GNU octave

Free alternative to Matlab -> (below is how to get actual Matlab but please try this first for open science sake!) Yes this is not a click-bait or anything. You don’t need to pay to have Matlab to run the free available toolboxes (e.g. SPM, EEGLAB and psychotoolbox).
And you should also consider that octave consume less RAM than Matlab so it’s a good alternative for older computers.

For Linux

sudo apt-get install octave-control octave-image octave-io octave-optim octave-signal octave-statistics liboctave-dev gnuplot

And that’s it! You can run pretty much anything Matlab can.

For Mac

Please follow this guide

1.b Install an external toolbox (here -> SPM12)

Download SPM here version 12.

sudo mv ~/Downloads/spm12 /usr/local/octave/
cd /usr/local/octave/spm12/src
make PLATFORM=octave
make PLATFORM=octave install

Now in octave (type octave in a terminal or open the octave application)

%% Add SPM12 to the function search path
cd /usr/local/octave/
addpath /usr/local/octave/spm12;
savepath
%% Start SPM12
spm fmri

VOILA!

2.a Install MATLAB (via Unige network license)

(these matlab instalation only works if you are on the UniGE VPN) Follow these instructions to install VPN UniGe all OS

2.b Download Matlab

Go to matlab home page
Create an account or sign in
/! Add a new a license number (2537) (this can be done by cliking on your profile and then on go under Licences) /! 
Then click on the license “server:matlab” to start the download menu.
Choose whatever OS you need (Linux, Mac, Windows).
Choose the version of matlab. Here I recommend you choose matlab 2019a since the newer version have issue with the server license authentification (at least for Mac and Linux).
Finally download the license file for UniGe. (You might need a Switch account).

For Linux

Fire up a terminal (ctrl+alt+t) and copy paste these lines

cd ~/downloads/
unzip matlab.zip
cd matlab
unzip matlab_R2019a_glnxa64.zip #or whichever version 
sudo ./install 

For Mac or Windows

Just double click on the matlab file installer (matlab_R2019a_maci64.dmg or matlab_R2019a_win64.exe)

2.c Finish Installing (all OS)

Now you will have to sign in to your MathWorks account and follow the matlab installer (try to keep the defaults settings so the rest of the tutorial works smoothly otherwie you will need to adapt accordingly). Choose the newtork license (2537). Then, when prompted for the license file you need to select (browse) the “network.lic” file inside your “Downloads” folder you downloaded earlier.

For Linux only

# replace _cisa_ by YOUR USERNAME
sudo chown -R cisa /usr/local/MATLAB/R2019a/

2.d Install an external toolbox (here -> SPM12)

Download SPM here version 12. I also personally recommend to install/take a look at these extensions according to your needs: Design optimisation by Bob spunt EEG lab for timeseries analysis

For Linux

cd ~/Downloads
unzip spm12.zip
sudo mv -r ~/Downloads/spm12 /usr/local/MATLAB/R2019a/toolbox/ #this will ask your admin password
matlab & #this will open a matlab instance

Then inside the matlab console

addpath /usr/local/MATLAB/R2019a/toolbox/spm12
savepath

Here it is, that’s the proper way to install an external toolbox on matlab. BONUS: If you want to install a SPM toolbox you should do the same thing but instead of “/usr/local/MATLAB/R2019a/toolbox/” you will put “/usr/local/MATLAB/R2019a/toolbox/spm12/toolbox/”

For Mac

Double click on the spm12.zip to exctract the folder with the archive utility

Then open up a terminal (either via the spotlight search or in Application -> Utilities)

mv ~/Downloads/spm12 /Applications/MATLAB_R2019a.app/toolbox/ 

Accept the pop-op window
Then open up matlab via applications and copy paste these lines

addpath /Applications/MATLAB_R2019a.app/toolbox/spm12
savepath

2.e Install a SPM extensions

If you want to install a SPM toolbox you should do the same thing but instead of “/Applications/MATLAB_R2019a.app/toolbox/” you will put “/Applications/MATLAB_R2019a.app/toolbox/spm12/toolbox/”

For example to install MarsBar on mac: Go to SPM extensions and download MarsBar

cd ~/Downloads
unzip marsbar-0.44.zip ## replace 0.44 by the version you have downloaded
sudo mv -r ~/Downloads/marsbar-0.44 /usr/local/MATLAB/R2019a/toolbox/spm12/toolbox/marsbar #here I change the name "marsbar-0.44" to "marsbar" so its easier to remember and deal with 
matlab & #this will open a matlab instance

Then inside the matlab console

addpath /Applications/MATLAB_R2019a.app/toolbox/spm12/toolbox/marsbar
savepath

I personally recommend to install/take a look at these SPM extensions:

Modeling: -MACS Model Assessment, Comparison and Selection (really useful to do BMS) -MRM Multivariate and Repeated Measures (my personal favorite for repeated measures second level analyisis + permutation based inferences) -RobustWLS Robust regression using Weighted-least-squares -SnPM Statistical Nonparametric Mapping -SwE Sandwich Estimator Toolbox for Longitudinal & Repeated Measures Data

ROI analysis - Anatomical proability masks: -MarsBar MARSeille Boite A Region d’interet (must have for creating ROI + super fun documentation) -SPM Anatomy toolbox

Connectivity and PPI: -CONN Functional Connectivity Toolbox (really cool and simple to use) -gPPI

Display: -Bspmview (really cool user interface for exploring statistical images)

Experimental design; -fMRIPower (power calculation for fMRI)

PsychoPhysio: -PsPM not in the spm extensions website (but SHOULD be installed as an extension)

BONUS

Cool themes for matlab https://github.com/scottclowe/matlab-schemer Then just type “schemer_import” and choose the matrix.prf

IDE (integrated development environment)

Here things might start to get personal…

There is much debate on what is THE best IDE but here I will just tell you what I think is best to start with. ### VS studio Get Visual Studio Code for long and heavy duty coding. It has thousand of cool features, great debugging mode, and you can easyly choose which environement profile you want to be in.

Vim

Use Vim to create and tinkle files in your terminal (or when you ssh connect to a remote server)

sudo apt-get install vim
vim file.txt 

Basics commands in Vim

This will create a ‘file.txt’ file (if it doesn’t exist already otherwise it just modifies it) and opens vim editor (or put sudo in front if you want to create/modify a file with super user privileges).

First you will be on a ‘read-only’ mode.
Press ‘a’ to insert or modify text (this is just a security so you don’t change something by mystake).
Then you are free to type whatever you want or move to another lign (with the arrow keys the mouse will not help you here!) or press ‘ctrl+shift+v’ to paste any text you gave copied on your clipboard.
Press ‘esc’ to escape the insert mode and go back to ‘read-only’ mode.
Press ‘:wq’ + ‘enter’ to save and quit.

-“Wait whhhat?!”
So basically the ‘:’ is to start a command, the ‘w’ is to save (‘write’) modficiations and ‘enter’ just runs the command.
-“What if I messed up ?”
Don’t worry, just press ‘:q!’ when you are in the ‘read-only’ mode and that will close the file without saving (here I added the ‘!’ which is the ‘force’ command).

Anaconda / Python

Has useful as it is easy to do install It’s pretty much a python package manager for data science, it comes with extremely cool packages such as: Jupyter, SciPy, Spyder, NumPy, ScikitLearn, Pandas, TensorFlow, Matplotlib, Pytorch that you should look into. Getting familiar with conda environmments could really get you out of a tone of trouble.

create minimal Python 3.7 env

conda create -y                 \
-n py37                   \
python=3.7                \
matplotlib numpy

create minimal Python 2.7 env

conda create -y                 \
-n py27                   \
python=2.7                \
matplotlib numpy

FSL

FSL (pronounced “fossil”) is pretty easy to install through their ‘fslinstaller.py’ BUT be sure to use python2 as follows:

sudo apt install python2
python2 fslinstaller.py

AFNI

AFNI is definitely a bit more trickier (for Linux user at least) but it’s really well documented here
Something that really helped me out was to install ‘tcsh’ so I could follow their tutorials more strickly (they use C-shell instead of standard ‘bash, eval=F’ (Bourne Again SHell) command language which goes along with their geek philosophy)

sudo apt-get install -y tcsh
#so you can run their command
tcsh @update.afni.binaries ...

After the hustle you might be scared (I was..) by AFNI because the GUI looks more like an ultra confusing pilot cockpit than anything else but.. be brave, its worth it.

R/Rstudio

Install R (4.0) on Linux!

If you are on Linux and you absolutely NEED the newest version of R (4.0 at the moment) like I did, you are probably as pissed-off as I was when I saw that it is not anywhere near to be released yet. But if you don’t fear the bleeding edge, I have a solution for you!

# be sure to totally remove R if you already installed it 
sudo apt-get purge r-base* r-recommended r-cran-*
sudo apt autoremove
sudo apt update

# You will need this 'key' to acces it (it's a new mirror that is not yet released)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
#sudo apt install libssl-dev # install libraries
sudo apt update
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
# Install new version of R (4.0)
sudo apt install r-base r-base-core r-recommended r-base-dev gdebi-core
# Then you can just download [Rstudio](https://rstudio.com/products/rstudio/download/#download) (still no Focal Fossa update though..)
# or via wget 
wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.2.5042-amd64.deb # that works for ubuntu 20 others might not
sudo gdebi rstudio-1.2.5042-amd64.deb

and get you other package from Rstudio now.

Clutser computing (AKA Cisa-Calc server)

Link to tutorials on how to run you scipts on a server

Install stuff

If your are not connected to the Unige WIFI -> You will need to install the UniGE VPN client

On Linux:

Install via a terminal

sudo apt-get install sshfs -y

On Mac:

You can install sshfs on Mac OSX. You will need to download FUSE and SSHFS from the osxfuse site

On Windows:

You can install sshfs from this exe file

How to acces cisa-calc

Replace “user” by your user name on your machine Replace “username” by the user name the administrator of cisa-calc has given you (might not be the same as “user”)

No graphic interface -> only terminal

To connect to the cisa-calc:

ssh username@cisa-calc.unige.ch

To exit

Just type:

exit

With graphic interface -> browse files seamlessly

To mount (or “fuse”) a folder from the cisa-calc to your machine: First you will have to create an empty folder on your machine (e.g., /home/user/SERVER).
Then, run this command:

sshfs username@cisa-calc.unige.ch:/home/username/ /home/user/SERVER

Explanation: The first term “/home/username/” is the folder you want to mount FROM the server TO your machine.
The second term “/home/user/SERVER” is the folder you want you TO RECEIVE the data FROM ther server.

To unmount

Just type:

umount -l /home/user/SERVER

Rules

Jobs cannot be run on the machine without going through Torque. Submit final jobs, debug on your machine first.

Power User

What if I don’t want to memorize those commands and type them each time?

On Linux and mac:

You can create “aliases” that will act as shortcut commands. THIS IS A HUGE TIMESAVER!
Inside a terminal: (You can replace vim by any editor (gedit, emacs, etc..))

vim ~/.bash_profile #This will open you "user profile"

Then inside you want to press “a” to swith to “insert” mode.
Navigate to the bottom of the file ans start typing your aliases.
! NB: there should not be any spaces between your alias name and the command between apostrophes ’’ !

Here an example of useful aliases:

# my super cool aliases
# moving through files
alias cd...='cd ../../../' #go back 3 folders
alias cd....='cd ../../../../' #go back 4 folders
alias ll='ls -alF' #show all files (included hidden files) and permissions
alias la='ls -A' #show all files (included hidden files)

# SERVER
alias CISA='ssh username@cisa-calc.unige.ch' # o connnect to cisa-calc
alias FUSE='sshfs username@cisa-calc.unige.ch:/home/username/ /home/user/SERVER' # to mount from cisa-calc
alias UNMOUNT='umount -l /home/user/SERVER' #to unmount folder from your machine


# Useful aliases
alias sourcebash, eval=F="source ~/.bash, eval=F_profile" # modif bash, eval=F profile
alias modbash, eval=F="vim ~/.bash, eval=Frc" #source bash, eval=F profile
alias fuck='eval $(thefuck $(fc -ln -1)); history -r' #evaluate last coimmand and autocompletes
alias open='xdg-open' #open file from terminal (only linux)
alias del='gio trash' # put file to the trash instead to remove them (only linux)
alias searchH='find /home/user/ -name' # seach in user directory
alias searchA='sudo find / -name' #search in whole machine

# ONLY LINUX UPDATE BOOT & POWEROFF
alias update='sudo apt-get update && sudo apt-get upgrade'
alias reboot='sudo /sbin/reboot'
alias poweroff='sudo /sbin/poweroff'
alias halt='sudo /sbin/halt'
alias shutdown='sudo /sbin/shutdown'

# function to quickly (lazyly) add commit and push gits
function lazygit() {
git add .
git commit -a -m "$1"
git push}

Zotero

The snap store version of Zotero didn’t work on my machines for whatever reasons so here is another way to get your Zotero working on Linux.

sudo add-apt-repository popa:smathot/cogscinl
sudo apt-get update
sudo apt-get install zotero-standalone

Install Better BibTex

Better BibTex is just so much easier to work with since it ouput a comprehensible output so go to Better BibTex.
Right click on the ‘.xpi’ and chose’save link as’
Now form Zotero go to ‘Tools’ -> ‘Add-ons’ and under the gear icon choose ‘Install add-on from fille..’
Browse to where you saved the ‘.xpi’ file and that’s it! #ThankLaviniaForThisOne

Backups

Simple backups with timeshift (need an external drive though)

Well this one is a biggie. We are all scared to loose are data so backing it up is a must do. The university suggest to use TSM (tivoli storage manager) but it’s garbage. First, it’sa huge pain to install on Linux, second it doesn’t alert you if there is a problem to fix, third it’s IBM. I personnally know someone who lost 3 years worth of work while having TSM installed (not even on Linux so this is not an OS issue) and the university never find a way to restore the data. So one solution I personnaly suggest, just buy an external drive (you can have 500Gb for 30$ nowadays so I don’t think it’s too much to be on the safe side) and install Timeshift.

Fun stuff (AKA just for fun)

Install “insults”

This will make your terminal “insult” you every time you mistype your password (it’s hilarious trust me)

sudo visudo
#you are now inside vi in "read" mode
#press "a" to be in the "insert" mode
Defaults insults #and add this line below  "# Override built-in defaults"
#now press "esc" (to quit insert mode) followed by ":wq" (to save and exit)

Install “theFuck”

The Fuck is a magnificent app, that corrects errors in previous console commands. So check it out on github
gif with examples

Tweaking your computer (on cisa’s Dell desktops)

First and foremost you should NEVER tweak boot options if you are not 200% sure of what you are doing. Now if you want (as I did) to speed up your boot time, I found out that disabling the (unused) legacy boot mode (since I assume that you are running UEFI boot on most linux distros).

Just press F2 (or maybe F12 depending on your model) at the sight of the Dell logo until you see the BIOS menu. From there you can change your Boot list options from Legacy to UEFI. Then you should disable (uncheck) Legacy Option ROMs. Then, under the “Security” tab you should now disable Secure boot. Save, apply and restart. That’s it you will boot in ~12 seconds now instead of the huge 1m30 before.

TODO

Bids

expliqer comment ls -n softlink tidy

Purves: https://drive.google.com/file/d/15Qaw-PSCSXHCSBWY_PxnQK2N7tYVt0Py/view?usp=sharing

scripts

images