Main Window (GUI)

The graphical user interface of encore is implemented in the encore.main.MainWindow class.

This class is responsible for:

  • Initializing the Qt-based GUI

  • Managing user interaction and state

  • Validating user input

  • Triggering analysis pipelines (runners)

  • Dispatching results to plotting modules

The GUI serves as a front-end to the same analysis functions that can be invoked programmatically or via the command-line interface.

Class Reference

class encore.main.MainWindow(gui_colors=None, *args, **kwargs)

Bases: QMainWindow

bin_matrix(mat, bin_size, bin_method)

Bins the input matrix along the timepoints dimension using the specified binning method.

Parameters:
  • mat (numpy.ndarray of shape (n, t)) – The input matrix to be binned, where each row represents an element and each column represents a timepoint.

  • bin_size (int) – The number of timepoints to include in each bin. Must be smaller than the number of timepoints in mat.

  • bin_method (str) – The method used to bin the data. Options are “mean” to compute the mean of each bin, or “sum” to compute the sum.

Raises:

ValueError – If bin_method is not one of the accepted values (“mean” or “sum”).

Returns:

A matrix with the same number of rows as mat but with columns reduced by the binning operation.

Return type:

numpy.ndarray of shape (n, b)

Example:
>>> mat = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
>>> bin_size = 2
>>> bin_method = "mean"
>>> binned_mat = self.bin_matrix(mat, bin_size, bin_method)
>>> print(binned_mat)
array([[1.5, 3.5],
    [5.5, 7.5]])
browse_files()

Opens a file browing dialog to open a new file.

This function also loads the file tree model and shows it in the variable browser widget.

clear_behavior()

Deletes the value of the MainWindow.data_behavior variable.

This function also updates the buttons related to load and clear the variable At the end the function clears visualization in the MainWindow.data_preview widget.

clear_cells()

Deletes the value of the MainWindow.data_cells variable.

This function also updates the buttons related to load and clear the variable At the end the function clears visualization in the MainWindow.data_preview widget.

clear_coordinates()

Deletes the value of the MainWindow.data_coordinates variable.

This function also updates the buttons related to load and clear the variable At the end the function clears visualization in the MainWindow.data_preview widget.

clear_dFFo()

Deletes the value of the MainWindow.data_dFFo variable.

This function also updates the buttons related to load and clear the variable At the end the function clears visualization in the MainWindow.data_preview widget.

clear_neuronal_activity()

Deletes the value of the MainWindow.data_neuronal_activity variable.

This function also updates the buttons related to load and clear the variable At the end the function clears visualization in the MainWindow.data_preview widget.

clear_stims()

Deletes the value of the MainWindow.data_stims variable.

This function also updates the buttons related to load and clear the variable At the end the function clears visualization in the MainWindow.data_preview widget.

collect_algorithm_data(algorithm_cfg: dict) dict

Collect the needed data for one algorithm using YAML configuration.

Parameters:

algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

Returns:

Dict mapping the requested data in config file, mapping name of parameter and value

Return type:

dict

collect_algorithm_parameters(algorithm_cfg: dict) dict

Collect parameters for one algorithm from the UI using YAML configuration.

Parameters:

algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

Returns:

Dictionary of parameter_name -> value

Return type:

dict

edit_bin()

Reads the binning parameters and performs the binning in the selected dataset.

Loads the bin size and bin method from the UI, and shows feedback to the user about the performed operation. If the input is invalid nothing is changed.

edit_transpose()

Transpose the currently visualized variable.

Simple transpose of the data currently viewed in the MainWindow.data_preview widget. This method changes both the stored data and the visualization. Also, a message is shown to the user about the interpretation of the transpose.

edit_trimmatrix()

Edits the currently visualized matrix by trimming its rows and/or columns based on user-specified indices.

Returns:

None

This method uses the start and end indices entered by the user to trim the matrix currently selected for editing. Depending on the selection, it will trim one of the following datasets: dFFo, neuronal_activity, coordinates, stims, cells, or behavior. For each dataset, if valid start and end indices are provided for the x-axis or y-axis, it slices the data accordingly and updates the view for that dataset.

