Welcome to CICADA’s documentation!

Calcium imaging pipeline

Contents

Dependencies

PyCICADA has the following minimum requirements, which must be installed before you can get started using PyNWB.

  1. Python 3.6, or 3.7
  2. pip

PyCICADA has been tested on Ubuntu 18.04.1 LTS, Windows 10 and macOS Mojave, using Python 3.6 & 3.7

Installation

Install release from PyPI

The Python Package Index (PyPI) is a repository of software for the Python programming language.

To install or update PyCICADA distribution from PyPI simply run:

$ pip install -U pycicada

This will automatically install the following required dependencies:

  1. h5py
  2. numpy
  3. sortedcontainers
  4. shapely
  5. qtpy
  6. Pillow
  7. PyYAML
  8. scanimage-tiff-reader
  9. pyabf
  10. hdf5storage
  11. pathlib
  12. scipy
  13. matplotlib
  14. PyQt5

Introduction

CICADA stands for Calcium Imaging Complete Automated Data Analysis.

It’s a Python pipeline aimed for analyzing calcium imaging data.

Motivation

We notice a lack of toolboxes or analysis pipelines for calcium imaging data, using open source language. Our motivation was to build an easy-to-use pipeline, which doesn’t need programming skills. In that purpose, we offer a Graphical User Interface as well as a command line usage.

In order to tackle the broadness of scientists’ needs, we built the pipeline to be easily extendable with a plugin-like interface, for data format and analyses.

Supported data format

The default data format chosen was Neurodata Without Borders: Neurophysiology (NWB:N). that is a data standard for neurophysiology, providing neuroscientists with a common standard to share, archive, use, and build analysis tools for neurophysiology data. NWB:N is designed to store a variety of neurophysiology data, including data from intracellular and extracellular electrophysiology experiments, data from optical physiology experiments, and tracking and stimulus data.

We provide some tools to convert their data into NWB, with a plugin-like interface. (Curently in Preprocessing)

Functionalities

  • We offer a Graphical User Interface (GUI) as well as a command line usage.
  • We have already implemented or aim to implement various kind of analyses such cell assemblies detection, network analyses, display functions (rasters, cells map) etc…
  • The GUI offers specifics functionalities: - Subjects and recorded sessions can be filtered or grouped in order to easily select the data to be analysed, and saved for future use. - Subjects and and recorded sessions’ informations can be displayed and modified depending on the data format. - Analyses are grouped by family. Each analysis provide a way to check the data see if they are compatible. - Analyses arguments can be saved in a yaml file allowing to easily load them later. - A multi-thread implementation allows multiple analysis at the same time. - A progression bar allows to follow the analysis current status.

Software architecture

Analysis

Each analysis is represented by a class that inherits CicadaAnalysis (in the module cicada.analysis).

Each CicadaAnalysis instance instanciate an ArgumentAnalysisHandler that communicates with the GUI and handle the arguments that will be passed to the analysis.

Each CicadaAnalaysis instance allows to check the compatibility of the data to analyze though the method check_data().

The method run_analysis() will be called to start the analysis.

The abstract class CicadaAnalysisFormatWrapper allows,through inheritance, to write a wrapper for a given data format, such as nwb. It allows to get the content from specific data format, and adding a new format consists in creating a new instance of CicadaAnalysisFormatWrapper, without any change in the CicadaAnalysis instances.

Graphical User Interface

The GUI uses Qt through QtPy which wrapps PyQt5 and PySide.

The GUI is composed of 3 main modules.

  1. A list that displays the loaded recorded sessions to analyse (SessionsWidget).
  2. A tree that displays the available analyses, updated depending on the data to analyse. (AnalysisTreeApp)
  3. A pop-up panel that allows to set arguments for the given analysis and to follow the status of the analysis. (AnalysisParametersApp). A corresponding overwiew of the opened panels is available on the main window (AnalysisOverview)

How to use

To be added

Pre-processing

Convert CI data to NWB file format

Data to NWB

cicada.preprocessing.cicada_data_to_nwb.convert_data_to_nwb(data_to_convert_dir, default_convert_to_nwb_yml_file, nwb_files_dir)[source]

Convert all default_config_data_for_conversion located in dir_path and put it in NWB format then create the file. Use the yaml file contains in dir_path to convert the default_config_data_for_conversion. A yaml file with in its name session_data and one with subject_data must be in directory. Otherwise nothing will happend. A yaml file with abf in its name will need to be present to convert the abf default_config_data_for_conversion.

Parameters:
  • data_to_convert_dir (str) – Absolute path to the directory containing all data
  • default_convert_to_nwb_yml_file (str) – Absolute path to the default YAML file to convert an NWB file
  • nwb_files_dir (str) – Absolute path to the directory where to save the nwb file created
cicada.preprocessing.cicada_data_to_nwb.create_convert_class(class_name, config_dict, converter_dict, nwb_file, yaml_path, files, dir_path)[source]
Parameters:
  • class_name
  • config_dict
  • converter_dict
  • nwb_file
  • yaml_path
  • files
  • dir_path

