driada 0.6.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.
- driada/__init__.py +104 -0
- driada/dim_reduction/README.md +74 -0
- driada/dim_reduction/__init__.py +71 -0
- driada/dim_reduction/data.py +499 -0
- driada/dim_reduction/dr_base.py +482 -0
- driada/dim_reduction/embedding.py +2247 -0
- driada/dim_reduction/flexible_ae.py +833 -0
- driada/dim_reduction/graph.py +800 -0
- driada/dim_reduction/losses.py +1293 -0
- driada/dim_reduction/manifold_metrics.py +1613 -0
- driada/dim_reduction/mvu.py +367 -0
- driada/dim_reduction/neural.py +1022 -0
- driada/dim_reduction/sequences.py +301 -0
- driada/dimensionality/README.md +56 -0
- driada/dimensionality/__init__.py +23 -0
- driada/dimensionality/effective.py +178 -0
- driada/dimensionality/intrinsic.py +543 -0
- driada/dimensionality/linear.py +243 -0
- driada/dimensionality/utils.py +150 -0
- driada/experiment/README.md +91 -0
- driada/experiment/__init__.py +123 -0
- driada/experiment/exp_base.py +2458 -0
- driada/experiment/exp_build.py +780 -0
- driada/experiment/neuron.py +3165 -0
- driada/experiment/spike_reconstruction.py +366 -0
- driada/experiment/synthetic/__init__.py +113 -0
- driada/experiment/synthetic/core.py +309 -0
- driada/experiment/synthetic/experiment_generators.py +1232 -0
- driada/experiment/synthetic/manifold_circular.py +599 -0
- driada/experiment/synthetic/manifold_spatial_2d.py +633 -0
- driada/experiment/synthetic/manifold_spatial_3d.py +660 -0
- driada/experiment/synthetic/mixed_selectivity.py +678 -0
- driada/experiment/synthetic/time_series.py +366 -0
- driada/experiment/synthetic/utils.py +60 -0
- driada/experiment/wavelet_event_detection.py +924 -0
- driada/experiment/wavelet_ridge.py +566 -0
- driada/gdrive/__init__.py +39 -0
- driada/gdrive/auth.py +115 -0
- driada/gdrive/config_template.py +13 -0
- driada/gdrive/download.py +619 -0
- driada/gdrive/gdrive_utils.py +296 -0
- driada/gdrive/upload.py +141 -0
- driada/information/README.md +74 -0
- driada/information/__init__.py +85 -0
- driada/information/alpha.xlsx +0 -0
- driada/information/entropy.py +377 -0
- driada/information/entropy_jit.py +162 -0
- driada/information/gcmi.py +1192 -0
- driada/information/gcmi_jit_utils.py +1023 -0
- driada/information/info_base.py +2313 -0
- driada/information/info_utils.py +206 -0
- driada/information/ksg.py +966 -0
- driada/information/time_series_types.py +967 -0
- driada/integration/README.md +72 -0
- driada/integration/__init__.py +10 -0
- driada/integration/manifold_analysis.py +466 -0
- driada/intense/README.md +62 -0
- driada/intense/__init__.py +111 -0
- driada/intense/disentanglement.py +429 -0
- driada/intense/intense_base.py +1933 -0
- driada/intense/pipelines.py +1368 -0
- driada/intense/stats.py +451 -0
- driada/intense/visual.py +1222 -0
- driada/network/__init__.py +107 -0
- driada/network/drawing.py +564 -0
- driada/network/graph_utils.py +290 -0
- driada/network/matrix_utils.py +1017 -0
- driada/network/net_base.py +1907 -0
- driada/network/quantum.py +280 -0
- driada/network/randomization.py +857 -0
- driada/network/spectral.py +227 -0
- driada/rsa/README.md +87 -0
- driada/rsa/__init__.py +45 -0
- driada/rsa/core.py +945 -0
- driada/rsa/core_jit.py +310 -0
- driada/rsa/integration.py +341 -0
- driada/rsa/visual.py +232 -0
- driada/utils/__init__.py +147 -0
- driada/utils/data.py +1283 -0
- driada/utils/gif.py +222 -0
- driada/utils/jit.py +221 -0
- driada/utils/matrix.py +128 -0
- driada/utils/naming.py +132 -0
- driada/utils/neural.py +294 -0
- driada/utils/output.py +127 -0
- driada/utils/plot.py +385 -0
- driada/utils/signals.py +479 -0
- driada/utils/spatial.py +872 -0
- driada/utils/visual.py +993 -0
- driada-0.6.0.dist-info/METADATA +233 -0
- driada-0.6.0.dist-info/RECORD +92 -0
- driada-0.6.0.dist-info/WHEEL +4 -0
driada/__init__.py
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DRIADA - Dimensionality Reduction for Integrated Activity Data
|
|
3
|
+
|
|
4
|
+
A library for single neuron and population-level analysis of inner workings
|
|
5
|
+
of intelligent systems, from brain neural recordings in vivo to RNNs.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.6.0"
|
|
9
|
+
|
|
10
|
+
# Core modules
|
|
11
|
+
from . import intense
|
|
12
|
+
from . import information
|
|
13
|
+
from . import experiment
|
|
14
|
+
from . import utils
|
|
15
|
+
from . import rsa
|
|
16
|
+
from . import network
|
|
17
|
+
from . import dim_reduction
|
|
18
|
+
from . import dimensionality
|
|
19
|
+
from . import integration
|
|
20
|
+
from . import gdrive
|
|
21
|
+
|
|
22
|
+
# Key classes
|
|
23
|
+
from .experiment import Experiment
|
|
24
|
+
from .information import TimeSeries, MultiTimeSeries
|
|
25
|
+
from .network import Network
|
|
26
|
+
|
|
27
|
+
# Main INTENSE pipeline functions
|
|
28
|
+
from .intense import (
|
|
29
|
+
compute_cell_feat_significance,
|
|
30
|
+
compute_feat_feat_significance,
|
|
31
|
+
compute_cell_cell_significance,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Common information theory functions
|
|
35
|
+
from .information import (
|
|
36
|
+
get_mi,
|
|
37
|
+
conditional_mi,
|
|
38
|
+
interaction_information,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Experiment utilities
|
|
42
|
+
from .experiment import (
|
|
43
|
+
load_experiment,
|
|
44
|
+
load_exp_from_aligned_data,
|
|
45
|
+
save_exp_to_pickle,
|
|
46
|
+
load_exp_from_pickle,
|
|
47
|
+
generate_synthetic_exp,
|
|
48
|
+
generate_circular_manifold_exp,
|
|
49
|
+
generate_2d_manifold_exp,
|
|
50
|
+
generate_3d_manifold_exp,
|
|
51
|
+
generate_mixed_population_exp,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Dimensionality reduction classes
|
|
55
|
+
from .dim_reduction import MVData, Embedding
|
|
56
|
+
|
|
57
|
+
# Dimensionality estimation
|
|
58
|
+
from .dimensionality import eff_dim, nn_dimension, pca_dimension
|
|
59
|
+
|
|
60
|
+
__all__ = [
|
|
61
|
+
# Version
|
|
62
|
+
"__version__",
|
|
63
|
+
# Modules
|
|
64
|
+
"intense",
|
|
65
|
+
"information",
|
|
66
|
+
"experiment",
|
|
67
|
+
"utils",
|
|
68
|
+
"rsa",
|
|
69
|
+
"network",
|
|
70
|
+
"dim_reduction",
|
|
71
|
+
"dimensionality",
|
|
72
|
+
"integration",
|
|
73
|
+
"gdrive",
|
|
74
|
+
# Core classes
|
|
75
|
+
"Experiment",
|
|
76
|
+
"TimeSeries",
|
|
77
|
+
"MultiTimeSeries",
|
|
78
|
+
"Network",
|
|
79
|
+
# INTENSE pipelines
|
|
80
|
+
"compute_cell_feat_significance",
|
|
81
|
+
"compute_feat_feat_significance",
|
|
82
|
+
"compute_cell_cell_significance",
|
|
83
|
+
# Information theory
|
|
84
|
+
"get_mi",
|
|
85
|
+
"conditional_mi",
|
|
86
|
+
"interaction_information",
|
|
87
|
+
# Experiment utilities
|
|
88
|
+
"load_experiment",
|
|
89
|
+
"load_exp_from_aligned_data",
|
|
90
|
+
"save_exp_to_pickle",
|
|
91
|
+
"load_exp_from_pickle",
|
|
92
|
+
"generate_synthetic_exp",
|
|
93
|
+
"generate_circular_manifold_exp",
|
|
94
|
+
"generate_2d_manifold_exp",
|
|
95
|
+
"generate_3d_manifold_exp",
|
|
96
|
+
"generate_mixed_population_exp",
|
|
97
|
+
# Dimensionality reduction
|
|
98
|
+
"MVData",
|
|
99
|
+
"Embedding",
|
|
100
|
+
# Dimensionality estimation
|
|
101
|
+
"eff_dim",
|
|
102
|
+
"nn_dimension",
|
|
103
|
+
"pca_dimension",
|
|
104
|
+
]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Dimensionality Reduction Module
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The dimensionality reduction module provides a comprehensive suite of algorithms for extracting low-dimensional representations from high-dimensional neural population data. It supports both linear and nonlinear methods with a unified interface.
|
|
6
|
+
|
|
7
|
+
## Key Components
|
|
8
|
+
|
|
9
|
+
### MVData Class
|
|
10
|
+
The core data container that `MultiTimeSeries` inherits from. Provides:
|
|
11
|
+
- Automatic downsampling
|
|
12
|
+
- Preprocessing (normalization, standardization)
|
|
13
|
+
- Direct access to dimensionality reduction methods via `get_embedding()`
|
|
14
|
+
|
|
15
|
+
### Supported Methods
|
|
16
|
+
|
|
17
|
+
**Linear Methods:**
|
|
18
|
+
- PCA (Principal Component Analysis)
|
|
19
|
+
- FA (Factor Analysis)
|
|
20
|
+
- LLE (Locally Linear Embedding)
|
|
21
|
+
- LEM (Laplacian Eigenmaps)
|
|
22
|
+
- DM (Diffusion Maps)
|
|
23
|
+
|
|
24
|
+
**Nonlinear Methods:**
|
|
25
|
+
- Isomap (Isometric Mapping)
|
|
26
|
+
- UMAP (Uniform Manifold Approximation and Projection)
|
|
27
|
+
- t-SNE (t-Distributed Stochastic Neighbor Embedding)
|
|
28
|
+
- Autoencoders (standard and variational)
|
|
29
|
+
- MVU (Maximum Variance Unfolding)
|
|
30
|
+
|
|
31
|
+
### Manifold Quality Metrics
|
|
32
|
+
- `knn_preservation_rate()` - Proportion of neighbors preserved
|
|
33
|
+
- `trustworthiness()` - Are close points in low-D truly close in high-D?
|
|
34
|
+
- `continuity()` - Are close points in high-D still close in low-D?
|
|
35
|
+
- `procrustes_analysis()` - Optimal alignment between embeddings
|
|
36
|
+
- `circular_structure_preservation()` - For ring-like manifolds
|
|
37
|
+
|
|
38
|
+
## Example Usage
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from driada.dim_reduction import MVData
|
|
42
|
+
|
|
43
|
+
# Create MVData object (or use experiment.calcium directly)
|
|
44
|
+
mvdata = MVData(neural_data, downsampling=5)
|
|
45
|
+
|
|
46
|
+
# Apply dimensionality reduction
|
|
47
|
+
embedding = mvdata.get_embedding(method='umap', n_components=2, n_neighbors=30)
|
|
48
|
+
|
|
49
|
+
# Access coordinates
|
|
50
|
+
coords = embedding.coords.T # Shape: (n_samples, n_dims)
|
|
51
|
+
|
|
52
|
+
# Evaluate quality
|
|
53
|
+
from driada.dim_reduction import knn_preservation_rate
|
|
54
|
+
quality = knn_preservation_rate(neural_data, coords, k=10)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Advanced Features
|
|
58
|
+
|
|
59
|
+
### Sequential Reduction
|
|
60
|
+
Chain multiple methods for optimal results:
|
|
61
|
+
```python
|
|
62
|
+
from driada.dim_reduction import dr_sequence
|
|
63
|
+
|
|
64
|
+
result = dr_sequence(
|
|
65
|
+
mvdata,
|
|
66
|
+
steps=[
|
|
67
|
+
('pca', {'dim': 50}), # Initial denoising
|
|
68
|
+
('umap', {'dim': 2}) # Final embedding
|
|
69
|
+
]
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Graph-Based Methods
|
|
74
|
+
The module includes `ProximityGraph` for methods that build on nearest-neighbor graphs, enabling shared graph construction across algorithms.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Dimensionality Reduction Module for DRIADA
|
|
3
|
+
|
|
4
|
+
This module provides various dimensionality reduction algorithms and
|
|
5
|
+
utilities for analyzing high-dimensional neural data.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .data import MVData
|
|
9
|
+
from .dr_base import (
|
|
10
|
+
METHODS_DICT,
|
|
11
|
+
DRMethod,
|
|
12
|
+
merge_params_with_defaults,
|
|
13
|
+
e_param_filter,
|
|
14
|
+
g_param_filter,
|
|
15
|
+
m_param_filter,
|
|
16
|
+
)
|
|
17
|
+
from .embedding import Embedding
|
|
18
|
+
from .graph import ProximityGraph
|
|
19
|
+
from .sequences import dr_sequence
|
|
20
|
+
|
|
21
|
+
# Import manifold metrics
|
|
22
|
+
from .manifold_metrics import (
|
|
23
|
+
compute_distance_matrix,
|
|
24
|
+
knn_preservation_rate,
|
|
25
|
+
trustworthiness,
|
|
26
|
+
continuity,
|
|
27
|
+
geodesic_distance_correlation,
|
|
28
|
+
stress,
|
|
29
|
+
circular_structure_preservation,
|
|
30
|
+
procrustes_analysis,
|
|
31
|
+
manifold_preservation_score,
|
|
32
|
+
# Reconstruction validation functions
|
|
33
|
+
circular_distance,
|
|
34
|
+
extract_angles_from_embedding,
|
|
35
|
+
compute_reconstruction_error,
|
|
36
|
+
compute_embedding_alignment_metrics,
|
|
37
|
+
compute_decoding_accuracy,
|
|
38
|
+
manifold_reconstruction_score,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
# Core classes
|
|
43
|
+
"MVData",
|
|
44
|
+
"METHODS_DICT",
|
|
45
|
+
"DRMethod",
|
|
46
|
+
"Embedding",
|
|
47
|
+
"ProximityGraph",
|
|
48
|
+
# Functions
|
|
49
|
+
"dr_sequence",
|
|
50
|
+
"merge_params_with_defaults",
|
|
51
|
+
"e_param_filter",
|
|
52
|
+
"g_param_filter",
|
|
53
|
+
"m_param_filter",
|
|
54
|
+
# Manifold metrics
|
|
55
|
+
"compute_distance_matrix",
|
|
56
|
+
"knn_preservation_rate",
|
|
57
|
+
"trustworthiness",
|
|
58
|
+
"continuity",
|
|
59
|
+
"geodesic_distance_correlation",
|
|
60
|
+
"stress",
|
|
61
|
+
"circular_structure_preservation",
|
|
62
|
+
"procrustes_analysis",
|
|
63
|
+
"manifold_preservation_score",
|
|
64
|
+
# Reconstruction validation functions
|
|
65
|
+
"circular_distance",
|
|
66
|
+
"extract_angles_from_embedding",
|
|
67
|
+
"compute_reconstruction_error",
|
|
68
|
+
"compute_embedding_alignment_metrics",
|
|
69
|
+
"compute_decoding_accuracy",
|
|
70
|
+
"manifold_reconstruction_score",
|
|
71
|
+
]
|