Isolating stable EEG data across all channels in EEGLAB I'm working on some EEG data we collected using the Emotiv Epoc headset using 14 channel sensors. 

I need to isolate chunks of data where all 14 channels are stable (non-noisy) for a given length of time (e.g. 5 seconds). I've written a MATLAB script for this, such that I calculate the standard deviation of each channel and pass an analysis window over the data, comparing the difference between maximum and minimum values in the window to this standard deviation (i.e. where maximum - minimum is less than the standard deviation [or 3-5 standard deviations], I treat that window as stable).

Based on this criteria, I am having some success in finding 5 second long segments but am worried this data may not be reliable (or not as stable/artefact free as desired).

Are there any better ways of performing this analysis? Even better, are there any functions built into EEGLAB for this very purpose?

Further info:

I've selected only the relevant channels and can now look through my EEG data files.

I am no neuroscience expert, actually I'm rather new to this sort of analysis, so apologies if this question is overly basic or off-point.

EDIT

We collected our data in a museum environment (very noisy in many ways), with participants sitting as still as possible for 2-minute sessions at a go. For this reason, there is a high likelihood of artefacts being found in the data due to movement, the environment and possibly even inaccuracies from the device itself (since we went through a rather large number of participants, cleaning and charging the headsets in between trials). 

From what I've discussed with the team, I've been told that removing artefacts wouldn't solve the issue (though admittedly I'm no expert as to why this would be). 

For clarity, the data we've collected looks similar to the plot below. 



And we're looking for a minimum of 5 seconds of stable data, closer to the plot below.



Also, I know this data selection can be done manually using pop_eegplot, however since we have close to 300 data files I'm looking to automate this (and hopefully get more reliable selections).
In this conference paper they propose an algorithm that roughly goes as follows (if you can't access it, just add "sci-hub.bz" after ".org" in the url and it redirects you directly to the pdf) :


Divide channels into four groups: 1) frontal, 2) central, 3) temporal and 4) parietal+occipital.
For each group take three signals: 1) the raw signal, 2) the alpha band(8-12Hz, using a 3rd order butterworth band-pass filter) and 3) the beta band(13-35Hz).
For each group and each signal calculate the four metrics: 1) max amplitude, 2) standard deviation, 3) kurtosis and 4) skewness. For the frequency band signals they also take the mean power and the standard deviation of the power.


They then go on and find optimal thresholds for each metric, group, and signal by using a differential evolution algorithm on training data, so unfortunately it's not immediately applicable for you. As I see it, you have at least two options here:


Create 5 seconds long epochs of your data and label a lot of them. Use that data to learn optimal thresholds (unfortunately they don't give any details on how to do that, so you would have to figure that out yourself). This would obviously take a lot of effort but at the end you can be quite confident about your classification.
Just try some value ranges for the different metrics, you can orient yourself on the values they found in the paper (you have to read them from the plots though).  Check the resulting classifications. Pick the threshold values that give the "best" results by inspections. This is not as systematic as the first option but might fit your needs already. For example if you just want to avoid to have segments that were falsely classified as "clean" you might just go for very conservative/safe threshold values. There is a big danger here though, that you will get lost in an endless loop of "maybe if I adjust this threshold a bit more" and will never stop exploring. To help with that, you might also reduce the number of metrics, groups or signals.