neurochat.nc_lfp module¶
This module implements NLfp Class for NeuroChaT software.
@author: Md Nurul Islam; islammn at tcd dot ie
-
class
neurochat.nc_lfp.NLfp(**kwargs)[source]¶ Bases:
neurochat.nc_base.NBaseThis data class contains information about the neural LFP signal.
It decodes data from different formats and analyses LFP signal in the recording.
-
_file_tag¶ The tag of the lfp data.
Type: str
-
_channel_id¶ The id of the channel the lfp data came from.
Type: int
-
_samples¶ Array of lfp samples.
Type: np.ndarray
-
_timestamp¶ Array of timestamps of the lfp samples.
Type: np.ndarray
-
add_lfp(lfp=None, **kwargs)[source]¶ Add new LFP node to current NLfp() object.
Parameters: lfp (NLfp) – NLfp object. If None, new object is created Returns: ` (obj:Nlfp`) – A new NLfp() object
-
add_spike(spike=None, **kwargs)[source]¶ Add new spike node to current NLfp() object.
Parameters: spike (NSpikes) – NSPike object. If None, new object is created Returns: ` (obj:NSpike()`) – A new NSpike() object
-
bandpower(band, **kwargs)[source]¶ Compute the average power of the signal x in a specific frequency band.
Modified from excellent article at https://raphaelvallat.com/bandpower.html
Parameters: band (list) – Lower and upper frequencies of the band of interest. [lower, upper].
Keyword Arguments: - method (string) – Periodogram method. Only ‘welch’ is currently supported.
- window_sec (float) – Length of each window in seconds. If None, window_sec = (1 / min(band)) * 2.
- band_total (bool) – Whether to band the total power Default False
- total_band (List) – low and high frequency values for the filter on total band. Default [1.5, 90]
- unit (str) – Currently support micro and milli. The scale to return Volts in. Defaults to micro.
Returns: bp (Dict) – “bandpower”, “total_power” and “relative_power”.
-
bandpower_ratio(first_band, second_band, win_sec, **kwargs)[source]¶ Calculate the ratio in power between two bandpass filtered signals.
Note that common ranges are: delta (1.5–4 Hz), theta (5-11 Hz)
Parameters: - first_band (1d array) – lower and upper bands
- second_band (1d array) – lower and upper bands
- win_sec (float) – length of the windows to bin lfp into in seconds. recommend 4 for eg.
Keyword Arguments: - first_name (str) – name of band 1, default “Band 1”
- second_name (str) – name of band 2, default “Band 2”
Returns: float – the ratio between the power signals.
See also
nc_lfp.NLfp()
-
event_trig_average(event_stamp=None, **kwargs)[source]¶ Averaging event-triggered LFP signals.
Parameters: - event_stamp (ndarray) – Timestamps of the events or the spiking activities for measuring the event triggered average of the LFP signal
- **kwargs – Keywrod arguments
Returns: dict – Graphical data of the analysis
-
find_artf(sd_thresh=3, min_artf_freq=8)[source]¶ Obtain locations of signal above threshold in windows.
Note
This function is still a work in progress and may see future changes.
Parameters: - sd_thresh (float) – threshold to exclude artf
- min_artf_freq (float) – minimum artf freq - Used to locate artf blocks eg. 250 Hz sampling rate, 40Hz min_artf_freq: locates artf within 9 samples of each other
-
get_bytes_per_sample()[source]¶ Return the number of bytes to represent each LFP waveform sample.
Parameters: None – Returns: int – Number of bytes to represent each sample of the LFP waveform
-
get_channel_id()[source]¶ Return the electrode channels ID.
Parameters: None – Returns: str – LFP channel ID
-
get_file_tag()[source]¶ Return the file tag or extension for the LFP dataset.
For example, Axona recordings usually have file tags like ‘eeg’ or ‘eeg8’ etc.
Parameters: None – Returns: str – File tag or extension for the LFP dataset
-
get_fullscale_mv()[source]¶ Return the fullscale value of the ADC in mV.
Parameters: None – Returns: int – Fullscale ADC value in mV
-
get_recording_time()[source]¶ Return the recording time in seconds.
Parameters: None – Returns: int – Recording time in seconds
-
get_samples()[source]¶ Return LFP waveform samples.
Parameters: None – Returns: ndarray – Samples of the LFP signal
-
get_sampling_rate()[source]¶ Return the sampling rate of spike waveforms.
Parameters: None – Returns: int – Sampling rate for spike waveforms
-
get_timestamp()[source]¶ Return the timestamps of the LFP waveform.
Parameters: None – Returns: ndarray – Timestamps of the LFP signal
-
get_timestamp_bytes()[source]¶ Return number of bytes to represent each timestamp in the binary file.
Parameters: None – Returns: int – Number of bytes to represent timestamps
-
get_total_channel()[source]¶ Return total number of electrode channels in the LFP data file.
Parameters: None – Returns: int – Total number of electrode channels
-
get_total_samples()[source]¶ Return total number of LFP samples.
Parameters: None – Returns: ndarray – Total number of LFP samples
-
get_type()[source]¶ Return the type of object. For NLfp, this is always lfp type.
Parameters: None – Returns: str
-
load(filename=None, system=None)[source]¶ Load LFP datasets.
Parameters: - filename (str) – Name of the spike datafile
- system (str) – Recording system or format of the spike data file
Returns: None
See also
load_lfp_axona(),load_lfp_NLX(),load_lfp_NWB()
-
load_lfp(names=None)[source]¶ Load datasets of the LFP nodes.
The name of each node is used for obtaining the filenames.
Parameters: names (list of str) – Names of the nodes to load. If all, all LFP nodes are loaded Returns: None
-
load_lfp_Axona(file_name)[source]¶ Decode LFP data from Axona file format.
Parameters: file_name (str) – Full file directory for the lfp data Returns: None
-
load_lfp_NWB(file_name)[source]¶ Decode LFP data from NWB (HDF5) file format.
Parameters: file_name (str) – Full file directory for the lfp data Returns: None
-
load_lfp_Neuralynx(file_name)[source]¶ Decode LFP data from Neuralynx file format.
Parameters: file_name (str) – Full file directory for the lfp data Returns: None
-
load_spike(names='all')[source]¶ Load datasets of the spike nodes.
The name of each node is used for obtaining the filenames.
Parameters: names (list of str) – Names of the nodes to load. If None, current NSpike() object is loaded Returns: None
-
phase_at_events(event_stamps, **kwargs)[source]¶ Phase based on times.
Parameters: - event_stamps (array) – an array of event times
- **kwargs – keyword arguments
Returns: - (array)
- Phase values for each position
-
phase_dist(event_stamp, **kwargs)[source]¶ Analysis of spike to LFP phase distribution.
Parameters: - event_stamp (ndarray) – Timestamps of the events of spiking activities for measuring the phase distribution.
- **kwargs – Keyword arguments
Returns: dict – Graphical data of the analysis
-
plv(event_stamp, **kwargs)[source]¶ Calculate phase-locking value of the spike train to underlying LFP signal.
When ‘mode’= None in the input kwargs, it calculates the PLV and SFC over the entire spike-train.
If ‘mode’= ‘bs’, it bootstraps the spike-timestamps and calculates the locking values for each set of new spike timestamps.
If ‘mode’= ‘tr’, a time-resolved phase-locking analysis is performed where the LFP signal is split into overlapped segments for each calculation.
Parameters: - evnet_stamp (ndarray) – Timestamps of the events or the spiking activities for measuring the phase locking
- **kwargs – Keyword arguments
Returns: dict – Graphical data of the analysis
-
save_to_hdf5(file_name=None, system=None)[source]¶ Store NLfp() object to HDF5 file.
Parameters: - file_name (str) – Full file directory for the lfp data
- system (str) – Recoring system or data format
Returns: - None
- Also see
- ——–
- nc_hdf.Nhdf().save_lfp()
-
set_channel_id(channel_id='')[source]¶ Set the electrode channels ID.
Parameters: channel_id (str) – Channel ID for the LFP data Returns: None
-
set_file_tag(file_tag)[source]¶ Set the file tag or extension for the LFP dataset.
For example, Axona recordings usually have file tags like ‘eeg’ or ‘eeg8’ etc.
Parameters: file_tag (str) – File tag or extension for the LFP dataset Returns: None
-
sharp_wave_ripples(in_range=None, **kwargs)[source]¶ Detect SWR events in the lfp, optionally in a given range.
This method is based on finding peaks in the Root mean square envelope of a filtered signal between 100 and 250Hz (default params). Peaks that are above the peak_percentile keyword argument are returned.
Parameters: - in_range (tuple) – A range in seconds
- kwargs –
- ------ –
- swr_lower (float) – Lower band in hz
- swr_upper (float) – Upper band in hz
- rms_window_size_ms (int) – Size of the rms window in ms
- percentile (float) – The percentile threshold for a peak
Returns: dict – lfp times, lfp samples, swr times, lfp sample rate
-
spectrum(**kwargs)[source]¶ Analyse frequency spectrum of the LFP signal.
Parameters: **kwargs – Keyword arguments Returns: dict – Graphical data of the analysis
-
spike_lfp_causality(spike=None, **kwargs)[source]¶ (Not implemented yet).
Analyses spike to underlying LFP causality
Parameters: - spike (NSpike) – Spike dataset which is used for the causality analysis
- **kwargs – Keywrod arguments
Returns: dict – Should return graphical data of the analysis. The function is not implemented yet.
-