Returns:

cicada.preprocessing.cicada_data_to_nwb.create_nwb_file(subject_data_yaml_file, session_data_yaml_file)[source]

Create an NWB file object using all metadata containing in YAML file

Parameters:
  • subject_data_yaml_file (str) – Absolute path to YAML file containing the subject metadata
  • session_data_yaml_file (str) – Absolute path to YAML file containing the session metadata
cicada.preprocessing.cicada_data_to_nwb.filter_list_according_to_keywords(list_to_filter, keywords, keywords_to_exclude)[source]

Conditional loop to remove all files or directories not containing the keywords # or containing excluded keywords. Inplace list modification

Parameters:
  • list_to_filter (list) – List containing all files/directories to be filtered
  • keywords (str) – If the list doesn’t contain the keyword, remove it from list
  • keywords_to_exclude (str) – If the list contains the keyword, remove it from list
Exemples:
>>> print(filter_list_of_files(["file1.py", "file2.c", "file2.h"],"2","h"))
["file2.c"]
cicada.preprocessing.cicada_data_to_nwb.filter_list_of_files(dir_path, files, extensions, directory=None)[source]

Take a list of file names and either no extensions (empty list or None) and remove the directory that starts by “.” or a list of extension and remove the files that are not with this extension. It returns a new list

Parameters:
  • dir_path (str) – path in which the files ares
  • files (list) – List of files to be filtered
  • extensions (str) – File extension to use as a filter
  • directory (str) – directory in which looking for files with a given extensions or return files in this directory
Exemples:
>>> print(filter_list_of_files(["file1.py", "file2.c", "file3.h"],"py"))
["file1.py"]

Run preprocessing

NWB file class

class cicada.preprocessing.convert_to_nwb.ConvertToNWB(nwb_file)[source]

NWB file object class

convert(**kwargs)[source]

Convert the data and add to the nwb_file

Parameters:**kwargs – arbitrary arguments

Suite 2P ROIs

class cicada.preprocessing.convert_suite_2p_rois_to_nwb.ConvertSuite2pRoisToNWB(nwb_file)[source]

Class to convert ROIs data from Suite2P to NWB if raw_traces from Suite2p are available they are loaded. Otherwise if the movie is available, build the raw_traces. create_roi_response_series

convert(**kwargs)[source]

Convert the data and add to the nwb_file

Parameters:**kwargs – arbitrary arguments

2D series

class cicada.preprocessing.convert_processed_2d_series_to_nwb.ConvertProcessed2dSeriesToNWB(nwb_file)[source]

Class to convert 2D series to NWB

convert(**kwargs)[source]

Convert the data and add to the nwb_file

Parameters:**kwargs – arbitrary arguments
static load_rasterplot_in_memory(rasterplot_file_name, matlab_string, frames_to_add=None)[source]

Get 2D series data from file

Parameters:
  • rasterplot_file_name (str) – Absolute path to file containing 2D series
  • matlab_string (str) – Key to the data from matlab and npz files
  • frames_to_add (dict) – Key is the frame where you add blank frames and value is the number of frames to add
  • is None. (Default) –
Returns:

Raster data as a 2d array

Return type:

raster (np.array)

Calcium imaging movie

class cicada.preprocessing.convert_ci_movie_to_nwb.ConvertCiMovieToNWB(nwb_file)[source]

Class to convert Calcium Imaging movies to NWB

convert(**kwargs)[source]

Convert the data and add to the nwb_file

Parameters:**kwargs – arbitrary arguments

ABF

class cicada.preprocessing.convert_abf_to_nwb.ConvertAbfToNWB(nwb_file)[source]

Class to convert ABF data to NWB

convert(**kwargs)[source]

The goal of this function is to extract from an Axon Binary Format (ABF) file its content and make it accessible through the NWB file. The content can be: LFP signal, piezzo signal, speed of the animal on the treadmill. All, None or a few of these informations could be available. One information always present is the timestamps, at the abf sampling_rate, of the frames acquired by the microscope to create the calcium imaging movie. Such movie could be the concatenation of a few movies, such is the case if the movie need to be saved every x frames for memory issue for ex. If the movie is the concatenation of many, then there is an option to choose to extract the information as if 2 frames concatenate are contiguous in times (such as then LFP signal or piezzo would be match movie), or to add interval_times indicating at which time the recording is on pause and at which time it’s starting again. The time interval containing this information is named “ci_recording_on_pause” and you can get it doing: if ‘ci_recording_on_pause’ in nwb_file.intervals: pause_intervals = nwb_file.intervals[‘ci_recording_on_pause’]

Parameters:
  • **kwargs (dict) – kwargs is a dictionary, potentials keys and values types are:
  • abf_yaml_file_name – mandatory parameter. The value is a string representing the path
  • file_name of the yaml file associated to this abf file. In the abf (and) –
  • frames_channel – mandatory parameter. The value is an int representing the channel
  • the abf in which is the frames timestamps data. (of) –
  • abf_file_name – mandatory parameter. The value is a string representing the path
  • file_name of the abf file. (and) –
