contrastive communication subspace
Python code for contrastive communication subspace and also implementations of regular communication subspace (CS) analysis between two neural populations (region 1 and region 2):
ReducedRankRegress- reduced-rank regression (RRR) from region 1 to region 2. The original method used for CS in Semedo et al., 2019CrossDecomposition- CCA (method='correlation') and PLS-SVD (method='covariance'). Other ways of achieving CScCS- contrastive communication subspace: finds pairs of directions whose coupling between the two regions differs most between two conditions (A and B). Objectives:'difference','ratio','normalized_difference'and'normalized_index'.
All data arrays are (n_samples, n_features).
Installation
pip install commsubspace
Requires Python >= 3.10, NumPy, SciPy and scikit-learn.
Quick start
import numpy as np
from commsubspace import cCS, CrossDecomposition, ReducedRankRegress
rng = np.random.default_rng(0)
region1_A, region2_A = rng.standard_normal((500, 20)), rng.standard_normal((500, 15)) # condition A
region1_B, region2_B = rng.standard_normal((400, 20)), rng.standard_normal((400, 15)) # condition B
# Contrastive communication subspace: coupling that differs between conditions A and B.
ccs = cCS(method="normalized_index").fit(region1_A, region2_A, region1_B, region2_B)
print(ccs.region1_loadings_.shape, ccs.contrast_values_.shape) # (20, N_dim), (N_dim,)
# Canonical correlation analysis between the two regions (condition A only).
cca = CrossDecomposition(method="correlation").fit(region1_A, region2_A)
scores_region1, scores_region2 = cca.transform(region1_A, region2_A)
# Reduced-rank regression of region 2 on region 1, with 3 predictive dimensions.
rrr = ReducedRankRegress(rank=3).fit(region1_A, region2_A)
predicted_region2 = rrr.predict(region1_A)
See the docstrings of cCS, CrossDecomposition and ReducedRankRegress for all options, fitted attributes and
units. Fitted cCS objects carry a meta_ dictionary with the parameters, random seed and analysis version.
License
MIT, see LICENSE.
Metadata
Release files for commsubspace 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| commsubspace-0.3.0.tar.gz | 19.6 kB | With provenance | Details for commsubspace-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| commsubspace-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for commsubspace-0.3.0-py3-none-any.whl |
Total release size: 40.2 kB
Release files / commsubspace-0.3.0.tar.gz
| Download URL | commsubspace-0.3.0.tar.gz |
|---|---|
| Size | 19.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d45f54bb48b55c2e68aef70385f8de49128cfcce8914bafa1ceddfc2aa90953
|
|
BLAKE2b-256 checksum How to use checksums |
8dbc53124b17b24607e6551fde5c9232aa472f9b721b205b078b330454980f65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logRelease files / commsubspace-0.3.0-py3-none-any.whl
| Download URL | commsubspace-0.3.0-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b25bc7b5b940bf36913499138dc80dcea1302ddb3ab3d15296de21aa93de4fc
|
|
BLAKE2b-256 checksum How to use checksums |
55282e44021a62d5056fa2351ef4b15c439cc9a0d92c6b8e3b5ffc3c3e40e93f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logSecurity for commsubspace 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for commsubspace-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.