Source:
Re-referencing only applies to EEG data, MEG is reference-free. In EEG, voltages recorded at each electrode are relative to voltages recorded at other electrodes. Theoretically, a reference could be anywhere but the reference needs to be carefully chosen because any activity in the reference electrode will reflected in the activity at other electrodes. Often, the mastoids are chosen as reference electrodes, because while being close in distance to the electrodes, they record less signal from the brain. However, the very fact of being close to the brain means that mastoid signal does contain some neural signal, which means that the mastoids are not the ideal references. For high density EEG (100+ electrodes), the average of activity at all electrodes is often chosen as the reference. As a rule of thumb, the position of a reference electrode should not be close to that of an electrode where you expect your main effects to be. For example, the Cz is often used as a reference electrode, but it should not be used as such if you expect task-related activity to be centred around this electrode. It also not advisable to reference your data to an electrode of one hemisphere as this could introduce a laterality bias into your data.
As referencing is a linear transformation, it is possible to re-reference your data “offline”, thus changing the reference used during the recording of the EEG data. EEGLAB permits you to reference your data “offline” either when importing your raw EEG data file or after having imported your data as part of the pre-processing stage (Tools menu>>Re-reference).
In EEGLAB, if you import a *.bdf file using the BIOSIG plugin, the reference used “online” will not be automatically detected. If you are re-referencing your data while importing, this is not a problem. However, if you choose to re-reference your data later in the pre-processing stage, it is important to know which electrode was used as the reference during EEG recording as you may mistake the reference electrode (characterised as a flat line) for a bad electrode.