detect_run_periods(run_data, min_speed)[source]

Using the data from the abf regarding the speed of the animal on the treadmill, return the speed in cm/s at each timestamps as well as period when the animal is moving (using min_speed threshold)

Parameters:
  • run_data (list) – Data from the subject run
  • min_speed (int) – Minimum speed
Returns:

List of movements periods speed_during_movement_periods (list) : List of subject speed during movements speed_by_time (list) : List of subject speed by time

Return type:

mvt_periods (list)

determine_ci_frames_indices()[source]

Using the frames data channel, estimate the timestamps of each frame of the calcium imaging movie. If there are breaks between each recording (the movie being a concatenation of different movies), then there is an option to either skip those non registered frames that will be skept in all other data (lfp, piezzo, …) or to determine how many frames to add in the movie and where so it matches the other data recording in the abf file

process_run_data(run_channel)[source]

Using the information in run_channel, will add to the nwb_file the speed of the subject at each acquisition frame of the movie in cm/s

Parameters:run_channel (int) – Run channel

Utils

class cicada.preprocessing.utils.ComparableItem(value)[source]

Make it possible to sort a list of items of different types, such as int and string

cicada.preprocessing.utils.class_name_to_file_name(class_name)[source]

Transform the string representing a class_name, by removing the upper case letters, and inserting before them an underscore if 2 upper case letters don’t follow. Underscore are also inserted before numbers ex: ConvertAbfToNWB -> convert_abf_to_nwb :param class_name: string :return:

cicada.preprocessing.utils.flatten(list)[source]

Flatten a nested list no matter the nesting level

Parameters:list (list) – List to flatten
Returns:List without nest

Examples

>>> flatten([1,2,[[3,4],5],[7]])
[1,2,3,4,5,7]
cicada.preprocessing.utils.get_continous_time_periods(binary_array)[source]

take a binary array and return a list of tuples representing the first and last position(included) of continuous positive period :param binary_array: :return:

cicada.preprocessing.utils.load_tiff_movie_in_memory(tif_movie_file_name, frames_to_add=None)[source]

Load tiff movie from filename using Scan Image Tiff

Parameters:tif_movie_file_name (str) – Absolute path to tiff movie
Returns:Tiff movie as 3D-array
Return type:tiff_movie (array)
cicada.preprocessing.utils.load_tiff_movie_in_memory_using_pil(tif_movie_file_name, frames_to_add=None)[source]

Load tiff movie from filename using PIL library

Parameters:
  • tif_movie_file_name (str) – Absolute path to tiff movie
  • frames_to_add – dict with key an int representing the frame index after which add frames. the value is the number of frames to add (integer)
Returns:

Tiff movie as 3D-array

Return type:

tiff_movie (array)

cicada.preprocessing.utils.merging_time_periods(time_periods, min_time_between_periods)[source]

Take a list of pair of values representing intervals (periods) and a merging thresholdd represented by min_time_between_periods. If the time between 2 periods are under this threshold, then we merge those periods. It returns a new list of periods. :param time_periods: list of list of 2 integers or floats. The second value represent the end of the period, the value being included in the period. :param min_time_between_periods: a float or integer value :return: a list of pair of list.

cicada.preprocessing.utils.sort_by_param(nwb_path_list, param_list)[source]

Sort NWB files depending on a list of parameters

Parameters:
  • nwb_path_list (list) – List of absolute path to NWB files
  • param_list (list) – List of parameters to sort by
Returns:

List of NWB files sorted

Return type:

nwb_sorted_list (list)

cicada.preprocessing.utils.update_frames_to_add(frames_to_add, nwb_file, ci_sampling_rate)[source]

Update frames_to_add (dict), based on pause_intervals and ci_frames_time_series :param frames_to_add: dict, with key an int representing the frame index after which add frames. :param the value is the number of frames to add: :type the value is the number of frames to add: integer :param nwb_file: nwb file, will get nwb_file.intervals[‘ci_recording_on_pause’] and :param nwb_file.get_acquisition: :type nwb_file.get_acquisition: “ci_frames”

Returns:

Appendix

UML graph of preprocessing module

Analysis

Analysises

Main analysis class

class cicada.analysis.cicada_analysis.CicadaAnalysis(name, short_description, family_id=None, long_description=None, data_to_analyse=None, data_format=None, config_handler=None, gui=True)[source]

An abstract class that should be inherit in order to create a specific analyse

add_argument_for_gui(with_incremental_order=True, **kwargs)[source]
Parameters:
  • **kwargs
  • with_incremental_order – boolean, if True means the order of the argument will be the same as when added

Returns:

add_ci_movie_arg_for_gui(long_description=None)[source]

Will add an argument for gui, named ci_movie that will list all calcium imaging available for each session Returns:

