Brainstorm's Database Structure

Authors: Martin Cousineau, Raymundo Cassani

Understanding the data structures used by Brainstorm is paramount when you want to work on the development of the software. In this page, we will describe the data structures used to store information about a dataset, both in memory and on the hard drive.

On the hard drive

When you first launch Brainstorm, it asks you to create a Brainstorm database directory (brainstorm_db) on your hard drive. Inside this directory, Brainstorm will create an individual folder for each protocols. This is where the data of a protocol will reside on your hard drive. The database explorer of the software (data tree) is populated directly from the files located in this folder. It has a strict hierarchy, explained in the bullet list below:

All required metadata should always be saved on the hard drive outside of the protocol.mat / protocol.db files, such that if they get corrupted, deleted or one does a fresh reload of the database, there is no loss of information. This is why things like: which cortex file is selected, or which trials are marked as bad are also saved in separate files (brainstormsubject.mat and brainstormstudy.mat).

The filename of each file should always clearly indicate the basic type of the file, hence the required prefixes (e.g. data_*.mat).

The content of the structure of each .mat files is defined in db_template(), with the 'mat' suffix to differenciate from the in-memory metadata structure and the in-momery data structure of each type. For example:

Metadata Matlab Structure (Old)

Once a protocol is loaded, Brainstorm has Matlab structures in memory that contain the metadata of all the files in this protocol. These are located in the GlobalData.DataBase global variable, such that it is easily accessible in any function of the software. It is defined db_template('GlobalData'). Let's walk through some of the important variables in this structure:

TODO: db_template('Subject'), db_template('Study'), db_template('Data'). etc

Metadata SQLite Structure (New)

TODO.

Tutorials/Database (last edited 2021-03-18 16:18:40 by ?MartinCousineau)