Flexible-channel acquisition and analysis of EEG and event-related potentials: instrumentation and algorithms