TranCIT: Transient Causal Interaction Toolbox
TranCIT: Transient Causal Interaction Toolbox - Published in JOSS (2025)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
○codemeta.json file
-
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 9 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: zenodo.org -
○Academic email domains
-
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Repository
Transient Causal Interaction estimator
Basic Info
Statistics
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 9
- Releases: 8
Metadata Files
README.md
TranCIT: Transient Causal Interaction Toolbox
TranCIT (Transient Causal Interaction Toolbox) is a Python package for quantifying causal relationships in multivariate time series data. It provides methods for analyzing directional influences using model-based statistical tools, inspired by information-theoretic and autoregressive frameworks.
🚀 Features
- Dynamic Causal Strength (DCS): Time-varying causal relationships
- Transfer Entropy (TE): Information-theoretic causality measures
- Granger Causality (GC): Linear causality detection
- Relative Dynamic Causal Strength (rDCS): Event-based causality
- VAR-based Modeling: Vector autoregressive time series analysis
- BIC Model Selection: Automatic model order selection
- Bootstrap Support: Statistical significance testing
- DeSnap Analysis: Debiased statistical analysis
- Pipeline Architecture: Modular, stage-based analysis pipeline
📦 Installation
From PyPI (Recommended)
bash
pip install trancit
From Source
bash
git clone https://github.com/CMC-lab/TranCIT.git
cd TranCIT
pip install -e .
Development Installation
bash
git clone https://github.com/CMC-lab/TranCIT.git
cd TranCIT
pip install -e ".[dev]"
🎯 Quick Start
Basic Causality Analysis
```python import numpy as np from trancit import DCSCalculator, generate_signals
Generate synthetic data
data, , _ = generatesignals(T=1000, Ntrial=20, h=0.1, gamma1=0.5, gamma2=0.5, Omega1=1.0, Omega2=1.2)
Create DCS calculator
calculator = DCSCalculator(modelorder=4, timemode="inhomo")
Perform analysis
result = calculator.analyze(data) print(f"DCS shape: {result.causalstrength.shape}") print(f"Transfer Entropy shape: {result.transferentropy.shape}") ```
Event-Based Analysis Pipeline
```python import numpy as np from trancit import PipelineOrchestrator, generate_signals from trancit.config import ( PipelineConfig, PipelineOptions, DetectionParams, CausalParams, BicParams, OutputParams )
Generate data
data, , _ = generatesignals(T=1200, Ntrial=20, h=0.1, gamma1=0.5, gamma2=0.5, Omega1=1.0, Omega2=1.2) original_signal = np.mean(data, axis=2)
Create detection signal: use second variable which often has clearer peaks
The detection signal must be 2D with shape (2, T)
detectionvar = originalsignal[1, :] detectionsignal = np.vstack([detectionvar, detection_var])
Configure pipeline
config = PipelineConfig( options=PipelineOptions(detection=True, causalanalysis=True), detection=DetectionParams(thresratio=1.2, aligntype="peak", lextract=150, lstart=75), bic=BicParams(morder=4), causal=CausalParams(reftime=75, estimmode="OLS"), output=OutputParams(filekeyword="example"), )
Run analysis
orchestrator = PipelineOrchestrator(config) try: result = orchestrator.run(originalsignal, detectionsignal)
Access results
if result.results.get("CausalOutput"): dcsvalues = result.results["CausalOutput"]["OLS"]["DCS"] tevalues = result.results["CausalOutput"]["OLS"]["TE"] print(f"DCS shape: {dcsvalues.shape}") else: print("No events detected. Try adjusting thresratio or use real data.") except Exception as e: print(f"Pipeline failed: {e}") print("Note: Event detection may fail with synthetic data. ") print("For reliable results, use real data or adjust detection parameters.") ```
VAR Model Estimation
```python import numpy as np from trancit import VAREstimator
Generate sample data
data = np.random.randn(2, 1000, 20) # (nvars, nobs, n_trials)
VAR estimation
estimator = VAREstimator(modelorder=4, timemode="inhomo") coefficients, residuals, loglikelihood, hessiansum = ( estimator.estimatevarcoefficients( data, modelorder=4, maxmodelorder=6, timemode="inhomo", lag_mode="infocrit" ) )
print(f"Coefficients shape: {coefficients.shape}") print(f"Log-likelihood: {log_likelihood:.4f}") ```
Controlling Logging Verbosity
By default, TranCIT uses INFO-level logging, which provides detailed progress information during analysis. If you find the logging output too verbose for your use case, you can reduce it:
```python import logging
Reduce logging to show only warnings and errors
logging.getLogger("trancit").setLevel(logging.WARNING)
Or set to ERROR for minimal output
logging.getLogger("trancit").setLevel(logging.ERROR)
For more detail, use DEBUG
logging.getLogger("trancit").setLevel(logging.DEBUG) ```
Note: The examples above will show INFO-level logging by default. To reduce verbosity, add the logging configuration at the beginning of your script. For debugging purposes, you can increase verbosity using logging.DEBUG.
📚 Documentation & Examples
For comprehensive documentation, tutorials, and API reference:
Examples
- Basic Usage: Simple causality analysis
- CA3-CA1 Causality Analysis: Local field potential causality analysis
- DCS Introduction: Interactive tutorial
🔬 Scientific Background
This package implements methods from:
- Shao et al. (2023): Information theoretic measures of causal influences during transient neural events
- Granger Causality: Linear causality detection in time series
- Transfer Entropy: Information-theoretic causality measures
🧪 Testing
```bash
Run all tests
pytest
Run with coverage
pytest --cov=trancit --cov-report=html
Run linting
flake8 trancit/ tests/
Format code
black trancit/ tests/ ```
🤝 Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Setup
bash
git clone https://github.com/CMC-lab/TranCIT.git
cd TranCIT
pip install -e ".[dev]"
pre-commit install
📖 Citing This Work
If you use TranCIT in your research, please cite:
```bibtex @article{shao2023information, title={Information theoretic measures of causal influences during transient neural events}, author={Shao, Kaidi and Logothetis, Nikos K and Besserve, Michel}, journal={Frontiers in Network Physiology}, volume={3}, pages={1085347}, year={2023}, publisher={Frontiers Media SA} }
@article{nouri2025trancit,
title={TranCIT: Transient Causal Interaction Toolbox},
author={Nouri, Salar and Shao, Kaidi and Safavi, Shervin},
year={2025},
journal={arXiv preprint arXiv:2509.00602},
url={https://doi.org/10.48550/arXiv.2509.00602}
}
```
And cite this software package:
bibtex
@software{nouri_2025_trancit,
author = {Nouri, Salar and
Shao, Kaidi and
Safavi, Shervin},
title = {TranCIT: Transient Causal Interaction Toolbox},
month = aug,
year = 2025,
publisher = {Zenodo},
doi = {10.5281/zenodo.16998396},
url = {https://doi.org/10.5281/zenodo.16998396},
}
📄 License
This project is licensed under the BSD 2-Clause License. See the LICENSE file for details.
🙏 Acknowledgments
- Based on research from the CMC-Lab
- Inspired by information-theoretic causality methods
- Built with support from the scientific Python community
📞 Contact
- Maintainer: Salar Nouri (salr.nouri@gmail.com)
- Issues: GitHub Issues
- Documentation: ReadTheDocs
JOSS Publication
TranCIT: Transient Causal Interaction Toolbox
Authors
School of Electrical and Computer Engineering, College of Engineering, University of Tehran, Tehran, Iran
Tags
neuroscience causal inference time series analysis Local field potential (LFP) Electroencephalogram (EEG) Magnetoencephalography (MEG)Citation (CITATION.cff)
cff-version: 1.2.0
title: "TranCIT: Transient Causal Interaction Toolbox"
message: "If you use this software, please cite it as below."
authors:
- given-names: Salar
family-names: Nouri
email: salr.nouri@gmail.com
orcid: "https://orcid.org/0000-0002-8846-9318"
affiliation: "School of Electrical and Computer Engineering, College of Engineering, University of Tehran, Tehran, Iran"
- given-names: Kaidi
family-names: Shao
orcid: "https://orcid.org/0000-0002-3027-0090"
affiliation: "International Center for Primate Brain Research (ICPBR), Center for Excellence in Brain Science and Intelligence Technology (CEBSIT), Chinese Academy of Sciences (CAS), Shanghai, China"
- given-names: Shervin
family-names: Safavi
orcid: "https://orcid.org/0000-0002-2868-530X"
affiliation: "Computational Neuroscience, Department of Child and Adolescent Psychiatry, Faculty of Medicine, Technische Universität Dresden, Dresden 01307, Germany"
repository-code: "https://github.com/CMC-lab/TranCIT"
url: "https://trancit.readthedocs.io"
license: BSD-2-Clause
version: 1.0.0
date-released: 2025-08-30
doi: "10.5281/zenodo.16998396"
keywords:
- causality
- time-series
- neuroscience
- statistics
- causal-inference
- trancit
- transfer-entropy
- granger-causality
- transient-neural-events
- local-field-potential
- electroencephalogram
- magnetoencephalography
Zenodo (.zenodo.json)
{
"title": "TranCIT: Transient Causal Interaction Toolbox",
"description": "A Python package for quantifying causal relationships in multivariate time series data, with a focus on transient neural events and neuroscience applications. TranCIT implements advanced causality measures including Dynamic Causal Strength (DCS), relative Dynamic Causal Strength (rDCS), Granger causality, and transfer entropy, specifically designed for analyzing transient neural interactions.",
"creators": [
{
"name": "Nouri, Salar",
"affiliation": "School of Electrical and Computer Engineering, College of Engineering, University of Tehran, Tehran, Iran",
"orcid": "0000-0002-8846-9318"
},
{
"name": "Shao, Kaidi",
"affiliation": "International Center for Primate Brain Research (ICPBR), Center for Excellence in Brain Science and Intelligence Technology (CEBSIT), Chinese Academy of Sciences (CAS), Shanghai, China",
"orcid": "0000-0002-3027-0090"
},
{
"name": "Safavi, Shervin",
"affiliation": "Computational Neuroscience, Department of Child and Adolescent Psychiatry, Faculty of Medicine, Technische Universität Dresden, Dresden 01307, Germany; Department of Computational Neuroscience, Max Planck Institute for Biological Cybernetics, Tübingen 72076, Germany",
"orcid": "0000-0002-2868-530X"
}
],
"license": "BSD-2-Clause",
"keywords": [
"causality",
"causal-inference",
"time-series",
"neuroscience",
"statistics",
"machine learning",
"trancit",
"transfer-entropy",
"granger-causality",
"transient-neural-events",
"local-field-potential",
"electroencephalogram",
"magnetoencephalography",
"robust-directed-coherence-spectroscopy",
"multivariate-time-series",
"computational-neuroscience"
],
"related_identifiers": [
{
"identifier": "https://github.com/CMC-lab/TranCIT",
"relation": "isSupplementTo",
"scheme": "url"
},
{
"identifier": "https://trancit.readthedocs.io",
"relation": "isDocumentedBy",
"scheme": "url"
},
{
"identifier": "https://pypi.org/project/trancit/",
"relation": "isIdenticalTo",
"scheme": "url"
}
]
}
GitHub Events
Total
- Create event: 10
- Issues event: 17
- Release event: 6
- Watch event: 3
- Delete event: 5
- Issue comment event: 2
- Push event: 21
Last Year
- Create event: 10
- Issues event: 17
- Release event: 6
- Watch event: 3
- Delete event: 5
- Issue comment event: 2
- Push event: 21
Issues and Pull Requests
Last synced: 2 months ago
All Time
- Total issues: 2
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- TheElnazzz (2)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 51 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 14
- Total maintainers: 2
pypi.org: trancit
TranCIT: Transient Causal Interaction Toolbox.
- Homepage: https://github.com/CMC-lab/TranCIT
- Documentation: https://trancit.readthedocs.io
- License: bsd-2-clause
-
Latest release: 1.1.0
published 2 months ago
Rankings
Maintainers (2)
Dependencies
- actions/checkout v4 composite
- actions/setup-python v5 composite
- codecov/codecov-action v3 composite
- pypa/gh-action-pypi-publish release/v1 composite
- matplotlib >=3.5.0
- numpy >=1.19.5
- scikit-learn >=1.0.0
- scipy >=1.7.0