string_util

Utilities for manipulating HedString objects.

Functions

gather_descriptions(hed_string)

Remove any description tags from the HedString and concatenates them.

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

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

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

Split a HedString object into two separate HedString objects based on the presence of def tags

gather_descriptions(hed_string)[source]

Remove any description tags from the HedString 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 description tags removed.

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

Split 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]

Split a HedString object into two separate HedString objects based on the presence of def 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