:py:mod:`sovabids.sovarpc` ========================== .. py:module:: sovabids.sovarpc .. autoapi-nested-parse:: Action Oriented RPC API for Sovabids. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: sovabids.sovarpc.apply_rules sovabids.sovarpc.convert_them sovabids.sovarpc.load_rules sovabids.sovarpc.apply_rules_to_single_file sovabids.sovarpc.save_rules sovabids.sovarpc.save_mappings sovabids.sovarpc.get_files sovabids.sovarpc.main Attributes ~~~~~~~~~~ .. autoapisummary:: sovabids.sovarpc.app sovabids.sovarpc.api .. py:data:: app .. py:data:: api .. py:function:: apply_rules(file_list: List[str], bids_path: str, rules: dict, mapping_path: str) -> dict Apply rules to a set of files. :param file_list: List of str with the paths of the files we want to convert (ie the output of get_files). :type file_list: list of str :param bids_path: The path we want the converted files in. :type bids_path: str :param rules: A dictionary with the rules. :type rules: dict :param mapping_path: The fullpath where we want to write the mappings file. If '', then bids_path/code/sovabids/mappings.yml will be used. :type mapping_path: str, optional :returns: A dictionary following: { 'General': rules given, 'Individual':list of mapping dictionaries for each file } :rtype: dict .. rubric:: Notes A wrapper of around rules.apply_rules function. See docstring of :py:func:`apply_rules() ` in :py:mod:`rules` .. py:function:: convert_them(general: dict, individual: List[dict]) -> None Convert eeg files to bids according to the mappings given. :param general: The general rules :type general: dict :param individual: List with the individual mappings of each file. :type individual: list[dict] .. rubric:: Notes A wrapper of around convert.convert_them function. See docstring of :py:func:`convert_them() ` in :py:mod:`convert` :rtype: None .. py:function:: load_rules(rules_path: str) -> dict Load rules from a path. :param rules_path: The path to the rules file. :type rules_path: str :returns: The rules dictionary. :rtype: dict .. rubric:: Notes A wrapper of around rules.load_rules function. See docstring of :py:func:`load_rules() ` in :py:mod:`rules` .. py:function:: apply_rules_to_single_file(file: str, rules: dict, bids_path: str, write: bool = False, preview: bool = False) -> dict Apply rules to a single file. :param file: Path to the file. :type file: str :param rules: The rules dictionary. :type rules: dict :param bids_path: Path to the bids directory :type bids_path: str :param write: Whether to write the converted files to disk or not. :type write: bool, optional :param preview: 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* :type preview: bool, optional :returns: { mapping : dict The mapping obtained from applying the rules to the given file preview : bool|dict If preview = False, then False. If True, then the preview dictionary. } :rtype: dict .. rubric:: Notes A wrapper of around rules.apply_rules_to_single_file function. See docstring of :py:func:`apply_rules_to_single_file() ` in :py:mod:`rules` .. py:function:: save_rules(rules: dict, path: str) -> None Save rules as a yaml file to a path. :param rules: The rules dictionary to save :type rules: dict :param path: The full-path (including filename) where to save the rules as yaml. :type path: str :rtype: None .. rubric:: Notes A wrapper of around files._write_yaml function. See docstring of :py:func:`_write_yaml() ` in :py:mod:`files` .. py:function:: save_mappings(path: str, general: dict, individual: List[dict]) -> None Save mappings as a yaml file to a path. :param path: The full-path (including filename) where to save the mappings as yaml. :type path: str :param general: The general rules dictionary. :type general: dict :param individual: A list containing the mapping dictionary of each file. :type individual: list of dict :rtype: None .. rubric:: Notes A wrapper of around files._write_yaml function. See docstring of :py:func:`_write_yaml() ` in :py:mod:`files` .. py:function:: get_files(path: str, rules: dict) -> list 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". :param path: The path we want to obtain the files from. :type path: str :param rules: The rules dictionary. :type rules: dict :returns: A list containing the path to each valid file in the source_path. :rtype: list[str] .. rubric:: Notes A wrapper of around rules.get_files function. See docstring of :py:func:`get_files() ` in :py:mod:`rules` .. py:function:: main(entry='sovarpc:app', port=5000, debug=False)