HED API reference#

HED Tools#

The HED tools module provides MATLAB interfaces for HED validation and operations.

HedTools (Abstract Base Class)#

class HedTools#

Bases: handle

base

Method Summary
static formatEvents(eventsIn)#

Convert eventsIn to a char array if necessary.

Parameters:

eventsIn - events as a char, string, or struct

Returns:

events converted to a char.

static formatSidecar(sidecarIn)#

Convert the sidecar to a char array if necessary.

Parameters:

sidecarIn - a sidecar as a char, string, or struct

Returns:

sidecar converted to a char.

HedToolsPython#

class HedToolsPython#

Bases: HedTools

Concrete class using direct calls to Python for HedTools interface.

HedToolsService#

class HedToolsService#

Bases: HedTools

Creates a connection object for the HED web online services.

getHedTools#

getHedTools(hedVersion, host)#

Factory method that returns either HedToolsService or HedToolsPython

Parameters:

hedVersion - char or cell array with HED version to be used. host - web address of service if HedToolsService is to be used.

Event Remodeling Demos#

Examples demonstrating event data remodeling and processing.

remodel(remodel_args)#

Run the remodeling tools.

Parameters:

remodel_args - A cell array of command line parameters for remodeling.

remodelBackup(backup_args)#

Create a remodeling backup.

Parameters:

backup_args - cell array with backup arguments.

remodelRestore(restore_args)#

Restore the specified remodeling backup.

Parameters:

restore_args - cell array with restore arguments.

runRemodelDemos()#

A test script for a wrapper functions for HED remodeling tools

Web Services Demos#

Examples demonstrating HED web service usage.

demoEventRemodelingServices(host)#

Shows how to call hed-services to remodel an events file.

Example 1: Remodeling an change events file by removing column

Example 2: Summarize the column values from an event file.

Example 3: Summarize the HED type tags from an event file

Example 4: Factor HED columns

demoEventSearchServices(host)#

Shows how to call hed-services to search a BIDS events file.

Example 1: Search an events file for HED using a valid query.

Example 2: Search an events file for HED and return additional columns.

demoEventServices(host)#

Shows how to call hed-services to process a BIDS events file.

Example 1: Validate valid events file using HED version.

Example 2: Validate invalid events file using a HED URL.

Example 3: Assemble valid event HED strings uploading HED schema.

Example 4: Assemble valid event HED strings (def expand) using HED version.

Example 5: Generate a JSON sidecar template from an events file.

demoGetServices(host)#

Get the options and data

demoLibraryServices(host)#

Shows how to call hed-services using libraries.

Example 1: Validate valid events file using HED version list. Example 2: Validate valid events file using HED version list needed libraries. Example 3: Validate events file invalid because of missing library.

demoSidecarServices(host)#

Shows how to call hed-services to process a BIDS JSON sidecar.

Example 1: Validate valid JSON sidecar using a HED version.

Example 2: Validate invalid JSON sidecar using HED URL.

Example 3: Convert valid JSON sidecar to long uploading HED schema.

Example 4: Convert valid JSON sidecar to short using a HED version.

Example 5: Extract a 4-column spreadsheet from a valid JSON sidecar.

Example 6: Merge a 4-column spreadsheet with a JSON sidecar.

demoSpreadsheetServices(host)#

Shows how to call hed-services to process a spreadsheet of event tags.

Example 1: Validate valid spreadsheet file using schema version.

Example 2: Validate invalid spreadsheet file using HED URL.

Example 3: Convert valid spreadsheet file to long uploading HED schema.

Example 4: Convert valid spreadsheet file to short using HED version.

Get the options and data

demoStringServices(host)#

Shows how to call hed-services to process a list of hedstrings.

Example 1: Validate valid list of strings using HED version.

Example 2: Validate invalid list of strings using HED URL.

Example 3: Validate invalid list of strings uploading HED schema.

Example 4: Convert valid strings to long using HED version.

exampleGenerateSidecar()#

Setup the options

getDemoData()#

Return the demo data in a struct for running the services.

getHostOptions(host)#

Set the options associated with the services for host.

getRequestTemplate()#

Create a parameter template for HEDTools web service request.

getSessionInfo(csrf_url)#

Setup the session for accessing the HED webservices

Parameters:

csrf_url - URL for the services.

Returns:

cookie - A string cookie value. csrftoken - A string csrf token for the session.

outputReport(response, theTitle)#
runAllDemos()#

host = ‘https://hedtools.org/hed_dev’; host = ‘http://127.0.0.1:5000’;

runDemo()#

Use this script to run an individual type of service. host = ‘https://hedtools.org/hed’;

Utilities#

Helper functions for common operations.

events2string(events)#

Returns string representing a rectified EEG.event structure

Parameters:

events - the EEGLAB EEG.event struct or similar srate - the EEG sampling rate in Hz (needed if no onset column)

Returns:

event_string - a string representation suitable to write to .tsv

Note 1: The conversion converts NaN to n/a.

Note 2: This assumes that the events structure has been rectified by adding onset and duration fields as required by BIDS.

filterDirectories(dirs, excludeDirs)#

Returns a filtered list of fullpaths of directories not in excludeDirs

Parameters:

dirs (cell array): List of fullpaths of directories to check. excludeDirs (cell array): List of fullpaths of directories to exclude.

Returns:

cell array: list of fullpaths of directories not excluded.

filterFiles(fileList, namePrefix, nameSuffix, extensions)#

Return a list whose filenames satisfy the specified criteria

Parameters:

fileList (cell array) paths of the files to be filtered. namePrefix (char) prefix of the filename or any if empty string nameSuffix (char) suffix of the filename or any if empty string extensions (cell array) names of extensions (with . included)

Returns:

filteredList (cell array) paths of files satisfying criteria.

getFileList(rootPath, namePrefix, nameSuffix, extensions, excludeDirs)#

Return a full path list of specified files in rootPath directory tree.

Parameters:

rootPath (char) full path of root of directory tree to search namePrefix (char) prefix of the filename or any if empty string nameSuffix (char) suffix of the filename or any if empty string extensions (cell array) names of extensions (with . included) excludeDirs (cell array) names of subdirectories to exclude

Returns:

selectedList (cell array) list of full paths of the files

rectify_events(event_struct, sampling_rate)#

Makes sure that an EEG.event structure has onset and duration fields.

Parameters:

event_struct - (Input/Output) EEG.event structure adjusted. sampling_rate - Sampling rate needed to convert latency to onset.

separateFiles(dirPath)#

Separate the files in a directory into lists of directories and files.

Parameters:

dirPath (str) Full path of a directory whose contents are separated.

Returns:

sep_files Cell array of full paths of the files in dirPath sep_dirs Cell array of the full paths of the subdirectories in dirPath

str2lines(inString)#

Splits a string based on n into cell entries.

Parameters:

inString -