예제 #1
0
    def loadSignal(self, file, name):
        signal = None
        ismat = False
        if file.endswith('.mat'):
            matfile = loadmat(file)
            ismat = True

        if not ismat:
            if not self.filesHasHeaders:
                signal = ExtractSignalFromCSV(str(file),
                                              separator=self.columnSeparator,
                                              unit='ms',
                                              columns=name,
                                              header=False,
                                              headerValues=self.signalsHeader)
            else:
                signal = ExtractSignalFromCSV(
                    str(file),
                    separator=self.columnSeparator,
                    unit='ms',
                    columns=[str(self.headerMap[name])])
        else:
            ci = self.signalsHeader.index(name)
            cn = str(self.signalsHeader[ci])
            signal = ExtractSignalFromMAT(str(file),
                                          columns_index=ci,
                                          columns_wanted_names=[cn],
                                          matfile=matfile)
        return signal
예제 #2
0
파일: SyncPy2.py 프로젝트: syncpy/SyncPy
    def computeBtnEvent(self):
        # load selected signals from selected files
        self.signals = []
        self.outputBaseName = None
        ismat = False
        dic = self.ui.methodWidget.getArgumentsAsDictionary()
        if not(dic.has_key("ignoreInputSignals") and dic["ignoreInputSignals"]):
            for f in self.filesSelected:
                if f.endswith('.mat'):
                    matfile = loadmat(f)
                    ismat = True
                for s in self.signalsSelected:
                    if not ismat:
                        if not self.filesHasHeaders:
                            self.signals.append(ExtractSignalFromCSV(str(f), separator=self.columnSeparator, unit='ms', columns=s, header=False, headerValues=self.signalsHeader))
                        else:
                            self.signals.append(ExtractSignalFromCSV(str(f), separator=self.columnSeparator, unit='ms', columns=[str(self.headerMap[s])]))
                    else:
                        ci = self.signalsHeader.index(s)
                        cn = str(self.signalsHeader[ci])
                        self.signals.append(ExtractSignalFromMAT(str(f), columns_index=ci, columns_wanted_names=[cn], matfile=matfile))

        self.ui.methodWidget.compute(self.signals, self.getOutputBasename())

        self.ui.stopPushButton.setEnabled(True)
        self.ui.startPushButton.setEnabled(False)
        self.ui.toolBox.setEnabled(False)

        self.showStatus("Computing...")
예제 #3
0
파일: SyncPy2.py 프로젝트: syncpy/SyncPy
    def exportSelectedSignals(self):
        table = self.ui.inputSignalsWidget
        selectedSignalsHeader = []
        # give filename
        self.getSelectedFiles()

        firstTime = True

        fileNumber = 1

        for index in range(table.rowCount()):
            item = table.item(index, 0)
            ismat = False
            for f in self.getSelectedFiles():
                if f.endswith('.mat'):
                    matfile = loadmat(f)
                    ismat = True
                if item.checkState() == QtCore.Qt.Checked:
                    s = str(item.text())
                    if not ismat:
                        if not self.filesHasHeaders:
                            signal = ExtractSignalFromCSV(str(f), separator=self.columnSeparator, unit='ms', columns=s, header=False,
                                                     headerValues=self.signalsHeader)
                        else:
                            signal = ExtractSignalFromCSV(str(f), separator=self.columnSeparator, unit='ms', columns=[str(self.headerMap[s])])
                    else:
                        ci = self.signalsHeader.index(s)
                        cn = str(self.signalsHeader[ci])
                        signal = ExtractSignalFromMAT(str(f), columns_index=ci, columns_wanted_names=[cn], matfile=matfile)


                    if firstTime:
                        seletedSignals = pd.DataFrame(index=signal.index)
                        firstTime = False

                    #seletedSignals.insert(col,s,signal)
                    #col += 1
                    seletedSignals[s+str(fileNumber)] = signal
                    fileNumber += 1

        fileName = ''

        fileName = QtGui.QFileDialog.getSaveFileName(self)

        if not fileName:
            print "Error export signals: No filename provided"
            return
        else:
            if not fileName.endsWith('.csv'):
                fileName = fileName+'.csv'
            seletedSignals.to_csv(path_or_buf=fileName,header=True,sep=';')
예제 #4
0
    def computeBtnEvent(self):
        # load selected signals from selected files
        self.signals = []

        ismat = False
        for f in self.filesSelected:
            if f.endswith('.mat'):
                matfile = loadmat(f)
                ismat = True
            for s in self.signalsSelected:
                if not ismat:
                    if not self.filesHasHeaders:
                        self.signals.append(
                            ExtractSignalFromCSV(
                                str(f),
                                separator=self.columnSeparator,
                                unit='ms',
                                columns=s,
                                header=False,
                                headerValues=self.signalsHeader))
                    else:
                        self.signals.append(
                            ExtractSignalFromCSV(
                                str(f),
                                separator=self.columnSeparator,
                                unit='ms',
                                columns=[str(self.headerMap[s])]))
                else:
                    ci = self.signalsHeader.index(s)
                    cn = str(self.signalsHeader[ci])
                    self.signals.append(
                        ExtractSignalFromMAT(str(f),
                                             columns_index=ci,
                                             columns_wanted_names=[cn],
                                             matfile=matfile))

        self.ui.methodWidget.compute(self.signals)

        self.ui.stopPushButton.setEnabled(True)
        self.ui.startPushButton.setEnabled(False)
        self.ui.toolBox.setEnabled(False)

        self.showStatus("Computing...")