traceHandler module¶
- class traceHandler.DATA¶
Bases:
objectThe main data container class. :attr: data: holds the
Traceobject which contains the trace setNote
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
Readfunction)- Returns:
a
traceobject 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
sizeErroris 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_formatand 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
Readfunction)- Returns:
a
dictionaryobject 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
sizeErroris raised.Note
In the future, it will return a
SpikeTimesobject 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
Readfunction)- Returns:
a
traceobject 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
sizeErroris 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
Readfunction)- Returns:
a
traceobject 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
sizeErroris raised.
- class traceHandler.SpikeTimes(dictionary, trace_type='spikes')¶
Bases:
objectNot in use! Stores spike times in
dictionaryindexed by the cell’s id.- Parameters:
dictionary – the
dictionarywhich contains the datatrace_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:
objectTrace 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
datain 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
listand stores it in the container.- Parameters:
hoc_obj – a hoc vector object
- GetTrace(index)¶
Returns the trace having the index
indexform 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
sizeErroris raised.- Returns:
the required trace
- Print()¶
Prints the contained data. Created for debugging purpose.
- SetTrace(d)¶
Adds the given trace to the container.
- Parameters:
d –
listcontaining the trace
- reScale(value)¶
Re-scales the given value based on the scale of the
Traceobject.- 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:
listof real values
- exception traceHandler.sizeError(message)¶
Bases:
ExceptionException 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:
TraceNot used! Writes the content of the given trace object to the given file(s).
- Parameters:
tr_object – trace object which must have
dataattributefull_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
stringflag_multi – indicates if the separate traces should be written into separate files
- Write()¶
Performs the writing.
Note
If
flag_multiwas set to true, then the traces will be written to multiple files.