neurochat.nc_clust module¶
This module implements NClust Class for NeuroChaT software.
@author: Md Nurul Islam; islammn at tcd dot ie
-
class
neurochat.nc_clust.NClust(**kwargs)[source]¶ Bases:
neurochat.nc_base.NBaseThis class facilitates clustering-related operations.
Although no clustering algorithm is implemented in this class, it can be subclassed to create such algorithms.
Many of the functions in this class are delegated to the spike attr.
-
add_spike(spike=None, **kwargs)[source]¶ Add new spike node to current NSpike() object.
Parameters: spike (NSpike) – NSPike object. If None, new object is created Returns: ` (obj:NSpike`) – A new NSpike() object
-
align_wave_peak(reach=300, factor=2)[source]¶ Align the waves by their peaks.
Parameters: - reach (int) – Maximum allowed time-shift in microsecond
- factors (int) – Resampling factor
Returns: None
-
burst(burst_thresh=5, ibi_thresh=50)[source]¶ Burst analysis of spike-train.
Delegates to NSpike().burst()
Parameters: - burst_thresh (int) – Minimum ISI between consecutive spikes in a burst
- ibi_thresh (int) – Minimum inter-burst interval between two bursting groups of spikes
Returns: None
See also
nc_spike.NSpike()
-
cluster_separation(unit_no=0)[source]¶ Measure the separation of a specific unit from other clusters.
This is performed quantitatively using the following: 1. Bhattacharyya coefficient 2. Hellinger distance
Parameters: unit_no (int) – Unit of interest. If ‘0’, pairwise comparison of all units are returned. Returns: - (bc, dh) ((ndarray, ndarray))
- bc (ndarray) – Bhattacharyya coefficient
- dh (ndarray) – Hellinger distance
-
cluster_similarity(nclust=None, unit_1=None, unit_2=None)[source]¶ Measure the similarity or distance of units in a cluster.
This is performed on one unit in a spike dataset to cluster of another unit in another dataset.
This is performed quantitatively using the following: 1. Bhattacharyya coefficient 2. Hellinger distance
Parameters: - nclust (Nclust) – NClust object whose unit is under comparison
- unit_1 (int) – Unit of current Nclust object
- unit_2 (int) – Unit of another NClust object under comparison
Returns: - (bc, dh) ((ndarray, ndarray))
- bc (ndarray) – Bhattacharyya coefficient
- dh (ndarray) – Hellinger distance
-
get_channel_ids()[source]¶ Return the identities of individual channels.
Parameters: None – Returns: list – Identities of individual channels
-
get_feat(npc=2)[source]¶ Return the spike-waveform features.
Parameters: npc (int) – Number of principle components in each channel. Returns: feat (ndarray) – Matrix of size (number_spike X number_features)
-
get_feat_by_unit(unit_no=None)[source]¶ Return the spike-waveform features for a particular unit.
Parameters: unit_no (int) – Unit of interest Returns: feat (ndarray) – Matrix of size (number_spike X number_features)
-
get_max_energy_chan()[source]¶ Return the maximum energy of the spike waveforms.
Parameters: None – Returns: ndarray – Maximum energy of the spikes
-
get_max_wave_chan()[source]¶ Return the maximum of waveform peaks among the electrode groups.
Parameters: None – Returns: - (max_wave_val, max_wave_chan, peak_loc) ((ndarray, ndarray, ndarray))
- max_wave_val (ndarray) – Maximum value of the peaks of the waveforms
- max_wave_chan (ndarray) – Channel of the electrode group where a spike waveform is strongest
- peak_loc (ndarray) – Peak location in the channel with strongest waveform
-
get_min_wave_chan()[source]¶ Return the maximum of waveform peaks among the electrode groups.
Parameters: None – Returns: (min_val, min_index) ((ndarray, ndarray)) – - min_val : ndarray
- Minimum value of the waveform at channels with peak value
- min_index : ndarray
- Index of minimum values
-
get_samples_per_spike()[source]¶ Return the number of bytes to represent each timestamp.
Parameters: None – Returns: int – Number of bytes to represent timestamps
-
get_sampling_rate()[source]¶ Return the sampling rate of spike waveforms.
Parameters: None – Returns: int – Sampling rate for spike waveforms
-
get_timebase()[source]¶ Return the timebase for spike event timestamps.
Parameters: None – Returns: int – Timebase for spike event timestamps
-
get_timestamp(unit_no=None)[source]¶ Return the timestamps of the spike-waveforms of specified unit.
Parameters: unit_no (int) – Unit whose timestamps are to be returned Returns: ndarray – Timestamps of the spiking waveforms
-
get_total_channels()[source]¶ Return total number of electrode channels in the spike data file.
Parameters: None – Returns: int – Total number of electrode channels
-
get_total_spikes()[source]¶ Return total number of spikes in the recording.
Parameters: None – Returns: int – Total number of spikes
-
get_unit_list()[source]¶ Return the list of units in a spike dataset.
Parameters: None – Returns: list – List of units
-
get_unit_spikes_count(unit_no=None)[source]¶ Return the total number of spikes in a specified unit.
Parameters: unit_no (int) – Unit whose count is returned Returns: int – Total number of spikes in the unit
Return tags of the spiking waveforms from clustering.
Parameters: None – Returns: None
-
get_unit_waves(unit_no=None)[source]¶ Return spike waveforms of a specific unit.
Parameters: unit_no (int) – Unit whose waveforms are returned Returns: dict – Spike waveforms in each channel of the electrode group
-
get_wave_energy()[source]¶ Energy of the spike waveforms.
This is measured as the summation of the square of samples.
Parameters: None – Returns: energy (ndarray) – Energy of spikes (num_spike X num_channels)
-
get_wave_min()[source]¶ Return the minimum values of the spike-waveforms.
Parameters: None – Returns: (min_w, min_loc) ((ndarray, ndarray)) – - min_w : ndarray
- Minimum value of the waveforms
- min_loc : ndarray
- Index of minimum value
-
get_wave_pc(npc=2)[source]¶ Return the Principle Components of the waveforms.
Parameters: npc (int) – Number of principle components from waveforms of each channel Returns: pc (ndarray) – Principle components (num_waves X npc*num_channels)
-
get_wave_peaks()[source]¶ Return the peaks of the spike-waveforms.
Parameters: None – Returns: (peak, peak_loc) ((ndarray, ndarray)) – - peak:
- Spike waveform peaks in all the electrode channels Shape is (num_waves X num_channels)
- peak_loc :
- Index of peak locations
-
get_wave_timestamp()[source]¶ Return the temporal resolution to represent samples of spike-waves.
Parameters: None – Returns: int – Number of bytes to represent timestamps
-
get_waveform()[source]¶ Return the waveforms in the spike dataset.
Parameters: None – Returns: dict – Each key represents one channel of the electrode group. Each value represents the waveforms of the spikes in a matrix form (no_samples x no_spikes)
-
get_wavetime()[source]¶ Return the timestamps of the waveforms, not the spiking-event.
Parameters: None – Returns: Timestamps of the spike-waveforms
-
isi(bins='auto', bound=None, density=False)[source]¶ Calculate the ISI histogram of the spike train.
Delegates to NSpike().isi()
Parameters: - bins (str or int) – Number of ISI histogram bins. If ‘auto’, NumPy default is used
- bound (int) – Length of the ISI histogram in msec
- density (bool) – If true, normalized histogram is calculated
Returns: dict – Graphical data of the analysis
See also
NSpike()
-
isi_corr(**kwargs)[source]¶ Analysis of ISI autocorrelation histogram.
Delegates to NSpike().isi_auto_corr()
Parameters: **kwargs – Keyword arguments Returns: dict – Graphical data of the analysis See also
nc_spike.NSpike()
-
load(filename=None, system=None)[source]¶ Load spike dataset from the file.
Parameters: - filename (str) – Name of the spike file
- system (str) – Name of the recording format or system.
Returns: None
See also
nc_spike.NSpike()
-
load_spike(names=None)[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
-
psth(event_stamp, **kwargs)[source]¶ Calculate peri-stimulus time histogram (PSTH).
Delegates to NSpike().psth()
Parameters: - event_stamp (ndarray) – Event timestamps
- **kwargs – Keyword arguments
Returns: dict – Graphical data of the analysis
See also
nc_spike.NSpike()
-
remove_null_chan()[source]¶ Remove the channel from the electrode group that has no spike in it.
Parameters: None – Returns: off_chan (int) – Channel number that has been removed
-
resample_wave(factor=2)[source]¶ Resample spike waveforms using spline interpolation.
Parameters: factor (int) – Resampling factor Returns: - wave (dict) – Upsampled waveforms
- uptime ndarray – Upsampled wave timestamps
-
resample_wavetime(factor=2)[source]¶ Resample the timestamps of spike-waveforms.
Parameters: factor (int) – Resampling factor Returns: Resampled timestamps
-
save_to_hdf5()[source]¶ Store NSpike() object to HDF5 file.
Delegates to NSPike().save_to_hdf5()
Parameters: None – Returns: - None
- Also see
- ——–
- nc_hdf.Nhdf().save_spike()
Return tags of the spiking waveforms from clustering.
Parameters: new_tags (ndarray) – Array that contains the tags for spike-waveforms which is based on the cluster number. Returns: None
-