brain_pipe.split.mid.MidSplit

class MidSplit(*args, **kwargs)

Bases: Splitter

Split data in the middle of the data.

__init__(*args, **kwargs)

Create a mid-splitter.

Parameters:
  • args (Sequence[Any]) – Arguments to pass to the Splitter.

  • kwargs (Dict[str, Any]) – Keyword arguments to pass to the Splitter.

Methods

__init__(*args, **kwargs)

Create a mid-splitter.

parse_dict_keys(key[, name, ...])

Parse a key or a sequence of keys.

split(data, shortest_length, split_fraction, ...)

Split the data into sets.

parse_dict_keys(key: str | Sequence[str] | Mapping[str, str], name='key', require_ordered_dict=False) OrderedDict[str, str]

Parse a key or a sequence of keys.

Parameters:
  • key (Union[str, Sequence[str], Mapping[str,str]]) – A key or a sequence of keys.

  • name (str) – The name of the key. Used for error messages.

  • require_ordered_dict (bool) – If True, the key must be an OrderedDict. If False, the key can also be an ordinary dict.

Returns:

A mapping of input keys to output keys.

Return type:

OrderedDict[str, str]

Raises:

TypeError – If the key is not a string, a sequence of strings or a mapping of strings. If the key is a mapping but require_ordered_dict is True and the mapping is not an OrderedDict.

split(data, shortest_length, split_fraction, start_index)

Split the data into sets.

The largest set will be extracted from the front and back of the data (this should also be the first set that this method encounters, see sort_split_names_fractions()) The other sets will be extracted from the middle of the data, sequentially.

Parameters:
  • data (np.ndarray) – Data to split.

  • shortest_length (int) – Length of the shortest data.

  • split_fraction (float) – Fraction of the data to split into the current set.

  • start_index (int) – Index to start splitting the data from.

Returns:

The split data and the index to start splitting the next data from.

Return type:

Tuple[np.ndarray, int]