add_segmentation_arg_for_gui()[source]

Will add an argument for gui, named segmentation that will list all segmentations available for each session Returns:

check_data()[source]

Check the data given one initiating the class and return True if the data given allows the analysis implemented, False otherwise. :return: a boolean

create_results_directory(dir_path)[source]

Will create a directory in dir_path with the name of analysis and time at which the directory is created so it can be unique. The attribute _results_path will be updated with the path of this new directory :param dir_path: path of the dir in which create the results dir

Returns: this new directory

get_data_identifiers()[source]

Return a list of string representing each data to analyse Returns:

get_data_to_analyse()[source]
Returns:a list of the data to analyse
get_results_path()[source]

Return the path when the results from the analysis will be saved or None if it doesn’t exist yet Returns:

run_analysis(**kwargs)[source]

Run the analysis :param kwargs: :return:

set_arguments_for_gui()[source]

Need to be implemented in order to be used through the graphical interface. super().set_arguments_for_gui() should be call first to instantiate an AnalysisArgumentsHandler and create the attribution for results_path :return: None

set_data(data_to_analyse, data_format='nwb')[source]

A list of :param data_to_analyse: list of data_structure :param data_format: indicate the type of data structure. for NWB, NIX

update_original_data()[source]

To be called if the data to analyse should be updated after the analysis has been run. :return: boolean: return True if the data has been modified

update_progressbar(time_started, increment_value=0, new_set_value=0)[source]
Parameters:
  • time_started (float) – Start time of the analysis
  • increment_value (float) – Value that should be added to the current value of the progress bar
  • new_set_value (float) – Value that should be set as the current value of the progress bar

Argument handler

class cicada.analysis.cicada_analysis_arguments_handler.AnalysisArgumentsHandler(cicada_analysis)[source]

Handle the AnalysisArgument instances for a given CicadaAnalysis instance. Allows to create the widgets and get the values to pass to run_analysis() of the CicadaAnalysis instance.

add_argument(**kwargs)[source]
Parameters:**kwargs

Returns:

check_arguments_validity()[source]

Check if all mandatory arguments have been filled Returns: True if we can run the analysis

get_analysis_argument(arg_name)[source]
Parameters:arg_name

Returns:

get_analysis_arguments(sorted=False)[source]
Parameters:sorted

Returns:

get_gui_widgets(group_by_family=False)[source]

Get the list of widgets necessary to fill the arguments for the cicada analysis associated :param group_by_family: if True, group the widgets in one widget to be grouped together if they belong to the same :param family. AnalysisArgument will have an attribute named family_widget whose value is a string.:

Returns:

load_analysis_argument_from_yaml_file(file_name)[source]

Set the analysis argument value based on the value in the yaml file. The :param file_name:

Returns:

save_analysis_arguments_to_yaml_file(path_dir, yaml_file_name)[source]

Save the arguments value to a yaml file. The first key will represent the argument name then the value will be a dict with the argument details such as the type etc… :param path_dir: directory in which save the yaml file :param yaml_file_name: yaml file name, with the extension or without (will be added in that case)

Returns:

set_argument_value(arg_name, **kwargs)[source]

Set an argument values, will be use to run analysis :param arg_name: :param **kwargs:

Returns:

set_widgets_to_default_value()[source]

Set the widgets to the default value of their AnalysisArgument Returns:

Format wrapper

class cicada.analysis.cicada_analysis_format_wrapper.CicadaAnalysisFormatWrapper(data_ref, data_format, load_data=True)[source]

An abstract class that should be inherit in order to create a specific format wrapper

age

Age of the subject :return: None if age unknown

contains_ci_movie(consider_only_2_photons)[source]

Indicate if the data object contains at least one calcium imaging movie :param consider_only_2_photons: boolean, it True means we consider only 2 photons calcium imaging movies, :param if other exists but not 2 photons, then False will be return:

Returns: True if it’s the case, False otherwise

genotype

Genotype of the subject :return: None if age unknown

get_ci_movies(only_2_photons)[source]

Return a dict with as key a string identifying the movie, and as value a dict of CI movies a string as file_name if external, or a 3d array :param only_2_photons: return only the 2 photon movies

Returns:

get_identifier(session_data)[source]

Get the identifier of one of the data to analyse :param session_data: Data we want to know the identifier

Returns: A hashable object identfying the data

get_intervals_names()[source]

Return a list representing the intervals contains in this data Returns:

get_pixel_mask(segmentation_info)[source]

Return pixel_mask which is a list of list of pair of integers representing the pixels coordinate (x, y) for each cell. the list length is the same as the number of cells. :param segmentation_info: object (could be list, dict etc…) given information about how to reach the pixel_mask :param data:

Returns:

get_roi_response_series()[source]

Returns: a list or dict of objects representing all roi response series (rrs) names rrs could represents raw traces, or binary raster, and its link to a given segmentation. The results returned should allow to identify the segmentation associated. Object could be strings, or a list of strings, that identify a rrs and give information how to get there.

