Modifying process_average.m for custom processing

If you only need the grouping, you don't need to modify the function process_average.m file, or copy anything from it. If you are writing your script as a process, you could directly call the function SortFiles from process_average.m. To get an example of how this is called, see line 173 in process_average.m.

[iGroups, GroupComments, GroupNames] = process_average('SortFiles', sInputs, avgtype);

For help with writing scripts in Brainstorm:
https://neuroimage.usc.edu/brainstorm/Tutorials/Scripting

The API for writing processes:
https://neuroimage.usc.edu/brainstorm/Tutorials/TutUserProcess