Module containing a collection of data readers for brain data.
Module used for reading of collections of HTK files of raw or processed neural recordings.
Bases: object
Class for management of a directory of HTK files from raw or processed neural recordings. All HTK files are expected to have the same size.
Variables: |
|
---|
Internal helper function used to check that all HTK files in the collection have the same structure (i.e, whether the header information of the HTK files is the same for all files). NOTE! This function assumes that the list of htk_files has already been computed.
Try to construct the bands from the filename. Note, this assumes that the metadata has already been constructed.
Parameters: |
|
---|
Internal helper function used to determine the block index and channel index based on the name of the file.
Parameters: | filename – Name of the HTK file |
---|---|
Returns: | Integer of the block index and integer of the channel index within the block |
Internal helper function used to compute the list of files (stored in self.htk_files) and the map of files to channels/blocks (stored in self.channel_block_map).
Returns: | This function returns: i) a list of htk filenames, ii) a 2D numpy array of shape (#blocks, #channels) indicating the index of the file associated with a given channel, and iii) a list of tuples indicating for each file the block and channel index. |
---|---|
Raises : | A ValueError is raised in case that HTK files of varying sizes are found. |
Internal helper function used to retrieve the sampling rate, number of samples sample size, and parameter kind. NOTE! This function assumes that the list of htk_files has already been computed.
Internal helper function used to define the default layout of the brain grid. Note! This function assumes that the list of htk_files has already been computed.
Read .mat file describing the anatomy of the data and return a dict describing for different brain regions (keys) the set of electrodes that are located in that region (values, stored as numpy arrays).
Parameters: | anatomy_file – The name of the .mat file with the description of the anatomy |
---|
Based on the blockindex and channelindex of the files, compute the linear order in which the files should be sorted.
Parameters: |
|
---|
Initialize object for management of directory of RAW neural recording in HTK format.
Parameters: |
|
---|---|
Raises : | AssertionError is raised if check_consistency if enabled and inconsistencies in metadata are found between HTK files in the collection. |
list of weak references to the object (if defined)
Clear the self.data instance variable to free up memory.
Get the anatomy dicitionary describing for each region the list of electrodes in the region.
Get numpy array of string, indicating for each electrode the name of the region it is located in . ‘unknown’ is added for electrodes with an unknown region assignment.
Get the block index for the file with the given index.
Parameters: | fileindex – Index of the file of interest |
---|---|
Returns: | integer indicting the block index for the file. |
Get the channel index with a block for the file with the given index.
Parameters: | fileindex – Index of the file of interest |
---|---|
Returns: | integer indicting the channel index for the file. |
Get the number of blocks in which the all channels are organized.
Get the number of channels per block.
Get the number of HTK files associated with the current collection of raw data.
Returns: | Integer indicating the number of HTK files. (len(self.htk_files)) |
---|
Check whether anatomy data is available for the collection.
Get the data for the file with the given index.
Read all data from file and return the numpy array. This function modifies self.data to safe the data retrieved.
Parameters: | print_status – Print status message on read progress on screen. Default is False. |
---|
Module used for reading of htk files.
Bases: object
Class used for reading HTK format files.
Instance Variables:
Variables: |
|
---|
Internal Variables:
Variables: |
|
---|
Simple helper function used to determine whether the system is little or big endianess. This is needed to determine whether the binary data read needs to be swapped or not.
Returns: | Boolean indicating whether the data is big or little endian. |
---|
Internal helper function used to position the file handle at the position of the sample with the given index.
Method use to check whether we need to swap the byteorder of the binary data read.
Returns: | Boolean indicating if the byteorder needs to be swapped. |
---|
Make the HTKFile iterable
list of weak references to the object (if defined)
Get the next item for iteration
Get a numpy data array of all the samples
Returns: | Numpy data array of all the samples |
---|
Read the data of a single sample with the given index.
Parameters: | sample_index – The index of the sample to be read |
---|---|
Returns: | The vector with the data for the sample. |
Bases: object
Specification of base information about the HTK file format.
list of weak references to the object (if defined)
Byte-order in which the HTK data is written
List describing the contents of the HTK file header.
Get the format string to unpack the header of the HTK file.
:returns string—e.g. ‘>IIHH’—describing the format to be used for unpacking the header.
Total length in bytes of the file header.
Dictionary describing the basic parameter kind codes.
- WAVEFORM = 0 : sampled waveform
- LPC = 1 : linear prediction filter coefficients
- LPCREFC = 2 : linear prediction reflection coefficients
- LPCEPSTRA = 3 : LPC cepstral coefficients
- LPCDELCEP = 4 : LPC cepstra plus delta coefficients
- IREFC = 5 : LPC reflection coefficient in 16 bit integer format
- MFCC = 6 : mel-frequency cepstral coefficients
- FBANK = 7 : log mel-filter bank channel outputs
- MELSPEC = 8 : linear mel-filter bank channel outputs
- USER = 9 : user-defined sample kind
- DISCRETE = 10 : vector quantised data
Dictionary describing the parameter kind encodings.
- _E = 0000100 : has energy
- _N = 0000200 : absolute energy suppressed
- _D = 0000400 : has delta coefficients
- _A = 0001000 : has acceleration (delta-delta) coefficients
- _C = 0002000 : is compressed
- _Z = 0004000 : has zero mean static coefficients
- _K = 0010000 : has CRC checksum
- _O = 0020000 : has 0th cepstral coefficient