convnwb.objects.task.TaskBase¶
- class convnwb.objects.task.TaskBase[source]¶
Base object for collecting task information.
Methods
__init__
()Initialize TaskBase object.
add_metadata
(subject, experiment, session)Add metadata information to task object.
apply_func
(field, keys, func, **kwargs)Apply a given function across a set of specified fields.
convert_to_array
(field, keys, dtype)Convert specified data fields to numpy arrays.
convert_type
(field, keys, dtype)Convert the type of specified data fields.
copy
()Return a deepcopy of this object.
data_keys
([skip])Get a list of data keys defined in the task object.
get_trial
(index[, field])Get the information for a specified trial.
plot_sync_allignment
([n_pulses])Plots alignment of the synchronization pulses.
set_info
(label, info)Set an info marker.
set_status
(label, status)Set a status marker.
to_dataframe
(field)Return a specified field as a dataframe.
to_dict
()Convert object data to a dictionary.
update_time
(update[, skip, apply_type])Offset all timestamps within the task object.
- add_metadata(subject, experiment, session)[source]¶
Add metadata information to task object.
- Parameters:
- subjectstr
Subject label.
- experimentstr
Name of the experiment.
- sessionstr
Session label.
- apply_func(field, keys, func, **kwargs)[source]¶
Apply a given function across a set of specified fields.
- Parameters:
- fieldstr
Which field to access data to convert from.
- keyslist of str or dict
Which key(s) of the field to convert to array. If list, should be a list of keys available in field. If dict, keys should be subfields, each with corresponding labels to typecast.
- funccallable
Function to apply to the selected fields.
- **kwargs
Keyword arguments to pass into func.
- convert_to_array(field, keys, dtype)[source]¶
Convert specified data fields to numpy arrays.
- Parameters:
- fieldstr
Which field to access data to convert from.
- keyslist of str or dict
Which key(s) of the field to convert to array. If list, should be a list of keys available in field. If dict, keys should be subfields, each with corresponding labels to typecast.
- dtypetype
The data type to give the converted array.
- convert_type(field, keys, dtype)[source]¶
Convert the type of specified data fields.
- Parameters:
- fieldstr
Which field to access data to convert from.
- keyslist of str or dict
Which key(s) of the field to convert to array. If list, should be a list of keys available in field. If dict, keys should be subfields, each with corresponding labels to typecast.
- dtypetype
The data type to cast the variables to.
- data_keys(skip=None)[source]¶
Get a list of data keys defined in the task object.
- Parameters:
- skipstr or list of str
Name(s) of any data attributes to skip.
- Returns:
- data_keyslist of str
List of data attributes available in the object.
- get_trial(index, field=None)[source]¶
Get the information for a specified trial.
- Parameters:
- indexint
The index of the trial to access.
- fieldstr, optional, default: None
Which trial data to access.
- plot_sync_allignment(n_pulses=100)[source]¶
Plots alignment of the synchronization pulses.
- Parameters:
- n_pulsesint, optional, default: 100
Number of pulses to plot for zoomed plot.
- set_info(label, info)[source]¶
Set an info marker.
- Parameters:
- labelstr
The label of which status marker to update.
- info
The info to update.
- set_status(label, status)[source]¶
Set a status marker.
- Parameters:
- labelstr
The label of which status marker to update.
- statusbool
The status to update to.
- to_dataframe(field)[source]¶
Return a specified field as a dataframe.
- Parameters:
- fieldstr
Which field to access to return as a dataframe.
- Returns:
- pd.DataFrame
Dataframe representation of the requested field.
- update_time(update, skip=None, apply_type=None, **kwargs)[source]¶
Offset all timestamps within the task object.
- Parameters:
- update{‘offset’, ‘change_units’, ‘predict_times’} or callable
What kind of update to do to the timestamps.
- skipstr, optional
Fields set to skip.
- apply_typetype, optional
If given, only apply update to specific type.
- kwargs
Additional arguments to pass to the update function.
- skipstr or list of str, optional
Any data fields to skip during the updating.