Skip to content

Function signature - #933

Draft
Edouard2laire wants to merge 4 commits into
brainstorm-tools:masterfrom
Edouard2laire:function_signature
Draft

Function signature#933
Edouard2laire wants to merge 4 commits into
brainstorm-tools:masterfrom
Edouard2laire:function_signature

Conversation

@Edouard2laire

@Edouard2laire Edouard2laire commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Hello,

This PR doesn't add much to brainstorm but kind of helps when writting script / process (i am always forgetting the exact spelling of the option when calling bst_get or db_template) :

it allows MATLAB to propose the context name for the function bst_get, when using tab after writing "bst_get" :
image

Unfortunately, it doesn't seem possible to complete the following arguments nicely depending on the first one; but I guess it's already nice.

If that's something you think might be useful, we could do the same thing for db_get, db_set, bst_set, db_template.

More information here: https://www.mathworks.com/help/matlab/matlab_prog/customize-code-suggestions-and-completions.html

Here is what it can look like on "simpler" function:
image

Edouard

@rcassani

rcassani commented Aug 3, 2026

Copy link
Copy Markdown
Member

This is a nice-to-have feature

Ideally, we would like to generate the .json file automatically on request and for a selected set of files.

@Edouard2laire

Copy link
Copy Markdown
Collaborator Author

So trying to parse the mat file, and extract the call from the comment ?

@rcassani

rcassani commented Aug 3, 2026

Copy link
Copy Markdown
Member

Parsing the code. Doc strings are not always up to date. That's another place of improvement.

VERIFY function has 'eval(macro_method)'
FIND all calls, regexp `'^\s*function.*\s(\w+)\('`
  1. Does it make sense to add the function signatures in the repo?
    As mentioned, this is more for developers.

  2. The autocompletion is suggested always as string "TEXT" rather than char vector 'TEXT', right?

In the scripting tutorial we indicate that text data should be given as char vector, as strings and char vectors are not always interchargeable. There have been some reported issues because of that: https://neuroimage.usc.edu/forums/t/org-brainstorm-tree-bstnode-is-not-assignable-to-org-brainstorm-tree-bstnode/33426/5

It would be strange that bst_get("Subject", 'MrFox') is valid, but not bst_get("Subject", "MrFox")

@Edouard2laire

Copy link
Copy Markdown
Collaborator Author

Parsing the code. Doc strings are not always up to date. That's another place of improvement.

VERIFY function has 'eval(macro_method)'
FIND all calls, regexp `'^\s*function.*\s(\w+)\('`

Another nice way is to use localfunctions; so for example:

>> process_absolute('localfunctions')

ans =

  3×1 cell array

    {@GetDescription}
    { @FormatComment}
    {           @Run}

  1. Does it make sense to add the function signatures in the repo?
    As mentioned, this is more for developers.

Where should we put it ? it seems it needs to be in the same folder as the function

  1. The autocompletion is suggested always as string "TEXT" rather than char vector 'TEXT', right?

yeah i wasn't happy about this too. But i just found that if you hit tab, after writing the ', then it completes as char, as expected. So for bst_get, you have to write bst_get(' , then hit tabs, and it completes correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants