string_util

Functions

gather_descriptions(hed_string)

Removes any description tags from the string and concatenates them

split_base_tags(hed_string, base_tags[, ...])

Splits a HedString object into two separate HedString objects based on the presence of base tags.

split_def_tags(hed_string, def_names[, ...])

Splits a HedString object into two separate HedString objects based on the presence of wildcard tags.

gather_descriptions(hed_string)[source]

Removes any description tags from the string and concatenates them

Parameters:

hed_string (HedString) – To be modified

Returns: tuple

description(str): The concatenated values of all description tags.

Side-effect:

The input HedString has its Definition tags removed.

split_base_tags(hed_string, base_tags, remove_group=False)[source]

Splits a HedString object into two separate HedString objects based on the presence of base tags.

Parameters:
  • hed_string (HedString) – The input HedString object to be split.

  • base_tags (list of str) – A list of strings representing the base tags. This is matching the base tag NOT all the terms above it.

  • remove_group (bool, optional) – Flag indicating whether to remove the parent group. Defaults to False.

Returns:

A tuple containing two HedString objects:
  • The first HedString object contains the remaining tags from hed_string.

  • The second HedString object contains the tags from hed_string that match the base_tags.

Return type:

tuple

split_def_tags(hed_string, def_names, remove_group=False)[source]

Splits a HedString object into two separate HedString objects based on the presence of wildcard tags.

This does NOT handle def-expand tags currently.

Parameters:
  • hed_string (HedString) – The input HedString object to be split.

  • def_names (list of str) – A list of def names to search for. Can optionally include a value.

  • remove_group (bool, optional) – Flag indicating whether to remove the parent group. Defaults to False.

Returns:

A tuple containing two HedString objects:
  • The first HedString object contains the remaining tags from hed_string.

  • The second HedString object contains the tags from hed_string that match the def_names.

Return type:

tuple