GithubHelp home page GithubHelp logo

econnerty / spectral_connectivity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eden-kramer-lab/spectral_connectivity

0.0 0.0 0.0 32.68 MB

Frequency domain estimation and functional and directed connectivity analysis tools for electrophysiological data

License: GNU General Public License v3.0

Shell 0.02% Python 92.26% TeX 7.72%

spectral_connectivity's Introduction

spectral_connectivity

PR Test DOI Binder status PyPI version Anaconda-Server Badge Documentation Status Coverage Status

Tutorials | Documentation | Usage Example | Installation | Developer Installation

What is spectral_connectivity?

spectral_connectivity is a Python software package that computes multitaper spectral estimates and frequency-domain brain connectivity measures such as coherence, spectral granger causality, and the phase lag index using the multitaper Fourier transform. Although there are other Python packages that do this (see nitime and MNE-Python), spectral_connectivity has several differences:

  • it is designed to handle multiple time series at once
  • it caches frequently computed quantities such as the cross-spectral matrix and minimum-phase-decomposition, so that connectivity measures that use the same processing steps can be more quickly computed.
  • it decouples the time-frequency transform and the connectivity measures so that if you already have a preferred way of computing Fourier coefficients (i.e. from a wavelet transform), you can use that instead.
  • it implements the non-parametric version of the spectral granger causality in Python.
  • it implements the canonical coherence, which can efficiently summarize brain-area level coherences from multielectrode recordings.
  • easier user interface for the multitaper fourier transform
  • all function are GPU-enabled if cupy is installed and the environmental variable SPECTRAL_CONNECTIVITY_ENABLE_GPU is set to 'true'.

Tutorials

See the following notebooks for more information on how to use the package:

Usage Example

from spectral_connectivity import Multitaper, Connectivity

# Compute multitaper spectral estimate
m = Multitaper(time_series=signals,
               sampling_frequency=sampling_frequency,
               time_halfbandwidth_product=time_halfbandwidth_product,
               time_window_duration=0.060,
               time_window_step=0.060,
               start_time=time[0])

# Sets up computing connectivity measures/power from multitaper spectral estimate
c = Connectivity.from_multitaper(m)

# Here are a couple of examples
power = c.power() # spectral power
coherence = c.coherence_magnitude()
weighted_phase_lag_index = c.weighted_phase_lag_index()
canonical_coherence = c.canonical_coherence(brain_area_labels)

Documentation

See the documentation here.

Implemented Measures

Functional

  1. coherency
  2. canonical_coherence
  3. imaginary_coherence
  4. phase_locking_value
  5. phase_lag_index
  6. weighted_phase_lag_index
  7. debiased_squared_phase_lag_index
  8. debiased_squared_weighted_phase_lag_index
  9. pairwise_phase_consistency
  10. global coherence

Directed

  1. directed_transfer_function
  2. directed_coherence
  3. partial_directed_coherence
  4. generalized_partial_directed_coherence
  5. direct_directed_transfer_function
  6. group_delay
  7. phase_lag_index
  8. pairwise_spectral_granger_prediction

Package Dependencies

spectral_connectivity requires:

  • python
  • numpy
  • matplotlib
  • scipy
  • xarray

See environment.yml for the most current list of dependencies.

Installation

pip install spectral_connectivity

or

conda install -c edeno spectral_connectivity

Developer Installation

If you want to make contributions to this library, please use this installation.

  1. Install miniconda (or anaconda) if it isn't already installed. Type into bash (or install from the anaconda website):
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
hash -r
  1. Clone the repository to your local machine (.../spectral_connectivity) and install the anaconda environment for the repository. Type into bash:
conda env create -f environment.yml
conda activate spectral_connectivity
pip install -e .

Recent publications and pre-prints that used this software

spectral_connectivity's People

Contributors

edeno avatar mehradsm avatar econnerty avatar mmyros avatar emilyps14 avatar sappelhoff avatar ajquinn avatar dizcza avatar bloniaszp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.