After trimming, the console log is updated to notify the user, and the appropriate preview function is called to display the updated dataset.

enscomp_get_color()

Opens the QColorDialog to select a color for the selected analysis.

The selected color will be applied to the elements of the algorithm selected in the combo box for the Ensemble Compare tab. :return: None :rtype: None

enscomp_get_color_behavior()

Opens the QColorDialog to select a color for the behavior.

The selected color will be applied to the elements of the behavior. :return: None :rtype: None

enscomp_get_color_stims()

Opens the QColorDialog to select a color for the stimulation.

The selected color will be applied to the elements of the stimulation. :return: None :rtype: None

ensembles_compare_get_elements_labels(criteria: dict)

Retrieves elements and their labels for ensembles comparison based on a given criterion.

This method extracts elements from the results dictionary according to the specified criterion (e.g., neurons in ensemble or timecourse). It also generates labels for these elements, indicating the algorithm and the ensemble index.

If a stimulation matrix is provided, each stimulus is added along with their label.

Parameters:

criteria (string) – The key used to extract elements from each algorithm’s results.

Returns:

A tuple containing the array of elements and their corresponding labels.

Return type:

tuple (numpy.ndarray, list of string)

ensembles_compare_get_simmatrix(method: str, all_elements: ndarray)

Calculates the similarity matrix for a set of elements using the specified method.

This method computes pairwise similarity or distance metrics (e.g., cosine, Euclidean, correlation, Jaccard) and formats the result as a similarity matrix.

Parameters:
  • method (string) – The similarity or distance metric to use. Valid options are: ‘Cosine’, ‘Euclidean’, ‘Correlation’, ‘Jaccard’.

  • all_elements (numpy.ndarray) – A numpy array containing the elements to compare. Each row represents a single element, and columns represent features.

Raises:

ValueError – If an unsupported method is provided.

Returns:

A similarity matrix where each entry represents the pairwise similarity between elements.

Return type:

numpy.ndarray

ensembles_compare_similarity(component=None, first_show=False)

Computes and visualizes the similarity matrix for ensembles based on a selected component.

This method calculates the similarity matrix for ensembles using either the “Neurons” or “Timecourses” component. It updates the visualization options and plots the results.

Parameters:
  • component (str, optional) – Specifies the component to compute the similarity for (“Neurons” or “Timecourses”). If not provided, the currently selected component in the GUI is used.

  • first_show (bool, optional) – Indicates whether this is the initial visualization, which determines default visualization settings.

Returns:

None

Return type:

None

ensembles_compare_similarity_update_combbox(text: str)

Updates the combo boxes for similarity method and colormap based on the selected component.

This method adjusts the currently displayed options in the similarity method and colormap combo boxes to match the visualization settings for the selected component (“Neurons” or “Timecourses”).

Parameters:

text (string) – The selected component, either “Neurons” or “Timecourses”.

Returns:

None

Return type:

None

ensembles_compare_tabchange(index: int)

Handles tab changes in the GUI, updating the interface and displaying similarity maps as needed.

This method is triggered when the user switches tabs in the GUI. It updates the state of dropdown menus and enables/disables specific components depending on the selected tab. If the user navigates to the tabs for “Neurons” or “Timecourses”, it ensures that the similarity maps are displayed for the first time.

Parameters:

index (int) – The index of the currently selected tab.

Returns:

None

Return type:

None

ensembles_compare_update_combo_results(text: str)

Updates the visualization options for the selected algorithm.

This function is executed when the combo box value is changed. Loads the visualization options for the current algorithm.

Parameters:

text (string) – Name of the selected analysis as shown in the combo box.

Returns:

None

Return type:

None

ensembles_compare_update_ensembles()

Updates the ensembles comparison settings and visualizations.

This method collects the selected ensembles from various methods (SVD, PCA, ICA, X2P), updates their corresponding properties (index, neurons in ensemble, and timecourse), and applies the visualization options to the GUI. The method also updates the comparison map and timecourse visualizations.

Returns:

None

Return type:

None

ensembles_compare_update_map(ensembles_to_compare: dict)

Updates the spatial map in ensembles compare.

