cibrrig.postprocess.extract_resp_modulation =========================================== .. py:module:: cibrrig.postprocess.extract_resp_modulation .. autoapi-nested-parse:: Compute respiratory related modulation for each unit Uses a different computation than coherence Not using coherence for the potential concerns that coherence may not be the most effective way. Attributes ---------- .. autoapisummary:: cibrrig.postprocess.extract_resp_modulation._log Functions --------- .. autoapisummary:: cibrrig.postprocess.extract_resp_modulation.get_vector_means cibrrig.postprocess.extract_resp_modulation._get_phase_max cibrrig.postprocess.extract_resp_modulation._get_phase_modulation cibrrig.postprocess.extract_resp_modulation._get_eta_squareds cibrrig.postprocess.extract_resp_modulation.compute_resp_mod cibrrig.postprocess.extract_resp_modulation.run_probe cibrrig.postprocess.extract_resp_modulation.sanity_check_plots cibrrig.postprocess.extract_resp_modulation.run_session cibrrig.postprocess.extract_resp_modulation.main Module Contents --------------- .. py:data:: _log .. py:function:: get_vector_means(bins, rates) Calculate the vector sum direction and tuning strength from a histogram of responses in polar space. Computes over all cells in the input rates. :param bins: Sampled bin locations from a polar histogram. Must be on [-pi, pi] Assumes number of bins is the same as the number of observed rates. Bin centers is a better usage. :type bins: np.ndarray :param rates: Observed rate at each bin location. Multiple units are passed in columns :type rates: np.ndarray :returns: A tuple containing: - theta (np.ndarray): The vector mean direction of the input bin locations and centers. - L_dir (np.ndarray): The strength of the tuning as defined by Mazurek FiNC 2014. Equivalent to 1 - Circular Variance. :rtype: tuple .. py:function:: _get_phase_max(bins, rates) Computes the phase value of the peak of the polar curve. :param bins: Sampled bin locations from a polar histogram. Must be on [-pi, pi]. :type bins: np.ndarray :param rates: Observed rate at each bin location. Multiple units are passed in columns. :type rates: np.ndarray :returns: The phase value of the peak of the polar curve. :rtype: np.ndarray .. py:function:: _get_phase_modulation(bins, rates) Compute the phase modulation index as: \Phi = rac{max(rates) - min(rates)}{mean(rates)} Args: bins (np.ndarray): Sampled bin locations from a polar histogram. Must be on [-pi, pi]. Assumes number of bins is the same as the number of observed rates. Bin centers is a better usage. rates (np.ndarray): Observed rate at each bin location. Multiple units are passed in columns. Returns: np.ndarray: The phase modulation index for each unit. .. py:function:: _get_eta_squareds(rates) Compute the eta squared for each unit in the rates matrix. Not currently implemented :param rates: Observed rate at each bin location. Multiple units are passed in columns :type rates: np.ndarray :returns: The eta squared value for each unit. :rtype: np.ndarray .. py:function:: compute_resp_mod(spike_times, spike_clusters, cluster_ids, breaths, t0=None, tf=None) Compute respiratory modulation according to Mazurek et al. for all clusters in cluster_ids Implicitly computes phase from breaths.on_sec and breaths.off_sec Optionally, specify a window to compute respiratory modulation Times are in seconds :param spike_times: Array of spike times :type spike_times: np.ndarray :param spike_clusters: Array of cluster IDs for each spike :type spike_clusters: np.ndarray :param cluster_ids: Array of cluster IDs to compute on :type cluster_ids: np.ndarray :param breaths: Breaths structure that contains on_sec and off_sec :type breaths: one.alf.io.AlfBunch :param t0: Start of the window to compute respiratory modulation. Defaults to 0. :type t0: float :param tf: End of the window to compute respiratory modulation. Defaults to the last spike or breath. :type tf: float :returns: bins - Phase bins np.ndarray: rates - Spike rate as a function of phase for each cluster np.ndarray: sems - Spike rate standard error as a function of phase for each cluster np.ndarray: theta - Preferred phase for each cluster np.ndarray: L_dir - Respiratory modulation strength for each cluster :rtype: np.ndarray .. py:function:: run_probe(probe_path, breaths, t0=None, tf=None, use_good=False, plot_tgl=True, save_tgl=True) Compute coherence using chronux ALF organized spike data in a probe path Wrapper to pass to "compute_resp_mod" :param probe_path: path to the ALF spiking data :type probe_path: Pathlib path :param breaths: Breaths structure that contains on_sec and off_sec :type breaths: AlfBunch :param t0: Defines the start of the window to compute respiratory modulation, defaults to 0 :type t0: float :param tf: Defines the end of the window to compute respiratory modulation, defaults to last spike or breath :type tf: float :param use_good: If True, only use "good" units. Defaults to False. :type use_good: bool, optional :param plot_tgl: _description_. Defaults to True. :type plot_tgl: bool, optional :param save: _description_. Defaults to True. :type save: bool, optional .. py:function:: sanity_check_plots(probe_path, bins, rates, sems, theta, L_dir) Make a few plots that show the respiratory modulation of individual units and the population. :param probe_path: Path to save the plots. :type probe_path: Path :param bins: Phase bins. :type bins: np.ndarray :param rates: Spike rate as a function of phase for each cluster. :type rates: np.ndarray :param sems: Spike rate standard error as a function of phase for each cluster. :type sems: np.ndarray :param theta: Preferred phase for each cluster. :type theta: np.ndarray :param L_dir: Respiratory modulation strength for each cluster. :type L_dir: np.ndarray .. py:function:: run_session(session_path, t0=None, tf=None, use_good=False, plot_tgl=True) Run respiratory modulation computation on all probes for a session. :param session_path: Path to the session data. :type session_path: Path :param t0: Start of the epoch to compute on. Defaults to None. :type t0: float, optional :param tf: End of the epoch to compute on. Defaults to None. :type tf: float, optional :param use_good: If True, only compute for the "good" units. Defaults to False. :type use_good: bool, optional :param plot_tgl: If True, generate plots. Defaults to True. :type plot_tgl: bool, optional .. py:function:: main(session_path, t0, tf, use_good, no_plot)