This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Programming

Tutorials about programming with matlab, julia, and others.

1 - Conda environments

A tutorial for setting up your conda environments on Neurodesk.

This tutorial was created by Fernanda L. Ribeiro.

Email: fernanda.ribeiro@uq.edu.au

Github: @felenitaribeiro

Twitter: @NandaRibeiro93

This tutorial documents how to create conda environments on Neurodesk.

Conda/Mamba environment

The default conda environment is not persistent across sessions, so this means any packages you install in the standard environment will disappear after you restart the Jupyterlab instance. However, you can create your own conda environment, which will be stored in your homedirectory, by following the steps on this page. This method can also be used to install additional kernels, such as an R kernel.

  1. In a Terminal window, type in:

1_terminal

For Python:

mamba create -n myenv ipykernel
#OR
conda create -n myenv ipykernel

or for R:

mamba create -n r_env r-irkernel
#OR
conda create -n r_env r-irkernel

Important: For Python environments, you have to set the ipykernel explicitly or a Python version (like “conda create -n myenv python=3.8”), since a kernel is required. Alternatively, in case it was forgotten, you can add a kernel with:

conda install ipykernel
  1. To check the list of environments you have created, run the following:
mamba env list
#OR
conda env list
  1. To activate your conda environment and install the required packages from a provided txt file, run:
conda activate myenv
pip install -r requirements.txt
  1. Given the available environment, when you open a new Launcher tab, there will be a new Notebook option for launching a Jupyter Notebook with that environment active.

2_env

Switching the environment on a Jupyter Notebook is also possible on the top right corner dropdown menu.

3_notebook

2 - Matlab

A tutorial for setting up your matlab license on Neurodesk.

This tutorial was created by Fernanda L. Ribeiro.

Email: fernanda.ribeiro@uq.edu.au

Github: @felenitaribeiro

Twitter: @NandaRibeiro93

This tutorial documents how to set up your matlab license on Neurodesk.

Matlab license

  1. In the application menu, navigate to Neurodesk → Programming → matlab → matlabGUI 2022a

1_menu

  1. Select “Activate automatically using the internet” and hit next.

2_matlabgui

Then, add your email address and password from your MathWorks account (which you can set up using your university credentials if they provide a license for staff and students).

2_login

  1. Hit next after you select the appropriate license.

3_license

  1. Do not change the login name and hit next.

4_username

  1. Hit confirm, and you are all set!

5_confirm

  1. To launch the GUI, navigate through the application menu to Neurodesk → Programming → matlab → matlabGUI 2022a

Calling Neurodesk tools from within Matlab

This is a new feature and doesn’t work yet on Neurodesk for Apple Silicon. Make sure to run the latest version of Neurodesk and hit the update Button in the Application menu to ensure this works. You can use Neurodesk software within Matlab by adding the specific Neurodesk container to your execution Path. For the example of adding the FSL package, this can be done as follows in Matlab:

setenv("PATH",getenv("PATH") + ":/cvmfs/neurodesk.ardc.edu.au/containers/fsl_6.0.7.4_20231005");

Now you can, for example, use fslmaths in Matlab scripts: image

Let us know if this works well for you, and we would be very keen to hear if there is a better way of integrating the lmod system in Matlab.

Changing Matlab Keyboard Shortcuts

By default, Matlab uses the emacs keyboard shortcuts in Linux, which might not be what most users expect. To change the keyboard shortcuts to a more common pattern, follow the next steps:

Open the Preferences menu:

image

Navigate to Keyboard -> Shortcuts and change the active settings from “Emacs Default Set” to “Windows Default Set”:

image