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.
None value of an optional parameter
When an optional parameter is not given (the input field stays empty), it is not written as
null
in theconfig.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 :
"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:
"param_st_duration": "",
Then the 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.
ValueError: could not convert string to float
So, to circumvent this issue, I had in my Python file:
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 in ENUM and let the user choose between the fixed values of the parameter of None
Add Comment