Operations¶
Core service modules for processing different types of HED data.
Base Operations¶
Common base classes and shared functionality for all operations.
Event operations¶
Process event files with HED annotations.
Performs operations on tabular data files using metadata from relevant sidecars if available.
- class hedweb.event_operations.EventOperations(arguments=None)[source]¶
Bases:
BaseOperationsClass to perform operations on events files.
- __init__(arguments=None)[source]¶
Construct a ProcessEvents object to handle events form requests.
- Parameters:
arguments (dict) – Dictionary with parameters extracted from form or service
- process() dict[source]¶
Perform the requested action for the events file and its sidecar.
- Returns:
A dictionary of results in the standard results format.
- Return type:
- Raises:
HedFileError – If the schema was not valid.
HedFileError – If the command was not found or the input arguments were not valid.
- assemble() dict[source]¶
Create a tabular file with the original positions in first column and a HED column.
- Returns:
A dictionary of results in standard format including either the assembled events string or errors.
- Return type:
Notes
options include columns_included and expand_defs.
- check_quality() dict[source]¶
Check the quality of the HED annotations for an events file.
- Returns:
A dictionary of results in standard format including either the assembled events string or errors.
- Return type:
- Notes: The options for this are
limit_errors (bool): If True, report at most 2 errors of each type
show_details (bool): If True, a detailed breakdown of the event annotation is displayed with error.
- generate_sidecar() dict[source]¶
Generate a JSON sidecar template from a BIDS-style events file.
- Returns:
A dictionary of results in standard format including either the generated sidecar string or errors.
- Return type:
Notes: Options are the columns selected. If None, all columns are used.
- get_hed_objs() tuple[list, DefinitionDict][source]¶
Return the assembled objects and applicable definitions.
- remodel() dict[source]¶
Remodel a given events file.
- Returns:
A dictionary pointing to results or errors.
- Return type:
- Raises:
HedFileError – If the remodeling operations were not valid.
- Notes: The options for this are
include_summaries (bool): If true and summaries exist, package event file and summaries in a zip file.
- search() dict[source]¶
Create a three-column tsv file with event number, matched string, and assembled strings for matched events.
- Returns:
A dictionary pointing to results or errors.
- Return type:
- Notes: The options for this are
columns_included (list): A list of column names of columns to include. expand_defs (bool): If True, expand the definitions in the assembled HED. Otherwise, shrink definitions.
- validate() dict[source]¶
Validate the events tabular input object and return the results.
- Returns:
A dictionary containing results of validation in standard format.
- Return type:
- Notes: The dictionary of options includes the following.
check_for_warnings (bool): If true, validation should include warnings. (default False)
Schema operations¶
Validate and manipulate HED schemas.
Performs operations on HED schemas, such as validation, comparison, and conversion.
- class hedweb.schema_operations.SchemaOperations(arguments=None)[source]¶
Bases:
BaseOperationsClass to perform operations on HED schemas.
- __init__(arguments=None)[source]¶
Construct a SchemaOperations object to handle sidecar operations.
- Parameters:
arguments (dict) – Dictionary with parameters extracted from form or service
- process() dict[source]¶
Perform the requested action for the schema.
- Returns:
A dictionary of results in the standard results format.
- Return type:
- Raises:
HedFileError – If the command was not found or the input arguments were not valid.
HedFileError – If the schema is not found or cannot be loaded.
- compare()[source]¶
Compare two schemas and return the differences. :returns: A dictionary of results in the standard results format. :rtype: dict
- convert() dict[source]¶
Convert schema to multiple formats, save to temp dir, zip, and return as base64-encoded data.
- Returns:
A dictionary of results in the standard results format.
- Return type:
Sidecar operations¶
Handle BIDS sidecar JSON files.
Performs operations on JSON sidecars, such as validation, conversion, extraction, and merging with spreadsheets.
- class hedweb.sidecar_operations.SidecarOperations(arguments=None)[source]¶
Bases:
BaseOperationsClass to perform operations on sidecars.
- __init__(arguments=None)[source]¶
Construct a SidecarOperations object to handle sidecar operations.
- Parameters:
arguments (dict or None) – Dictionary with parameters extracted from form or service
- process() dict[source]¶
Perform the requested action for the sidecar.
- Returns:
A dictionary of results in standard form.
- Return type:
- Raises:
HedFileError – If the command was not found or the input arguments were not valid.
HedFileError – If the schema is not found or cannot be loaded.
HedFileError – If the sidecar is not found or cannot be loaded.
HedFileError – If a required spreadsheet is not found or cannot be loaded.
- sidecar_convert() dict[source]¶
Convert a sidecar from long to short form or short to long form.
- Returns:
A downloadable response dictionary
- Return type:
Notes
command (str): Either ‘to short’ or ‘to long’ indicating type of conversion. expand_defs (bool): If True, expand definitions when converting, otherwise do no expansion
- sidecar_extract() dict[source]¶
Create a four-column spreadsheet with the HED portion of the JSON sidecar.
- Returns:
A downloadable dictionary file or a file containing warnings
- Return type:
- sidecar_merge() dict[source]¶
Merge an edited 4-column spreadsheet with JSON sidecar.
- Returns:
A downloadable dictionary file or a file containing warnings
- Return type:
- Raises:
HedFileError – If the spreadsheet is not provided or cannot be loaded.
- Notes: The allowed option for merge is:
include_description_tags (bool): If True, a Description tag is generated from Levels and included.
Spreadsheet operations¶
Process tabular data with HED columns.
Performs operations on spreadsheets, such as validation, conversion, and extraction.
- class hedweb.spreadsheet_operations.SpreadsheetOperations(arguments=None)[source]¶
Bases:
BaseOperationsClass to perform operations on spreadsheets.
- __init__(arguments=None)[source]¶
Construct a ProcessSpreadsheet object to handle spreadsheet operations.
- Parameters:
arguments (dict) – Dictionary with parameters extracted from form or service
- process() dict[source]¶
Perform the requested action for the spreadsheet.
- Returns:
A dictionary of results from spreadsheet processing in standard form.
- Return type:
- Raises:
HedFileError – If the command was not found or the input arguments were not valid.
HedFileError – If the schema is not found or cannot be loaded.
HedFileError – If the spreadsheet is not found or cannot be loaded.
- spreadsheet_convert() dict[source]¶
Convert a spreadsheet long to short unless the command is not COMMAND_TO_LONG then converts to short
- Returns:
A downloadable dictionary in standard format.
- Return type:
- Notes: the allowed options are
command (str): Name of the command to execute. check_for_warnings (bool): If True, check for warnings.
String operations¶
Validate and manipulate HED strings.
Performs operations on strings, such as validation and conversion between long and short forms.
- class hedweb.string_operations.StringOperations(arguments=None)[source]¶
Bases:
BaseOperationsClass to perform operations on spreadsheets.
- __init__(arguments=None)[source]¶
Construct a StringOperations object to handle sidecar operations.
- Parameters:
arguments (dict) – Dictionary with parameters extracted from form or service
- process() dict[source]¶
Perform the requested string processing action.
- Returns:
The results in standard format.
- Return type:
- Raises:
HedFileError – If the command was not found or the input arguments were not valid.
HedFileError – If the schema is not found or cannot be loaded.
HedFileError – If the string list is empty or not provided.
- convert() dict[source]¶
Convert a list of strings from long to short or from short to long.
- Returns:
The results of string processing in standard format.
- Return type:
- search() dict[source]¶
Return a list or a boolean
- Returns:
A dictionary pointing to results or errors.
- Return type:
- Notes: The options for this are
columns_included (list): A list of column names of columns to include. expand_defs (bool): If True, expand the definitions in the assembled HED. Otherwise, shrink definitions.