Skip to main content

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., 2019
  • CrossDecomposition - CCA (method='correlation') and PLS-SVD (method='covariance'). Other ways of achieving CS
  • cCS - 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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for commsubspace 0.1.0
File Size Uploaded Provenance Actions
commsubspace-0.1.0.tar.gz 21.1 kB With provenance Details for commsubspace-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for commsubspace 0.1.0
File Interpreter ABI Platform Actions
commsubspace-0.1.0-py3-none-any.whl Python 3 none any Details for commsubspace-0.1.0-py3-none-any.whl

Total release size: 41.2 kB

Release files / commsubspace-0.1.0.tar.gz

Download URL commsubspace-0.1.0.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9e5d338fb0abffff760747bf55c35d8b8c1619d271253b5254e510d609e6226f
BLAKE2b-256 checksum
How to use checksums
34b73559eb0b89d21502a34250a639401870b64b352e71b01b3a6d486475e0d5
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 Oct 29, 2026.

Transparency log

Release files / commsubspace-0.1.0-py3-none-any.whl

Download URL commsubspace-0.1.0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49f579e28ade0afd9bdcd83b19de85b14e9d28e7aa8872d9460bf47270f13845
BLAKE2b-256 checksum
How to use checksums
c06cf00c11bd73ce6743518fdc78c7023eb6a90ce38bc8c0d83367690827612b
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 Oct 29, 2026.

Transparency log

Security for commsubspace 0.1.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.

Select from 2 files

Attestation for commsubspace-0.1.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 Oct 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page