Describe the new feature or enhancement
In some cases, especially intracranial EEG, re-referencing of channels should be local (e.g. within the same shaft/grid/strip) rather than global (i.e., ref all channels to one or an average of channels). This thus requires some flexible re-ref schemes, but the existing functions set_eeg_reference and set_bipolar_reference are not super convenient for such purposes.
On the basis of the proposed function, multiple re-ref schemes can be added (for example see https://doi.org/10.1016/j.neuroimage.2018.08.020)
Describe your proposed implementation
A new preprocessing function mne.set_custom_reference(inst, ref_dict, copy=True, on_bad='warn', verbose=None)
Where ref_dict contains a dictionary with keys being the source channel names and values being ref channel names. For example: ref_dict = {'A1': 'A1', 'A2': 'A1', 'A3': 'A1', 'A4': 'A1'} performs monopolar reference; ref_dict = {'A1': 'A2', 'A2': ['A1', 'A3'], 'A3': ['A2', 'A4'], 'A4': 'A3'} performs Laplacian reference.
I'm happy to open a pull request draft if someone can confirm the value of the proposed function.
Describe possible alternatives
Alternatively we can expand mne.set_eeg_reference instead of writing a new function.
Additional context
No response
Describe the new feature or enhancement
In some cases, especially intracranial EEG, re-referencing of channels should be local (e.g. within the same shaft/grid/strip) rather than global (i.e., ref all channels to one or an average of channels). This thus requires some flexible re-ref schemes, but the existing functions
set_eeg_referenceandset_bipolar_referenceare not super convenient for such purposes.On the basis of the proposed function, multiple re-ref schemes can be added (for example see https://doi.org/10.1016/j.neuroimage.2018.08.020)
Describe your proposed implementation
A new preprocessing function
mne.set_custom_reference(inst, ref_dict, copy=True, on_bad='warn', verbose=None)Where
ref_dictcontains a dictionary with keys being the source channel names and values being ref channel names. For example:ref_dict = {'A1': 'A1', 'A2': 'A1', 'A3': 'A1', 'A4': 'A1'}performs monopolar reference;ref_dict = {'A1': 'A2', 'A2': ['A1', 'A3'], 'A3': ['A2', 'A4'], 'A4': 'A3'}performs Laplacian reference.I'm happy to open a pull request draft if someone can confirm the value of the proposed function.
Describe possible alternatives
Alternatively we can expand
mne.set_eeg_referenceinstead of writing a new function.Additional context
No response