Versions Compared

Key

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

...

For now, we have decided not to read and convert Python dictionaries, so the BL user won’t be able to give a dictionary as a parameter value. However, he can use a dictionary if he uses the App locally (see https://icm-institute.atlassian.net/wiki/pages/resumedraft.action?draftId=1562771457).

Python dictionaries are used in app-temporal-filtering to define optionally the parameters of an IIR filter, but also in app-make-epochs to define the threshold values for each type of channel to use to detect bad channels. So, it is important to find a way to make possible to use dictionaries on BL.

Case of a numpy.nd.array

It is impossible to enter a np.nd.array in BL. So we register such parameter as a STRING and ask the user to enter floats separated by a comma: 10, 15, 20. In the config.json, such parameter will be written as:

...

Code Block
if isinstance(config['param_baseline'], str):
    param_baseline = list(map(str, config['param_baseline'].split(', ')))
    param_baseline = [None if i=='None' else i for i in param_baseline]
    param_baseline = [float(i) if isinstance(i, str) else i for i in param_baseline]
    config['param_baseline'] = tuple(param_baseline)

The first step is to convert it into a list and then convert the elements of the list into the right type. For tuple parameters in which their elements are the same type, there is no need to compute the two list comprehensions:

Code Block
if isinstance(config['param_tuple_floats'], str):
    config['param_tuple_floats'] = list(map(str, config['param_tuple_floats'].split(', ')))
    config['param_tuple_floats'] = tuple(config['param_tuple_floats'])
Info

This parameter is entered the same way as a numpy.nd.array and a slice. So far it is not an issue because no parameter is either a numpy.nd.array, a slice or a tuple.

...

If you want to convert it into a list of floats or ints, just replace str in list(map(str, picks.split(', '))) by the type you want.

If the list is empty, the user must enter []. In the Python code it will be converted into an empty list:

Code Block
if config['param_extended_proj'] == '[]':
    config['param_extended_proj'] = [] 

Cases when a parameter can be two types

...