Example #1
0
print(f'Notch filter at {power_line} and band pass filter between {l_freq} and {h_freq} '
      f'applied to all subjects')
print("")

# Subject by subject, enter interactive mode to visually inspect the data and mark bad channels,
# that will be excluded after you manually close the interactive console pressing Ctrl+D
for id, data in preproc_raw_list:
    print(f"Interactive mode for sub {id}. Please check the data and mark bad channels "
          f"if necessary (adding them to data.info['bads']). Also, plase check the data"
          f"and select channels to be used for re-referencing (defaults to 'average' for"
          f"all subjects). You can change it assigning a list of channels or an empty list"
          f"to re_reference_list[id].")
    print("")

    shell = InteractiveShellEmbed()
    shell.enable_matplotlib()

    shell()

    data.pick_types(eeg=True, eog=True, ecg=True, stim=True, exclude='bads')

# Interpolate bads and add re-reference to data
preproc_raw_list = Parallel(n_jobs=len(raw_names))(delayed(interpolate_reference_data)(
                            sub_id=sub_id,
                            raw=raw,
                            referene_type=re_reference_dict[sub_id])
                            for sub_id, raw in raw_dict.items())

print("Performed bad channels interpolation and re-referencing for all subjects.")

if save: