Songbird Data Analysis
A software that allows you to perform analysis on songbirds' neural and vocalization data stored as Spike2 format (.smr).
Functions

Functions

def getinfo (file)
 This function will allow you to get information inside the .smr file. More...
 
def getarrays (file)
 This function will get the analogical signals and the spiketrains from the .smr file and return them in the end as arrays. More...
 
def plotplots (file)
 This function will allow you to plot the analog signals and spiketrains inside the .smr file. More...
 
def createsave (file)
 This function will create a few files inside a folder which will be named according to the date and time. More...
 
def spikeshapes (file, raw, rawfiltered)
 This function will get and save the spikeshapes (.txt) from the Raw unfiltered neuronal signal. More...
 
def lfpdown (LFPfile, fs)
 This function will downsample your LFP signal to 1000Hz and save it as .npy file. More...
 
def ISI (spikefile)
 This function will compute and plot an logarithmic inter spike interval histogram. More...
 
def spectrogram (songfile, beg, end, fs)
 This function generates spectrogram of the motifs in the song raw signal. More...
 
def psth (spikefile, motifile, basebeg, basend, binwidth, fs)
 This function generates a PSTH for motifs. More...
 
def corrduration (spikefile, motifile, n_iterations, fs)
 Generates correlations for each syllable. More...
 
def plotEnvelopes (songfile, beg, end, window_size)
 This function allows you to see the envelope for song signal. More...
 
def powerspectrum (songfile, beg, end, fs)
 This function will perform the Fast Fourier Transform to obtain the power spectrum of the syllables. More...
 
def corrpitch (songfile, motifile,spikefile, lags, window_size, fs, means=None)
 This function can be used to obtain the pitch of specific tones inside a syllable. More...
 
def corramplitude (songfile, motifile, spikefile, fs, window_size, means=None)
 This function can be used to obtain the amplitude and its correlations of specific tones inside a syllable. More...
 
def complexity_entropy_spectral (signal, fs, bands=None)
 This function computes the Spectral Entropy of a signal. More...
 
def corrspectral (songfile, motifile, spikefile, fs, window_size, means=None)
 This function can be used to obtain the spectral entropy and its correlations of specific tones inside a syllable. More...
 

Function Documentation

◆ complexity_entropy_spectral()

def functions.complexity_entropy_spectral (   signal,
  fs,
  bands = None 
)

This function computes the Spectral Entropy of a signal.

The power spectrum is computed through Fast Fourier Transform. Then, it is normalised and assimilated to a probability density function.

Arguments:

signal : list or array List or array of values.

fs : int Sampling rate (Hz).

bands : list or array A list of numbers delimiting the bins of the frequency bands. If None the entropy is computed over the whole range of the DFT (from 0 to f_s/2).

Returns

spectral_entropy : float The spectral entropy as float value.

Based on the `pyrem <https://github.com/gilestrolab/pyrem>`_ repo by Quentin Geissmann. 

◆ corramplitude()

def functions.corramplitude (   songfile,
  motifile,
  spikefile,
  fs,
  window_size,
  means = None 
)

This function can be used to obtain the amplitude and its correlations of specific tones inside a syllable.

It will allow you to work with the means or the area under the curve (integration)

Arguments:

songfile : .npy File containing the song signal.

motifile : .txt File containing the annotations of the beggining and end of each syllable/motif.

fs: int Sampling rate (Hz).

spikefile: .txt File with the spiketimes.

window_size : int The size of the window for the convolve function (RMS of signal)

means: .txt File that contains the cutting points for the tones. If None, it will allow you to create this list of means by visual inspection of plots.

Returns

This function will save as .txt files all the correlation data (raw and bootstrapped).

raw file: First column is the amplitude value, second is the number of spikes inside premotor window, third is the number of spikes inside 'during' window.

bootstrap file: First column is the correlation value, second is the p value. First line is the original correlation, all below are the bootstrapped correlations.

◆ corrduration()

def functions.corrduration (   spikefile,
  motifile,
  n_iterations,
  fs 
)

Generates correlations between the spike activity and the duration for each syllable.

Arguments:

spikefile: .txt File with the spiketimes.

motifile : .txt File containing the annotations of the beggining and end of each syllable/motif.

n_iterations: int Number of iterations for the bootstrapping [int]

fs: int Sampling frequency

Returns

This function will save as .txt files all the correlation data (raw and bootstrapped).

raw file: First column is the duration value, second is the number of spikes inside the respective duration.

bootstrap file: First column is the correlation value, second is the p value. First line is the original correlation, all below are the bootstrapped correlations.

◆ corrpitch()

def functions.corrpitch (   songfile,
  motifile,
  spikefile,
  lags,
  window_size,
  fs,
  means = None 
)

This function can be used to obtain the pitch of specific tones inside a syllable.

It will execute an autocorrelation for the identification of the pitchs.

Generates correlations between the spike activity and the pitch for each note of a syllable.

Arguments:

songfile: .npy File containing the song signal.

motifile : .txt File containing the annotations of the beggining and end of each syllable/motif.

lags int Number of lags for the autocorrelation

window_size : int The size of the window for the convolve function (RMS of signal)

fs: int Sampling rate (Hz)

spikefile: .txt File with the spiketimes.

means: .txt File that contains the cutting points for the tones. If None, it will allow you to create this list of means by visual inspection of plots.

Returns

This function will save as .txt files all the correlation data (raw and bootstrapped).

raw file: First column is the pitch value, second is the number of spikes inside premotor window, third is the number of spikes inside 'during' window.

bootstrap file: First column is the correlation value, second is the p value. First line is the original correlation, all below are the bootstrapped correlations.

◆ corrspectral()

def functions.corrspectral (   songfile,
  motifile,
  spikefile,
  fs,
  window_size,
  means = None 
)

This function can be used to obtain the spectral entropy and the correlations between it and the spike activity for each note of a syllable.

Arguments:

songfile: .npy File containing the song signal.

motifile : .txt File containing the annotations of the beggining and end of each syllable/motif.

fs: int Sampling rate (Hz)

spikefile: .txt File with the spiketimes.

window_size : int The size of the window for the convolve function (RMS of signal)

means: .txt File that contains the cutting points for the tones. If None, it will allow you to create this list of means by visual inspection of plots.

Returns

This function will save as .txt files all the correlation data (raw and bootstrapped).

raw file: First column is the spectral value, second is the number of spikes inside premotor window, third is the number of spikes inside 'during' window.

bootstrap file: First column is the correlation value, second is the p value. First line is the original correlation, all below are the bootstrapped correlations.

◆ createsave()

def functions.createsave (   file)

This function will create a few files inside a folder which will be named according to the date and time. * In case you need to define a specific window to your spiketrain, you have to create a file named "unitswindow.txt" and save it in the same folder as the .smr. For more informations about this file, please check our Demo Section.

Arguments:

file: .smr Recording file.

Returns:

1 - summary.txt : this file will contain a summary of the contents of the .smr file.

2- the spiketimes as .txt: these files will contain the spiketimes of each spiketrain.

3- the analog signals as .npy: these files will contain the raw data of the analog signals.

◆ getarrays()

def functions.getarrays (   file)

This function will get the analogical signals and the spiketrains from the .smr file and return them in the end as arrays.

Arguments:

file: .smr Recording file.

Returns:

analog: list of arrays of the analogical signals

sp: list of arrays of the spike trains

◆ getinfo()

def functions.getinfo (   file)

This function will allow you to get information inside the .smr file.

Arguments:

file: .smr Recording file.

Returns:

It will return the number of analog signals inside the file, the number of spike trains, a numpy array with the time, and the sampling rate of the recording.

◆ ISI()

def functions.ISI (   spikefile)

This function will compute and plot a logarithmic inter spike interval histogram.

Arguments:

spikefile: .txt File with the spike times.

Returns:

A logarithmic ISI graph.

◆ lfpdown()

def functions.lfpdown (   LFPfile,
  fs
)

This function will downsample your LFP signal to 1000Hz and save it as .npy file.

Arguments:

LFPfile: .npy File with signal to be downsampled.

fs: int Sampling rate (Hz).

Returns:

It will return the downsampled LFP as array.

◆ plotEnvelopes()

def functions.plotEnvelopes (   songfile,
  beg,
  end,
  window_size 
)

This function allows you to see the envelope for song signal.

Arguments:

songfile:.npy File containing the song signal.

beg, end : int The indexes that would correspond to the beginning and the end of the motif/syllable (check syllables annotations file for that)

window_size int The size of the window for the convolve function.

◆ plotplots()

def functions.plotplots (   file)

This function will allow you to plot the analog signals and spiketrains inside the .smr file.

Arguments:

file: .smr Recording file.

◆ powerspectrum()

def functions.powerspectrum (   songfile,
  beg,
  end,
  fs 
)

This function will perform the Fast Fourier Transform to obtain the power spectrum of the syllables.

Arguments:

songfile: .npy File containing the song signal.

beg, end : int The indexes that would correspond to the beginning and the end of the motif/syllable (check syllables annotations file for that)

fs: int Sampling rate (Hz)

◆ psth()

def functions.psth (   spikefile,
  motifile,
  basebeg 
  basend 
  binwidth 
  fs 
)

This function generates a PSTH for motifs.

To be used with the new matfiles.

Arguments:

spikefile: .txt File with the spiketimes.

motifile : .txt File containing the annotations of the beggining and end of each syllable/motif.

fs: int Sampling rate (Hz)

basebeg: float The time to start computing the baseline

basend: float The time to finish computing the baseline

binwidth: float Width of histogram bin.

◆ read()

def functions.read (   file)

This function will allow you to read the .smr files from Spike2.

Arguments:

file: .smr Recording file.

Returns:

data: block of the .smr file.

data_seg: the segments inside the block of the .smr file.

◆ spectrogram()

def functions.spectrogram (   songfile,
  beg,
  end,
  fs 
)

This function generates spectrogram of the motifs in the song raw signal.

Arguments:

songfile: .npy File containing the song signal.

beg, end : int The indexes that would correspond to the beginning and the end of the motif/syllable (check syllables annotations file for that)

fs: int Sampling rate (Hz)

◆ spikeshapes()

def functions.spikeshapes (   file,
  raw,
  rawfiltered 
)

This function will get and save the spikeshapes (.txt) from the Raw unfiltered neuronal signal.

Arguments:

file: .smr Recording file.

raw: .npy File containing the Raw unfiltered neuronal signal

rawfiltered: .npy File containing the spike2 filtered neuronal signal

Returns:

It will save as .txt files the spikeshapes of each spiketrain.