get_segmentations()[source]

Returns: a list or dict of objects representing all segmentation names up the segmentation planes (like in nwb) Object could be strings, or a list of strings, that identify a segmentation and give information how to get there.

identifier

Identifier of the session :return:

load_data()[source]

Load data in memory Returns:

sex

Sex (gender) of the subject :return: None if sex unknown

species

Species of the subject :return: None if age unknown

subject_id

Id of the subject :return: None if age unknown

weight

Id of the subject :return: None if age unknown

NWB wrapper

class cicada.analysis.cicada_analysis_nwb_wrapper.CicadaAnalysisNwbWrapper(data_ref, load_data=True)[source]

Allows to communicate with the nwb format

age

Age of the subject :return: None if age unknown

contains_ci_movie(consider_only_2_photons)[source]

Indicate if the data object contains at least one calcium imaging movie represented by an instance of pynwb.image.ImageSeries :param consider_only_2_photons: boolean, it True means we consider only 2 photons calcium imaging movies, :param if other exists but not 2 photons, then False will be return:

Returns: True if it’s the case, False otherwise

genotype

Genotype of the subject :return: None if age unknown

get_ci_movies(only_2_photons)[source]

Return a dict with as key a string identifying the movie, and as value a dict of CI movies a string as file_name if external, or a 3d array :param only_2_photons: return only the 2 photon movies

Returns:

get_identifier(session_data)[source]

Get the identifier of one of the data to analyse :param session_data: Data we want to know the identifier

Returns: A hashable object identfying the data

get_intervals_names()[source]

Return a list representing the intervals contains in this data Returns:

get_pixel_mask(segmentation_info)[source]

Return pixel_mask which is a list of list of pair of integers representing the pixels coordinate (x, y) for each cell. the list length is the same as the number of cells. :param segmentation_info: a list of 3 elements: first one being the name of the module, then the name :param of image_segmentation and then the name of the segmentation plane.:

Returns:

get_roi_response_series()[source]

Returns: a list or dict of objects representing all roi response series (rrs) names rrs could represents raw traces, or binary raster, and its link to a given segmentation. The results returned should allow to identify the segmentation associated. Object could be strings, or a list of strings, that identify a rrs and give information how to get there.

get_segmentations()[source]

Returns: a dict that for each step till plane_segmentation represents the different option. First dict will have as keys the name of the modules, then for each modules the value will be a new dict with keys the ImageSegmentation names and then the value will be a list representing the segmentation plane

identifier

Identifier of the session :return:

load_data()[source]

Load data in memory Returns:

sex

Sex (gender) of the subject :return: None if sex unknown

species

Species of the subject :return: None if age unknown

subject_id

Id of the subject :return: None if subject_id unknown

weight

Id of the subject :return: None if weight unknown

Cells count

Connectivity graph

class cicada.analysis.cicada_connectivity_graph.CicadaConnectivityGraph[source]
check_data()[source]

Check the data given one initiating the class and return True if the data given allows the analysis implemented, False otherwise. :return: a boolean

run_analysis(**kwargs)[source]

test :param kwargs: :return:

update_original_data()[source]

To be called if the data to analyse should be updated after the analysis has been run. :return: boolean: return True if the data has been modified

Frames count

Hubs analysis

class cicada.analysis.cicada_hubs_analysis.CicadaHubsAnalysis[source]
check_data()[source]

Check the data given one initiating the class and return True if the data given allows the analysis implemented, False otherwise. :return: a boolean

run_analysis(**kwargs)[source]

test :param kwargs: :return:

update_original_data()[source]

To be called if the data to analyse should be updated after the analysis has been run. :return: boolean: return True if the data has been modified

PSTH analysis

class cicada.analysis.cicada_psth_analysis.CicadaPsthAnalysis[source]
check_data()[source]

Check the data given one initiating the class and return True if the data given allows the analysis implemented, False otherwise. :return: a boolean

run_analysis(**kwargs)[source]

test :param kwargs: :return:

set_arguments_for_gui()[source]

Returns:

update_original_data()[source]

To be called if the data to analyse should be updated after the analysis has been run. :return: boolean: return True if the data has been modified

Annexe

UML graph of analysis module

GUI

Graphic interface to launch analyses

Main Window

class cicada.gui.cicada_main_window.CicadaMainWindow(config_handler)[source]

Main window of the GUI

about()[source]

Small about QMessageBox for the project

add_data()[source]

Open a directory

add_group_data(group_name)[source]

Add a group of saved sessions to the current list of session

Parameters:group_name (str) – Name of the group saved in YAML
closeEvent(event)[source]

Close all analyses windows on main window close

createActions()[source]

Create some QAction

createMenus()[source]

Create menu bar and put some menu in it

create_group_menu()[source]

Create group menu

create_sort_menu()[source]

Create sort menu

load_data_from_config()[source]