This function calculates the shared neurons between every ensemble according to the current visualization options, and asigns colors for each neuron in the map.

Parameters:

ensembles_to_compare (dict) – Dictionary with where each key is the name of an algorithm, the value is another dictionary. The key used here is neus_in_ens with a binary numpy matrix with shape with the members of each ensemble.

Returns:

None

Return type:

None

ensembles_compare_update_opts(algorithm: str)

Updates the option buttons with the data from the given analysis.

This function receives the name of some algorithm and then updates the options in the Ensemble Compare tab. In this function the slider and labels of each analysis is assigned and then the general buttons are loaded.

Parameters:

algorithm (string) – String with the name of the algorithm, in lower case and three chars syntax.

Returns:

None

Return type:

None

ensembles_compare_update_timecourses(ensembles_to_compare: dict)

Updates the timecourse plot in the ensembles compare tab.

This function extracts the timecourse of the selected ensembles accordingly with the current visualization options and then plots those in the corresponding figure.

Parameters:

ensembles_to_compare (dict) – Dictionary with where each key is the name of an algorithm, the value is another dictionary. The keys used here are “neus_in_ens” with a binary numpy matrix with shape with the members of each ensemble and “timecourse” with a binary matrix describing the moment of activation of the selected ensembles.

Returns:

None

Return type:

None

ensvis_tabchange(index)

Identifies the tab change in the ensamble visualizer for asynchronous loading of plots.

The loading of all the comparations and plots could be slow when loaded all at the same time. For this, the plots are loaded only when the user reaches the relevant tab.

Parameters:

index (int) – Index of the tab opened by the user.

flatten_dict(dict_to_flatten: dict, parent_key='', sep='/') dict

Recunsively flattens the keys in a dictionary to create a new dictionary where each key contains all the keys needed to get to the value. For example, aplying this function to the dictionary: input[‘first’][‘element_a’] = 1 input[‘first’][‘element_b’] = 2 input[‘second’] = 3 Will produce: result[‘first/element_a’] == 1 result[‘first/element_b’] == 2 result[‘second’] == 3

Args:

dict_to_flatten (dict): Dictionary to flatten parent_key (str, optional): Parent top key. Defaults to “”. sep (str, optional): Character to be used as separator. Defaults to “/”.

Returns:

dict: Dictionary with the flatten keys and elements.

get_data_to_save()

Prepares data for saving based on the selected checkboxes in the GUI.

This method compiles data from various sources, including input data, results, analysis parameters, algorithms results, ensembles comparison, and performance metrics. It gathers and organizes the data to be saved into a dictionary format, which can later be written to a file. The specific data included depends on the user’s selections in the GUI checkboxes.

It collects the following data: - Input data (e.g., dFFo, neuronal activity, stimuli, coordinates, behavior, etc.) - Results from the ensembles comparison - Parameters used in the analysis - Full algorithm results - Performance metrics for ensembles, including correlation with stimuli, behavior, and cross-correlation

Returns:

A dictionary containing the data to be saved.

Return type:

dict

initialize_ensemble_view()

Loads the slider for ensemble selection for the chosen analysis and sets its limits.

Returns:

None

Return type:

None

This function makes available the ensemble selector. This function also loads the visualization of the first ensemble.

initialize_user_algorithms()

Build algorithm tabs dynamically from YAML configuration.

item_clicked(index)

Handles the click event on a variable in the MainWindow.tree_view, displaying relevant information about the selected variable and enabling or disabling assign and clear buttons in the UI.

Parameters:

index (QModelIndex) – The index of the clicked item in the file model.

Returns:

None

This method retrieves information about the selected variable, including its path in the file, type, and size. The item’s name is extracted from the path and displayed along with its description in the UI. Depending on the type and size of the item, it enables or disables specific buttons related to the assigning to a dataset. The relevant information is also stored for further processing.

load_algorithm_defaults(algorithm_cfg: dict)

Load default values from config into parameter widgets.

Parameters:

algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

load_project_metadata(package_name: str) dict

Load project metadata from the installed package.

Parameters:

package_name (str) – Name of the installed package (e.g. ‘encore’)

Returns:

Project metadata dictionary

