Skip to content

Commit 9f1216d

Browse files
committed
Add and expand module docstrings throughout package
Comprehensive docstrings were added or expanded for all major modules, providing overviews, usage context, and parameter documentation. This improves code readability and helps users understand the purpose and functionality of each component in the replay_trajectory_classification package.
1 parent 5ce6bab commit 9f1216d

22 files changed

+176
-45
lines changed

replay_trajectory_classification/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
"""Replay trajectory classification package.
2+
3+
A Python package for decoding spatial position from neural activity and
4+
classifying trajectory types in hippocampal replay events using state-space
5+
modeling approaches.
6+
7+
The main classes are:
8+
9+
- SortedSpikesClassifier/Decoder: For spike-sorted neural data
10+
- ClusterlessClassifier/Decoder: For clusterless (unsorted) neural data
11+
- Environment: Spatial environment representation with discrete grids
12+
13+
Examples
14+
--------
15+
>>> from replay_trajectory_classification import SortedSpikesClassifier
16+
>>> classifier = SortedSpikesClassifier()
17+
"""
18+
119
# flake8: noqa
220
from track_linearization import (
321
get_linearized_position,

replay_trajectory_classification/clusterless_simulation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"""Simulate clusterless spikes and associated spike waveform features."""
1+
"""Simulate clusterless spikes and associated spike waveform features.
2+
3+
This module provides functions for simulating clusterless (unsorted) spike
4+
data with associated waveform features used in multiunit decoding approaches.
5+
"""
26

37
from __future__ import annotations
48

replay_trajectory_classification/continuous_state_transitions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
"""Classes for constructing different types of movement models."""
1+
"""Classes for constructing different types of movement models.
2+
3+
This module provides continuous state transition models that describe how
4+
animals move through space, including random walks, empirical movement,
5+
and uniform transitions.
6+
"""
27

38
from __future__ import annotations
49

replay_trajectory_classification/decoder.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,25 @@ def convert_results_to_xarray(
395395

396396

397397
class SortedSpikesDecoder(_DecoderBase):
398+
"""Decoder for sorted spike data.
399+
400+
This class provides spatial decoding functionality for sorted (clustered)
401+
spike trains using Bayesian state-space models.
402+
403+
Parameters
404+
----------
405+
environment : Environment, optional
406+
Spatial environment representation, by default Environment().
407+
transition_type : EmpiricalMovement | RandomWalk | RandomWalkDirection1 |
408+
RandomWalkDirection2 | Uniform, optional
409+
Movement model for state transitions, by default RandomWalk().
410+
initial_conditions_type : UniformInitialConditions, optional
411+
Initial state probability distribution, by default UniformInitialConditions().
412+
infer_track_interior : bool, optional
413+
Whether to infer valid track areas from position data, by default True.
414+
415+
"""
416+
398417
def __init__(
399418
self,
400419
environment: Environment = Environment(environment_name=""),
@@ -583,23 +602,25 @@ def predict(
583602

584603

585604
class ClusterlessDecoder(_DecoderBase):
586-
"""Classifies neural population representation of position from multiunit
587-
spikes and waveforms.
605+
"""Decoder for clusterless (multiunit) spike data.
606+
607+
This class provides spatial decoding functionality for clusterless spike
608+
data using waveform features and marked point processes.
588609
589610
Parameters
590611
----------
591612
environment : Environment, optional
592-
The spatial environment to fit
613+
The spatial environment to fit, by default Environment().
593614
transition_type : EmpiricalMovement | RandomWalk | RandomWalkDirection1 |
594-
RandomWalkDirection2 | Uniform
595-
The continuous state transition matrix
615+
RandomWalkDirection2 | Uniform, optional
616+
The continuous state transition matrix, by default RandomWalk().
596617
initial_conditions_type : UniformInitialConditions, optional
597-
The initial conditions class instance
618+
The initial conditions class instance, by default UniformInitialConditions().
598619
infer_track_interior : bool, optional
599-
Whether to infer the spatial geometry of track from position
600-
clusterless_algorithm : str
601-
The type of clusterless algorithm. See _ClUSTERLESS_ALGORITHMS for keys
602-
clusterless_algorithm_params : dict
620+
Whether to infer the spatial geometry of track from position, by default True.
621+
clusterless_algorithm : str, optional
622+
The type of clusterless algorithm. See _CLUSTERLESS_ALGORITHMS for keys.
623+
clusterless_algorithm_params : dict, optional
603624
Parameters for the clusterless algorithms.
604625
605626
"""

replay_trajectory_classification/discrete_state_transitions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
"""Classes to generate transitions between categories."""
1+
"""Classes for generating discrete state transitions.
2+
3+
This module provides discrete state transition models that define
4+
transition probabilities between different trajectory categories
5+
or behavioral states.
6+
"""
27

38
from __future__ import annotations
49

replay_trajectory_classification/initial_conditions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"""Classes for constructing the initial conditions for the state space models."""
1+
"""Classes for constructing initial conditions for state space models.
2+
3+
This module provides classes that define initial probability distributions
4+
over states and spatial bins at the start of decoding/classification.
5+
"""
26

37
from __future__ import annotations
48

replay_trajectory_classification/likelihoods/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
"""Functions to fit the position intensities and likelihoods for each data type"""
1+
"""Likelihood functions for different neural data types.
2+
3+
This subpackage provides likelihood estimation functions for various types
4+
of neural data including sorted spikes, clusterless spikes, and calcium
5+
imaging data.
6+
7+
The module supports:
8+
9+
- Sorted spikes: GLM and KDE-based likelihood estimation
10+
- Clusterless data: Multiunit likelihood functions with mark information
11+
- Calcium imaging: Gamma likelihood for calcium activity traces
12+
- GPU acceleration: CUDA implementations for performance
13+
"""
214

315
from __future__ import annotations
416

replay_trajectory_classification/likelihoods/calcium_likelihood.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
"""Calculate a Gamma likelihood for calcium imaging activity traces.
1+
"""Calculate Gamma likelihood for calcium imaging activity traces.
2+
3+
This module provides functions for computing Gamma-distributed likelihoods
4+
from calcium imaging data, which is commonly used for decoding from calcium
5+
fluorescence signals.
26
37
References
48
----------
5-
[1] Farhoodi, S., Plitt, M.H., Giocomo, L., and Eden, U.T. (2020). Estimating Fluctuations in Neural Representations of Uncertain Environments. 20. .
9+
.. [1] Farhoodi, S., Plitt, M.H., Giocomo, L., and Eden, U.T. (2020).
10+
Estimating Fluctuations in Neural Representations of Uncertain
11+
Environments.
612
713
"""
814

replay_trajectory_classification/likelihoods/diffusion.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
"""Calculate diffusion distances by simulating diffusion at
2-
each position bin. This can be used for more accurate 2D kernel density
3-
estimates with boundaries."""
1+
"""Calculate diffusion distances for accurate boundary-aware density estimates.
2+
3+
This module simulates diffusion at each position bin to provide more accurate
4+
2D kernel density estimates that properly handle spatial boundaries in complex
5+
environments.
6+
"""
47

58
from __future__ import annotations
69

replay_trajectory_classification/likelihoods/multiunit_likelihood.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
"""Estimates a marked point process likelihood where the marks are
2-
features of the spike waveform. Features are float32."""
1+
"""Estimate marked point process likelihood for clusterless spike data.
2+
3+
This module provides functions for computing likelihoods from clusterless
4+
(multiunit) spike data where marks are features of the spike waveforms.
5+
Features are represented as float32 arrays.
6+
"""
37

48
from __future__ import annotations
59

0 commit comments

Comments
 (0)