.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/rpc_example.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_rpc_example.py: ======================================== RPC API example with the LEMON dataset ======================================== This example illustrates the use of ``sovabids`` on the `LEMON dataset `_ using the RPC API. .. warning:: To run this example, you need to install sovabids in 'advanced-usage' mode ( `see here `_ ). .. GENERATED FROM PYTHON SOURCE LINES 16-21 Sovabids uses an action-oriented API. Here we will illustrate each of the available functionalities. Imports ------- First we import some functions we will need: .. GENERATED FROM PYTHON SOURCE LINES 21-34 .. code-block:: Python import os # For path manipulation import shutil # File manipulation from mne_bids import print_dir_tree # To show the input/output directories structures inside this example from sovabids.datasets import lemon_prepare # Download the dataset from sovabids.settings import REPO_PATH from sovabids.sovarpc import app as sovapp # The RPC API application import sovabids.sovarpc as sovarpc from fastapi.testclient import TestClient # This will be for simulating ourselves as a client of the RPC API import json # for making json-based requests import copy # just to make deep copies of variables .. GENERATED FROM PYTHON SOURCE LINES 35-42 Getting and preparing the dataset --------------------------------- We have to download and decompress the dataset. We also need to fix a filename inconsistency (without this correction the file won't be able to be opened in mne). Luckily all of that is encapsulated in the lemon_prepare function since these issues are not properly of sovabids. By default the files are saved in the '_data' directory of the sovabids project. .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: Python lemon_prepare() .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading sub-032301.tar.gz at /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon WARNING: File already existed. Skipping... Downloading sub-032302.tar.gz at /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon WARNING: File already existed. Skipping... Downloading sub-032303.tar.gz at /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon WARNING: File already existed. Skipping... Downloading name_match.csv at /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon WARNING: File already existed. Skipping... LEMON PREPARE DONE! .. GENERATED FROM PYTHON SOURCE LINES 45-50 Setting up the paths -------------------- Now we will set up four paths. Because this example is intended to run relative to the repository directory we use relative path but for real use-cases it is easier to just input the absolute-path. We will print these paths for more clarity. .. GENERATED FROM PYTHON SOURCE LINES 50-61 .. code-block:: Python source_path = os.path.abspath(os.path.join(REPO_PATH,'_data','lemon')) # For the input data we will convert bids_path= os.path.abspath(os.path.join(REPO_PATH,'_data','lemon_bids_rpc')) # The output directory that will have the converted data rules_path = os.path.abspath(os.path.join(REPO_PATH,'examples','lemon_example_rules.yml')) # The rules file that setups the rule for conversion mapping_path = os.path.abspath(os.path.join(bids_path,'code','sovabids','mappings.yml')) # The mapping file that will hold the results of applying the rules to each file print('source_path:',source_path.replace(REPO_PATH,'')) print('bids_path:', bids_path.replace(REPO_PATH,'')) print('rules_path:',rules_path.replace(REPO_PATH,'')) print('mapping_path:',mapping_path.replace(REPO_PATH,'')) .. rst-class:: sphx-glr-script-out .. code-block:: none source_path: /_data/lemon bids_path: /_data/lemon_bids_rpc rules_path: /examples/lemon_example_rules.yml mapping_path: /_data/lemon_bids_rpc/code/sovabids/mappings.yml .. GENERATED FROM PYTHON SOURCE LINES 62-65 Cleaning the output directory ----------------------------- We will clean the output path as a safety measure from previous conversions. .. GENERATED FROM PYTHON SOURCE LINES 65-71 .. code-block:: Python try: shutil.rmtree(bids_path) except: pass .. GENERATED FROM PYTHON SOURCE LINES 72-75 The input directory ------------------- For clarity purposes we will print here the directory we are trying to convert to BIDS. .. GENERATED FROM PYTHON SOURCE LINES 75-80 .. code-block:: Python print_dir_tree(source_path) .. rst-class:: sphx-glr-script-out .. code-block:: none |lemon/ |--- name_match.csv |--- sub-032301.tar.gz |--- sub-032302.tar.gz |--- sub-032303.tar.gz |--- sub-010002/ |------ RSEEG/ |--------- sub-010002.eeg |--------- sub-010002.vhdr |--------- sub-010002.vmrk |--- sub-010003/ |------ RSEEG/ |--------- sub-010003.eeg |--------- sub-010003.vhdr |--------- sub-010003.vmrk |--- sub-010004/ |------ RSEEG/ |--------- sub-010004.eeg |--------- sub-010004.vhdr |--------- sub-010004.vmrk .. GENERATED FROM PYTHON SOURCE LINES 81-86 RPC API ------- Simulating ourselves as clients ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ We will use the TestClient class to send requests to the API (the sovapp variable) .. GENERATED FROM PYTHON SOURCE LINES 86-89 .. code-block:: Python client = TestClient(sovapp) .. GENERATED FROM PYTHON SOURCE LINES 90-94 The general request ^^^^^^^^^^^^^^^^^^^ We will define a function to make a request to the API given the name of the method and its parameters as a dictionary .. GENERATED FROM PYTHON SOURCE LINES 94-127 .. code-block:: Python def make_request(method,params): print('Method:',method) print('');print(''); print('Parameters:') print(json.dumps(params, indent=4)) print('');print(''); # We create the complete request request= { "jsonrpc": "2.0", "id": 0, "method": method, "params": params} print('Request:') print(json.dumps(request, indent=4)) print('');print(''); # json dumps is important to avoid parsing errors in the API request request = json.dumps(request) # Send the request request_url = "/api/sovabids/" +method print('Request URL:') print(request_url) print('');print(''); response = client.post(request_url,data=request ) # POST request as common in RPC-based APIs # Get the answer result = json.loads(response.content.decode())['result'] print('Answer:') print(json.dumps(result, indent=4)) print('');print(''); return result .. GENERATED FROM PYTHON SOURCE LINES 128-132 load_rules ^^^^^^^^^^ For loading a yaml rules file. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 132-135 .. code-block:: Python print(sovarpc.load_rules.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none Load rules from a path. Parameters ---------- rules_path : str The path to the rules file. Returns ------- dict The rules dictionary. Notes ----- A wrapper of around rules.load_rules function. See docstring of :py:func:`load_rules() ` in :py:mod:`rules` .. GENERATED FROM PYTHON SOURCE LINES 136-137 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 137-144 .. code-block:: Python method = 'load_rules' # Just a variable for the method name params = { # Parameters of the method "rules_path": rules_path } .. GENERATED FROM PYTHON SOURCE LINES 145-146 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 146-151 .. code-block:: Python result = make_request(method,params) rules = copy.deepcopy(result) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: load_rules Parameters: { "rules_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/examples/lemon_example_rules.yml" } Request: { "jsonrpc": "2.0", "id": 0, "method": "load_rules", "params": { "rules_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/examples/lemon_example_rules.yml" } } Request URL: /api/sovabids/load_rules Answer: { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } } .. GENERATED FROM PYTHON SOURCE LINES 152-156 save_rules ^^^^^^^^^^ We can for example use it as a way to save a backup of the already-existing rules file. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 156-158 .. code-block:: Python print(sovarpc.save_rules.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 ------- None Notes ----- A wrapper of around files._write_yaml function. See docstring of :py:func:`_write_yaml() ` in :py:mod:`files` .. GENERATED FROM PYTHON SOURCE LINES 159-160 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 160-168 .. code-block:: Python method = "save_rules" # Just a variable for the method name params = { # Parameters of the method "rules": rules, "path": mapping_path.replace('mappings','rules')+'.bkp' # We will do it as if we were saving a backup of the rules # Since the rules file already exists } .. GENERATED FROM PYTHON SOURCE LINES 169-170 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 170-172 .. code-block:: Python result = make_request(method,params) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: save_rules Parameters: { "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/code/sovabids/rules.yml.bkp" } Request: { "jsonrpc": "2.0", "id": 0, "method": "save_rules", "params": { "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/code/sovabids/rules.yml.bkp" } } Request URL: /api/sovabids/save_rules Answer: null .. GENERATED FROM PYTHON SOURCE LINES 173-177 get_files ^^^^^^^^^ Useful for getting the files on a directory. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 177-179 .. code-block:: Python print(sovarpc.get_files.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 ------- list[str]: A list containing the path to each valid file in the source_path. Notes ----- A wrapper of around rules.get_files function. See docstring of :py:func:`get_files() ` in :py:mod:`rules` .. GENERATED FROM PYTHON SOURCE LINES 180-183 .. note:: get_files uses the rules because of the non-bids.eeg_extension configuration. .. GENERATED FROM PYTHON SOURCE LINES 186-187 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 187-194 .. code-block:: Python method = "get_files" # Just a variable for the method name params = { # Parameters of the method "rules": rules, "path": source_path } .. GENERATED FROM PYTHON SOURCE LINES 195-196 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 196-200 .. code-block:: Python result = make_request(method,params) filelist = copy.deepcopy(result) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: get_files Parameters: { "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon" } Request: { "jsonrpc": "2.0", "id": 0, "method": "get_files", "params": { "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon" } } Request URL: /api/sovabids/get_files Answer: [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ] .. GENERATED FROM PYTHON SOURCE LINES 201-206 apply_rules_to_single_file ^^^^^^^^^^^^^^^^^^^^^^^^^^ We can use this to get a mapping for a single mapping and for previewing the bids files that would be written. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 206-208 .. code-block:: Python print(sovarpc.apply_rules_to_single_file.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 ------- dict: { 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. } 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` .. GENERATED FROM PYTHON SOURCE LINES 209-210 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 210-220 .. code-block:: Python method = "apply_rules_to_single_file" # Just a variable for the method name params = { # Parameters of the method "file": filelist[0], "bids_path": bids_path+'.preview', "rules": rules, "write":False, "preview":True } .. GENERATED FROM PYTHON SOURCE LINES 221-222 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 222-225 .. code-block:: Python result = make_request(method,params) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: apply_rules_to_single_file Parameters: { "file": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "bids_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc.preview", "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "write": false, "preview": true } Request: { "jsonrpc": "2.0", "id": 0, "method": "apply_rules_to_single_file", "params": { "file": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "bids_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc.preview", "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "write": false, "preview": true } } Request URL: /api/sovabids/apply_rules_to_single_file Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr... Setting channel info structure... /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:286: RuntimeWarning: Converting data files to BrainVision format write_raw_bids(raw, bids_path=bids_path,overwrite=True,format=output_format,allow_preload=True,verbose=False) /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:286: RuntimeWarning: Encountered data in "short" format. Converting to float32. write_raw_bids(raw, bids_path=bids_path,overwrite=True,format=output_format,allow_preload=True,verbose=False) Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc.preview/dataset_description.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc.preview/sub-010002/eeg/sub-010002_task-resting_eeg.json'... Answer: { "mapping": { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010002", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc.preview/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" } }, "preview": { "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc.preview/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" }, "entities": { "subject": "010002", "task": "resting" }, "dataset_description": "{ \"Name\": \"Lemon\", \"BIDSVersion\": \"1.7.0\", \"DatasetType\": \"raw\", \"Authors\": [ \"Anahit Babayan\", \"Miray Erbey\", \"Deniz Kumral\", \"Janis D. Reinelt\", \"Andrea M. F. Reiter\", \"Josefin R\\u00f6bbig\", \"H. Lina Schaare\", \"Marie Uhlig\", \"Alfred Anwander\", \"Pierre-Louis Bazin\", \"Annette Horstmann\", \"Leonie Lampe\", \"Vadim V. Nikulin\", \"Hadas Okon-Singer\", \"Sven Preusser\", \"Andr\\u00e9 Pampel\", \"Christiane S. Rohr\", \"Julia Sacher1\", \"Angelika Th\\u00f6ne-Otto\", \"Sabrina Trapp\", \"Till Nierhaus\", \"Denise Altmann\", \"Katrin Arelin\", \"Maria Bl\\u00f6chl\", \"Edith Bongartz\", \"Patric Breig\", \"Elena Cesnaite\", \"Sufang Chen\", \"Roberto Cozatl\", \"Saskia Czerwonatis\", \"Gabriele Dambrauskaite\", \"Maria Dreyer\", \"Jessica Enders\", \"Melina Engelhardt\", \"Marie Michele Fischer\", \"Norman Forschack\", \"Johannes Golchert\", \"Laura Golz\", \"C. Alexandrina Guran\", \"Susanna Hedrich\", \"Nicole Hentschel\", \"Daria I. Hoffmann\", \"Julia M. Huntenburg\", \"Rebecca Jost\", \"Anna Kosatschek\", \"Stella Kunzendorf\", \"Hannah Lammers\", \"Mark E. Lauckner\", \"Keyvan Mahjoory\", \"Natacha Mendes\", \"Ramona Menger\", \"Enzo Morino\", \"Karina N\\u00e4the\", \"Jennifer Neubauer\", \"Handan Noyan\", \"Sabine Oligschl\\u00e4ger\", \"Patricia Panczyszyn-Trzewik\", \"Dorothee Poehlchen\", \"Nadine Putzke\", \"Sabrina Roski\", \"Marie-Catherine Schaller\", \"Anja Schieferbein\", \"Benito Schlaak\", \"Hanna Maria Schmidt\", \"Robert Schmidt\", \"Anne Schrimpf\", \"Sylvia Stasch\", \"Maria Voss\", \"Anett Wiedemann\", \"Daniel S. Margulies\", \"Michael Gaebler\", \"Arno Villringer\" ]}", "sidecar": "{ \"TaskName\": \"resting\", \"Manufacturer\": \"Brain Products\", \"PowerLineFrequency\": 50, \"SamplingFrequency\": 2500.0, \"SoftwareFilters\": \"n/a\", \"RecordingDuration\": 1021.9996, \"RecordingType\": \"continuous\", \"EEGReference\": \"FCz\", \"EEGGround\": \"n/a\", \"EEGPlacementScheme\": \"based on the extended 10/20 system\"}", "channels": { "name": "Fp1,Fp2,F7,F3,Fz,F4,F8,FC5,FC1,FC2,FC6,T7,C3,Cz,C4,T8,VEOG,CP5,CP1,CP2,CP6,AFz,P7,P3,Pz,P4,P8,PO9,O1,Oz,O2,PO10,AF7,AF3,AF4,AF8,F5,F1,F2,F6,FT7,FC3,FC4,FT8,C5,C1,C2,C6,TP7,CP3,CPz,CP4,TP8,P5,P1,P2,P6,PO7,PO3,POz,PO4,PO8", "type": "EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,VEOG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG,EEG", "units": "\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V,\u00b5V", "low_cutoff": "0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534,0.015915494309189534", "high_cutoff": "1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0,1000.0", "description": "ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroOculoGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram,ElectroEncephaloGram", "sampling_frequency": "2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0,2500.0", "status": "good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good,good", "status_description": "n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a,n/a" } } } .. GENERATED FROM PYTHON SOURCE LINES 226-230 apply_rules ^^^^^^^^^^^ We can use this to get the mappings for all the files in a list of them. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 230-232 .. code-block:: Python print(sovarpc.apply_rules.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 ------- dict : A dictionary following: { 'General': rules given, 'Individual':list of mapping dictionaries for each file } Notes ----- A wrapper of around rules.apply_rules function. See docstring of :py:func:`apply_rules() ` in :py:mod:`rules` .. GENERATED FROM PYTHON SOURCE LINES 233-234 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 234-243 .. code-block:: Python method = "apply_rules" # Just a variable for the method name params = { # Parameters of the method "file_list": filelist, "bids_path": bids_path, "rules": rules, "mapping_path":mapping_path } .. GENERATED FROM PYTHON SOURCE LINES 244-245 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 245-249 .. code-block:: Python result = make_request(method,params) file_mappings=copy.deepcopy(result) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: apply_rules Parameters: { "file_list": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "bids_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc", "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "mapping_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/code/sovabids/mappings.yml" } Request: { "jsonrpc": "2.0", "id": 0, "method": "apply_rules", "params": { "file_list": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "bids_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc", "rules": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } } }, "mapping_path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/code/sovabids/mappings.yml" } } Request URL: /api/sovabids/apply_rules Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr... Setting channel info structure... Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr... Setting channel info structure... Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr... Setting channel info structure... Answer: { "General": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "IO": { "source": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc" } }, "Individual": [ { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010002", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010003", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010004", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" } } ] } .. GENERATED FROM PYTHON SOURCE LINES 250-254 save_mappings ^^^^^^^^^^^^^ We can use this to save a backup of the mappings. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 254-256 .. code-block:: Python print(sovarpc.save_mappings.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 ------- None Notes ----- A wrapper of around files._write_yaml function. See docstring of :py:func:`_write_yaml() ` in :py:mod:`files` .. GENERATED FROM PYTHON SOURCE LINES 257-258 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 258-266 .. code-block:: Python method = "save_mappings" # Just a variable for the method name params = { # Parameters of the method "general": file_mappings['General'], "individual":file_mappings['Individual'], "path": mapping_path+'.bkp' } .. GENERATED FROM PYTHON SOURCE LINES 267-268 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 268-270 .. code-block:: Python result = make_request(method,params) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: save_mappings Parameters: { "general": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "IO": { "source": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc" } }, "individual": [ { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010002", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010003", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010004", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" } } ], "path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/code/sovabids/mappings.yml.bkp" } Request: { "jsonrpc": "2.0", "id": 0, "method": "save_mappings", "params": { "general": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "IO": { "source": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc" } }, "individual": [ { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010002", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010003", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010004", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" } } ], "path": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/code/sovabids/mappings.yml.bkp" } } Request URL: /api/sovabids/save_mappings Answer: null .. GENERATED FROM PYTHON SOURCE LINES 271-275 convert_them ^^^^^^^^^^^^ We can use this to perform the conversion given the mappings. Lets see the docstring of this method .. GENERATED FROM PYTHON SOURCE LINES 275-277 .. code-block:: Python print(sovarpc.convert_them.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 :py:func:`convert_them() ` in :py:mod:`convert` Returns ------- None .. GENERATED FROM PYTHON SOURCE LINES 278-279 Lets define the request .. GENERATED FROM PYTHON SOURCE LINES 279-286 .. code-block:: Python method = "convert_them" # Just a variable for the method name params = { # Parameters of the method "general": file_mappings['General'], "individual":file_mappings['Individual'] } .. GENERATED FROM PYTHON SOURCE LINES 287-288 And proceed with it .. GENERATED FROM PYTHON SOURCE LINES 288-291 .. code-block:: Python result = make_request(method,params) .. rst-class:: sphx-glr-script-out .. code-block:: none Method: convert_them Parameters: { "general": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "IO": { "source": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc" } }, "individual": [ { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010002", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010003", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010004", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" } } ] } Request: { "jsonrpc": "2.0", "id": 0, "method": "convert_them", "params": { "general": { "entities": { "task": "resting" }, "dataset_description": { "Name": "Lemon", "Authors": [ "Anahit Babayan", "Miray Erbey", "Deniz Kumral", "Janis D. Reinelt", "Andrea M. F. Reiter", "Josefin R\u00f6bbig", "H. Lina Schaare", "Marie Uhlig", "Alfred Anwander", "Pierre-Louis Bazin", "Annette Horstmann", "Leonie Lampe", "Vadim V. Nikulin", "Hadas Okon-Singer", "Sven Preusser", "Andr\u00e9 Pampel", "Christiane S. Rohr", "Julia Sacher1", "Angelika Th\u00f6ne-Otto", "Sabrina Trapp", "Till Nierhaus", "Denise Altmann", "Katrin Arelin", "Maria Bl\u00f6chl", "Edith Bongartz", "Patric Breig", "Elena Cesnaite", "Sufang Chen", "Roberto Cozatl", "Saskia Czerwonatis", "Gabriele Dambrauskaite", "Maria Dreyer", "Jessica Enders", "Melina Engelhardt", "Marie Michele Fischer", "Norman Forschack", "Johannes Golchert", "Laura Golz", "C. Alexandrina Guran", "Susanna Hedrich", "Nicole Hentschel", "Daria I. Hoffmann", "Julia M. Huntenburg", "Rebecca Jost", "Anna Kosatschek", "Stella Kunzendorf", "Hannah Lammers", "Mark E. Lauckner", "Keyvan Mahjoory", "Natacha Mendes", "Ramona Menger", "Enzo Morino", "Karina N\u00e4the", "Jennifer Neubauer", "Handan Noyan", "Sabine Oligschl\u00e4ger", "Patricia Panczyszyn-Trzewik", "Dorothee Poehlchen", "Nadine Putzke", "Sabrina Roski", "Marie-Catherine Schaller", "Anja Schieferbein", "Benito Schlaak", "Hanna Maria Schmidt", "Robert Schmidt", "Anne Schrimpf", "Sylvia Stasch", "Maria Voss", "Anett Wiedemann", "Daniel S. Margulies", "Michael Gaebler", "Arno Villringer" ] }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "IO": { "source": [ "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr", "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" ], "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc" } }, "individual": [ { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010002", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010003", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr" } }, { "non-bids": { "eeg_extension": ".vhdr", "path_analysis": { "pattern": "RSEEG/sub-%entities.subject%.vhdr" } }, "sidecar": { "PowerLineFrequency": 50, "EEGReference": "FCz" }, "channels": { "type": { "VEOG": "VEOG", "F3": "EEG" } }, "entities": { "subject": "010004", "task": "resting" }, "IO": { "target": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.vhdr", "source": "/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr" } } ] } } Request URL: /api/sovabids/convert_them Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010002/RSEEG/sub-010002.vhdr... Setting channel info structure... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/README'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/participants.tsv'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/participants.json'... The provided raw data contains annotations, but you did not pass an "event_id" mapping from annotation descriptions to event codes. We will generate arbitrary event codes. To specify custom event codes, please pass "event_id". Used Annotations descriptions: ['Comment/no USB Connection to actiCAP', 'New Segment/', 'Stimulus/S 1', 'Stimulus/S200', 'Stimulus/S210'] Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_events.tsv'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_events.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/dataset_description.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_channels.tsv'... Copying data files to sub-010002_task-resting_eeg.vhdr /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:278: RuntimeWarning: Converting data files to BrainVision format write_raw_bids(raw, bids_path=bids_path,format=output_format,allow_preload=True,overwrite=True) /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:278: RuntimeWarning: Encountered data in "short" format. Converting to float32. write_raw_bids(raw, bids_path=bids_path,format=output_format,allow_preload=True,overwrite=True) Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/sub-010002_scans.tsv'... Wrote /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/sub-010002_scans.tsv entry with eeg/sub-010002_task-resting_eeg.vhdr. Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010002/eeg/sub-010002_task-resting_eeg.json'... Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010003/RSEEG/sub-010003.vhdr... Setting channel info structure... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/participants.tsv'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/participants.json'... The provided raw data contains annotations, but you did not pass an "event_id" mapping from annotation descriptions to event codes. We will generate arbitrary event codes. To specify custom event codes, please pass "event_id". Used Annotations descriptions: ['Comment/no USB Connection to actiCAP', 'New Segment/', 'Stimulus/S 1', 'Stimulus/S200', 'Stimulus/S210'] Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_events.tsv'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_events.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/dataset_description.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_channels.tsv'... Copying data files to sub-010003_task-resting_eeg.vhdr /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:278: RuntimeWarning: Converting data files to BrainVision format write_raw_bids(raw, bids_path=bids_path,format=output_format,allow_preload=True,overwrite=True) /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:278: RuntimeWarning: Encountered data in "short" format. Converting to float32. write_raw_bids(raw, bids_path=bids_path,format=output_format,allow_preload=True,overwrite=True) Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/sub-010003_scans.tsv'... Wrote /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/sub-010003_scans.tsv entry with eeg/sub-010003_task-resting_eeg.vhdr. Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010003/eeg/sub-010003_task-resting_eeg.json'... Extracting parameters from /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon/sub-010004/RSEEG/sub-010004.vhdr... Setting channel info structure... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/participants.tsv'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/participants.json'... The provided raw data contains annotations, but you did not pass an "event_id" mapping from annotation descriptions to event codes. We will generate arbitrary event codes. To specify custom event codes, please pass "event_id". Used Annotations descriptions: ['Comment/actiCAP Data On', 'New Segment/', 'Stimulus/S 1', 'Stimulus/S200', 'Stimulus/S210'] Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_events.tsv'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_events.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/dataset_description.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_channels.tsv'... Copying data files to sub-010004_task-resting_eeg.vhdr /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:278: RuntimeWarning: Converting data files to BrainVision format write_raw_bids(raw, bids_path=bids_path,format=output_format,allow_preload=True,overwrite=True) /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/sovabids/rules.py:278: RuntimeWarning: Encountered data in "short" format. Converting to float32. write_raw_bids(raw, bids_path=bids_path,format=output_format,allow_preload=True,overwrite=True) Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/sub-010004_scans.tsv'... Wrote /home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/sub-010004_scans.tsv entry with eeg/sub-010004_task-resting_eeg.vhdr. Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/sub-010004/eeg/sub-010004_task-resting_eeg.json'... Writing '/home/docs/checkouts/readthedocs.org/user_builds/sovabids/checkouts/latest/_data/lemon_bids_rpc/dataset_description.json'... Answer: null .. GENERATED FROM PYTHON SOURCE LINES 292-295 Checking the conversion ----------------------- For clarity purposes we will check the output directory we got from sovabids. .. GENERATED FROM PYTHON SOURCE LINES 295-300 .. code-block:: Python print_dir_tree(bids_path) print('LEMON CONVERSION FINISHED!') .. rst-class:: sphx-glr-script-out .. code-block:: none |lemon_bids_rpc/ |--- README |--- dataset_description.json |--- participants.json |--- participants.tsv |--- code/ |------ sovabids/ |--------- mappings.yml |--------- mappings.yml.bkp |--------- rules.yml.bkp |--------- sovabids.log |--------- sovabids.log.errors |--- sub-010002/ |------ sub-010002_scans.tsv |------ eeg/ |--------- sub-010002_task-resting_channels.tsv |--------- sub-010002_task-resting_eeg.eeg |--------- sub-010002_task-resting_eeg.json |--------- sub-010002_task-resting_eeg.vhdr |--------- sub-010002_task-resting_eeg.vmrk |--------- sub-010002_task-resting_events.json |--------- sub-010002_task-resting_events.tsv |--- sub-010003/ |------ sub-010003_scans.tsv |------ eeg/ |--------- sub-010003_task-resting_channels.tsv |--------- sub-010003_task-resting_eeg.eeg |--------- sub-010003_task-resting_eeg.json |--------- sub-010003_task-resting_eeg.vhdr |--------- sub-010003_task-resting_eeg.vmrk |--------- sub-010003_task-resting_events.json |--------- sub-010003_task-resting_events.tsv |--- sub-010004/ |------ sub-010004_scans.tsv |------ eeg/ |--------- sub-010004_task-resting_channels.tsv |--------- sub-010004_task-resting_eeg.eeg |--------- sub-010004_task-resting_eeg.json |--------- sub-010004_task-resting_eeg.vhdr |--------- sub-010004_task-resting_eeg.vmrk |--------- sub-010004_task-resting_events.json |--------- sub-010004_task-resting_events.tsv LEMON CONVERSION FINISHED! .. GENERATED FROM PYTHON SOURCE LINES 301-311 The ideal GUI for the designed API ---------------------------------- Here is the GUI schematic we had in mind when we designed the API .. image:: https://user-images.githubusercontent.com/36543115/125894264-9e1bd421-41e2-444b-adcb-ecf11e81d1a0.png :alt: Ideal GUI .. warning:: The only difference is that apply_rules will receive a list of the paths of the files we want to convert rather than a single input directory path .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 39.171 seconds) .. _sphx_glr_download_auto_examples_rpc_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: rpc_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: rpc_example.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_