cedanirs 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cedanirs-0.0.1/PKG-INFO +38 -0
- cedanirs-0.0.1/README.md +14 -0
- cedanirs-0.0.1/cedanirs/__init__.py +1 -0
- cedanirs-0.0.1/cedanirs/preprocessor.py +98 -0
- cedanirs-0.0.1/cedanirs.egg-info/PKG-INFO +38 -0
- cedanirs-0.0.1/cedanirs.egg-info/SOURCES.txt +10 -0
- cedanirs-0.0.1/cedanirs.egg-info/dependency_links.txt +1 -0
- cedanirs-0.0.1/cedanirs.egg-info/requires.txt +9 -0
- cedanirs-0.0.1/cedanirs.egg-info/top_level.txt +1 -0
- cedanirs-0.0.1/pyproject.toml +31 -0
- cedanirs-0.0.1/setup.cfg +4 -0
- cedanirs-0.0.1/tests/test_preprocessor.py +28 -0
cedanirs-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cedanirs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A wrapper around cedalion for streamlined fNIRS preprocessing and analysis
|
|
5
|
+
Author-email: Adam Emile Aske <adask2429@oslomet.no>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/adamaske/cedanirs
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/adamaske/cedanirs/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: xarray
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: cedalion
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest; extra == "dev"
|
|
22
|
+
Requires-Dist: black; extra == "dev"
|
|
23
|
+
Requires-Dist: flake8; extra == "dev"
|
|
24
|
+
|
|
25
|
+
# cedanirs
|
|
26
|
+
|
|
27
|
+
## What is Cedanirs?
|
|
28
|
+
Cedanirs is a repository with reusable programs to process and analyze functional near-infrared spectroscopy (fNIRS) data.
|
|
29
|
+
|
|
30
|
+
## Modules
|
|
31
|
+
- Preprocessing
|
|
32
|
+
Input your .snirf file. Outputs preprocessed .snirf file.
|
|
33
|
+
Motion correction. Temporal filtering. Normalization.
|
|
34
|
+
- Analysis
|
|
35
|
+
GLM solvers. HRF estimation. DOT image reconstruction.
|
|
36
|
+
- Experiments
|
|
37
|
+
Input standardaized experimental parameters, preprocess, analyze and report in a one swing.
|
|
38
|
+
-
|
cedanirs-0.0.1/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# cedanirs
|
|
2
|
+
|
|
3
|
+
## What is Cedanirs?
|
|
4
|
+
Cedanirs is a repository with reusable programs to process and analyze functional near-infrared spectroscopy (fNIRS) data.
|
|
5
|
+
|
|
6
|
+
## Modules
|
|
7
|
+
- Preprocessing
|
|
8
|
+
Input your .snirf file. Outputs preprocessed .snirf file.
|
|
9
|
+
Motion correction. Temporal filtering. Normalization.
|
|
10
|
+
- Analysis
|
|
11
|
+
GLM solvers. HRF estimation. DOT image reconstruction.
|
|
12
|
+
- Experiments
|
|
13
|
+
Input standardaized experimental parameters, preprocess, analyze and report in a one swing.
|
|
14
|
+
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .preprocessor import Preprocessor
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import xarray as xr
|
|
4
|
+
import cedalion.io as io
|
|
5
|
+
import cedalion.nirs.cw as cw
|
|
6
|
+
import cedalion.sigproc.frequency as frequency
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Preprocessor:
|
|
10
|
+
"""Configurable preprocessing pipeline for cedalion fNIRS data.
|
|
11
|
+
|
|
12
|
+
Steps (in execution order):
|
|
13
|
+
1. Raw intensity -> Optical density
|
|
14
|
+
2. Motion correction (TDDR)
|
|
15
|
+
3. Optical density -> Haemoglobin (Beer-Lambert)
|
|
16
|
+
4. Bandpass temporal filtering
|
|
17
|
+
|
|
18
|
+
Usage::
|
|
19
|
+
|
|
20
|
+
pp = Preprocessor()
|
|
21
|
+
pp.set_bandpass(0.01, 0.2)
|
|
22
|
+
result = pp.apply(recording)
|
|
23
|
+
|
|
24
|
+
Or fluent::
|
|
25
|
+
|
|
26
|
+
result = Preprocessor().set_bandpass(0.01, 0.2).apply(recording)
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
optical_density: bool = True,
|
|
32
|
+
motion_correction: bool = True,
|
|
33
|
+
hemoglobin: bool = True,
|
|
34
|
+
bandpass: bool = True,
|
|
35
|
+
bandpass_low: float = 0.01,
|
|
36
|
+
bandpass_high: float = 0.1,
|
|
37
|
+
dpf: float = 6.0,
|
|
38
|
+
):
|
|
39
|
+
self.optical_density = optical_density
|
|
40
|
+
self.motion_correction = motion_correction
|
|
41
|
+
self.hemoglobin = hemoglobin
|
|
42
|
+
self.bandpass = bandpass
|
|
43
|
+
self.bandpass_low = bandpass_low
|
|
44
|
+
self.bandpass_high = bandpass_high
|
|
45
|
+
self.dpf = dpf
|
|
46
|
+
|
|
47
|
+
def set_optical_density(self, enabled: bool = True) -> "Preprocessor":
|
|
48
|
+
self.optical_density = enabled
|
|
49
|
+
return self
|
|
50
|
+
|
|
51
|
+
def set_motion_correction(self, enabled: bool = True) -> "Preprocessor":
|
|
52
|
+
self.motion_correction = enabled
|
|
53
|
+
return self
|
|
54
|
+
|
|
55
|
+
def set_hemoglobin(self, enabled: bool = True, dpf: float = 6.0) -> "Preprocessor":
|
|
56
|
+
self.hemoglobin = enabled
|
|
57
|
+
self.dpf = dpf
|
|
58
|
+
return self
|
|
59
|
+
|
|
60
|
+
def set_bandpass(self, low: float = 0.01, high: float = 0.1, enabled: bool = True) -> "Preprocessor":
|
|
61
|
+
self.bandpass = enabled
|
|
62
|
+
self.bandpass_low = low
|
|
63
|
+
self.bandpass_high = high
|
|
64
|
+
return self
|
|
65
|
+
|
|
66
|
+
def apply(self, recording):
|
|
67
|
+
"""Apply the configured pipeline to a cedalion recording.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
recording:
|
|
72
|
+
A cedalion ``Recording`` or ``ContinuousData`` object.
|
|
73
|
+
|
|
74
|
+
Returns the processed recording.
|
|
75
|
+
"""
|
|
76
|
+
raise NotImplementedError(
|
|
77
|
+
"Preprocessor.apply() is not yet implemented. "
|
|
78
|
+
"Wire cedalion calls here based on the loaded recording type."
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def print(self) -> None:
|
|
82
|
+
print("Preprocessor Settings:")
|
|
83
|
+
print(f" optical_density: {self.optical_density}")
|
|
84
|
+
print(f" motion_correction (TDDR): {self.motion_correction}")
|
|
85
|
+
print(f" hemoglobin (Beer-Lambert):{self.hemoglobin} (dpf={self.dpf})")
|
|
86
|
+
print(f" bandpass: {self.bandpass} ({self.bandpass_low}-{self.bandpass_high} Hz)")
|
|
87
|
+
|
|
88
|
+
def __repr__(self) -> str:
|
|
89
|
+
steps = []
|
|
90
|
+
if self.optical_density:
|
|
91
|
+
steps.append("OD")
|
|
92
|
+
if self.motion_correction:
|
|
93
|
+
steps.append("TDDR")
|
|
94
|
+
if self.hemoglobin:
|
|
95
|
+
steps.append("HbX")
|
|
96
|
+
if self.bandpass:
|
|
97
|
+
steps.append(f"BP({self.bandpass_low}-{self.bandpass_high})")
|
|
98
|
+
return f"Preprocessor([{' -> '.join(steps)}])"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cedanirs
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A wrapper around cedalion for streamlined fNIRS preprocessing and analysis
|
|
5
|
+
Author-email: Adam Emile Aske <adask2429@oslomet.no>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/adamaske/cedanirs
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/adamaske/cedanirs/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
Requires-Dist: numpy
|
|
17
|
+
Requires-Dist: xarray
|
|
18
|
+
Requires-Dist: matplotlib
|
|
19
|
+
Requires-Dist: cedalion
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest; extra == "dev"
|
|
22
|
+
Requires-Dist: black; extra == "dev"
|
|
23
|
+
Requires-Dist: flake8; extra == "dev"
|
|
24
|
+
|
|
25
|
+
# cedanirs
|
|
26
|
+
|
|
27
|
+
## What is Cedanirs?
|
|
28
|
+
Cedanirs is a repository with reusable programs to process and analyze functional near-infrared spectroscopy (fNIRS) data.
|
|
29
|
+
|
|
30
|
+
## Modules
|
|
31
|
+
- Preprocessing
|
|
32
|
+
Input your .snirf file. Outputs preprocessed .snirf file.
|
|
33
|
+
Motion correction. Temporal filtering. Normalization.
|
|
34
|
+
- Analysis
|
|
35
|
+
GLM solvers. HRF estimation. DOT image reconstruction.
|
|
36
|
+
- Experiments
|
|
37
|
+
Input standardaized experimental parameters, preprocess, analyze and report in a one swing.
|
|
38
|
+
-
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
cedanirs/__init__.py
|
|
4
|
+
cedanirs/preprocessor.py
|
|
5
|
+
cedanirs.egg-info/PKG-INFO
|
|
6
|
+
cedanirs.egg-info/SOURCES.txt
|
|
7
|
+
cedanirs.egg-info/dependency_links.txt
|
|
8
|
+
cedanirs.egg-info/requires.txt
|
|
9
|
+
cedanirs.egg-info/top_level.txt
|
|
10
|
+
tests/test_preprocessor.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cedanirs
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cedanirs"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "A wrapper around cedalion for streamlined fNIRS preprocessing and analysis"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Adam Emile Aske", email = "adask2429@oslomet.no" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3.10",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Medical Science Apps.",
|
|
19
|
+
]
|
|
20
|
+
dependencies = ["numpy", "xarray", "matplotlib", "cedalion"]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/adamaske/cedanirs"
|
|
24
|
+
"Bug Tracker" = "https://github.com/adamaske/cedanirs/issues"
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
dev = ["pytest", "black", "flake8"]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["."]
|
|
31
|
+
include = ["cedanirs*"]
|
cedanirs-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from cedanirs import Preprocessor
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_preprocessor_defaults():
|
|
6
|
+
pp = Preprocessor()
|
|
7
|
+
assert pp.optical_density is True
|
|
8
|
+
assert pp.motion_correction is True
|
|
9
|
+
assert pp.hemoglobin is True
|
|
10
|
+
assert pp.bandpass is True
|
|
11
|
+
assert pp.bandpass_low == 0.01
|
|
12
|
+
assert pp.bandpass_high == 0.1
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_preprocessor_fluent_builder():
|
|
16
|
+
pp = Preprocessor().set_bandpass(0.02, 0.3).set_motion_correction(False)
|
|
17
|
+
assert pp.bandpass_low == 0.02
|
|
18
|
+
assert pp.bandpass_high == 0.3
|
|
19
|
+
assert pp.motion_correction is False
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_preprocessor_repr():
|
|
23
|
+
pp = Preprocessor()
|
|
24
|
+
r = repr(pp)
|
|
25
|
+
assert "OD" in r
|
|
26
|
+
assert "TDDR" in r
|
|
27
|
+
assert "HbX" in r
|
|
28
|
+
assert "BP" in r
|