neurochat.nc_control module

This module implements NeuroChaT Class for the NeuroChaT software.

@author: Md Nurul Islam; islammn at tcd dot ie

class neurochat.nc_control.NeuroChaT(config=<neurochat.nc_config.Configuration object>, data=<neurochat.nc_data.NData object>, parent=None)[source]

Bases: PyQt5.QtCore.QThread

The NeuroChaT class is the controller class in NeuroChaT software.

The NeuroChaT class is the backend to the NeuroChaT GUI. It reads data, parameter and analysis specifications from the Configuration class and executes accordingly. It also interfaces the GUI to the rest of the NeuroChaT elements.

ndata

NData object to store neural data.

Type:NData
config

Configuration object

Type:Configuration
log

Central logger object

Type:NLog
hdf

Nhdf object

Type:Nhdf
__getattr__(arg)[source]

Forward __getattr__ to configuration class.

angle_calculation(excel_file=None, should_plot=True)[source]

Find the angle between place field centroids from an excel file.

This takes an input excel file which lists unit specifications and finds the angle between the place field centroids. The results of the analysis are written back to the input Excel file.

Parameters:excel_file (str) – Name of the excel file that contains data specifications
Returns:None
append_selection_to_excel(excel_file)[source]

Append the current selection of files to the Excel file.

Parameters:excel_file (str) – The path to the Excel file to append the selection to.
Returns:None
close_fig(fig)[source]

Close a matplotlib.figure.Figure() object after saving it.

These figures are saved to the output PDF stored on this object. If a tuple or list of such figures are provided each of them are saved and closed accordingly.

Parameters:fig – matplotlib.figure.Figure() or a list or tuple of them.
Returns:None
close_hdf_file()[source]

Close the HDF5 file object.

Parameters:None
Returns:None
close_pdf()[source]

Close the PDF file object.

Parameters:None
Returns:None
cluster_evaluate(excel_file=None)[source]

Take a list of unit specifications and evaluates clustering quality.

The results of the analysis are written back to the input Excel file.

Parameters:excel_file (str) – Name of the excel file that contains data specifications
Returns:None
cluster_similarity(excel_file=None)[source]

Take a list of specifications for pairwise comparison of units.

The results are written back to the input Excel file.

Parameters:excel_file (str) – Name of the excel file that contains unit specifications
Returns:None

Note

There should be 8 columns overall in the sheet, regardless of format. So the input excel sheet should have column format: directory1 | hdf5_file1 (leave entry blank for non NWB) | spike_file1 or h5_group1 | unit_no1 | directory2 | hdf5_file2 (leave entry blank for non NWB) | spike_file2 or h5_group2 | unit_no2

convert_to_nwb(excel_file=None)[source]

Take a list of datasets in Excel file and converts them into NWB.

This method currently supports Axona and Neuralynx data formats.

Parameters:excel_file (str) – Name of the excel file that contains data specifications
Returns:None
execute(name=None, do_border=True)[source]

Execute each analysis that is selected in the configuration.

This also exports the plot data from individual analyses to the hdf file and figures to the graphics file that are set in the mode() method.

Parameters:
  • name (str, optional) – Name of the unit or the unique unit ID. Defaults to None.
  • do_border (bool, optional) – If true, calculate the border. Defaults to True.
Returns:

None

exist_hdf_path(path='')[source]

Check and return if an HDF5 file path exists.

Parameters:path (str) – path to HDF5 file group
Returns:exists (bool) – True if the path exists
finished
get_configuration()[source]

Return the Configuration() object from this class.

Parameters:None
Returns:Configuration – NeuroChaT’s config attribute
get_hdf_groups(path='')[source]

Return the names of groups or datasets in a path.

Parameters:path (str) – path to HDF5 file group
Returns:list – Names of the groups or datasets in the path
get_neuro_data()[source]

Return the NData() object from this class.

Parameters:None
Returns:NData – NeuroChaT’s ndata attribute
get_output_files()[source]

Return a DataFrame of output graphic files and HDF5 files.

This should be called after thecompletion of the analysis. Index are the unit IDs of the analysed units.

Parameters:None
Returns:op_files (pandas.DataFrame) – Column 1 contains the name of the output graphic files. Column 2 gives the name of the NWB files
get_results()[source]

Return the parametric results of the analyses.

Parameters:None
Returns:results (OrderedDict) – Parametric results of the analysis
mode()[source]

Read data and perform analysis based on the mode set in config.

This is the principle method in NeuroChaT. The method reads the specifications and analyses data according to the mode that is set in the Configuration file.

This sets the input and output data files and sets the NData() object. After this, it calls the execute() method for running the analyses.

Parameters:None
Returns:None
modify_excel_row(pd_row)[source]
open_hdf_file(filename=None)[source]

Set the filename and open the file object for the HDF5 file.

Parameters:filename (str) – Filename of the HDF5 object
Returns:None
open_pdf(filename=None)[source]

Open the PDF file object using PdfPages.

PdfPages is from matplotlib.backends.backend_pdf.

Parameters:filename (str) – Filename of the PDF output
Returns:None
place_cell_plots(directory, dpi=400)[source]

Plot png images of place cell figures, looping over a directory.

Currently only works for axona files, but can be extended. Extension performed by supporting more formats in NDataContainer.

Parameters:
  • dir (str) – The directory to get files from.
  • dpi (int) – The desired dpi of the pngs.
Returns:

None

plot_data_to_hdf(name=None, graph_data=None)[source]

Store plot data to the HDF5 file in the ‘/analysis/’ path.

Parameters:
  • name (str) – Unit ID which is the name of the group in the ‘/analysis/’ path
  • graph_data (dict) – Dictionary of data that are plotted
Returns:

None

reset()[source]

Reset NeuroChaT’s internal attributes.

This prepares it for another set of analysis or a new session.

Parameters:None
Returns:None
run()[source]

After calling start(), the NeuroChaT thread calls this function.

It verifies the input specifications and calls the mode() method.

Parameters:None
Returns:None
set_configuration(config)[source]

Set a new Configuration() object or its subclass object.

Parameters:config (Configuration) – Object of Configuration class or its subclass.
Returns:None
set_neuro_data(ndata)[source]

Set a new NData() object or its subclass object.

Parameters:ndata (NData) – Object of NData class or its subclass.
Returns:None
static sortingextractor_to_nwb(sorting, plot_waveforms=False)[source]

Convert a SpikeInterface sortingextractor to NWB format.

This allows for Neurochat to later analyse it. See examples/spike_inteface_convert.py for an example.

Parameters:
  • sorting (spikeinterface.extractors.SortingExtractor) – The sortingextractor to convert.
  • plot_waveforms (bool, optional.) – Defaults to False. Whether to plot unit waveforms.
Returns:

None

update_results(_results)[source]

Update the results with new analysis results.

Parameters:_results (OrderedDict) – Dictionary of the new results
Returns:None
verify_units(excel_file=None)[source]

Take a list of datasets and verify the specifications of the units.

The verification tool is useful for prescreening of units before the batch-mode analysis using ‘Listed Units’ mode of NeuroChaT.

Parameters:excel_file (str) – Name of the excel file that contains data specifications
Returns:None