def launch(self, matfile):
        mat = loadmat(matfile)
        hdr = mat['hdr']
        fs, ns = [hdr[key][0, 0][0, 0] for key in ['Fs', 'nSamples']]

        # the entities to populate
        #ch = SensorsMEG(storage_path=self.storage_path)
        ts = TimeSeriesEEG(storage_path=self.storage_path)

        # (nchan x ntime) -> (t, sv, ch, mo)
        dat = mat['dat'].T[:, numpy.newaxis, :, numpy.newaxis]

        # write data
        ts.write_data_slice(dat)

        # fill in header info
        ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape
        ts.labels_ordering = 'Time 1 Channel 1'.split()
        ts.write_time_slice(numpy.r_[:ns] * 1.0 / fs)
        ts.start_time = 0.0
        ts.sample_period_unit = 's'
        ts.sample_period = 1.0 / float(fs)
        ts.close_file()

        return ts
    def launch(self, matfile, fdtfile):

        self.mat = loadmat(matfile)
        self.fs = self.mat['EEG']['srate'][0, 0][0, 0]
        self.nsamp = self.mat['EEG']['pnts'][0, 0][0, 0]
        self.data = numpy.fromfile(fdtfile, dtype=numpy.float32)
        self.data = self.data.reshape((self.nsamp, -1)).T
        self.nchan = self.data.shape[0]
        self.labels = [
            c[0] for c in self.mat['EEG']['chanlocs'][0, 0]['labels'][0]
        ]

        ch = SensorsEEG(storage_path=self.storage_path,
                        labels=self.labels,
                        number_of_sensors=len(self.labels))
        self._capture_operation_results([ch])

        ts = TimeSeriesEEG(sensors=ch, storage_path=self.storage_path)

        # (nchan x ntime) -> (t, sv, ch, mo)
        dat = self.data.T[:, numpy.newaxis, :, numpy.newaxis]

        # write data
        ts.write_data_slice(dat)

        # fill in header info
        ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape
        ts.labels_ordering = 'Time 1 Channel 1'.split()
        ts.write_time_slice(numpy.r_[:dat.shape[0]] * 1.0 / self.fs)
        ts.start_time = 0.0
        ts.sample_period_unit = 's'
        ts.sample_period = 1.0 / float(self.fs)
        ts.close_file()

        return ts
    def launch(self, matfile):
        mat = loadmat(matfile)
        hdr = mat['hdr']
        fs, ns = [hdr[key][0, 0][0, 0] for key in ['Fs', 'nSamples']]

        # the entities to populate
        #ch = SensorsMEG(storage_path=self.storage_path)
        ts = TimeSeriesEEG(storage_path=self.storage_path)

        # (nchan x ntime) -> (t, sv, ch, mo)
        dat = mat['dat'].T[:, numpy.newaxis, :, numpy.newaxis]

        # write data
        ts.write_data_slice(dat)

        # fill in header info
        ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape
        ts.labels_ordering = 'Time 1 Channel 1'.split()
        ts.write_time_slice(numpy.r_[:ns] * 1.0 / fs)
        ts.start_time = 0.0
        ts.sample_period_unit = 's'
        ts.sample_period = 1.0 / float(fs)
        ts.close_file()

        return ts
    def launch(self, matfile, fdtfile):

        self.mat = loadmat(matfile)
        self.fs = self.mat["EEG"]["srate"][0, 0][0, 0]
        self.nsamp = self.mat["EEG"]["pnts"][0, 0][0, 0]
        self.data = numpy.fromfile(fdtfile, dtype=numpy.float32)
        self.data = self.data.reshape((self.nsamp, -1)).T
        self.nchan = self.data.shape[0]
        self.labels = [c[0] for c in self.mat["EEG"]["chanlocs"][0, 0]["labels"][0]]

        ch = SensorsEEG(storage_path=self.storage_path, labels=self.labels, number_of_sensors=len(self.labels))
        self._capture_operation_results([ch])

        ts = TimeSeriesEEG(sensors=ch, storage_path=self.storage_path)

        # (nchan x ntime) -> (t, sv, ch, mo)
        dat = self.data.T[:, numpy.newaxis, :, numpy.newaxis]

        # write data
        ts.write_data_slice(dat)

        # fill in header info
        ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape
        ts.labels_ordering = "Time 1 Channel 1".split()
        ts.write_time_slice(numpy.r_[: dat.shape[0]] * 1.0 / self.fs)
        ts.start_time = 0.0
        ts.sample_period_unit = "s"
        ts.sample_period = 1.0 / float(self.fs)
        ts.close_file()

        return ts
    def launch(self, vhdr, dat):

        self.filename = vhdr
        self.wd, _ = os.path.split(vhdr)

        # read file
        with open(vhdr, 'r') as fd:
            self.srclines = fd.readlines()

        # config parser expects each section to have header
        # but vhdr has some decorative information at the beginning
        while not self.srclines[0].startswith('['):
            self.srclines.pop(0)

        self.sio = StringIO()
        self.sio.write('\n'.join(self.srclines))
        self.sio.seek(0)

        self.cp = ConfigParser.ConfigParser()
        self.cp.readfp(self.sio)

        for opt in self.cp.options('Common Infos'):
            setattr(self, opt, self.cp.get('Common Infos', opt))

        self.binaryformat = self.cp.get('Binary Infos', 'BinaryFormat')

        self.labels = [
            self.cp.get('Channel Infos', o).split(',')[0]
            for o in self.cp.options('Channel Infos')
        ]

        self.fs = self.srate = 1e6 / float(self.samplinginterval)
        self.nchan = int(self.numberofchannels)

        # important if not in same directory
        self.datafile = os.path.join(self.wd, self.datafile)

        self.read_data()

        # create TVB datatypes
        ch = SensorsEEG(storage_path=self.storage_path,
                        labels=self.labels,
                        number_of_sensors=len(self.labels))
        uid = vhdr + '-sensors'
        self._capture_operation_results([ch], uid=uid)

        ts = TimeSeriesEEG(sensors=ch, storage_path=self.storage_path)
        dat = self.data.T[:, numpy.newaxis, :, numpy.newaxis]
        ts.write_data_slice(dat)
        ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape
        ts.labels_ordering = 'Time 1 Channel 1'.split()
        ts.write_time_slice(numpy.r_[:dat.shape[0]] * 1.0 / self.fs)
        ts.start_time = 0.0
        ts.sample_period_unit = 's'
        ts.sample_period = 1.0 / float(self.fs)
        ts.close_file()

        return ts
    def launch(self, vhdr, dat):

        self.filename = vhdr
        self.wd, _ = os.path.split(vhdr)

        # read file
        with open(vhdr, "r") as fd:
            self.srclines = fd.readlines()

        # config parser expects each section to have header
        # but vhdr has some decorative information at the beginning
        while not self.srclines[0].startswith("["):
            self.srclines.pop(0)

        self.sio = StringIO()
        self.sio.write("\n".join(self.srclines))
        self.sio.seek(0)

        self.cp = ConfigParser.ConfigParser()
        self.cp.readfp(self.sio)

        for opt in self.cp.options("Common Infos"):
            setattr(self, opt, self.cp.get("Common Infos", opt))

        self.binaryformat = self.cp.get("Binary Infos", "BinaryFormat")

        self.labels = [self.cp.get("Channel Infos", o).split(",")[0] for o in self.cp.options("Channel Infos")]

        self.fs = self.srate = 1e6 / float(self.samplinginterval)
        self.nchan = int(self.numberofchannels)

        # important if not in same directory
        self.datafile = os.path.join(self.wd, self.datafile)

        self.read_data()

        # create TVB datatypes
        ch = SensorsEEG(storage_path=self.storage_path, labels=self.labels, number_of_sensors=len(self.labels))
        uid = vhdr + "-sensors"
        self._capture_operation_results([ch], uid=uid)

        ts = TimeSeriesEEG(sensors=ch, storage_path=self.storage_path)
        dat = self.data.T[:, numpy.newaxis, :, numpy.newaxis]
        ts.write_data_slice(dat)
        ts.length_1d, ts.length_2d, ts.length_3d, ts.length_4d = dat.shape
        ts.labels_ordering = "Time 1 Channel 1".split()
        ts.write_time_slice(numpy.r_[: dat.shape[0]] * 1.0 / self.fs)
        ts.start_time = 0.0
        ts.sample_period_unit = "s"
        ts.sample_period = 1.0 / float(self.fs)
        ts.close_file()

        return ts