sovabids.sovarpc
¶
Action Oriented RPC API for Sovabids.
Module Contents¶
Functions¶
|
Apply rules to a set of files. |
|
Convert eeg files to bids according to the mappings given. |
|
Load rules from a path. |
|
Apply rules to a single file. |
|
Save rules as a yaml file to a path. |
|
Save mappings as a yaml file to a path. |
|
Recursively scan the directory for valid files, returning a list with the full-paths to each. |
|
Attributes¶
- 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()
inrules
- 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()
inconvert
- Returns
- 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()
inrules
- 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()
inrules
- 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.
- Returns
- Return type
None
Notes
A wrapper of around files._write_yaml function.
See docstring of
_write_yaml()
infiles
- 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.
- Returns
- Return type
None
Notes
A wrapper of around files._write_yaml function.
See docstring of
_write_yaml()
infiles
- 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()
inrules