Return type:

dict

main_tabs_change(index)

Identifies the change in tabs to load some data.

This function allows the asynchronous verification and loading of some tabs identified by index. For the analysis tabs, the necessary data is evaluated and then change the text accordingly. For the ensembles compare tab the visualizations are only loaded when the user reaches this tab.

Parameters:

index (int) – Index of the currently open tab, 0 indexing.

parse_project_urls(project_urls: list[str]) dict
performance_check_change()

Updates the list of selected methods for performance comparison based on user input.

This method checks the state of multiple checkboxes corresponding to different analysis methods and updates the list of methods to compare. It also enables or disables the compare button based on whether any methods are selected.

Returns:

None

Return type:

None

performance_compare()

Performs performance comparison and initializes relevant performance tabs.

This method sets up temporary variables to track which performance tabs have been displayed, sets the default tab to the first tab, and updates the correlations with stimulus data if such data is available.

Returns:

None

Return type:

None

performance_tabchange(index: int)

Handles tab changes in the performance analysis section of the GUI, triggering updates for the selected tab.

This method ensures that specific updates are performed when the user switches tabs in the performance analysis section. Each tab corresponds to a different type of performance metric or visualization.

Parameters:

index (int) – The index of the currently selected tab. - 0: Correlation with ensemble presentation - 1: Correlations between cells - 2: Cross correlations between ensembles and stimuli - 3: Correlation with behavior - 4: Cross correlations with behavior

Returns:

None

Return type:

None

plot_algorithm_plots(algorithm_cfg: dict, answer: dict)

Runs the plot function for a given algorithm

Parameters:
  • algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

  • answer (dict) – Dictionary with the answer of the algorithm.

reset_gui()

Reset the GUI, delete all the variables and analysis results. Also clears all the figures and restores the analysis and display options. The result is the GUI just like the first time you opened it.

run_algorithm(algorithm_cfg: dict)

Runs once the run algorithm button is pressed. Loads the parameters and the necessary data, clears the figures and start the parallel worker for the requested algorithm

Parameters:

algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

run_algorithm_end(algorithm_cfg: dict, times: list)

Runs after an algorithm has finished running. Reports the running times and number of ensembels identified to the log box.

Parameters:
  • algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

  • params (list[float, float, float, int]) – list of times in the order [engine_time, running_time, plotting_time, ensembles_found]

run_analysis_function(algorithm_cfg: dict, params: dict, data: dict, logger=None)

Dynamically load and execute an analysis function.

Parameters:
  • algorithm_cfg (dict) – Dictionary with the algorithm definition as described in encore/config/encore_runners_config.yaml

  • params (dict) – Validated parameters dictionary

  • data (dict[var_name] = numpy.ndarray) – Dict mapping variable name and data matrix provided by the pipeline. Available variables are ‘data_neuronal_activity’, ‘data_dFFo’, ‘data_coordinates’ ‘data_stims’, ‘data_cells’, ‘data_behavior’. Each variable is expected to contain numpy matrix with shape (items, timepoints).

  • logger – Function to use to report the progress and error of the function logger(srt, srt). The first string defines the message and the second the log level

save_data_to_hdf5(group, data)

Recursively saves data to an HDF5 file group.

This method iterates through a dictionary and saves its contents to the provided HDF5 group. If a value in the dictionary is another dictionary, it creates a subgroup and recursively saves its contents. If the value is a list, it attempts to create a dataset in the group, catching exceptions if the data cannot be saved. For other data types, the method directly stores the value in the group.

Parameters:
  • group (h5py.Group) – The HDF5 group to which the data will be saved.

  • data (dict) – The data to be saved, which can be a dictionary, list, or other types.

save_results_hdf5()

Saves the current results to an HDF5 file.

This method retrieves the data to be saved using MainWindow.get_data_to_save(), prompts the user to choose a location and name for the file, and then saves the data in HDF5 format. The file is saved using the MainWindow.save_data_to_hdf5() method to recursively write the data into the file.

The file is named based on the current date and a prefix “ENCORE”, and the user is prompted to choose a location and file name via a file dialog.

Raises:

