Skip to main content

FastSRM

CircleCI

Implementation of FastSRM algorithms.

The model of probabilistic SRM is given by:

where

  • is the data of subject
  • is the basis of subject
  • is the shared response (or sources) assumed to be sampled from a centered Gaussian with covariance
  • is the noise in subject assumed to be sampled from a centered Gaussian with covariance where is the identity matrix. We call the noise variance of subject .

In practice we observe n samples of . When the number of samples is much lower than the number of features v, the SRM model can be fitted efficiently. This is what this repository provides. We also assume that the covariance of the shared response is diagonal to obtain identifiability.

Install

Clone the repository

git clone https://github.com/hugorichard/FastSRM

In the cloned directory execute

pip install -e .

Requirements:

scipy>=0.18.0
numpy>=1.12
scikit-learn>=0.23
joblib>=1.1.0
matplotlib>=2.0.0
pytest>=6.2.5

To run the experiments on identifiability, brainiak (https://github.com/brainiak/brainiak) and nilearn (https://nilearn.github.io/stable/index.html) are necessary.

Usage

In many neuroscience datasets, the samples are split into sessions. Therefore, for each subject we will have several sessions that can be time-wise concatenated to obtain all samples. In IdentifiableFastSRM

# Input data X: neuroimaging data 
# X is a np array of shape (n_subjects, n_sessions)
# X[i, j] is a path to a np array of shape (n_voxels, n_timeframes)
from fastsrm.identifiable_srm import IdentifiableFastSRM
srm = IdentifiableFastSRM(n_components=5, temp_dir="./", n_jobs=5)
S = srm.fit_transform(X) # Shared response: np array of shape (n_components, n_timeframes)
W = srm.basis_list # Shared response: np array of shape (n_components, n_timeframes)
Sigma = srm.source_covariance # (Diagonal) Covariance of the shared response: np array of shape (n_components,)
sigmas = srm.noise_variance # Variance of the noise: np array of shape (n_subjects)

Run experiments

Synthetic experiment

  1. In the experiments folder run ipython synthetic.py

  2. Go in the plotting folder and run ipython plot_synthetic_gradients.py

The figure is now available in the figures folder under the name synthetic_gradient.pdf

Timesegment matching experiment

  1. Go in the experiments folder and download the sherlock dataset by running: ipython get_sherlock.py

  2. Go in the experiments folder and run bash timesegment.bash if you have access to a cluster with slurm otherwise run bash timesegment_local.bash

  3. Go in the plotting folder and run ipython plot_timesegment.py

The figure is now available in the figures folder under the name timesegment_matching_sherlock.pdf

Identifiability experiment

  1. Go in the experiments folder and download the sherlock dataset by running: ipython get_sherlock.py

  2. Download and install Brainiak (see https://github.com/brainiak/brainiak)

  3. Go in the experiments folder and run bash identifiability.bash if you have access to a cluster with slurm otherwise run bash identifiability_local.bash

  4. Go in the plotting folder and run ipython plot_identifiability.py

The figure is now available in the figures folder under the name identifiability.pdf

Documentation

https://hugorichard.github.io/FastSRM/

Metadata

Release files for fastsrm 0.0.5

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

Source distribution (sdist)

Source distribution for fastsrm 0.0.5
File Size Uploaded Provenance Actions
fastsrm-0.0.5.tar.gz 9.8 MB Without provenance Details for fastsrm-0.0.5.tar.gz

Built distribution (wheel)

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

Total release size: 9.8 MB

Release files / fastsrm-0.0.5.tar.gz

Download URL fastsrm-0.0.5.tar.gz
Size 9.8 MB
Tags Source
SHA-256 checksum
How to use checksums
ca50d7222fd8328ace3c616084c2e1aa7e25668ec6b2fcbcc46567e5b81ec01d
BLAKE2b-256 checksum
How to use checksums
49194a76d71f31c980a4dc971d10a9f24c00553d34ff5b5f5257c7aff18432bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / fastsrm-0.0.5-py3-none-any.whl

Download URL fastsrm-0.0.5-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f883acde8ac94421486a4b6a739b89a77330f0a063cf4a46221eae3f4e013d4
BLAKE2b-256 checksum
How to use checksums
1673877693c830f912699f59677d78cc29dbfe48e9cabff941f56040dd820984
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for fastsrm 0.0.5

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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