Sorting files in database

I'm wondering if Brainstorm will delete unrecognized fields added to each files underlying Matlab structure variable

No. If you save additional fields in the .mat files, they will remain in place. You can store any additional data you want in them. However:

  • If you transform the files (eg. filtering), they might not be carried to the new file, but I guess you want to add fields to the imported epochs, which are already fully pre-processed, therefore this should not be a limitation.
  • The extra fields are not loaded in memory, and therefore not available from the GUI. If you want to create new displays, you would need to read the extra data from the files instead of the data structures in memory. This is a very minor problem, but I just wanted to point out the fact that the data structures loaded in memory when viewing the files are not exactly the files that are on the hard drive.

What you want to do is probably achievable with a custom version of view_erpimag.m, in which you would add an extra block that sorts the input files based on the extra fields (maybe around line 62).