sovabids.sovarpc#

Action Oriented RPC API for Sovabids.

Module Contents#

Functions#

apply_rules(→ dict)

Apply rules to a set of files.

convert_them(→ None)

Convert eeg files to bids according to the mappings given.

load_rules(→ dict)

Load rules from a path.

apply_rules_to_single_file(→ dict)

Apply rules to a single file.

save_rules(→ None)

Save rules as a yaml file to a path.

save_mappings(→ None)

Save mappings as a yaml file to a path.

get_files(→ list)

Recursively scan the directory for valid files, returning a list with the full-paths to each.

main([entry, port, debug])

Attributes#

sovabids.sovarpc.app[source]#
sovabids.sovarpc.api[source]#
sovabids.sovarpc.apply_rules(file_list: List[str], bids_path: str, rules: dict, mapping_path: str) dict[source]#

Apply rules to a set of files.

Parameters
  • file_list (list of str) – List of str with the paths of the files we want to convert (ie the output of get_files).

  • bids_path (str) – The path we want the converted files in.

  • rules (dict) – A dictionary with the rules.

  • mapping_path (str, optional) – The fullpath where we want to write the mappings file. If ‘’, then bids_path/code/sovabids/mappings.yml will be used.

Returns

A dictionary following: {

‘General’: rules given, ‘Individual’:list of mapping dictionaries for each file

}

Return type

dict

Notes

A wrapper of around rules.apply_rules function. See docstring of apply_rules() in rules

sovabids.sovarpc.convert_them(general: dict, individual: List[dict]) None[source]#

Convert eeg files to bids according to the mappings given.

Parameters
  • general (dict) – The general rules

  • individual (list[dict]) – List with the individual mappings of each file.

Notes

A wrapper of around convert.convert_them function.

See docstring of convert_them() in convert

Return type

None

sovabids.sovarpc.load_rules(rules_path: str) dict[source]#

Load rules from a path.

Parameters

rules_path (str) – The path to the rules file.

Returns

The rules dictionary.

Return type

dict

Notes

A wrapper of around rules.load_rules function.

See docstring of load_rules() in rules

sovabids.sovarpc.apply_rules_to_single_file(file: str, rules: dict, bids_path: str, write: bool = False, preview: bool = False) dict[source]#

Apply rules to a single file.

Parameters
  • file (str) – Path to the file.

  • rules (dict) – The rules dictionary.

  • bids_path (str) – Path to the bids directory

  • write (bool, optional) – Whether to write the converted files to disk or not.

  • preview (bool, optional) – Whether to return a dictionary with a “preview” of the conversion. This dict will have the same schema as the “Mapping File Schema” but may have flat versions of its fields. UNDER CONSTRUCTION

Returns

{ mapping : dict

The mapping obtained from applying the rules to the given file

previewbool|dict

If preview = False, then False. If True, then the preview dictionary.

}

Return type

dict

Notes

A wrapper of around rules.apply_rules_to_single_file function.

See docstring of apply_rules_to_single_file() in rules

sovabids.sovarpc.save_rules(rules: dict, path: str) None[source]#

Save rules as a yaml file to a path.

Parameters
  • rules (dict) – The rules dictionary to save

  • path (str) – The full-path (including filename) where to save the rules as yaml.

Return type

None

Notes

A wrapper of around files._write_yaml function.

See docstring of _write_yaml() in files

sovabids.sovarpc.save_mappings(path: str, general: dict, individual: List[dict]) None[source]#

Save mappings as a yaml file to a path.

Parameters
  • path (str) – The full-path (including filename) where to save the mappings as yaml.

  • general (dict) – The general rules dictionary.

  • individual (list of dict) – A list containing the mapping dictionary of each file.

Return type

None

Notes

A wrapper of around files._write_yaml function.

See docstring of _write_yaml() in files

sovabids.sovarpc.get_files(path: str, rules: dict) list[source]#

Recursively scan the directory for valid files, returning a list with the full-paths to each.

The valid files are given by the ‘non-bids.eeg_extension’ rule. See the “Rules File Schema”.

Parameters
  • path (str) – The path we want to obtain the files from.

  • rules (dict) – The rules dictionary.

Returns

A list containing the path to each valid file in the source_path.

Return type

list[str]

Notes

A wrapper of around rules.get_files function.

See docstring of get_files() in rules

sovabids.sovarpc.main(entry='sovarpc:app', port=5000, debug=False)[source]#