dj_helper_fn.py
Helper functions for manipulating information from DataJoint fetch calls.
fuzzy_get(index, names, sources)
¶
Given lists of items/names, return item at index or by substring.
Source code in src/spyglass/utils/dj_helper_fn.py
unique_dicts(list_of_dict)
¶
deprecated_factory(classes, old_module='')
¶
Creates a list of classes and logs a warning when instantiated
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classes |
list
|
list of tuples containing old_class, new_class |
required |
Returns:
Type | Description |
---|---|
list
|
list of classes that will log a warning when instantiated |
Source code in src/spyglass/utils/dj_helper_fn.py
dj_replace(original_table, new_values, key_column, replace_column)
¶
Given the output of a fetch() call from a schema and a 2D array made up of (key_value, replace_value) tuples, find each instance of key_value in the key_column of the original table and replace the specified replace_column with the associated replace_value. Key values must be unique.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
original_table |
Result of a datajoint .fetch() call on a schema query. |
required | |
new_values |
list
|
List of tuples, each containing (key_value, replace_value). |
required |
replace_column |
str
|
The name of the column where to-be-replaced values are located. |
required |
Returns:
Type | Description |
---|---|
original_table
|
Structured array of new table entries that can be inserted back into the schema |
Source code in src/spyglass/utils/dj_helper_fn.py
get_fetching_table_from_stack(stack)
¶
Get all classes from a stack of tables.
Source code in src/spyglass/utils/dj_helper_fn.py
get_nwb_table(query_expression, tbl, attr_name, *attrs, **kwargs)
¶
Get the NWB file name and path from the given DataJoint query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_expression |
query
|
A DataJoint query expression (e.g., join, restrict) or a table to call fetch on. |
required |
tbl |
table
|
DataJoint table to fetch from. |
required |
attr_name |
str
|
Attribute name to fetch from the table. |
required |
*attrs |
list
|
Attributes from normal DataJoint fetch call. |
()
|
**kwargs |
dict
|
Keyword arguments from normal DataJoint fetch call. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
nwb_files |
list
|
List of NWB file names. |
file_path_fn |
function
|
Function to get the absolute path to the NWB file. |
Source code in src/spyglass/utils/dj_helper_fn.py
fetch_nwb(query_expression, nwb_master, *attrs, **kwargs)
¶
Get an NWB object from the given DataJoint query.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_expression |
query
|
A DataJoint query expression (e.g., join, restrict) or a table to call fetch on. |
required |
nwb_master |
tuple
|
Tuple (table, attr) to get the NWB filepath from. i.e. absolute path to NWB file can be obtained by looking up attr column of table table is usually Nwbfile or AnalysisNwbfile; attr is usually 'nwb_file_abs_path' or 'analysis_file_abs_path' |
required |
*attrs |
list
|
Attributes from normal DataJoint fetch call. |
()
|
**kwargs |
dict
|
Keyword arguments from normal DataJoint fetch call. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
nwb_objects |
list
|
List of dicts containing fetch results and NWB objects. |