Analysis

Analyses

Main analysis class

class cicada.analysis.cicada_analysis.CicadaAnalysis(name, short_description, accepted_data_formats, 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_analysis_description_for_gui(description)[source]

Add a description that will be displayed as a widget on top of the arguments list :param description:

Returns:

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_bool_option_for_gui(arg_name, true_by_default, short_description, long_description=None, family_widget=None)[source]

Add an option which is a boolean to the menu :param arg_name: (string) used to get back the value :param true_by_default: (bool) :param short_description: (str) :param long_description: (string or None)

Returns:

add_choices_for_groups_for_gui(arg_name, choices, with_color, short_description, long_description=None, family_widget=None, mandatory=False, add_custom_group_field=False, custom_group_validation_fct=None, custom_group_processor_fct=None)[source]

Allows to create group based composed of elements of choices.. :param arg_name: :param choices: :param with_color: If True, means that we can select a color for each group :param short_description: :param long_description: :param family_widget: :param mandatory: (bool) :param add_custom_group_field: if True, add a text field allowing to name the group to be added :param custom_group_validation_fct: if not None, called when a custom group is created to check the text :param field and validate the name. Return True or False. If False: :param the field is erased. Instead of False: :param can: :param return a string: :param in that case a message box will display a message indicating the error: :param custom_group_processor_fct: None or function that process the text in the custom group field and return :param a list of string representing the elements in the group. If this fct is None: :param then the new group will: :param just contain one element the content of the text field that can be then processed later on.:

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_dpi_arg_for_gui(family_widget)[source]

Add dpi value :param family_widget:

Returns:

add_field_float_option_for_gui(arg_name, default_value, mandatory, short_description, long_description=None, family_widget=None)[source]

Add a field to add some float Returns:

add_field_text_option_for_gui(arg_name, default_value, short_description, long_description=None, family_widget=None)[source]

Add a field to add some text Returns:

add_image_format_package_for_gui()[source]

Add a few arguments at once: save_formats, dpi, width_fig & height_fig Returns:

add_open_dir_dialog_arg_for_gui(arg_name, mandatory, short_description, long_description=None, key_names=None, family_widget=None)[source]

Allows to add widget to select a directory. If key_names is given then multiple option are added, one for each key_name :param arg_name: :param mandatory: (boolean) :param short_description: :param long_description: :param key_names: None or list of string :param family_widget:

Returns:

add_open_file_dialog_arg_for_gui(arg_name, extensions, mandatory, short_description, long_description=None, key_names=None, family_widget=None)[source]

Allows to add widget to select a file. If key_names is given then multiple option are added, one for each key_name :param arg_name: :param extensions: str or list of str, ex: “txt” :param mandatory: (boolean) :param short_description: :param long_description: :param key_names: None or list of string :param family_widget:

Returns:

add_save_formats_arg_for_gui(family_widget=None)[source]

Add save_formats option, True or False 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:

add_verbose_arg_for_gui()[source]

Add verbose option, True or False Returns:

add_with_timestamp_in_filename_arg_for_gui()[source]

Add with_timestamp_in_file_name option, True or False Returns:

abstract 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

abstract copy()[source]

Make a copy of the analysis Returns:

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:

is_data_format_accepted(data_format)[source]
Parameters

data_format

Returns: boolean, True is the data format is accepted for this analysis

abstract 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)[source]

A list of :param data_to_analyse: list of data_structure

transfer_attributes_to_tabula_rasa_copy(analysis_copy)[source]

Transfers attributes values from self to a new copy that doesn’t have all information yet :param analysis_copy:

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

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 Two constants should be added on the classe WRAPPER_ID and DATA_FORMAT

property data_ref

Return the path of the file or directory corresponding to this data session :return:

static grouped_by()[source]

Indicate by which factor the data can be grouped ex: age, species, contains behavior, categories of age.. :return: a dictionary with key the name of the group (str) that will be displayed in the GUI, and as value the a sring representing either an argument or a method of the wrapper class (hasattr() and callable() will be use to get them)

abstract property identifier

Identifier of the session :return:

abstract static is_data_valid(data_ref)[source]

Check if the data can be an input for this wrapper as data_ref :param data_ref: file or directory

Returns: a boolean

load_data()[source]

Load data in memory Returns:

NWB wrapper

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

Allows to communicate with the nwb format

abf_status()[source]

Using neuronal data and timestamps to infer if the abf has been used to create the NWB :return:

property age

Age of the subject (int), in days or months :return: None if age unknown, int otherwise, months or days is found with age_unit

property age_unit

Unit for the animal age :return:’D’ for days, ‘M’ for months

cell_types_status()[source]

Return the cells types in a string, or a message saying no cell types :return:

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: :param then False will be return:

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

property genotype

Genotype of the subject :return: None if age unknown

get_acquisition_names()[source]

Returns:

get_all_cell_types()[source]

Return a list of all cell types identified in this session. If the list is empty, it means the type of the cells is not identified Returns:

get_behavior_movies(key_to_identify='behavior')[source]

Return a dict with as key a string identifying the movie, and as value a dict of behavior movies a string as file_name if external, or a 3d array :param key_to_identify: string, key to identify that a movie is a behavior movie

Returns:

get_behavioral_epochs_names()[source]

The name of the different behavioral Returns:

get_behavioral_epochs_times(epoch_name)[source]