IOError – If the file could not be saved.

save_results_mat()

Saves the current results to a MATLAB (.mat) file.

This method retrieves the data to be saved using the MainWindow.get_data_to_save() method, prompts the user to choose a location and file name using a file dialog, and then saves the retrieved data into a MATLAB .mat file using the scipy.io.savemat() function.

The default file name is based on the current date and a prefix “ENCORE”. If the user cancels or does not provide a file name, the function will not proceed.

If an error occurs while saving the file, a message is shown to notify the user that the file could not be saved.

save_results_npz()

Saves the current results to a Numpy NPZ (.npz) file.

This method retrieves the data to be saved using the MainWindow.get_data_to_save() method, prompts the user to choose a location and file name using a file dialog, and then saves the retrieved data into a NPZ (.npz) file.

The default file name is based on the current date and a prefix “ENCORE”. If the user cancels or does not provide a file name, the function will not proceed.

If an error occurs while saving the file, a message is shown to notify the user that the file could not be saved.

save_results_pkl()

Saves the current results to a Pickle (.pkl) file.

This method retrieves the data to be saved using the MainWindow.get_data_to_save() method, prompts the user to choose a location and file name using a file dialog, and then saves the retrieved data into a Pickle (.pkl) file. The Pickle format is a binary format used for serializing Python objects.

The default file name is based on the current date and a prefix “ENCORE”. If the user cancels or does not provide a file name, the function will not proceed.

If an error occurs while saving the file, a message is shown to notify the user that the file could not be saved.

set_able_edit_options(boolval)

Changes the enabled status of the editing options.

Parameters:

boolval (bool) – When true, all the buttons for editing are enabled, dissabled otherwise.

set_behavior()

Sets the value of the MainWindow.data_behavior variable.

The assigned value is the one of the selected variable in the variable broswer. This function also updates the buttons related to load and clear the variable and triggers the visualization function. At the end the function shows the loaded data in the MainWindow.data_preview widget.

set_cells()

Sets the value of the MainWindow.data_cells variable.

The assigned value is the one of the selected variable in the variable broswer. This function also updates the buttons related to load and clear the variable and triggers the visualization function. At the end the function shows the loaded data in the MainWindow.data_preview widget.

set_coordinates()

Sets the value of the MainWindow.data_coordinates variable.

The assigned value is the one of the selected variable in the variable broswer. Only the first two elements of the second dimention are assigned. This function also updates the buttons related to load and clear the variable and triggers the visualization function. At the end the function shows the loaded data in the MainWindow.data_preview widget.

set_dFFo()

Sets the MainWindow.data_dFFo dataset by assigning data from a file and updating the relevant UI components.

This method loads the dFFo dataset from the selected file. It then updates the UI to reflect that the dataset has been assigned, enables buttons for further edition, and logs the update message.

Returns:

None

set_neuronal_activity()

Sets the MainWindow.data_neuronal_activity dataset by assigning data from a file and updating the relevant UI components.

This method loads the data_neuronal_activity dataset from the selected file and extracts the number of cells (cant_neurons) and time points (cant_timepoints). It then updates the UI to reflect that the dataset has been assigned, enables buttons for further edition, and logs the update message.

Returns:

None

set_stims()

Sets the value of the MainWindow.data_stims variable.

The assigned value is the one of the selected variable in the variable broswer. This function also updates the buttons related to load and clear the variable and triggers the visualization function. At the end the function shows the loaded data in the MainWindow.data_preview widget.

set_theme()

Toggles the dark or light mode based on the status of the mode check box.

setup_about_tab()

Populate the About tab using metadata from pyproject.toml.

update_analysis_results()

Pre-loads the General tab in the ensembles visualizer.

Returns:

None

Return type:

None

This function also saves the state of shown/not-shown of the other tabs for asynchronous loading and caching.

update_console_log(message, level='log')

Updates the console log with a new message, formatted with a specific color based on the message type.

Parameters:
  • message (str) – The message to be displayed in the console log.

  • level (str, optional) – The type of the message, which determines its color. It can be one of “log”, “error”, “warning”, or “complete”. Defaults to “log”.

Returns:

None

