datafile Package

datafile Package

interfaces for reading (multichanneled) data from files

atf Module

datafile implementation for atf file format

class AtfFile(filename=None, dtype=None)[source]

Bases: botmpy.common.datafile.datafile.DataFile

ATF file format - GenePix software

get_data(**kwargs)

returns a numpy array of the data with samples on the rows and channels on the columns. channels may be selected via the channels parameter.

Parameters:
  • mode (str) – One of ‘all’, ‘chan’, ‘data’ or ‘device’. ‘all’ return all the data in the file. ‘chan’ returns a specific channel.’data’ returns. ‘device’ returns all data for a specific device.
  • item (int) – identifier as per mode
Return type:

ndarray

Returns:

requested data

datafile Module

interfaces for reading (multichanneled) data from various file formats

exception DataFileError[source]

Bases: exceptions.Exception

class DataFileMetaclass[source]

Bases: type

This Metaclass is meant to overwrite doc strings of methods with those defined in the corresponding private methods. Corresponding means there is a public interface entry method and a private implementation method. For the instances object, the call to the public method should present the private methods docstring.

This makes it possible for subclasses implementing the interface to document the usage of public methods, without the need to overwrite the ancestor’s methods.

DOC_METHODS = ['_close', '_closed', '_filename', '_get_data']
class DataFile(filename=None, dtype=None, **kwargs)[source]

Bases: object

abstract data file interface

This is an abstract datafile interface. Implementations should implement the private interface as required for that file format! A DataFile manages a file handle to the physical file and should try to hold its contents in memory, and use buffering to reduce filesystem load.

All public methods belong to the interface and relay to their private counter parts, which are provided by the file format implementation.

close()[source]

close this DataFile

closed()[source]

return the closed status

filename()[source]

return the filename of the physical file

get_data(**kwargs)[source]

returns a numpy array of the data with samples on the rows and channels on the columns. channels may be selected via the channels parameter.

Return type:ndarray
Returns:requested data

gdf Module

datafile implementation for gdf file format

class GdfFile(filename=None, dtype=None, **kwargs)[source]

Bases: botmpy.common.datafile.datafile.DataFile

GDF file format - Chen Sorter

static convert_dict_to_matrix(gdf)[source]

converts a GDF dict representation to a matrix

Parameters:gdf (dict) – mapping unit ids to spike trains
Return type:ndarray
Returns:first column ids, second column samples
static convert_matrix_to_dict(gdf)[source]

converts a GDF ndarray representation to a dict

Parameters:gdf (ndarray) – first column ids, second column samples
Return type:dict
Returns:mapping unit ids to spike trains
get_data(**kwargs)

returns the GDF data as ndarray

Return type:dict
Returns:mapping unit ids to spike trains
static read_gdf(filename)[source]

reads a GDF file and stores to a dict

Parameters:filename (string[path]) – path to the file to read
Return type:dict of numpy.ndarray
Returns:one sequence per unit
static write_gdf(filename, gdf)[source]

Writes GDF data file.

Parameters:
  • filename (str) – valid path on the filesystem
  • gdf (dict or ndarray) – either a dict mapping unit ids to spike trains or a ndarray with the keys in the first column and the samples in the second column

nas Module

datafile implementation for nas file format

class NasFile(filename=None, dtype=None)[source]

Bases: botmpy.common.datafile.datafile.DataFile

NAS file format - NeuronMeter

static check_nas_file(filename)[source]
static get_cols(filename, cols)[source]
static get_gdf(filename)[source]
get_n_data_points()[source]

sample count per waveform

Return type:int
Returns:sample count per waveform
static get_timepoints(filename)[source]
static read_data(filename)[source]
write_header(contact_count, srate, window_before, window_after)[source]

write the NAS file format header

Parameters:
  • contact_count (int) – electrodes per recording point
  • srate (int) – sampling rate in Hz
  • window_before (int) – cut_left in us
  • window_after (int) – cut_right in us
write_row(tetr=0, unit=0, trial=0, time=0, data=None)[source]

write one row of data to the file

Parameters:
  • tetr (int) – tetrode id
  • unit (int) – unit id
  • trial (int) – trial id
  • time (float) – time in us
  • data (sequence) – waveform data

wri Module

datafile implementation for wri file format

class WriFile(filename=None, dtype=<type 'numpy.float32'>)[source]

Bases: botmpy.common.datafile.datafile.DataFile

WRI file format - Chen Sorter

get_data(**kwargs)

Returns the wri content as a dictionary of numpy arrays :rtype: dict :returns: mapping unit id to spike train

xpd Module

datafile implementation for xpd file format

class XpdFile(filename=None, dtype=None, cache=False)[source]

Bases: botmpy.common.datafile.datafile.DataFile

XPD file from - Matthias Munk Group @ MPI Tübingen

get_available_tetrodes()[source]

yields the set of available tetrodes

get_data(**kwargs)

returns a numpy array of the data with samples on the rows and channels on the columns. channels may be selected via the channels parameter.

get data for one tetrode (default all channels) as ndarray

Parameters:
  • item (int) – tetrode id. starts at 1!! Default = 1
  • chans (list) – Channel list. Default = [0,1,2,3]