neurochat.nc_containeranalysis module¶
This module contains analysis functions for NDataContainer objects.
@author: Sean Martin; martins7 at tcd dot ie
-
neurochat.nc_containeranalysis.count_units_in_bins(collection, bin_length, in_range=None, multi_ranges=None)[source]¶ Count the amount of units that fire in certain bins.
Parameters: - collection (NDataCollection) – The collection of units to count over
- bin_length (float) – The length of the bins in seconds
- in_range (tuple, default None) – The range of time to count units over
- multi_ranges (list of tuple, default None) – A different range to count units over for each item in the collection.
Returns: list of tuples –
- [(unit counts in bins, bin_centres)
for each data object in collection]
-
neurochat.nc_containeranalysis.evaluate_clusters(collection, idx1, idx2, set_units=False)[source]¶ Find which units are closest in terms of clustering.
Uses the Hungarian (Munkres) cost optimisation based on the Hellinger distance between the clusters.
Parameters: - collection (NDataCollection) – The collection to find similar cells in
- idx1 (int) – The first data point in the collection to consider
- idx2 (int) – The second data point in the collection to consider
- set_units (bool, default False) – Whether to set the list of units to analyse in the container at idx1 and idx2 to the best matches found in this function.
Returns: dict – For each key, or unit in data[idx1], val is a tuple consisting of the best matching unit from data[idx2] and the distance for this.
-
neurochat.nc_containeranalysis.place_cell_summary(collection, dpi=150, out_dirname='nc_plots', filter_place_cells=False, filter_low_freq=False, opt_end='', base_dir=None, output_format='png', output=['Wave', 'Path', 'Place', 'HD', 'LowAC', 'Theta', 'HighISI'], isi_bound=350, isi_bin_length=2, fixed_color=None, save_data=False, point_size=None, color_isi=True, burst_thresh=5, hd_predict=False, one_by_one='auto')[source]¶ Perform spatial information summary of each cell in collection.
The function is named as place_cell_summary as it can be a quick visual way to look for place cells. However, it can be used to look other spatial properties, such as head directionality.
The output image (any matplotlib format is supported) contains the information from and in the order of the output argument.
Parameters: - collection (NDataCollection) – The collection to plot spatial summaries of.
- dpi (int, default 150) – Dpi of the output figures if the output_format supports dpi.
- out_dirname (str, default "nc_plots) – The relative name of the directory to save output to.
- filter_place_cells (bool, default True) – Whether to filter out non spatial place cells from the plots. A unit is considered a spatial place cell if: Sparsity < 0.3 and Coherence > 0.55. Recommended filter_low_freq=True if this flag is True. See https://www.nature.com/articles/ncomms11824.
- filter_low_freq (bool, default True) – Filter out cells with spike freq less than 0.1Hz
- opt_end (str, default "") – A string to append to the file output just before the extension Can be used if doing multiple runs to avoid overwriting output files.
- base_dir (str, default None) – An optional directory to save all the files to. If not provided, the files will save to the location of the input data.
- output_format (str, default "png") – What format to save the output image in.
- output (List of str,) – default [“Wave”, “Path”, “Place”, “HD”, “LowAC”, “Theta”, “HighISI”] Provided argument should be some subset and/or permutation of these.
- isi_bound (int, default 350) – How long in ms to plot the ISI for.
- isi_bin_length (int, default 2) – How long in ms the ISI bins should be.
- fixed_color (str, default None) – If provided, will plot all units with this color instead of auto color. Can be any matplotlib compatible color.
- save_data (bool, default False) – Whether to save out the information used for the plot. If True, will produce a csv with all the data used for plotting.
- point_size (int, default None) – If provided, the size of the matplotlib points to use in spatial plots. If None, the point size is dpi / 7.
- color_isi (bool, default True) – Whether the ISI should be black (False) or blue (True).
- burst_thresh (int, default 5) – How long in ms to consider the window for burst to be
- hd_predict (bool, default False) – Whether the head directional graph should be plotted with predicted HD.
- one_by_one (bool or str, default "auto") – Whether to plot all units in each tetrode file to single plot. Options: True - plot each unit to a seperate file. False - plot all units on a tetrode to the same file. “auto” - Determine T/F based on output_format. pdf and svg are True.
Returns: None
-
neurochat.nc_containeranalysis.spike_positions(collection, should_sort=True, mode='vertical')[source]¶ Get the spike positions for a number of units.
Parameters: collection (NDataContainer or NData list or NData object) – Returns: positions (list of positions of the rat when the cell spiked)
-
neurochat.nc_containeranalysis.spike_times(collection, filter_speed=False, **kwargs)[source]¶ Return a list of all spike times in the collection.
Parameters: - collection (NDataContainer or NData) – Either the container or data object to get spike times from
- filter_speed (bool) – If true, don’t consider spike times when the rat is non moving
- kwargs –
- should_smooth : bool
- Smooth the speed data if true
- ranges : list
- List of tuples indicating time ranges to get spikes in
Returns: list – The list of spike times if collection is NData or a 2d list containing a list of times for each collection item