Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So we have to convert these values in the Python file.

Case of numpy nd.array

In the config.json.example, it is not possible to enter directly a numpy.nd.array, so we enter a list of floats instead:

...

The part when we test if config['param_origin'] is a list is here to make this condition only used when the App is run locally.

Case of a slice

Here again it is impossible to enter a slice in the config.json.example, so in this file we enter:

...

In this case, these lines of code are used to convert the string to a slice when the App runs locally but also on Brainlife.

Case of a tuple

It is also impossible to enter a tuple in a json file, so instead the we enter:

Code Block
{
"param_baseline": [null, 0]
}

...

Code Block
if config['param_baseline'] is not None:
    config['param_baseline'] = tuple(config['param_baseline'])

Case of a dictionary

It is possible to enter a dictionary in the config.json.example using a nested structure:

Code Block
{    
"param_reject": {
                 "grad": 4000e-13,
                 "mag": 4e-12,
                 "eeg": 40e-6
                 }
}

When the config.json.example is parsed by the Python code, config['param_reject'] is directly a dictionary, so no conversion is required.

Case of a pandas.Dataframe

Some metadata can be stored in a pandas.Dataframe and given to a MNE function (for instance mne.Epochs). So either, the information is stored into a .csv and converted into a pandas.Dataframe using:

Code Block
if isinstance(config['param_metadata'], str):
    config['param_metadata'] = pd.read_csv(config['param_metadata'])

Or the user enters a dictionary in the config.json.example and this dictionary will be then converted into a pandas.Dataframe using:

Code Block
elif isinstance(config['param_metadata'], dict):
    config['param_metadata'] = pd.DataFrame(list(config['param_metadata'].items()))