From c02e845c16505d00db2ef701b9fae6f160b2e652 Mon Sep 17 00:00:00 2001 From: Josef Cutler Date: Fri, 6 Sep 2024 11:15:39 +0200 Subject: [PATCH 01/73] Docstrings for storing HRFs in snirf --- src/cedalion/io/snirf.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cedalion/io/snirf.py b/src/cedalion/io/snirf.py index b850d98..a0f001d 100644 --- a/src/cedalion/io/snirf.py +++ b/src/cedalion/io/snirf.py @@ -872,6 +872,14 @@ def measurement_list_from_stacked( def _write_recordings(snirf_file: Snirf, rec: cdc.Recording): + """Write a recording to a .snirf file. + + See snirf specification for details (:cite:t:`Tucker2022`) + + Args: + snirf_file (Snirf): Snirf object to write to. + rec (Recording): Recording object to write to the file. + """ # create and populate nirs element snirf_file.nirs.appendGroup() ne = snirf_file.nirs[-1] @@ -1002,6 +1010,13 @@ def write_snirf( fname: Path | str, recordings: cdc.Recording | list[cdc.Recording], ): + """Write one or more recordings to a .snirf file. + + Args: + fname (Path | str): Path to .snirf file. + recordings (Recording | list[Recording]): Recording object(s) to write to the + file. + """ if isinstance(fname, Path): fname = str(fname) From 9f35b9580b549649d6f483c51809c2240f7185d9 Mon Sep 17 00:00:00 2001 From: Eike Middell Date: Sun, 8 Sep 2024 13:40:58 +0200 Subject: [PATCH 02/73] fix in datasets.get_colin27_segmentation which stumbled over subdirectories in the zip file --- src/cedalion/datasets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cedalion/datasets.py b/src/cedalion/datasets.py index bc506a6..1575d00 100644 --- a/src/cedalion/datasets.py +++ b/src/cedalion/datasets.py @@ -50,7 +50,7 @@ def get_colin27_segmentation(downsampled=False): else: fnames = DATASETS.fetch("colin27_segmentation.zip", processor=pooch.Unzip()) - basedir = os.path.dirname(fnames[0]) + basedir = os.path.join(os.path.commonpath(fnames), "colin27_segmentation") mask_files = { "csf": "mask_csf.nii", "gm": "mask_gray.nii", From 9957956c64fc0e7cef1bc09edff8fddbb865c7b9 Mon Sep 17 00:00:00 2001 From: Eike Middell Date: Sun, 8 Sep 2024 13:49:17 +0200 Subject: [PATCH 03/73] temporarily disable image reco in docs --- docs/examples/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/Makefile b/docs/examples/Makefile index 641332f..aee53ac 100644 --- a/docs/examples/Makefile +++ b/docs/examples/Makefile @@ -2,13 +2,13 @@ EXAMPLE_NOTEBOOKS = xarray_datastructs_fnirs.ipynb \ finger_tapping_lda_classification.ipynb \ scalp_coupling_index.ipynb \ 1010_system.ipynb \ - image_reconstruction.ipynb \ store_hrfs_in_snirf_file.ipynb \ recording.ipynb \ glm_basis_functions.ipynb \ glm_illustrative_example.ipynb \ glm_fingertapping_example.ipynb + #image_reconstruction.ipynb \ #photogrammetric_optode_coregistration.ipynb \ #pruning_and_motion_artifacts.ipynb \ From a9c46fea32d378d6c736a424330dda2426e88710 Mon Sep 17 00:00:00 2001 From: Eike Middell Date: Sun, 8 Sep 2024 13:54:44 +0200 Subject: [PATCH 04/73] fix in datasets.get_colin27_segmentation --- src/cedalion/datasets.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cedalion/datasets.py b/src/cedalion/datasets.py index 1575d00..b4f401b 100644 --- a/src/cedalion/datasets.py +++ b/src/cedalion/datasets.py @@ -47,10 +47,12 @@ def get_colin27_segmentation(downsampled=False): fnames = DATASETS.fetch( "colin27_segmentation_downsampled_3x3x3.zip", processor=pooch.Unzip() ) + basedir = os.path.commonpath(fnames) + else: fnames = DATASETS.fetch("colin27_segmentation.zip", processor=pooch.Unzip()) + basedir = os.path.join(os.path.commonpath(fnames), "colin27_segmentation") - basedir = os.path.join(os.path.commonpath(fnames), "colin27_segmentation") mask_files = { "csf": "mask_csf.nii", "gm": "mask_gray.nii", From 9b22feb1047c38c5cfc458fad37c2db956215b86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20von=20L=C3=BChmann?= Date: Sun, 8 Sep 2024 15:50:23 +0200 Subject: [PATCH 05/73] validated example_plots & photogrammetry, minof updated docu, added CITATION.cff --- CITATION.cff | 9 + docs/community/contributing_code.md | 2 +- docs/community/contributors.md | 2 +- docs/community/toolboxes.md | 4 +- docs/examples/Makefile | 6 +- docs/index.md | 4 +- examples/finger_tapping_full_pipeline.ipynb | 16 +- ...hotogrammetric_optode_coregistration.ipynb | 292 ++++++++--------- examples/plots_example.ipynb | 294 +++++++++++++----- src/cedalion/datasets.py | 18 -- 10 files changed, 378 insertions(+), 269 deletions(-) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..a3af178 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,9 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +authors: +- family-names: "Intelligent Biomedical Sensing (IBS) Lab" +- family-names: "Cedalion Developers" +title: "Cedalion Python Toolbox" +version: 1.0.0 +date-released: 2024-09-08 +url: "https://github.com/ibs-lab/cedalion" \ No newline at end of file diff --git a/docs/community/contributing_code.md b/docs/community/contributing_code.md index a450109..e5599ea 100644 --- a/docs/community/contributing_code.md +++ b/docs/community/contributing_code.md @@ -5,5 +5,5 @@ Here you will find information on how to interface your own developments with ce In the meantime, you can find a small introduction to how to contribute code to cedalion below: ```{toctree} -contributing_code/contributing_code.md +getting_started/contributing_code.md ``` diff --git a/docs/community/contributors.md b/docs/community/contributors.md index 7ede97f..f19ffdc 100644 --- a/docs/community/contributors.md +++ b/docs/community/contributors.md @@ -2,7 +2,7 @@ This section is WIP. You will find more information and detailed stats here soon. -Cedalion is an open source project driven by the [IBS-Lab](https://ibs-lab.com/) with the aim to encourage continuous use, contribution and improvement from the whole community to make it last. Therefore, code credit is important to us. +Cedalion is an open source project driven by the [IBS-Lab](https://ibs-lab.com/) with the aim to encourage continuous use, contribution and improvement from the whole community to make it last. Therefore, it is important to us establish a transparent system of crediting contributors. ## Code Credit diff --git a/docs/community/toolboxes.md b/docs/community/toolboxes.md index 8d511ff..57d1f4f 100644 --- a/docs/community/toolboxes.md +++ b/docs/community/toolboxes.md @@ -6,11 +6,11 @@ This section is WIP. A part of the core set of Cedalion's scientific fNIRS processing functionality is based on the matlab toolboxes [Homer2/3](https://github.com/BUNPC/Homer3) and [AtlasViewer](https://github.com/BUNPC/AtlasViewer) from which we have adopted methods into the python ecosystem. -## Current toolboxes cedalion interfaces with: +## Current toolboxes cedalion interfaces with - [Monte Carlo Xtreme](http://mcx.space/), for Monte-Carlo-based photon simulation - [NIRFASTer](https://github.com/nirfaster/NIRFASTer), for FEM-based photon simulation -## Planned future toolboxes: +## Planned future toolboxes - [MNE](https://mne.tools/stable/index.html), for state of the art EEG/MEG processing functionality - [NeuroKit](https://github.com/neuropsychology/NeuroKit), for Neurophysiological Signal Processing - [...?](https://openfnirs.org/software/) \ No newline at end of file diff --git a/docs/examples/Makefile b/docs/examples/Makefile index aee53ac..c8a2462 100644 --- a/docs/examples/Makefile +++ b/docs/examples/Makefile @@ -1,15 +1,15 @@ EXAMPLE_NOTEBOOKS = xarray_datastructs_fnirs.ipynb \ + recording.ipynb \ finger_tapping_lda_classification.ipynb \ scalp_coupling_index.ipynb \ 1010_system.ipynb \ store_hrfs_in_snirf_file.ipynb \ - recording.ipynb \ glm_basis_functions.ipynb \ glm_illustrative_example.ipynb \ glm_fingertapping_example.ipynb - + plots_example.ipynb #image_reconstruction.ipynb \ - #photogrammetric_optode_coregistration.ipynb \ + photogrammetric_optode_coregistration.ipynb \ #pruning_and_motion_artifacts.ipynb \ .PHONY: notebooks diff --git a/docs/index.md b/docs/index.md index 9ecff49..359c553 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ # Cedalion -![cedalion graphical abstract](/docs/img/cedalion_frontpage.png) +![cedalion graphical abstract](img/cedalion_frontpage.png) A python-based framework for the data driven analysis of multimodal fNIRS and DOT in naturalistic environments. Developed by the Intelligent Biomedical Sensing (IBS) Lab with and for the community. @@ -21,7 +21,7 @@ LICENSE.md ## Special Thanks We cordially thank our friends and long-term collaborators at the BOAS Lab for their contributions and support in starting this project. -![special thanks](/docs/img/special_thanks.png) +![special thanks](img/special_thanks.png) ## Version This documentation was built from commit {{commit_hash}}. diff --git a/examples/finger_tapping_full_pipeline.ipynb b/examples/finger_tapping_full_pipeline.ipynb index d3ec521..1e2316f 100644 --- a/examples/finger_tapping_full_pipeline.ipynb +++ b/examples/finger_tapping_full_pipeline.ipynb @@ -35,7 +35,7 @@ "import pickle\n", "\n", "import pyvista as pv\n", - "pv.set_jupyter_backend('client')\n", + "pv.set_jupyter_backend('server')\n", "#pv.set_jupyter_backend('static')\n", "\n", "from IPython.display import Image\n", @@ -142,18 +142,18 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "2c659f7717f94d56b6a0ee3c80da07ce", + "model_id": "30d925509be947c29076fd0271433d38", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "Widget(value='