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 installation instructions.

[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 installation instructions.

[2]:
import cedalion
import cedalion.data
import cedalion.vis.blocks as vbx

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.data.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.data.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.data.get_colin27_segmentation()

/tmp/ipykernel_3412/4145678133.py:1: DeprecationWarning: 'get_colin27_segmentation' is deprecated: This function and the corresponding data files were replaced by cedalion.data.get_icbm152_headmodel_files .
  cedalion.data.get_colin27_segmentation()
[5]:
('/home/runner/.cache/cedalion/dev/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.data.get_precomputed_sensitivity("fingertappingDOT", "colin27")
display(Adot)
<xarray.DataArray (channel: 100, vertex: 35050, wavelength: 2)> Size: 28MB
array([[[7.86044507e-18, 7.86044507e-18],
        [2.92198773e-20, 2.92198773e-20],
        [4.21332955e-16, 4.21332955e-16],
        ...,
        [3.84422138e-12, 3.84422138e-12],
        [1.09104154e-12, 1.09104154e-12],
        [2.92177935e-12, 2.92177935e-12]],

       [[6.08132185e-18, 6.08132185e-18],
        [1.88014679e-18, 1.88014679e-18],
        [1.28715673e-18, 1.28715673e-18],
        ...,
        [1.82535194e-12, 1.82535194e-12],
        [5.95263856e-13, 5.95263856e-13],
        [2.58798516e-12, 2.58798516e-12]],

       [[1.15899955e-16, 1.15899955e-16],
        [1.43107075e-18, 1.43107075e-18],
        [1.79761183e-16, 1.79761183e-16],
        ...,
...
        [4.00709748e-17, 4.00709748e-17],
        [3.27515374e-16, 3.27515374e-16],
        [4.11977386e-15, 4.11977386e-15]],

       [[4.43908311e-13, 4.43908311e-13],
        [1.67562633e-13, 1.67562633e-13],
        [1.32101065e-14, 1.32101065e-14],
        ...,
        [3.35938323e-16, 3.35938323e-16],
        [1.05045353e-16, 1.05045353e-16],
        [1.17797973e-15, 1.17797973e-15]],

       [[6.72998224e-13, 6.72998224e-13],
        [3.09515759e-13, 3.09515759e-13],
        [1.11142420e-14, 1.11142420e-14],
        ...,
        [2.85535005e-17, 2.85535005e-17],
        [2.56247716e-16, 2.56247716e-16],
        [1.03397862e-14, 1.03397862e-14]]],
      shape=(100, 35050, 2), dtype=float32)
Coordinates:
    parcel      (vertex) object 280kB 'VisCent_ExStr_8_LH' ... 'scalp'
    is_brain    (vertex) bool 35kB 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.data.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")
#pv.set_jupyter_backend("server") # for interactive plots
plt = pv.Plotter()
vbx.plot_surface(plt, s, opacity=1.0)
plt.show()
../../_images/examples_getting_started_io_00_test_installation_11_0.png

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

References

[9]:
cedalion.bib.dump_to_notebook()

Methods used

[1]Luke2021cedalion.data.get_fingertappingRobert Luke and David McAlpine. fNIRS Finger Tapping Data in BIDS Format. September 2021. doi:10.5281/zenodo.5529797.
[2]Tucker2022cedalion.io.snirf.read_snirfStephen Tucker, Jay Dubb, Sreekanth Kura, Alexander von Lühmann, Robert Franke, Jörn M. Horschig, Samuel Powell, Robert Oostenveld, Michael Lührs, Édouard Delaire, Zahra M. Aghajan, Hanseok Yun, Meryem A. Yücel, Qianqian Fang, Theodore J. Huppert, Blaise deB. Frederick, Luca Pollonini, David A. Boas, and Robert Luke. Introduction to the shared near infrared spectroscopy format. Neurophotonics, 10(1):013507, 2022. doi:10.1117/1.NPh.10.1.013507.
[3]Holmes1998cedalion.data.get_colin27_segmentationColin J. Holmes, Rick Hoge, Louis Collins, Roger Woods, Arthur W. Toga, and Alan C. Evans. Enhancement of mr images using registration for signal averaging. Journal of Computer Assisted Tomography, 22(2):324–333, March 1998. doi:10.1097/00004728-199803000-00032.
[4]Fang2009cedalion.data.get_precomputed_sensitivityQianqian Fang and David A Boas. Monte carlo simulation of photon migration in 3d turbid media accelerated by graphics processing units. Optics express, 17(22):20178–20190, 2009. doi:10.1364/OE.17.020178.
[5]Yu2018cedalion.data.get_precomputed_sensitivityLeiming Yu, Fanny Nina-Paravecino, David Kaeli, and Qianqian Fang. Scalable and massively parallel monte carlo photon transport simulations for heterogeneous computing platforms. Journal of biomedical optics, 23(1):010504–010504, 2018. doi:10.1117/1.JBO.23.1.010504.
[6]Yan2020cedalion.data.get_precomputed_sensitivityShijie Yan and Qianqian Fang. Hybrid mesh and voxel based monte carlo algorithm for accurate and efficient photon transport modeling in complex bio-tissues. Biomedical Optics Express, 11(11):6262–6270, 2020. doi:10.1364/BOE.409468.