Check if the last dir opened is saved in config and load it automatically

load_data_from_dir(dir_name, method)[source]

Load data (currently only NWB) from selected directory

Parameters:
  • dir_name (str) – Path to data
  • method (str) – String to choose whether to add data to the existing dataset or open a new one, takes two values : ‘add’ or ‘clear’
load_group(group_name)[source]

Load a group of saved sessions, it will clear the current session list

Parameters:group_name (str) – Name of the group saved in YAML
load_group_from_config()[source]

Load groups from a YAML file in the config folder

on_group(param, state)[source]

Give group list and parameters value to populate QListWidget

Parameters:
  • param (str) – Parameter to group by
  • state (int) – State of the checkbox
on_sort(param, state)[source]

Give sorted list to populate QListWidget :param param: Parameter to sort by :type param: str :param state: State of the checkbox :type state: int

openWindow()[source]

Open all widgets in a CentralWidget and call some menus that needed those widgets

open_new_dataset()[source]

Open a directory

populate_menu()[source]

Populate the menu to load groups

save_last_data_location(dir_name)[source]

Keep path to last data directory selected in a YAML in config

Parameters:dir_name (str) – Path to data to be saved
see_all_groups()[source]

Display a widget with all existing groups

select_group(group_name)[source]

Select all sessions of a group

Parameters:group_name (str) – Name of the group saved in YAML
uncheck_all_sort()[source]

Uncheck all checkboxes in sort menu

uncheck_group(param='')[source]

Uncheck group menu parameter

Parameters:param (str) – Parameter name to uncheck
class cicada.gui.cicada_main_window.MusketeersWidget(config_handler, cicada_main_window=None)[source]

Gather in a layout the 3 main sub-windows composing the gui: displaying the subject sessions, the analysis tree and an overview of the running analysis

Filter/group sessions

Display metadata

Analysises list

class cicada.gui.cicada_analysis_tree_gui.AnalysisTreeApp(parent, config_handler, to_parameters_button=None)[source]
create_tree_model()[source]

Create the tree model Returns: the tree model, an instance of QAnalysisTreeModel

doubleClickedItem(idx)[source]

Method called when the user double click in the tree :param idx: Index of the branch clicked

Returns:

init_ui()[source]

Set some of the elements used to build the tree Returns:

invalidate_all_items()[source]

invalidate all items if the tree Returns:

load_arguments_parameters_section()[source]

Used to load the parameters section with widgets, based on the current selection in the tree. If the selection is not on any valid tree item, nothing will happen Returns: None

set_data(data_to_analyse, data_format)[source]

Give to the tree the data that the analysis classes will be given to analyze. Allows the tree to inactivate the analyses for which the data don’t fulfill the requierements :param data_to_analyse: a list of data in a given format (could be nwb or other) :param data_format: format of the data, must be a string. So far only “nwb” is supported

Returns: None

class cicada.gui.cicada_analysis_tree_gui.QAnalysisTreeModel(tree_item, parent=None)[source]
columnCount(self, parent: QModelIndex = QModelIndex()) → int[source]
data(index, role)[source]
Parameters:
  • index
  • role
Returns:

flags(self, QModelIndex) → Qt.ItemFlags[source]
headerData(self, int, Qt.Orientation, role: int = Qt.DisplayRole) → Any[source]
index(self, int, int, parent: QModelIndex = QModelIndex()) → QModelIndex[source]
parent(self, QModelIndex) → QModelIndex[source]

parent(self) -> QObject

rowCount(self, parent: QModelIndex = QModelIndex()) → int[source]
class cicada.gui.cicada_analysis_tree_gui.QAnalysisTreeView(tree_item, config_handler, parent=None)[source]
drawBranches(self, QPainter, QRect, QModelIndex)[source]
isIndexHidden(q_model_index)[source]

Avoid to select the line that display the family name :param q_model_index: :return:

keyPressEvent(event)[source]
Parameters:event – P -> set background picture

Returns:

cicada.gui.cicada_analysis_tree_gui.fill_tree_item_with_dict(root_tree, instances_dict)[source]

Recursive function that fills the root_tree according to data in instances_dict. :param root_tree: instance of TreeItem :param instances_dict: Contains instance of cicada_analysis, in a hierarchy similar to the one we want the tree to be :return:

Overview of analysises

class cicada.gui.cicada_analysis_overview.AnalysisOverview(config_handler, parent=None)[source]

Class containing the overview linked to an analysis

add_analysis_overview(cicada_analysis, analysis_id, obj)[source]

Add widgets to track the corresponding analysis :param cicada_analysis: CicadaAnalysis instance :type cicada_analysis: CicadaAnalysis :param analysis_id: Randomly generated ID linked to the analysis :type analysis_id: str :param obj: The analysis window’s object itself :type obj: object

keyPressEvent(self, QKeyEvent)[source]
class cicada.gui.cicada_analysis_overview.AnalysisState(analysis_id, cicada_analysis, parent=None, without_bringing_to_front=False)[source]