This method formats the log entry by including the current timestamp and the provided message. The message is displayed in a monospace font with different colors based on the message type. The new message is appended to the console log, and the view is updated to scroll to the bottom to ensure the message is visible.

update_corr_behavior()

Updates the plot of correlation with behavior data by initiating a parallel worker thread.

This method retrieves the plot widget for displaying correlation with behavior, and starts a worker thread to perform the correlation update in parallel, which is then rendered in the plot widget.

Returns:

None

Return type:

None

update_corr_behavior_parallel(plot_widget, logger=None)

Calculates and updates the correlation between the ensemble timecourses and behavior data.

This method computes the correlation for each selected method (e.g., SVD, PCA, ICA, etc.) between the ensemble timecourses and the behavior data, and then updates the plot widget with the results. It handles the display by organizing the plots into a specified layout based on the number of methods being compared.

Parameters:
  • plot_widget (MatplotlibWidget) – The widget used to display the correlation plots.

  • logger – Function to use to report the progress and error of the function logger(srt, srt). The first string defines the message and the second the log level

Returns:

None

Return type:

None

update_corr_stim()

Updates the plot of correlation with stimulus data by initiating a parallel worker thread.

This method retrieves the plot widget for displaying correlation with stimuli, and starts a worker thread to perform the correlation update in parallel, which is then rendered in the plot widget.

Returns:

None

Return type:

None

update_corr_stim_parallel(plot_widget, logger=None)

Calculates and updates the correlation between the ensemble timecourses and stimulus data.

This method computes the correlation for each selected method (e.g., SVD, PCA, ICA, etc.) between the ensemble timecourses and the stimulus data, and then updates the plot widget with the results. It handles the display by organizing the plots into a specified layout based on the number of methods being compared.

Parameters:
  • plot_widget (MatplotlibWidget) – The widget used to display the correlation plots.

  • logger – Function to use to report the progress and error of the function logger(srt, srt). The first string defines the message and the second the log level

Returns:

None

Return type:

None

update_correlation_cells()

Updates the plot of correlation between the activations of the neurons in the same ensemble by initiating a parallel worker thread.

This method retrieves the plot widget for displaying correlation between the neurons in the ensembles, and starts a worker thread to perform the correlation update in parallel, which is then rendered in the plot widget.

Returns:

None

Return type:

None

update_correlation_cells_parallel(plot_widget, logger=None)

Calculates and updates the correlation between the activation of the cells in the ensemble.

This method computes the correlation for each selected method (e.g., SVD, PCA, ICA, etc.) between the neurons in the ensemble, and then updates the plot widget with the results. It handles the display by organizing the plots into a specified layout based on the number of methods being compared.

Parameters:
  • plot_widget (MatplotlibWidget) – The widget used to display the correlation plots.

  • logger – Function to use to report the progress and error of the function logger(srt, srt). The first string defines the message and the second the log level

Returns:

None

Return type:

None

update_cross_behavior()

Updates the plot of cross-correlation with behavior data by initiating a parallel worker thread.

This method retrieves the plot widget for displaying cross-correlation with behavior, and starts a worker thread to perform the cross-correlation update in parallel, which is then rendered in the plot widget.

Returns:

None

Return type:

None

update_cross_behavior_parallel(plot_widget, logger=None)

Calculates and updates the cross-correlation between the ensemble timecourses and behavior data.

This method computes the cross-correlation for each selected method (e.g., SVD, PCA, ICA, etc.) between the ensemble timecourses and the behavior data, and then updates the plot widget with the results. It handles the display by organizing the plots into a specified layout based on the number of methods being compared.

Parameters:

plot_widget (MatplotlibWidget) – The widget used to display the cross-correlation plots.

Returns:

None

Return type:

None

update_cross_ens_stim()

Updates the plot of cross-correlation with stimulus data by initiating a parallel worker thread.

This method retrieves the plot widget for displaying cross-correlation with stimuli, and starts a worker thread to perform the cross-correlation update in parallel, which is then rendered in the plot widget.

Returns:

None

Return type:

None

update_cross_ens_stim_parallel(plot_widget, logger=None)

