Matrix-type Montage implementation in Montage Editor for Local Composite Reference (LCR) method

Hello Brainstorm Team,

I am currently collaborating with a research team developing micro-ECOG sensors for mouse models. We are utilizing various sensor layouts, and one of our current configurations is as follows:

In this setup, if we define A-000 to A-007 as "Set A" and A-008 to A-015 as "Set B," we can apply a Local Average Reference (LAR) as shown in the attached image:

While Brainstorm currently supports Common Average Reference (CAR), Local Average Reference (LAR), and Bipolar Reference (BPR), I am looking to implement a Local Composite Reference (LCR) method.
To achieve this, I believe I need to implement a Matrix-type montage, which does not seem to be directly supported in the current version of the Montage Editor.
(Reference: Mercier, Manuel R., et al. "Advances in human intracranial electroencephalography research, guidelines and good practices." Neuroimage 260 (2022): 119438.)

My goal is to subtract the average of specific neighboring channels for each individual channel, as outlined below:

A-000 : 1 2 5 6 7
A-001 : 0 2 3 4 5 6 7
A-002 : 0 1 4 7
A-003 : 1 4 5
A-004 : 1 2 3
A-005 : 0 1 3 6
A-006 : 0 1 5
A-007 : 0 1 2

A-008 : 13 14 15
A-009 : 10 12 14 15
A-010 : 9 12 14
A-011 : 12 13 14
A-012 : 9 10 11 13 14
A-013 : 8 11 12 14
A-014 : 8 9 10 11 12 13 15
A-015 : 8 9 14

While one could theoretically calculate and import a montage matrix manually, I’ve found that even when creating a new montage or duplicating an existing average reference in the Montage Editor, it cannot be converted into a Matrix-type.
Furthermore, the standard "New Montage" creation seems limited to selecting only two channels (signal and reference).

Is there an existing way to generate or edit a Matrix-type montage within Brainstorm?

If this is not currently possible, I would like to formally request a feature that allows users to manually define a "Matrix-type" montage by selecting a target channel and multiple neighboring channels to be used for the reference calculation.

Thank you for your time and for this excellent software.

Hi @breakofday13, that is right, you would need to create your own montage matrix.

The montage you are describing has the same channel "in" and "out", so you can take as template the Average reference template. This can be done easily in the Montage editor:

  1. Select the Average reference montage
  2. Export it (button ) to a file using the type Brainstorm montage file (montage_*.mat)
  3. Open it in Matlab, and change these fields
    1. Name, give it a unique name
    2. Matrix, here is where the magic happens. As a sanity test, you can set it to be the -1 times identity matrix, so the montage just changes the polarity when selected.
  4. Save the modified montage
  5. Import the modified montage. Now you can selected and see its effects

With this said, you montage matrix will have the size 16x16 where each row indicates the mixing row vector that will be applied to compute each channel.

E.g. in the case of A0

  1. The average across the adjacent channels (1, 2, 5, 6, 7) can be computed as a matrix multiplication (b*X) with b equal [0 1 1 0 0 1 1 1 0 0 0 0 0 0 0 0 ] / 5, and X is the data in the shape [nChannels, nTime]

  2. Thus A0 minus the average c*X with c = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] - b

You would need to compute the mixing row vector c for all channels, and then concatenate them in the montage matrix.

I had not considered exporting the matrix-type montage components as a MAT file, modifying them, and then re-importing them.

I will try this approach, and if I encounter any issues, I will let you know.

Thank you.