redbirdpy 0.1.0__py3-none-any.whl
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.
- redbirdpy/__init__.py +112 -0
- redbirdpy/analytical.py +927 -0
- redbirdpy/forward.py +589 -0
- redbirdpy/property.py +602 -0
- redbirdpy/recon.py +893 -0
- redbirdpy/solver.py +814 -0
- redbirdpy/utility.py +1117 -0
- redbirdpy-0.1.0.dist-info/METADATA +596 -0
- redbirdpy-0.1.0.dist-info/RECORD +13 -0
- redbirdpy-0.1.0.dist-info/WHEEL +5 -0
- redbirdpy-0.1.0.dist-info/licenses/LICENSE.txt +674 -0
- redbirdpy-0.1.0.dist-info/top_level.txt +1 -0
- redbirdpy-0.1.0.dist-info/zip-safe +1 -0
redbirdpy/__init__.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Redbird - Python toolbox for Diffuse Optical Tomography
|
|
3
|
+
|
|
4
|
+
A Python translation of the Redbird MATLAB toolbox for forward and inverse
|
|
5
|
+
modeling of diffuse optical tomography (DOT) and near-infrared spectroscopy (NIRS).
|
|
6
|
+
|
|
7
|
+
This toolbox provides:
|
|
8
|
+
- Forward modeling using Finite Element Method (FEM) for the diffusion equation
|
|
9
|
+
- Inverse reconstruction using Gauss-Newton methods with Tikhonov regularization
|
|
10
|
+
- Multi-spectral analysis for chromophore concentration estimation
|
|
11
|
+
- Support for both continuous-wave (CW) and frequency-domain (FD) measurements
|
|
12
|
+
|
|
13
|
+
IMPORTANT: This toolbox uses 1-based indexing for mesh elements (node, elem, face)
|
|
14
|
+
to maintain compatibility with the MATLAB version and iso2mesh conventions.
|
|
15
|
+
When interfacing with numpy arrays (0-based), conversion is handled internally.
|
|
16
|
+
|
|
17
|
+
Modules:
|
|
18
|
+
forward: Forward modeling functions (FEM solver, Jacobian computation)
|
|
19
|
+
recon: Reconstruction algorithms (Gauss-Newton, regularization)
|
|
20
|
+
utility: Mesh utilities, source/detector handling, data processing
|
|
21
|
+
property: Optical property management, extinction coefficients
|
|
22
|
+
|
|
23
|
+
Dependencies:
|
|
24
|
+
- numpy, scipy
|
|
25
|
+
- iso2mesh (pyiso2mesh): https://github.com/NeuroJSON/pyiso2mesh
|
|
26
|
+
|
|
27
|
+
Example:
|
|
28
|
+
|
|
29
|
+
import redbird as rb
|
|
30
|
+
import numpy as np
|
|
31
|
+
from iso2mesh import meshabox
|
|
32
|
+
|
|
33
|
+
# Create mesh using iso2mesh (returns 1-based indices)
|
|
34
|
+
node, face, elem = meshabox([0,0,0], [60,60,30], 5)
|
|
35
|
+
|
|
36
|
+
cfg = {
|
|
37
|
+
'node': node,
|
|
38
|
+
'elem': elem,
|
|
39
|
+
'prop': [[0,0,1,1], [0.01, 1, 0, 1.37]],
|
|
40
|
+
'srcpos': [30, 30, 0],
|
|
41
|
+
'srcdir': [0, 0, 1],
|
|
42
|
+
'detpos': [30, 40, 0],
|
|
43
|
+
'detdir': [0, 0, 1],
|
|
44
|
+
'seg': elem.shape[0],
|
|
45
|
+
'omega': 0
|
|
46
|
+
}
|
|
47
|
+
cfg, sd = rb.utility.meshprep(cfg)
|
|
48
|
+
detval, phi = rb.forward.runforward(cfg)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Author: Translated from Redbird MATLAB toolbox by Qianqian Fang (q.fang <at> neu.edu)
|
|
52
|
+
License: GPL version 3
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
__version__ = "0.1.0"
|
|
56
|
+
__author__ = "Qianqian Fang"
|
|
57
|
+
|
|
58
|
+
from . import forward
|
|
59
|
+
from . import recon
|
|
60
|
+
from . import utility
|
|
61
|
+
from . import property
|
|
62
|
+
from . import solver
|
|
63
|
+
|
|
64
|
+
# Re-export all public functions from submodules
|
|
65
|
+
from .forward import *
|
|
66
|
+
from .recon import *
|
|
67
|
+
from .utility import *
|
|
68
|
+
from .property import *
|
|
69
|
+
from .solver import *
|
|
70
|
+
|
|
71
|
+
# Combine all exports
|
|
72
|
+
__all__ = (
|
|
73
|
+
forward.__all__
|
|
74
|
+
+ solver.__all__
|
|
75
|
+
+ recon.__all__
|
|
76
|
+
+ utility.__all__
|
|
77
|
+
+ property.__all__
|
|
78
|
+
+ ["run", "forward", "recon", "utility", "property", "solver"]
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# Main entry point (similar to rbrun in MATLAB)
|
|
83
|
+
def run(cfg, recon_cfg=None, detphi0=None, sd=None, **kwargs):
|
|
84
|
+
"""
|
|
85
|
+
Main entry point for Redbird - runs forward or inverse modeling.
|
|
86
|
+
|
|
87
|
+
If only cfg is provided, runs forward simulation.
|
|
88
|
+
If recon_cfg and detphi0 are provided, runs reconstruction.
|
|
89
|
+
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
cfg : dict
|
|
93
|
+
Forward simulation configuration
|
|
94
|
+
recon_cfg : dict, optional
|
|
95
|
+
Reconstruction configuration
|
|
96
|
+
detphi0 : ndarray, optional
|
|
97
|
+
Measured data for reconstruction
|
|
98
|
+
sd : ndarray or dict, optional
|
|
99
|
+
Source-detector mapping
|
|
100
|
+
**kwargs : dict
|
|
101
|
+
Additional options passed to runforward or runrecon
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
Results from runforward (if forward only) or runrecon (if reconstruction)
|
|
106
|
+
"""
|
|
107
|
+
if recon_cfg is None:
|
|
108
|
+
return runforward(cfg, **kwargs)
|
|
109
|
+
else:
|
|
110
|
+
if detphi0 is None:
|
|
111
|
+
raise ValueError("detphi0 is required for reconstruction")
|
|
112
|
+
return runrecon(cfg, recon_cfg, detphi0, sd, **kwargs)
|