Class containing the name of the analysis and the subjects analysed

bring_to_front(window_id, event)[source]

Bring corresponding analysis window to the front (re-routed from the double click method)

Parameters:
  • window_id (QWidget) – Analysis Widget object
  • event (QEvent) – Double click event
deleteLater()[source]

Re-implementation of the deleteLater method to properly delete the whole widget

class cicada.gui.cicada_analysis_overview.ResultsButton(cicada_analysis)[source]

Class containing the button to open the result folder

deleteLater()[source]

Re-implementation of the deleteLater method to properly delete the widget

open_explorer()[source]

Open the file explorer depending on the OS

Analysis parameters

class cicada.gui.cicada_analysis_parameters_gui.AnalysisData(cicada_analysis, arguments_section_widget, config_handler, parent=None)[source]
keyPressEvent(event)[source]
Parameters:event – P -> set background picture

Returns:

populate_session_list(session_list)[source]

Add all session to the QListWidget :param session_list: List of all sessions’ identifier :type session_list: list

class cicada.gui.cicada_analysis_parameters_gui.AnalysisPackage(cicada_analysis, analysis_name, name, main_window, config_handler, parent=None)[source]

Widget containing the whole analysis window

bring_to_front(window_id, event)[source]

Bring corresponding window to the front (re-routed from the double click method)

Parameters:
  • window_id (QWidget) – Analysis Widget object
  • event (QEvent) – Double click event
errOutputWritten(text, path)[source]

Append std.err text to the QLabel and create an err file.

Parameters:
  • text (str) – Output of the standard output in python interpreter
  • path (str) – path where we will output the err file
normalOutputWritten(text, path)[source]

Append std.out text to the QLabel and create a log file.

Parameters:
  • text (str) – Output of the standard output in python interpreter
  • path (str) – path where we will output the log file
on_close(event)[source]

Check if an analysis is still on going and prompt the user to let him know then ask whether he still wants to close. If yes, delete the associated overview and stop the thread

Parameters:event (QEvent) – Qt Event triggered when attempting to close the window
class cicada.gui.cicada_analysis_parameters_gui.AnalysisParametersApp(thread_name, progress_bar, analysis_name, config_handler, parent=None)[source]

Class containing the parameters widgets

create_widgets(cicada_analysis)[source]
Parameters:cicada_analysis (CicadaAnalysis) – Chosen analysis
keyPressEvent(event)[source]
Parameters:event – P -> set background picture

Returns:

load_arguments()[source]

Will open a FileDialog to select a yaml file used to load arguments used for a previous analysis

reset_arguments()[source]

Reset all arguments to default value

run_analysis()[source]

Check if the parameters are valid and then create a thread which will run the analysis

save_yaml_with_name()[source]

Save parameters as a YAML file under the name given by the user. The path is retrieved from the config file and if it doesn’t exist a QFileDialog will be displayed to select the path

tabula_rasa()[source]

Erase the widgets and make an empty section

class cicada.gui.cicada_analysis_parameters_gui.CheckBoxWidget(analysis_arg, parent=None)[source]

Used to set a boolean value

get_value()[source]

Return the value of the widget Returns:

set_value(value)[source]

Set the widget value to the value passed Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.ColorDialogWidget(analysis_arg, show_alpha_channel, parent=None)[source]

Widget used to select a color

get_value()[source]

Returns: a tuple of 4 floats representing RGBA with values from 0.0 to 1.0

open_dialog()[source]

Open the color dialog Returns:

set_value(value)[source]
Parameters:value – a list or tuple of 3 or 4 float between 0.0 to 1.0, RGB or RGBA values, the A representing the alpha

Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

update_button_color()[source]

Returns:

class cicada.gui.cicada_analysis_parameters_gui.ComboBoxWidget(analysis_arg, parent=None)[source]
add_multiple_combo_boxes(session_id, choices_dict, legends, index)[source]

Allows to add multiple combo boxes, each changing the content of the next one for on given session_id :param session_id: :param choices_dict: each key represent a content to put in the list and the value could be either None, either :param another dict which keys will be the content of the next ComboBox etc… or instead of a dict as value it: :param could be a list that will define the content.: :param legends: :param index:

Returns:

get_value()[source]

Returns:

set_value(value)[source]

Set a new value. Either value is None and nothing will happen If value is a list instance, :param value:

Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.EmittingErrStream(parent=None)[source]

Class managing the std.err redirection

write(text)[source]

Override of the write function used to display output :param text: Python output from stdout :type text: str

class cicada.gui.cicada_analysis_parameters_gui.EmittingStream(parent=None)[source]

Class managing the std.out redirection

write(text)[source]

Override of the write function used to display output :param text: Python output from stdout :type text: str

class cicada.gui.cicada_analysis_parameters_gui.FileDialogWidget(analysis_arg, directory_only, extensions=None, parent=None)[source]

