'Mark channels as bad from a text file.
This function operates mostly in the style of the C function
``mne_mark_bad_channels``.
Parameters
bad_file : string
File name of the text file containing bad channels
If bad_file = None, bad channels are cleared, but this
is more easily done directly as raw.info[\'bads\'] = [].
force : boolean
Whether or not to force bad channel marking (of those
that exist) if channels are not found, instead of
raising an error.'

def load_bad_channels(self, bad_file=None, force=False):

    if (bad_file is not None):
        names = frozenset(self.info['ch_names'])
        with open(bad_file) as fid:
            bad_names = [l for l in fid.read().splitlines() if l]
        names_there = [ci for ci in bad_names if (ci in names)]
        count_diff = (len(bad_names) - len(names_there))
        if (count_diff > 0):
            if (not force):
                raise ValueError(('Bad    channels    from:\n%s\n    not    found    in:\n%s' % (bad_file, self.filenames[0])))
            else:
                warn(('%d    bad    channels    from:\n%s\nnot    found    in:\n%s' % (count_diff, bad_file, self.filenames[0])))
        self.info['bads'] = names_there
    else:
        self.info['bads'] = []
