This Notebook tests whether your cedalion installation is working
Everything that is specific to the installation of Cedalion can be found on our documentation page: https://doc.ibs.tu-berlin.de/cedalion/doc/dev
It is assumed that you already followed the steps below:
Have the conda package manager installed, either by installing Anaconda or Miniconda.
Clone the Cedalion repository from github to your local disk. The main branch is the release branch.
In your IDE, switch to the Cedalion folder as your local working folder or “add to path”.
In its Python terminal create a conda environment with the necessary dependencies by running:
$ conda env create -n cedalion -f environment_dev.yml
This installs all relevant dependencies and creates an environment in which you can run the toolbox. It also includes Jupyter Notebook to run the example notebooks.
Afterwards activate the environment and add an editable install of Cedalion to it:
$ conda activate cedalion
$ pip install -e .
If creating the environment is slow:
To create the environment conda needs to find a set of packages that fulfills all requirements. If conda needs too much time to find a solution, there are two ways to speed it up.
Install libmamba-solver and configure conda to use it. (recommended )
If you have a recent conda version (23.10 or later), libmamba is already preconfigured. Otherwise update:
$ conda update -n base conda
[1]:
# This cells setups the environment when executed in Google Colab.
try:
import google.colab
!curl -s https://raw.githubusercontent.com/ibs-lab/cedalion/dev/scripts/colab_setup.py -o colab_setup.py
# Select branch with --branch "branch name" (default is "dev")
%run colab_setup.py
except ImportError:
pass
Import Cedalion Dependencies
If you get an error here, revisit the setup above.
[2]:
import cedalion
import cedalion.datasets
import cedalion.plots
Download datasets
These will be cached and are used by amongst others by the example notebooks.
Depending on your operating system the user cache directory is one of these:
Mac:
~/Library/Caches/cedalion
Unix:
~/.cache/cedalion
Windows:
C:\Users\<user>\AppData\Local\cedalion\cedalion\Cache
It is safe to delete the downloaded files, if they are not needed anymore. During a new run of the example notebooks they are downloaded again.
[3]:
# loads finger tapping data with sparse probe
rec = cedalion.datasets.get_fingertapping()
display(rec)
<Recording | timeseries: ['amp'], masks: [], stim: ['1.0', '15.0', '2.0', '3.0'], aux_ts: [], aux_obj: []>
[4]:
# loads finger tapping data with high density probe
rec = cedalion.datasets.get_fingertappingDOT()
display(rec)
<Recording | timeseries: ['amp'], masks: [], stim: ['1', '2', '3', '4', '5'], aux_ts: ['ACCEL_X_1', 'ACCEL_Y_1', 'ACCEL_Z_1', 'GYRO_X_1', 'GYRO_Y_1', 'GYRO_Z_1', 'ExGa1', 'ExGa2', 'ExGa3', 'ExGa4', 'ECG', 'Respiration', 'PPG', 'SpO2', 'Heartrate', 'GSR', 'Temperature'], aux_obj: []>
[5]:
cedalion.datasets.get_colin27_segmentation()
[5]:
('/home/runner/.cache/cedalion/v25.1.0/colin27_segmentation.zip.unzip/colin27_segmentation',
{'csf': 'mask_csf.nii',
'gm': 'mask_gray.nii',
'scalp': 'mask_skin.nii',
'skull': 'mask_bone.nii',
'wm': 'mask_white.nii'},
'landmarks.mrk.json')
[6]:
Adot = cedalion.datasets.get_precomputed_sensitivity("fingertappingDOT", "colin27")
display(Adot)
<xarray.DataArray (channel: 100, vertex: 25052, wavelength: 2)> Size: 40MB array([[[1.21179827e-17, 1.21179827e-17], [3.96194809e-20, 3.96194809e-20], [4.10971853e-19, 4.10971853e-19], ..., [3.50555240e-12, 3.50555240e-12], [5.26119937e-13, 5.26119937e-13], [8.08679933e-13, 8.08679933e-13]], [[7.61680927e-18, 7.61680927e-18], [1.23019221e-18, 1.23019221e-18], [1.67531031e-19, 1.67531031e-19], ..., [2.33481439e-12, 2.33481439e-12], [4.92126651e-13, 4.92126651e-13], [1.07023130e-12, 1.07023130e-12]], [[5.52717640e-17, 5.52717640e-17], [1.78701021e-18, 1.78701021e-18], [6.99671883e-18, 6.99671883e-18], ..., ... ..., [5.98963847e-19, 5.98963847e-19], [6.62891414e-18, 6.62891414e-18], [1.28914788e-15, 1.28914788e-15]], [[3.15260006e-12, 3.15260006e-12], [8.79590880e-12, 8.79590880e-12], [1.06539458e-11, 1.06539458e-11], ..., [3.80802873e-19, 3.80802873e-19], [1.03147281e-16, 1.03147281e-16], [2.13242570e-16, 2.13242570e-16]], [[2.51903559e-12, 2.51903559e-12], [6.00967488e-12, 6.00967488e-12], [1.87582313e-12, 1.87582313e-12], ..., [2.80353969e-20, 2.80353969e-20], [1.96006079e-18, 1.96006079e-18], [3.81463022e-16, 3.81463022e-16]]], shape=(100, 25052, 2)) Coordinates: parcel (vertex) object 200kB 'VisCent_ExStr_8_LH' ... 'scalp' is_brain (vertex) bool 25kB True True True True ... False False False * channel (channel) object 800B 'S1D1' 'S1D2' 'S1D4' ... 'S14D31' 'S14D32' source (channel) object 800B 'S1' 'S1' 'S1' 'S1' ... 'S14' 'S14' 'S14' detector (channel) object 800B 'D1' 'D2' 'D4' 'D5' ... 'D29' 'D31' 'D32' * wavelength (wavelength) float64 16B 760.0 850.0 Dimensions without coordinates: vertex Attributes: units: mm
[7]:
# loads photogrammetry scan example
fname_scan, fname_snirf,fname_montage = cedalion.datasets.get_photogrammetry_example_scan()
s = cedalion.io.read_einstar_obj(fname_scan)
Optional: Plot a 3D scan with Pyvista
Note: If you run into problems here this will not be due to a faulty Cedalion installation, but your Pyvista setup
[8]:
# plot the scan
import pyvista as pv
pv.set_jupyter_backend("static") # use "client" for interactive rendering
plt = pv.Plotter()
cedalion.plots.plot_surface(plt, s, opacity=1.0)
plt.show()

If you run into trouble you can get help by the community
Visit the Cedalion forum on openfnirs.org/community/cedalion and particularly the thread for installing cedalion