Calculates and updates the cross-correlation between the ensemble timecourses and stimulus data.

This method computes the cross-correlation for each selected method (e.g., SVD, PCA, ICA, etc.) between the ensemble timecourses and the stimulus data, and then updates the plot widget with the results. It handles the display by organizing the plots into a specified layout based on the number of methods being compared.

Parameters:
  • plot_widget (MatplotlibWidget) – The widget used to display the cross-correlation plots.

  • logger – Function to use to report the progress and error of the function logger(srt, srt). The first string defines the message and the second the log level

Returns:

None

Return type:

None

update_datetime()

Updates the date time object in the current session, used in the saved results files.

update_edit_validators(lim_sup_x=10000000, lim_sup_y=10000000, xl='time', yl='cells')

Update the validators for bining and slicing. Also reports to the corresponding labels.

Parameters:
  • lim_sup_x (int, optional) – Maximum value possible for the x dimention, defaults to 10000000

  • lim_sup_y (int, optional) – Mavimum value possible for the y dimention, defaults to 10000000

  • xl (str, optional) – Optional label to describe the meaning of the items in x, defaults to “time”

  • yl (int, optional) – Optional label to describe the meaning of the items in y, defaults to “cells”

update_ens_vis_coords()

Shows the neurons maps in the ensembles visualizer and enables the visualizer buttons.

This is a separated function to be executed also when the visualization options are updated and show the visualization with the new options in real time.

Returns:

None

Return type:

None

update_enscomp_options(exp_data: str)

Loads the behavior or stimulation data into the Ensemble Compare tab.

This function is executed when a dataset of behavior or stimulation is assigned. The data of this dataset is loaded in the corresponding field in the ensembles compare tab.

Parameters:

exp_data (string.) – Kind of dataset, options are “behavior” and “stims”.

update_ensemble_visualization(value=-1)

Loads the visualization of the selected ensemble.

This function shows the members of the ensemble, exclusive members and timepoints of activation of the selected ensemble in text boxes. If coordinates are provided, it also loads the visualization of the coordinates and enables customization buttons If dFFo is provided it also plots the dFFo traces.

Parameters:

value (int) – Index of th eensamble to be shown, indexed at 1.

Returns:

None

Return type:

None

update_ensvis_allbinary()

Plot the binary activations of every neurons in every ensemble.

This function creates a subplot for every ensemble and shows the activations of every neuron in every ensemble.

Returns:

None

Return type:

None

update_ensvis_allcoords()

Plot the coordiantes of the neurons in every ensemble.

This function creates a subplot for every ensemble and shows the neuron maps for every ensemble.

Returns:

None

Return type:

None

update_ensvis_alldFFo()

Plot the dFFo of the neurons in every ensemble.

This function creates a subplot for every ensemble and shows the dFFo traces for every neuron in every ensemble.

Returns:

None

Return type:

None

update_ensvis_allens()

Plot the activations of every ensemble.

This function creates figure with the timecourse of every ensemble identified.

Returns:

None

Return type:

None

update_user_analysis_requirements()

Checks if the necessary data for an algorithm is loaded, changes the labels in the UI and updates the availability of the run button.

validate_loaded_data()

Validates if the loaded data has consistency taken as reference the binary activity data or the dFFo. This is, the stimulation and/or behavioral data should have the same number of timepoints,, the cells same number of neurons or the dFFo the same neurons and time as the binary data.

varlabels_clear()

Clears the saved labels for the currently visualized dataset.

Returns:

None

Determines the label family based on the currently visualized dataset (MainWindow.currently_visualizing) and removes the corresponding entries from the MainWindow.varlabels dictionary if they exist. This action clears all custom labels previously assigned to the dataset.

After clearing the labels, the function updates the view of the current dataset to reflect the removal of labels and reinitializes the MainWindow.table_setlabels widget to show empty label entries.

varlabels_save()

Saves the labels entered by the user for the currently visualized dataset.

Returns:

None

Based on the current dataset selected (MainWindow.currently_visualizing), this function assigns a label family, retrieves the label values entered by the user in the second column of MainWindow.table_setlabels, and stores them in the MainWindow.varlabels dictionary under the corresponding label family. If a label is missing for any row, the row index is used as the default label.