Return an interval times (start and stop in seconds) as a numpy array of 2*n_times. :param epoch_name: Name of the interval to retrieve

Returns: None if the interval doesn’t exists or a 2d array

get_behavioral_events_names()[source]

The name of the different behavioral Returns:

get_behavioral_events_times(event_name)[source]

The name of the different behavioral Returns:

get_behavioral_time_series_names()[source]

The name of the different behavioral Returns:

get_behaviors_movie_time_stamps()[source]

return a dict with key the cam id and value np.array with the timestamps of each frame of the behavior movie return None if non available Returns:

get_cell_indices_by_cell_type(roi_serie_keys)[source]

Return a dict with key the cell_type name and value an array of int representing the cell indices of this type :param roi_serie_keys:

Returns:

get_ci_movie_sampling_rate(only_2_photons=False, ci_movie_name=None)[source]
Parameters
  • only_2_photons – if True only 2 photons one are considere

  • ci_movie_name – (string) if not None, return the sampling rate for a given ci_movie, otherwise the first

  • found (one) –

Returns: (float) sampling rate of the movie, return None if no movie is found

get_ci_movie_time_stamps()[source]

return a np.array with the timestamps of each frame of the CI movie return None if non available Returns:

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_ci_movies_sample(only_2_photons, n_frames=2000)[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 :param n_frames: number of frames to take from movie to serve as data sample

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_imaging_plan_location(only_2_photons=False, ci_movie_name=None)[source]
Parameters
  • only_2_photons – if True only 2 photons one are considere

  • ci_movie_name – (string) if not None, return the sampling rate for a given ci_movie, otherwise the first

  • found (one) –

Returns: (str) imaging plan location

get_interval_as_data_frame(interval_name)[source]

Return an interval time as a pandas data frame. :param interval_name: Name of the interval to retrieve

Returns: None if the interval doesn’t exists or a pandas data frame otherwise

get_interval_original_frames(interval_name)[source]

Return an interval times (start and stop in frames) as a numpy array of 2*n_times. :param interval_name: Name of the interval to retrieve

Returns: None if the interval doesn’t exists or a 2d array

get_interval_times(interval_name)[source]

Return an interval times (start and stop in seconds) as a numpy array of 2*n_times. :param interval_name: Name of the interval to retrieve

Returns: None if the interval doesn’t exists or a 2d array

get_intervals_names()[source]

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

get_mouse_position_info()[source]

Returns:

get_mouse_speed_info()[source]

Returns:

get_opto_stimulation_time_serie()[source]

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_serie_data(keys)[source]
Parameters

keys – lsit of string allowing to get the roi repsonse series wanted

Returns:

get_roi_response_serie_data_by_keyword(keys, keyword)[source]

Return a dict with other last key data :param keys: list of string allowing to get the roi response series in data_interfaces :param keyword:

Returns:

get_roi_response_serie_timestamps(keys, verbose=True)[source]
Parameters
  • keys – lsit of string allowing to get the roi repsonse series wanted

  • verbose – print info

Returns:

get_roi_response_series(keywords_to_exclude=None)[source]

param: keywords_to_exclude: if not None, list of str, if one of neuronal data has this keyword, then we don’t add it to the choices

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_roi_response_series_list(keywords_to_exclude=None)[source]

param: keywords_to_exclude: if not None, list of str, if one of neuronal data has this keyword, then we don’t add it to the list

Returns: a list with all roi response series (rrs) names

get_rrs_sampling_rate(keys)[source]

Args:

Returns: (float) sampling rate of the movie, return None if no sampling rate is found

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

get_signal_by_keyword(keyword, exact_keyword=False)[source]

Look for a signal with this keyword. Returns the first instance found that matches it. :param keyword: (str) :param exact_keyword: (bool) if True, the name of the TimeSeries representing the signal should be the same :param as keyword: :param otherwise keyword should be in the name of the TimeSeries:

Returns: a two 1d array representing a signal and its timestamps.

If no sginal with this keyword found, return None, None

get_signal_keys()[source]

Return a list of str representing the key of the signals available. Signals are TimeSeries instance registered as data interfaces in modules. Returns:

get_signals_info()[source]

Returns: a dict that for each step till the TimeSeries name represents the different option. First dict will have as keys the name of the modules, then for each modules the value will be the name of the TimeSeries representing the signal

get_timestamps_range()[source]

Return a tuple of float representing the first and last time stamp with movie recording (behavior or ci movie) Returns:

static grouped_by()[source]

Indicate by which factor the data can be grouped ex: age, species, contains behavior, categories of age.. :return: a dictionary with key the name of the group (str) that will be displayed in the GUI, and as value the a sring representing either an argument or a method of the wrapper class (hasattr() and callable() will be use to get them)

property identifier

Identifier of the session :return:

static is_data_valid(data_ref)[source]

Check if the data can be an input for this wrapper as data_ref :param data_ref: file or directory

Returns: a boolean

load_data()[source]

Load data in memory Returns:

property session_id

Id of the subject :return: None if subject_id unknown

property sex

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

property species

Species of the subject :return: None if age unknown

property subject_id

Id of the subject :return: None if subject_id unknown

property weight

Id of the subject :return: None if weight unknown

Cells count

Connectivity graph

Frames count

Hubs analysis

PSTH analysis

Annexe

UML graph of analysis module