Create a widget that will contain a button to open a FileDialog and a label to display the file or directory choosen A label will also explain what this parameter do

get_value()[source]

Return the argument

Returns:Dictionary with the set value
Return type:result_dict (dict)
one_for_all()[source]

Allows to select the same dir of files for all session Returns:

set_value(value)[source]

Set the value :param value: either None, either a string or etiher a dictionary

Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.FinalMeta[source]
class cicada.gui.cicada_analysis_parameters_gui.LineEditWidget(analysis_arg, parent=None)[source]
get_value()[source]

Return the value of the widget Returns:

set_value(value)[source]

Set the widget value to the value passed Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.ListCheckboxWidget(analysis_arg, choices_attr_name, parent=None)[source]

Allows multiple choices

get_value()[source]

Returns:

set_value(value)[source]

Set the value. :param value: value is either a string or integer or float, or a list. If a list, then item whose value matches :param one of the elements in the list will be checkeds:

Returns: None

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.MyFileDialogQButton(key_name, file_dialog, file_dialogs_dict, parent=None)[source]

Special button for opening file dialog

open_dialog()[source]

Open the QFileDialog :param key_name:

Returns:

class cicada.gui.cicada_analysis_parameters_gui.MyQComboBox[source]

Special instance of ComboBox allowing to handle change so that it is connected to other combo_boxes

selection_change(index)[source]

Called if the selection is changed either by the user or by the code :param index:

Returns:

class cicada.gui.cicada_analysis_parameters_gui.MyQFrame(analysis_arg=None, parent=None, with_description=True)[source]
change_mandatory_property(value)[source]

Changing the property allowing to change the style sheet depending on the mandatory aspect of the argument :param value:

Returns:

set_property_to_missing()[source]

Allows the change the stylesheet and indicate the user that a Returns:

class cicada.gui.cicada_analysis_parameters_gui.ParameterWidgetModel[source]
get_value()[source]

Return the value of the widget Returns:

set_value(value)[source]

Set the widget value to the value passed Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.ProgressBar(remaining_time_label, parent=None)[source]

Class containing the progress bar of the current analysis

update_progress_bar(time_elapsed, increment_value=0, new_set_value=0)[source]

Update the progress bar in the analysis widget and the corresponding remaining time :param time_elapsed: Time elepased since beginning of analysis, in seconds :type time_elapsed: float :param increment_value: Value that should be added to the current value of the progress bar :type increment_value: float :param new_set_value: Value that should be set as the current value of the progress bar :type new_set_value: float

Returns:

update_progress_bar_overview(name, increment_value=0, new_set_value=0)[source]

Update the overview progress bar

Parameters:
  • name (str) – Analysis ID
  • time_started (float) – Start time of the analysis
  • increment_value (float) – Value that should be added to the current value of the progress bar
  • new_set_value (float) – Value that should be set as the current value of the progress bar
class cicada.gui.cicada_analysis_parameters_gui.RemainingTime(parent=None)[source]

Class containing the remaining time of the analysis

static correct_time_converter(time_to_convert)[source]

Convert a float in a correct duration value :param time_to_convert: Float value representing seconds to be converted in a correct duration with MM.SS :type time_to_convert: float

Returns:String of the correct duration
Return type:time_text (str)
update_remaining_time(progress_value, time_elapsed, done=False)[source]

Update the remaining time :param progress_value: Current progress bar value :type progress_value: float :param time_elapsed: Time elepased since the beginning of the analysis (in sec) :type time_elapsed: float :param done: True if the analysis is done and false if still running :type done: bool

class cicada.gui.cicada_analysis_parameters_gui.SameFamilyWidgetsContainer(widgets, parent=None)[source]

A QFrame used to group widgets that belongs to a same group. Just useful for visual purposes

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.SliderWidget(analysis_arg, parent=None)[source]

Used to set a numerical value

get_value()[source]

Return the value of the widget Returns:

set_value(value)[source]

Set the widget value to the value passed Returns:

to_stretch()[source]

Indicate if the widget should take all the space of a horizontal layout how might share the space with another widget Returns: Boolean

class cicada.gui.cicada_analysis_parameters_gui.Worker(name, cicada_analysis, analysis_arguments_handler, parent)[source]

Thread to manage multiple analysises at the same time

run()[source]

Run the analysis

setProgress(name, time_elapsed=0, increment_value=0, new_set_value=0)[source]

Emit the new value of the progress bar and time remaining

Parameters:
  • name (str) – Analysis ID
  • time_elapsed (float) – Start elpased (in sec)
  • increment_value (float) – Value that should be added to the current value of the progress bar
  • new_set_value (float) – Value that should be set as the current value of the progress bar
set_results_path(results_path)[source]

Set the selected path to the results in the “Open result folder” button in the corresponding overview

Parameters:results_path (str) – Path to the results
cicada.gui.cicada_analysis_parameters_gui.except_hook(cls, exception, traceback)[source]

Redirect exception to std.err so we can display stack trace on exceptions

Indices and tables