After saving, the function updates the view of the current dataset to reflect any changes and logs a message to notify the user.

varlabels_setup_tab(rows_cant)

Sets up the table for labeling variables according to the currently visualized dataset.

Parameters:

rows_cant (int) – The number of rows to display in the table.

Returns:

None

Based on the dataset currently selected for viewing (MainWindow.currently_visualizing), this function configures the label for the index column and initializes the label family. It sets the row count of MainWindow.table_setlabels to rows_cant, populates the table with index values in the first column, and sets up editable label fields in the second column. If labels have already been registered for the selected dataset type, these are pre-filled in the table; otherwise, previous entries are cleared.

The first column items are set as non-editable to prevent user modification of index values.

view_behavior()

Displays the data saved in the MainWindow.data_behavior variable.

This function also runs update the status for editing the variable using MainWindow.set_able_edit_options() and updates validators using MainWindow.update_edit_validators(). This function also triggers the setup of the variable labels tab using MainWindow.varlabels_setup_tab().

view_cells()

Displays the data saved in the MainWindow.data_cells variable.

This function also runs update the status for editing the variable using MainWindow.set_able_edit_options() and updates validators using MainWindow.update_edit_validators(). This function also triggers the setup of the variable labels tab using MainWindow.varlabels_setup_tab().

view_coordinates()

Displays the data saved in the MainWindow.data_coordinates variable.

This function also runs update the status for editing the variable using MainWindow.set_able_edit_options() and updates validators using MainWindow.update_edit_validators(). This function also triggers the setup of the variable labels tab using MainWindow.varlabels_setup_tab().

view_dFFo()

Displays the data saved in the MainWindow.data_dFFo variable.

This function also runs update the status for editing the variable using MainWindow.set_able_edit_options() and updates validators using MainWindow.update_edit_validators(). This function also triggers the setup of the variable labels tab using MainWindow.varlabels_setup_tab().

view_neuronal_activity()

Displays the data saved in the MainWindow.data_neuronal_activity variable.

This function also runs update the status for editing the variable using MainWindow.set_able_edit_options() and updates validators using MainWindow.update_edit_validators(). This function also triggers the setup of the variable labels tab using MainWindow.varlabels_setup_tab().

view_stims()

Displays the data saved in the MainWindow.data_stims variable.

This function also runs update the status for editing the variable using MainWindow.set_able_edit_options() and updates validators using MainWindow.update_edit_validators(). This function also triggers the setup of the variable labels tab using MainWindow.varlabels_setup_tab().

visualize_ensembles(algorithm_cfg: dict)

Loads the results of the SVD into the ensembles visualizer.

This is done this way to use only one function to update the ensembles visualizer. The variable MainWindow.ensemble_currently_shown is used to set the algorithm to show. Then the global funtion MainWindow.update_analysis_results() is executed.

we_have_results()

Updates the UI for the ensembles compare and performance analysis given the available analysis results.

Returns:

None

Return type:

None

class encore.main.QtLoggerAdapter(log_signal)

Bases: object

class encore.main.WorkerRunnable(long_running_function, *args, **kwargs)

Bases: QRunnable

Runnable task to execute a long-running function in a separate thread.

Parameters:
  • long_running_function (callable) – The function to be executed in the thread.

  • args (tuple) – Positional arguments to pass to the function.

  • kwargs (dict) – Keyword arguments to pass to the function.

Variables:
  • long_running_function (callable) – The function to execute in the thread.

  • args (tuple) – Positional arguments for the function.

  • kwargs (dict) – Keyword arguments for the function.

  • signals (WorkerSignals) – Signals for communicating the result of the function execution.

run()

Execute the long-running function with the provided arguments.

Raises:

Exception – Propagates any exception raised by the long-running function.

Returns:

Emits the result of the function execution via the result_ready signal.

Return type:

None

class encore.main.WorkerSignals

Bases: QObject

Signals used by the worker thread.

log

Signal emitted when the long running function emits a message. Arguments: message (str), message type (str).

result_ready

Signal emitted when the long running function finishes execution and returns a result.

encore.main.main()