Skip to main content

Implementation of the connectome embedding workflow.

Project description

cepy

Implementation of the connectome embedding (CE) framework.

Embedding of brain graph or connectome embedding (CE) involves finding a compact vectorized representation of nodes that captures their higher-order topological attributes. CE are obtained using the node2vec algorithm fitted on random walk on a brain graph. The current framework includes a novel approach to align separately learned embeddings to the same latent space.

Installation

pip install cepy

Usage

import cepy as ce
import numpy as np

# Load an adjacency matrix (structural connectivity matrix)
sc_group = ce.get_example('sc_group_matrix')

# Initiate and fit the connectome embedding model
ce_group = ce.CE(permutations = 1, seed=1)  
ce_group.fit(sc_group)

# Extract the cosine similarity matrix among all pairwise nodes
cosine_sim = ce_group.similarity()

# Save and load the model
ce_group.save_model('group_ce.pkl') 
ce_loaded = ce.load_model('group_ce.pkl') # load it

# Load two existing CE models  
ce_subject1 = ce.get_example('ce_subject1')
ce_subject2 = ce.get_example('ce_subject2')

# Align the two to the space of the [ce_group]:
ce_subject1_aligned = ce.align(ce_group, ce_subject1)
ce_subject2_aligned = ce.align(ce_group, ce_subject2)

# Extract the node vectorized representations (normalized) for subsequent use - prediction, for example 
w_sbject1 = ce_subject1_aligned.weights.get_w_mean(norm = True)
w_sbject2 = ce_subject2_aligned.weights.get_w_mean(norm = True)

A set of example interactive Jupyter notebooks are also available here.

Citing

If you find cepy useful for your research, please consider citing the following paper:

Levakov, G., Faskowitz, J., Avidan, G. & Sporns, O. (2021). Mapping structure to function
 and behavior with individual-level connectome embedding. bioRxiv. doi: https://doi.org/10.1101/2021.01.13.426513 

Contributing

Cepy is an open-source software project, and we welcome contributions from anyone. We suggest raising an issue prior to working on a new feature.

Reference

  • The node2vec implementation is modeified from the node2vec package by Elior Cohen and the connectome_embedding code by Gideon Rosenthal.
  • Rosenthal, G., Váša, F., Griffa, A., Hagmann, P., Amico, E., Goñi, J., ... & Sporns, O. (2018). Mapping higher-order relations between brain structure and function with embedded vector representations of connectomes. Nature communications, 9(1), 1-12. ;

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cepy-0.0.8.tar.gz (24.6 MB view details)

Uploaded Source

Built Distribution

cepy-0.0.8-py3-none-any.whl (24.6 MB view details)

Uploaded Python 3

File details

Details for the file cepy-0.0.8.tar.gz.

File metadata

  • Download URL: cepy-0.0.8.tar.gz
  • Upload date:
  • Size: 24.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.9

File hashes

Hashes for cepy-0.0.8.tar.gz
Algorithm Hash digest
SHA256 ce6a8bf2b65f733c56b24158cd299e465c92f38f60b85e7fb7d41c9e782a4d3f
MD5 2d79f803187954898341414097d719d0
BLAKE2b-256 a7939bda1e764d9d0885ff611f6359ab821ab563e534d4dd92d276badfbd244b

See more details on using hashes here.

File details

Details for the file cepy-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: cepy-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 24.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.7.9

File hashes

Hashes for cepy-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 137e1444a124207af6e0d6207a0552033d9af04ea4a4026643dfce74a88445ec
MD5 a9b1110f2aab4d45d891d3976282c592
BLAKE2b-256 e5698ee89a7da42f48ff2d46e6d322dc2f15c2def62c473f8b521b5982629883

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page