Versions Compared

Key

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

Status
colourRed
titledraft

Although an App runs smoothly locally, when you try to run it on BL errors can occur. Here are the errors I came across and the way I solved them.

Null value of an optional parameter

  • When an optional parameter is not given (the input field stays empty), it is not written as null in the config.json file generated by Brainlife but it is written as ““. So it is considered as a string by the Python code and an error occurs.

For instance, the app-maxfilter takes the parameter st_duration as optional. Locally, in the config.json.example, when this parameter is not given it is written as :

Code Block
"param_st_duration": null

When this App was registered on BL, the st_duration parameter was entered as follows:

...

But, when no value was entered when executing the App, the config.json writes it as follows:

Code Block
"param_st_duration": "",

Then this value of this parameter is passed to the MNE function maxfilter, which reads it as a string instead of None and an error is raised because the function expects a float or None:

Code Block
ValueError: could not convert string to float

So, to circumvent this issue, I add to my Python file the lines:

Code Block
if config['param_st_duration'] == "":
    param_st_duration = None
else:
    param_st_duration = config['param_st_duration']

When it is possible, instead of registering an optional parameter as optional in BL, define it as an ENUM parameter and let the user choose between the fixed values of the parameter or an empty field, don’t propose None because in the config.json it will be written as:

Code Block
"param_regularize": "None"

instead of null.

Child pages (Children Display)