vrfcd 0.1.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.
- vrfcd-0.1.1/LICENSE +0 -0
- vrfcd-0.1.1/PKG-INFO +278 -0
- vrfcd-0.1.1/README.md +248 -0
- vrfcd-0.1.1/pyproject.toml +51 -0
- vrfcd-0.1.1/setup.cfg +4 -0
- vrfcd-0.1.1/src/vrfcd/__init__.py +14 -0
- vrfcd-0.1.1/src/vrfcd/communities.py +130 -0
- vrfcd-0.1.1/src/vrfcd/distance.py +109 -0
- vrfcd-0.1.1/src/vrfcd/graph.py +55 -0
- vrfcd-0.1.1/src/vrfcd/kernels.py +71 -0
- vrfcd-0.1.1/src/vrfcd/pipeline.py +131 -0
- vrfcd-0.1.1/src/vrfcd/plotting.py +119 -0
- vrfcd-0.1.1/src/vrfcd.egg-info/PKG-INFO +278 -0
- vrfcd-0.1.1/src/vrfcd.egg-info/SOURCES.txt +17 -0
- vrfcd-0.1.1/src/vrfcd.egg-info/dependency_links.txt +1 -0
- vrfcd-0.1.1/src/vrfcd.egg-info/requires.txt +17 -0
- vrfcd-0.1.1/src/vrfcd.egg-info/top_level.txt +1 -0
- vrfcd-0.1.1/tests/test_kernels.py +43 -0
- vrfcd-0.1.1/tests/test_pipeline.py +28 -0
vrfcd-0.1.1/LICENSE
ADDED
|
File without changes
|
vrfcd-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vrfcd
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: van Rossum distance based functional community detection for spike trains
|
|
5
|
+
Author-email: Indranil Ghosh <indranilg49@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/indrag49/vrfcd
|
|
8
|
+
Project-URL: Repository, https://github.com/indrag49/vrfcd
|
|
9
|
+
Project-URL: Issues, https://github.com/indrag49/vrfcd/issues
|
|
10
|
+
Keywords: computational-neuroscience,spike-trains,van-rossum-distance,functional-connectivity,community-detection,network-science
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: scipy
|
|
16
|
+
Requires-Dist: pandas
|
|
17
|
+
Requires-Dist: matplotlib
|
|
18
|
+
Requires-Dist: networkx
|
|
19
|
+
Requires-Dist: joblib
|
|
20
|
+
Requires-Dist: scikit-learn
|
|
21
|
+
Provides-Extra: leiden
|
|
22
|
+
Requires-Dist: igraph; extra == "leiden"
|
|
23
|
+
Requires-Dist: leidenalg; extra == "leiden"
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest; extra == "dev"
|
|
26
|
+
Requires-Dist: black; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff; extra == "dev"
|
|
28
|
+
Requires-Dist: jupyter; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# vrfcd
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
`vrfcd` stands for **van Rossum Functional Community Detection**.
|
|
36
|
+
|
|
37
|
+
This is a `Python` package for constructing functional connectivity networks from neural spike-train data
|
|
38
|
+
using the van Rossum distance, and then detecting functional assemblies in the resulting weighted network.
|
|
39
|
+
The package is designed for computational neuroscience workflows where the input data are spike rasters.
|
|
40
|
+
The goal is to identify groups of neurons with similar temporal spiking structure.
|
|
41
|
+
|
|
42
|
+
## Workflow
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
Given a ```spike train``` as input the workflow is a four step process:
|
|
46
|
+
```
|
|
47
|
+
- Compute the van Rossum distance matrix
|
|
48
|
+
- Transform it into functional adjacency matrix
|
|
49
|
+
- Prepare the weighted `networkX` graph
|
|
50
|
+
- Perform community detection on the graph
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
`vrfcd` provides tools to:
|
|
55
|
+
|
|
56
|
+
- compute a normalised van Rossum distance matrix from spike-train raster datasets,
|
|
57
|
+
- convert the distance matrix into a functional adjacency matrix using different similarity transformations,
|
|
58
|
+
- construct a weighted functional graph from the adjacency matrix,
|
|
59
|
+
- detect communitues using either the Louvain or Leiden community detection algorithm,
|
|
60
|
+
- visualise the distance matrix, functional matrix, and network representation, and
|
|
61
|
+
- run the full analysis using a single pipeline interface.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install vrfcd
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
For development:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/indranilg49/vrfcd.git
|
|
74
|
+
cd vrfcd
|
|
75
|
+
pip install -e ".[dev]"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For optional Leiden community detection:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install -e ".[dev,leiden]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Simple usage
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
import numpy as np
|
|
88
|
+
from vrfcd import VRFCDPipeline
|
|
89
|
+
|
|
90
|
+
pipeline = VRFCDPipeline( t_R=0.01, kernel="minmax", community_method="louvain", n_jobs=4, )
|
|
91
|
+
|
|
92
|
+
result = pipeline.fit(spike_matrix, t_axis)
|
|
93
|
+
|
|
94
|
+
D = result.D
|
|
95
|
+
A = result.A
|
|
96
|
+
G = result.G
|
|
97
|
+
|
|
98
|
+
partition = result.partition
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Here `spike_matrix` should have the shape of `n_neurons x n_time_bins`, and `t_axis` should be the corresponding
|
|
102
|
+
time axis. Note that if the time axis comes from experimental data with absolute time stamps, it is a good idea
|
|
103
|
+
to rescale it so that it starts at zero:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
t_axis = t_axis - t_axis[0]
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Main functions
|
|
110
|
+
|
|
111
|
+
- ```compute_van_rossum_distance```
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
from vrfcd import compute_van_rossum_distance
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This computes the pairwise van Rossum distance matrix between spike trains.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
D = compute_van_rossum_distance(
|
|
121
|
+
spike_matrix,
|
|
122
|
+
t_axis,
|
|
123
|
+
t_R=0.01,
|
|
124
|
+
traces=False,
|
|
125
|
+
n_jobs=4,
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The parameter `t_R` controls the time scale of the exponential filter used in the van Rossum distance.
|
|
130
|
+
Smaller values of `t_R` make the distance more sensitive to precise spike timing, while larger values smooth
|
|
131
|
+
spike trains over a longer temporal window.
|
|
132
|
+
|
|
133
|
+
If `traces=True`, the function also returns the convolved spike-train waveforms:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
D, waveforms = compute_van_rossum_distance( spike_matrix, t_axis, t_R=0.01, traces=True, )
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
- ```distance_to_functional_matrix```
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
from vrfcd import distance_to_functional_matrix
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
This converts the van Rossum distance matrix into a functional adjacency matrix.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
A = distance_to_functional_matrix( D, kernel="minmax", )
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
This package currently supports three similarity transformations.
|
|
152
|
+
|
|
153
|
+
```kernel = "clipping"```
|
|
154
|
+
|
|
155
|
+
When using this, the distances are capped at 1 and converted to similarities using: A = 1-D.
|
|
156
|
+
|
|
157
|
+
```kernel = "exponential"```
|
|
158
|
+
|
|
159
|
+
When using this, the distances are rescaled using an exponential kernel: A = exp(-D/beta). The parameter
|
|
160
|
+
`beta` controls how quickly similarity decays with distance.
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
A = distance_to_functional_matrix( D, kernel="exponential", beta=0.1, )
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
```kernel = "minmax"```
|
|
167
|
+
|
|
168
|
+
When using this, the distances are rescaled using a min-max transformation:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
A = distance_to_functional_matrix(
|
|
172
|
+
D,
|
|
173
|
+
kernel="minmax",
|
|
174
|
+
q_low=0.0,
|
|
175
|
+
q_high=1.0,
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
This maps small distances to high functional similarity and large distances to low functional similarity.
|
|
180
|
+
The diagonal of the resulting matrix is set to 0 by default.
|
|
181
|
+
|
|
182
|
+
- ```build_functional_graph```
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
from vrfcd import build_functional_graph
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
This builds a weighted `networkX` graph from the functional adjacency matrix.
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
G = build_functional_graph( A, threshold=0.0, )
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
In the graph representation, each neuron is a node, and edges are weighted by the functional similarity values
|
|
195
|
+
in `A`. The `threshold` parameter can be used to remove weak functional connections.
|
|
196
|
+
|
|
197
|
+
- ```detect_communities```
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
from vrfcd import detect_communities
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
This function detects communities in the weighted functional graph.
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
partition = detect_communities( G, method="louvain", seed=42, )
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The output is a disctionary mapping each node to a community label. The package currently supports two
|
|
210
|
+
methods for community detection:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
method = "louvain"
|
|
214
|
+
method = "leiden"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The Louvain method works with the core dependencies. In order to use Leiden, you will need to install the optional dependencies
|
|
218
|
+
`igraph` and `leidenalg` additionally.
|
|
219
|
+
|
|
220
|
+
## Pipeline interface
|
|
221
|
+
|
|
222
|
+
Here we outline the easiest way to use the package through `VRFCDPipeline`.
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
from vrfcd import VRFCDPipeline
|
|
226
|
+
|
|
227
|
+
pipeline = VRFCDPipeline( t_R=0.01, kernel="minmax", q_low=0.0, q_high=1.0, community_method="louvain", n_jobs=4, traces=True, )
|
|
228
|
+
|
|
229
|
+
result = pipeline.fit(spike_matrix, t_axis)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
The pipeline returns a `VRFCDResult` object containing:
|
|
233
|
+
|
|
234
|
+
- `result.D`: van Rossum distance matrix
|
|
235
|
+
- `result.A`: functional adjacency matrix
|
|
236
|
+
- `result.G`: community labels
|
|
237
|
+
- `result.partition`: graph with community attributes
|
|
238
|
+
- `result.G_partitioned`: van Rossum distance matrix
|
|
239
|
+
- `result.counts`: number of nodes in each community
|
|
240
|
+
- `result.waveforms`: convolved spike traces, if `traces=True`
|
|
241
|
+
|
|
242
|
+
This allows the full analysis to be run in one step while still giving access to every intermediate object.
|
|
243
|
+
|
|
244
|
+
## Plotting
|
|
245
|
+
|
|
246
|
+
`vrfcd` also includes helper functions for viusalisation.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
from vrfcd.plotting import plot_matrix, plot_functional_network
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
To plot the van Rossum distance matrix:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
plot_matrix( result.D, colorbar_title=r"$\tilde{D}(t_R)$", savepath="distance_matrix.pdf", )
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
To plot the adjacency matrix:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
plot_matrix( result.A, colorbar_title=r"$A(t_R)$", savepath="functional_matrix.pdf", )
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
To plot the functional network:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
plot_functional_network( result.G_partitioned, partition=result.partition, savepath="functional_network.pdf", )
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Overview
|
|
271
|
+
|
|
272
|
+
This package is intended for exploratory and research-focused analysis of spike-train data. It is particularly useful when
|
|
273
|
+
one wants to compare neurons based on spike timing, construct a functional network from these similarities,
|
|
274
|
+
and identify groups of neurons with similar temporal spiking patterns. This package can be used with synthetic spike raster,
|
|
275
|
+
simulated spiking network models, and experimental recordings such as Neuropixels spike-train datasets.
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
vrfcd-0.1.1/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# vrfcd
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
`vrfcd` stands for **van Rossum Functional Community Detection**.
|
|
6
|
+
|
|
7
|
+
This is a `Python` package for constructing functional connectivity networks from neural spike-train data
|
|
8
|
+
using the van Rossum distance, and then detecting functional assemblies in the resulting weighted network.
|
|
9
|
+
The package is designed for computational neuroscience workflows where the input data are spike rasters.
|
|
10
|
+
The goal is to identify groups of neurons with similar temporal spiking structure.
|
|
11
|
+
|
|
12
|
+
## Workflow
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
Given a ```spike train``` as input the workflow is a four step process:
|
|
16
|
+
```
|
|
17
|
+
- Compute the van Rossum distance matrix
|
|
18
|
+
- Transform it into functional adjacency matrix
|
|
19
|
+
- Prepare the weighted `networkX` graph
|
|
20
|
+
- Perform community detection on the graph
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
`vrfcd` provides tools to:
|
|
25
|
+
|
|
26
|
+
- compute a normalised van Rossum distance matrix from spike-train raster datasets,
|
|
27
|
+
- convert the distance matrix into a functional adjacency matrix using different similarity transformations,
|
|
28
|
+
- construct a weighted functional graph from the adjacency matrix,
|
|
29
|
+
- detect communitues using either the Louvain or Leiden community detection algorithm,
|
|
30
|
+
- visualise the distance matrix, functional matrix, and network representation, and
|
|
31
|
+
- run the full analysis using a single pipeline interface.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install vrfcd
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For development:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
git clone https://github.com/indranilg49/vrfcd.git
|
|
44
|
+
cd vrfcd
|
|
45
|
+
pip install -e ".[dev]"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For optional Leiden community detection:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install -e ".[dev,leiden]"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Simple usage
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
import numpy as np
|
|
58
|
+
from vrfcd import VRFCDPipeline
|
|
59
|
+
|
|
60
|
+
pipeline = VRFCDPipeline( t_R=0.01, kernel="minmax", community_method="louvain", n_jobs=4, )
|
|
61
|
+
|
|
62
|
+
result = pipeline.fit(spike_matrix, t_axis)
|
|
63
|
+
|
|
64
|
+
D = result.D
|
|
65
|
+
A = result.A
|
|
66
|
+
G = result.G
|
|
67
|
+
|
|
68
|
+
partition = result.partition
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Here `spike_matrix` should have the shape of `n_neurons x n_time_bins`, and `t_axis` should be the corresponding
|
|
72
|
+
time axis. Note that if the time axis comes from experimental data with absolute time stamps, it is a good idea
|
|
73
|
+
to rescale it so that it starts at zero:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
t_axis = t_axis - t_axis[0]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Main functions
|
|
80
|
+
|
|
81
|
+
- ```compute_van_rossum_distance```
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
from vrfcd import compute_van_rossum_distance
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This computes the pairwise van Rossum distance matrix between spike trains.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
D = compute_van_rossum_distance(
|
|
91
|
+
spike_matrix,
|
|
92
|
+
t_axis,
|
|
93
|
+
t_R=0.01,
|
|
94
|
+
traces=False,
|
|
95
|
+
n_jobs=4,
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The parameter `t_R` controls the time scale of the exponential filter used in the van Rossum distance.
|
|
100
|
+
Smaller values of `t_R` make the distance more sensitive to precise spike timing, while larger values smooth
|
|
101
|
+
spike trains over a longer temporal window.
|
|
102
|
+
|
|
103
|
+
If `traces=True`, the function also returns the convolved spike-train waveforms:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
D, waveforms = compute_van_rossum_distance( spike_matrix, t_axis, t_R=0.01, traces=True, )
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
- ```distance_to_functional_matrix```
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
from vrfcd import distance_to_functional_matrix
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This converts the van Rossum distance matrix into a functional adjacency matrix.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
A = distance_to_functional_matrix( D, kernel="minmax", )
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This package currently supports three similarity transformations.
|
|
122
|
+
|
|
123
|
+
```kernel = "clipping"```
|
|
124
|
+
|
|
125
|
+
When using this, the distances are capped at 1 and converted to similarities using: A = 1-D.
|
|
126
|
+
|
|
127
|
+
```kernel = "exponential"```
|
|
128
|
+
|
|
129
|
+
When using this, the distances are rescaled using an exponential kernel: A = exp(-D/beta). The parameter
|
|
130
|
+
`beta` controls how quickly similarity decays with distance.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
A = distance_to_functional_matrix( D, kernel="exponential", beta=0.1, )
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```kernel = "minmax"```
|
|
137
|
+
|
|
138
|
+
When using this, the distances are rescaled using a min-max transformation:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
A = distance_to_functional_matrix(
|
|
142
|
+
D,
|
|
143
|
+
kernel="minmax",
|
|
144
|
+
q_low=0.0,
|
|
145
|
+
q_high=1.0,
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This maps small distances to high functional similarity and large distances to low functional similarity.
|
|
150
|
+
The diagonal of the resulting matrix is set to 0 by default.
|
|
151
|
+
|
|
152
|
+
- ```build_functional_graph```
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
from vrfcd import build_functional_graph
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This builds a weighted `networkX` graph from the functional adjacency matrix.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
G = build_functional_graph( A, threshold=0.0, )
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
In the graph representation, each neuron is a node, and edges are weighted by the functional similarity values
|
|
165
|
+
in `A`. The `threshold` parameter can be used to remove weak functional connections.
|
|
166
|
+
|
|
167
|
+
- ```detect_communities```
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
from vrfcd import detect_communities
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
This function detects communities in the weighted functional graph.
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
partition = detect_communities( G, method="louvain", seed=42, )
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The output is a disctionary mapping each node to a community label. The package currently supports two
|
|
180
|
+
methods for community detection:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
method = "louvain"
|
|
184
|
+
method = "leiden"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The Louvain method works with the core dependencies. In order to use Leiden, you will need to install the optional dependencies
|
|
188
|
+
`igraph` and `leidenalg` additionally.
|
|
189
|
+
|
|
190
|
+
## Pipeline interface
|
|
191
|
+
|
|
192
|
+
Here we outline the easiest way to use the package through `VRFCDPipeline`.
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
from vrfcd import VRFCDPipeline
|
|
196
|
+
|
|
197
|
+
pipeline = VRFCDPipeline( t_R=0.01, kernel="minmax", q_low=0.0, q_high=1.0, community_method="louvain", n_jobs=4, traces=True, )
|
|
198
|
+
|
|
199
|
+
result = pipeline.fit(spike_matrix, t_axis)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The pipeline returns a `VRFCDResult` object containing:
|
|
203
|
+
|
|
204
|
+
- `result.D`: van Rossum distance matrix
|
|
205
|
+
- `result.A`: functional adjacency matrix
|
|
206
|
+
- `result.G`: community labels
|
|
207
|
+
- `result.partition`: graph with community attributes
|
|
208
|
+
- `result.G_partitioned`: van Rossum distance matrix
|
|
209
|
+
- `result.counts`: number of nodes in each community
|
|
210
|
+
- `result.waveforms`: convolved spike traces, if `traces=True`
|
|
211
|
+
|
|
212
|
+
This allows the full analysis to be run in one step while still giving access to every intermediate object.
|
|
213
|
+
|
|
214
|
+
## Plotting
|
|
215
|
+
|
|
216
|
+
`vrfcd` also includes helper functions for viusalisation.
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
from vrfcd.plotting import plot_matrix, plot_functional_network
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
To plot the van Rossum distance matrix:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
plot_matrix( result.D, colorbar_title=r"$\tilde{D}(t_R)$", savepath="distance_matrix.pdf", )
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
To plot the adjacency matrix:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
plot_matrix( result.A, colorbar_title=r"$A(t_R)$", savepath="functional_matrix.pdf", )
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
To plot the functional network:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
plot_functional_network( result.G_partitioned, partition=result.partition, savepath="functional_network.pdf", )
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Overview
|
|
241
|
+
|
|
242
|
+
This package is intended for exploratory and research-focused analysis of spike-train data. It is particularly useful when
|
|
243
|
+
one wants to compare neurons based on spike timing, construct a functional network from these similarities,
|
|
244
|
+
and identify groups of neurons with similar temporal spiking patterns. This package can be used with synthetic spike raster,
|
|
245
|
+
simulated spiking network models, and experimental recordings such as Neuropixels spike-train datasets.
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vrfcd"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "van Rossum distance based functional community detection for spike trains"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Indranil Ghosh", email = "indranilg49@gmail.com"}
|
|
13
|
+
]
|
|
14
|
+
license = {text = "MIT"}
|
|
15
|
+
keywords = [
|
|
16
|
+
"computational-neuroscience",
|
|
17
|
+
"spike-trains",
|
|
18
|
+
"van-rossum-distance",
|
|
19
|
+
"functional-connectivity",
|
|
20
|
+
"community-detection",
|
|
21
|
+
"network-science"
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"numpy",
|
|
25
|
+
"scipy",
|
|
26
|
+
"pandas",
|
|
27
|
+
"matplotlib",
|
|
28
|
+
"networkx",
|
|
29
|
+
"joblib",
|
|
30
|
+
"scikit-learn"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
leiden = [
|
|
35
|
+
"igraph",
|
|
36
|
+
"leidenalg"
|
|
37
|
+
]
|
|
38
|
+
dev = [
|
|
39
|
+
"pytest",
|
|
40
|
+
"black",
|
|
41
|
+
"ruff",
|
|
42
|
+
"jupyter"
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[tool.setuptools.packages.find]
|
|
46
|
+
where = ["src"]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://github.com/indrag49/vrfcd"
|
|
50
|
+
Repository = "https://github.com/indrag49/vrfcd"
|
|
51
|
+
Issues = "https://github.com/indrag49/vrfcd/issues"
|
vrfcd-0.1.1/setup.cfg
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .distance import compute_van_rossum_distance
|
|
2
|
+
from .kernels import distance_to_functional_matrix
|
|
3
|
+
from .graph import build_functional_graph
|
|
4
|
+
from .communities import detect_communities
|
|
5
|
+
from .pipeline import VRFCDPipeline, VRFCDResult
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"compute_van_rossum_distance",
|
|
9
|
+
"distance_to_functional_matrix",
|
|
10
|
+
"build_functional_graph",
|
|
11
|
+
"detect_communities",
|
|
12
|
+
"VRFCDPipeline",
|
|
13
|
+
"VRFCDResult",
|
|
14
|
+
]
|