traceHandler module

class traceHandler.DATA

Bases: object

The main data container class. :attr: data: holds the Trace object which contains the trace set

Note

This class will be able to hold multiple data sets with multiple types.

PyNNReader(path, no_traces, scale, t_length, freq, trace_type)

Reads a default recording result from PyNN with 9 line of headers (the parameters are the same as in the Read function)

Returns:

a trace object holding the content of the file

Note

If the given file is not accessible the program will abort.

Note

If the number of traces in the file and the corresponding parameter is not equal, a sizeError is raised.

Read(path=['/home/docs/checkouts/readthedocs.org/user_builds/neuroptimus/checkouts/latest/docs/inputTrace.txt'], no_traces=1, scale='mV', t_length=1000, freq=1000, trace_type='voltage')

The main reader function. This calls the recognition function detect_format and uses the obtained reader function to read the data.

Parameters:

path – list of data path(s) (currently only one file is handled)

(see the explanation of the other parameters in the description of Trace)

Note

The function uses the 5. line of the file for recognition.

abstractDataReader(path)
convert(dict_to_conv)
detect_format(line)

Automatically detects the format of the file and returns a reader functions which can process it correctly. The recognized formats are the following:

  • simple text file with data columns separated by “\t”

  • simple text file, containing time trace as well and data columns separated by “\t”

  • default recording result from PyNN with 9 line of headers

  • spike timing file from PyNN with 9 line of headers (not used)

Parameters:

line – one line from the file, which the recognition is based on

Returns:

a reader function

get_type()

Gets the type of the trace set.

Returns:

type

number_of_traces()

Gets the number of traces held by the object.

Returns:

number of traces

spikeTimeReader(path, no_traces, scale, t_length, freq, trace_type)

Not available yet! Reads a spike timing file from PyNN with 9 line of headers (the parameters are the same as in the Read function)

Returns:

a dictionary object holding the content of the file

Note

If the given file is not accessible the program will abort.

Note

If the number of traces in the file and the corresponding parameter is not equal, a sizeError is raised.

Note

In the future, it will return a SpikeTimes object instead.

traceReader(path, no_traces, scale, t_length, freq, trace_type)

Reads a simple text file with data columns separated by “ “. (the parameters are the same as in the Read function)

Returns:

a trace object holding the content of the file

Note

If the given file is not accessible the program will abort.

Note

If the number of traces in the file and the corresponding parameter is not equal, a sizeError is raised.

traceReaderTime(path, no_traces, scale, t_length, freq, trace_type)

Reads a simple text file, containing time trace as well and data columns separated by “t”. (the parameters are the same as in the Read function)

Returns:

a trace object holding the content of the file

Note

If the given file is not accessible the program will abort.

Note

If the number of traces in the file and the corresponding parameter is not equal, a sizeError is raised.

class traceHandler.SpikeTimes(dictionary, trace_type='spikes')

Bases: object

Not in use! Stores spike times in dictionary indexed by the cell’s id.

Parameters:
  • dictionary – the dictionary which contains the data

  • trace_type – type of the trace (should be fixed to “spikes”)

class traceHandler.Trace(no_traces, scale='milli', t_length=1000, freq=100, trace_type=None)

Bases: object

Trace set object. Stores a trace set of a given type with every relevant data.

Parameters:
  • no_traces – number of traces held by the object

  • scale – the unit of the data (required for conversions)

  • t_length – length of the trace(s)

  • freq – sampling frequency

  • trace_type – type of the trace set

Attr:

data: the traces are contained in the attribute named data in the order they were in the input file

Note

The sampling rate should be uniform in the set.

Note

The length of the traces should be the same, or the length of the shortest one should be considered.

Note

If the type of the trace is not recognized, the program will abort. The recognized types are “voltage”, “current” and “other” (“spike” is not available yet).

Convert(hoc_obj)

Converts a hoc vector into a python list and stores it in the container.

Parameters:

hoc_obj – a hoc vector object

GetTrace(index)

Returns the trace having the index index form the container. Always use this function to get a given trace as they are stored in a non intuitive way and direct access would probably cause errors.

Parameters:

index – the index of the trace to get

Note

If the given index is out of range, a sizeError is raised.

Returns:

the required trace

Print()

Prints the contained data. Created for debugging purpose.

SetTrace(d)

Adds the given trace to the container.

Parameters:

dlist containing the trace

reScale(value)

Re-scales the given value based on the scale of the Trace object.

Parameters:

value – the value to be rescaled

Returns:

the rescaled value

traceHandler.real_range(start, step, end)

Not in use! Generates real values from the given range.

Parameters:
  • start – begin of range

  • step – step between the values

  • end – the end of the range

Returns:

list of real values

exception traceHandler.sizeError(message)

Bases: Exception

Exception class used by the trace handling related objects.

Parameters:

message – error message to be displayed

class traceHandler.traceWriter(tr_object, full_path, comment='', flag_write=1, sep='\n', flag_multi=0)

Bases: Trace

Not used! Writes the content of the given trace object to the given file(s).

Parameters:
  • tr_object – trace object which must have data attribute

  • full_path – the path of the output file

  • comment – some header information

  • flag_write – indicates if the properties of the trace is written or not

  • sep – data separator string

  • flag_multi – indicates if the separate traces should be written into separate files

Write()

Performs the writing.

Note

If flag_multi was set to true, then the traces will be written to multiple files.