neurochat.nc_hdf module

This module implements Nhdf Class for NeuroChaT software.

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

class neurochat.nc_hdf.Nhdf(**kwargs)[source]

Bases: object

Manages importing and exporting NeuroChaT datasets to HDF5 file.

It also creates and manages the nomenclature for storage paths within the HDF5 file.

_filename

The filename of the hdf5 file.

Type:str
f

The h5py file object that is opened.

Type:io.IOBase
close()[source]

Close the h5py file object.

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

Open the file, and returns the file object.

Parameters:None
Returns:object – h5py file object
get_dataset(group=None, path='', name='')[source]

Retrieve a dataset from a specific path.

Parameters:
  • group (str) – Path of a group in HDF5 file. If None, uses self.f as the group.
  • path (str) – Name of the member group. This path is relative to the ‘group’
  • name (str) – Name of the dataset
Returns:

ndarray or numeric objects – Value of the dataset

get_file_object()[source]

Return the file object that is opened using h5py.

Parameters:None
Returns:object – h5py file object
static get_file_tag(data=None)[source]

Return the file tag or extension to name the neural data in the HDF5 file.

Parameters:data (NSpike or NLfp) – Neural data objects of NeuroChaT
Returns:str – File extention (Axona) or name (Neuralynx) of the neural datasets
get_filename()[source]

Return the full file of the HDF5 dataset.

Parameters:None
Returns:str
get_groups_in_path(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_type()[source]

Return the type of object. For Nhdf, this is always hdf type.

Parameters:None
Returns:str
initialize()[source]

Initialize the basic groups for the HDF5 file.

Parameters:None
Returns:None
path_exists(path)[source]

Return True if self.f exists and path is in it.

path can be either a path in the hdf5 file. or the full name of a hdf5 file.

Parameters:path (str) – The path to check for.
Returns:bool – Whether or not the path is exists

See also

neurochat.nc_control.exist_hdf_path()

resolve_analysis_path(spike=None, lfp=None)[source]

Return path of the dataset where analysis results will be stored.

This path is also the unique unit ID.

Parameters:
  • spike (NSpike) – Spike data object
  • lfp (NLfp) – Lfp data object
Returns:

str – Unique unit ID resolved from spike and lfp filenames. This is the name of the path to store the data of NeuroChaT analysis.

resolve_datapath(data=None)[source]

Resolve and return the path of the dataset from NeuroChaT data objects.

This is used to obtain a path within the HDF5 file.

Parameters:data – NeuroChaT data objects
Returns:str – Path of the NeuroChaT data
static resolve_hdfname(data=None)[source]

Return the name of the HDF5 file from the filenames of NeuroChaT data.

Parameters:data – One of the NeuroChaT data objects
Returns:hdf_name (str) – Hdf5 file name
save_attributes(path=None, attr=None)[source]

Store attributes to a group or dataset.

Parameters:
  • path (str) – Path of a group or dataset in HDF5 file
  • attr (dict) – Attribute names and values in a dictionary
Returns:

None

save_cluster(clust=None)[source]

Store NClust() dataset to the HDF5 file.

Parameters:clust (NClust()) – Cluster data object in NeuroChaT
Returns:None
save_dataset(path=None, name=None, data=None, create_group=True)[source]

Store a dataset to a specific path.

Parameters:
  • path (str) – Path of a group in HDF5 file
  • name (str) – Name of the new dataset
  • data (ndarray or list of numbers) – Data to be stored
  • create_group (bool) – If True, creates a new group if the ‘path’ is not in the file
Returns:

None

save_dict_recursive(path=None, name=None, data=None, create_group=True)[source]

Store a dictionary dataset to a specific path.

If the dictionary is nested, it creates a group for each of the outermost keys.

Parameters:
  • path (str) – Path of a group in HDF5 file
  • name (str) – Name of the new dataset
  • data (ndarray or list of numbers) – Data to be stored
  • create_group (bool) – If True, creates a new group if the ‘path’ is not in the file
Returns:

None

save_lfp(lfp=None)[source]

Store NLfp() dataset to the HDF5 file.

Parameters:lfp (NLfp()) – LFP data object in NeuroChaT
Returns:None
save_object(obj=None)[source]

Store a NeuroChaT dataset to the HDF5 file.

It resolves the name first and then stores the data in the storage path.

Parameters:obj – One of the NeuroChaT data types
Returns:None
save_spatial(spatial=None)[source]

Store NSpatial() dataset to the HDF5 file.

Parameters:spatial (NSpatial()) – Spatial data object in NeuroChaT
Returns:None
save_spike(spike=None)[source]

Store NSpike() dataset to the HDF5 file.

Parameters:spike (NSpike()) – Spike data object in NeuroChaT
Returns:None
set_filename(filename=None)[source]

Set the full file of the HDF5 dataset.

Parameters:filename (str) – Filename of the HDF5 dataset
Returns:None