Giter Club home page Giter Club logo

anlffr's Introduction

ANLffr

From the Systems Neuroscience of Auditory Perception lab at Purdue University, a set of tools to analyze and interpret auditory steady-state responses, particularly the subcortical kind commonly known as frequency-following responses (FFRs). In particular, the package provides code for multitaper-analysis of spectra and phase locking along with complex-principal component analysis of phase-locking for multichannel FFRs. Support for "bootstrapping" any of the included functions is also available via the boostrap module. Finally, time-frequency analysis can also be performed flexibly using the tfr module. Although originally created to analyze steady-state electrophysiological responses, the generality of the spectral analysis and time-frequency analysis function allow them to be applied widely. Typical usage would begin with:

#!/usr/bin/env python

from anlffr import spectral

# If using a Biosemi EEG system
from anlffr.helper import biosemi2mne

Get the latest code

To get the latest code using git, simply type:

git clone https://github.com/SNAPsoftware/ANLffr.git

To use a particular realease/pre-release version, say vX.X.Xyz, type:

git checkout tags/vX.X.Xy

If you don't have git installed, you can download a zip or tarball of the latest code: https://github.com/SNAPsoftware/ANLffr/archive/master.zip If you have pip, you may be able to download and install anlffr in one step using (and hence skip the "Install anlffr" steps below):

pip install git+https://github.com/SNAPsoftware/ANLffr.git --user

Note: The GITHUB URL for this package has changed. The old URLs may temporarily continue to be redirected here. However, if you have local copies of the repository with the old URL, please update your remote bindings within git for easier longterm maintenance:

git remote set-url origin https://github.com/SNAPsoftware/ANLffr.git

Install anlffr

As with any Python packages, to install ANLffr, go into the ANLffr source code directory and do:

python setup.py install

or if you don't have admin access to your python setup (permission denied when install) use:

python setup.py install --user

Dependencies

The minimum required dependencies to run ANLffr are:

  • Python >= 3.6
  • NumPy >= 1.15.4
  • SciPy >= 1.1.0

For full functionality, some functions (e.g., modules in the anlffr.helper package) require:

  • Matplotlib >= 3.0.3
  • MNE-Python >= 0.21

Getting Started

The examples directory contains a sample script that you could modify for your purposes. That would be a good place to get started! See Bharadwaj & Shinn-Cunningham (2014) for details of the multichannel complex-PCA method. However, note that critical issues in Bharadwaj & Shinn-Cunningham (2014) were found and described in Lu et al., 2020. For details of the PLV computation and bootstrapping, see Zhu et al., (2013).

Briefly, consider the following example:

#!/usr/bin/env python

# If you already have a data.mat file with data

# Using scipy to load the data
from scipy import io
dat = io.loadmat(path_to_data + 'data.mat')

# Say the variable containing the data array is 'x'
x = dat['x']

# View to check if 'x' is in the right format
x.shape

# Import the spectral module to calculate PLV
from anlffr import spectral

# Set parameters for the PLV computation
# Sampling rate is 4096 Hz
# Frequencies of interest are with 5 and 500 Hz
# Calculate inter-trial coherence instead of PLV
# Zero-pad data to the next power of 2 for fast FFT
# Use 3 tapers with the time-half bandwidth product of 2
params = dict(Fs = 4096, tapers = [2, 3], fpass = [5, 500], itc = 1,
              pad = 1)

# Actually compute the phase-locking measure (ITC here)
(plv, f) = spectral.mtplv(x, params)

# Plot results for channel number 31 (index 30)
# Use pylab for plotting

import pylab as pl
pl.plot(f, plv[30,:],linewidth = 2)
pl.xlabel('Frequency (Hz)', fontsize = 20)
pl.ylabel('Inter-Trial Coherence')
pl.show()

Licensing

ANLffr is BSD-licenced (3 clause):

This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative.

Copyright (c) 2013-2021, authors of ANLffr. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the names of ANLffr authors nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

anlffr's People

Contributors

haribharadwaj avatar lennyvarghese avatar haolu-a avatar lennyv avatar

Stargazers

Yasuo Kabe avatar  avatar 了无歌 avatar Taylor Salo avatar  avatar Pēteris Skorovs avatar Eryk Walczak avatar Tim Schoof avatar Rob Luke avatar Samuele Carcagno avatar  avatar

Watchers

James Cloos avatar  avatar

anlffr's Issues

multithreaded bootstrap is completely broken on Windows

Ran into this one when I was helping the CCH folks troubleshoot the code:

Multiprocessing doesn't work exactly the same on Windows as it does on Mac/Linux, so attempting to run the boostrapping functions in multithreaded mode results in a broken pipe given the way I wrote it. I confirmed the behavior using a 32 bit install of the latest Python X,Y (2.7.6.1?) on Windows 7.

Am working on a fix that should be transparent to end users aside from the "slowness"...

Use multiple cores for bootstrapping

Since the individual draws for bootstrapping procedures are independent of one another, I think that we can do the computations in parallel with a minimal amount of effort using the "Multiprocessing" module. I can submit a patch so that a user-selectable number of cores are used for computation (defaulting to 1 less than the total number of cores).

Update doc and download instructions to match pre-release v0.1.0 and the beta version respectively

@lennyvarghese ... I started thinking about updating the doc and wondered if going back to the tuple output for the specific functions may help.. (1) to maintain back compatibility... and (2) for functions like mtcspec(.) for instance, it's pretty clear that CPCA spectrum is the main output and dictionary outputs are not the prettiest when returning just one or two things... It is standard practice to return tuples for such functions anyway (e.g., u, s, v = scipy.linalg.svd(blah..)).. The dict output makes a lot of sense for the _complete(.) function..

Thoughts?

RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility

Dropping this here because I think we mentioned this on an earlier (now resolved) pull request.

....../local/lib/python2.7/site-packages/scipy/spatial/init.py:91: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility
from .qhull import *

....../local/lib/python2.7/site-packages/scipy/spatial/init.py:91: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility
from .qhull import *

Confirmed that this has something to do with the .dpss standalone thing - I don't get this warning if I import dpss_windows from nitime.algorithms, using either nitime 0.4 or nitime 0.5 - but I haven't traced it back further to a specific line of code in the new dpss.py.

Practically speaking, I don't know how big of a deal this is.

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.