Note
Go to the end to download the full example code
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 ).
Sovabids uses an action-oriented API. Here we will illustrate each of the available functionalities.
Imports#
First we import some functions we will need:
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
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.
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!
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.
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,''))
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
Cleaning the output directory#
We will clean the output path as a safety measure from previous conversions.
try:
shutil.rmtree(bids_path)
except:
pass
The input directory#
For clarity purposes we will print here the directory we are trying to convert to BIDS.
print_dir_tree(source_path)
|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
RPC API#
Simulating ourselves as clients#
We will use the TestClient class to send requests to the API (the sovapp variable)
client = TestClient(sovapp)
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
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
load_rules#
For loading a yaml rules file. Lets see the docstring of this method
print(sovarpc.load_rules.__doc__)
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() <rules.load_rules>` in :py:mod:`rules`
Lets define the request
method = 'load_rules' # Just a variable for the method name
params = { # Parameters of the method
"rules_path": rules_path
}
And proceed with it
result = make_request(method,params)
rules = copy.deepcopy(result)
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"
}
}
}
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
print(sovarpc.save_rules.__doc__)
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() <files._write_yaml>` in :py:mod:`files`
Lets define the request
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
}
And proceed with it
result = make_request(method,params)
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
get_files#
Useful for getting the files on a directory. Lets see the docstring of this method
print(sovarpc.get_files.__doc__)
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() <rules.get_files>` in :py:mod:`rules`
Note
get_files uses the rules because of the non-bids.eeg_extension configuration.
Lets define the request
method = "get_files" # Just a variable for the method name
params = { # Parameters of the method
"rules": rules,
"path": source_path
}
And proceed with it
result = make_request(method,params)
filelist = copy.deepcopy(result)
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"
]
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
print(sovarpc.apply_rules_to_single_file.__doc__)
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() <rules.apply_rules_to_single_file>` in :py:mod:`rules`
Lets define the request
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
}
And proceed with it
result = make_request(method,params)
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": {
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010002",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
}
}
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
print(sovarpc.apply_rules.__doc__)
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() <rules.apply_rules>` in :py:mod:`rules`
Lets define the request
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
}
And proceed with it
result = make_request(method,params)
file_mappings=copy.deepcopy(result)
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": [
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010002",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010003",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010004",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
}
]
}
save_mappings#
We can use this to save a backup of the mappings. Lets see the docstring of this method
print(sovarpc.save_mappings.__doc__)
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() <files._write_yaml>` in :py:mod:`files`
Lets define the request
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'
}
And proceed with it
result = make_request(method,params)
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": [
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010002",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010003",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010004",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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": [
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010002",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010003",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010004",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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
convert_them#
We can use this to perform the conversion given the mappings. Lets see the docstring of this method
print(sovarpc.convert_them.__doc__)
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() <convert.convert_them>` in :py:mod:`convert`
Returns
-------
None
Lets define the request
method = "convert_them" # Just a variable for the method name
params = { # Parameters of the method
"general": file_mappings['General'],
"individual":file_mappings['Individual']
}
And proceed with it
result = make_request(method,params)
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": [
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010002",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010003",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010004",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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": [
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010002",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010003",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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"
}
},
{
"sidecar": {
"PowerLineFrequency": 50,
"EEGReference": "FCz"
},
"channels": {
"type": {
"VEOG": "VEOG",
"F3": "EEG"
}
},
"entities": {
"subject": "010004",
"task": "resting"
},
"non-bids": {
"eeg_extension": ".vhdr",
"path_analysis": {
"pattern": "RSEEG/sub-%entities.subject%.vhdr"
}
},
"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/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/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/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
Checking the conversion#
For clarity purposes we will check the output directory we got from sovabids.
print_dir_tree(bids_path)
print('LEMON CONVERSION FINISHED!')
|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.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.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.tsv
LEMON CONVERSION FINISHED!
The ideal GUI for the designed API#
Here is the GUI schematic we had in mind when we designed the API

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
Total running time of the script: ( 0 minutes 40.109 seconds)