region_averaging_analysis module#
@author: Théo Lambert
This module regroups all the functions related to region averaging.
- class region_averaging_analysis.FormatterBarcode(regions_acr)#
Bases:
objectObject for dynamically displaying the regions of the atlas under the cursor in the plots.
- Parameters:
atlas (ndarray) – The 3D atlas volume.
regions_acr (array) – Array containing the acronyms of the regions included in the atlas.
regions_nb (array) – Array containing the regions’ numbers / IDs included in the atlas.
- class region_averaging_analysis.RegionAveragingAnalysis(data_paths: List[str], atlas_path: str, regions_info_path: str, remove_empty: bool = True, regions_to_exclude: list = [], to_zscore=None, baseline=None)#
Bases:
objectObject handling the region averaging and associated displays.
- Parameters:
data_paths (list of str) – List of paths to the folders in which are stored the data after preprocessing. See doc for more info on folder structure and how to automatically select data.
atlas_path (str) – Path to the atlas volume file.
regions_info_path (str) – Text file listing all the regions included in the atlas.
remove_empty (bool) – If true, removes all the anatomical parts labelled as ‘empty’, eg fiber tracts.
to_zscore (bool) – If true, traces will be displayed as Z-scores. Requires to set the baseline argument as well.
baseline (iterable) – Baseline of the recording. Used for computing the Z-score.
- get_regions_traces(acronyms: Tuple[str, str] | List[Tuple[str, str]], names: str | List[str] | None = None) Dict[str, Dict[str, array]]#
Method for getting traces of individual regions from the object.
- Parameters:
acronyms (tuple | list of tuple) – The format of the tuple is (<region acronym>, <hemisphere>). Single tuple and list of tuples following this format are accepted.
names (str | list of str | None) – Names of the elements to get the data from. If None, all elements will be considered. Check on your terminal the elements available for display or the variable self.name.
- Returns:
res – Dictionary whose keys are the names of the elements, and values dictionaries with regions acronyms as keys and temporal traces as values.
- Return type:
dict of dict of arrays
- plot_barcode(names: None | List[str] = None, separate_plots: bool = False, scale: Tuple[float, float] = (-0.4, 0.4), show: bool = False) None#
Method for plotting the barcode view from the averaged data.
- Parameters:
names (None | list of str) – If None, all the data will be displayed. If list of strings, only the names specified in it will be displayed.
separate_plots (bool) – Whether or not to make separate windows for each element to be plotted, eg sessions.
scale (tuple of float) – Min and max scales for the display (arguments vmin / vmax from plt.imshow).
show (bool) – If True, the plot will be displayed at the end of the function’s execution. Otherwise, a call to plt.show() must be used to display the figures.
- plot_region(region_acr: List[Tuple[str, str]], names: None | List[str] = None, separate_plots: bool = True, display_individual_elements: bool = True, scale: None | Tuple[float, float] = None, show: bool = False) None#
Method for plotting the barcode view from the averaged data.
- Parameters:
region_acr (str | list of str) – Acronym(s) of the region to be plotted.
hemisphere (str | None) – If None, both hemispheres are plotted. Otherwise, ‘L’ or ‘R’ will only plot the selected hemisphere.
names (None | list of str) – If None, all the data will be displayed. If list of strings, only the names specified in it will be displayed.
separate_plots (bool) – If True, the plots will be displayed in separate windows. If not, all regions will be plotted together.
display_individual_elements (bool) – Whether or not to display individual elements defined in ‘self.names’ (eg animals, sessions) for the region. If not, 95% CI will be displayed instead. /!For the sake of readability, this option is not available if separate_plots is set to False.
scale (tuple of float | None) – Min and max scales for the display (arguments vmin / vmax from plt.imshow). If None, auto scale will be used.
show (bool) – If True, the plot will be displayed at the end of the function’s execution. Otherwise, a call to plt.show() must be used to display the figures.