Esempio n. 1
0
 def load(self):
     '''
     opens file manager, reads data from file,
     calls generateList to put into GUI
     '''
     self.lastdir = self.checkForLastDir()
     # second par - name of file dialog window
     # third parameter - default file name
     # forth parameter - file filter. types separated by ';;'
     filename = QtGui.QFileDialog.getOpenFileName(self, "", "%s"%(self.lastdir), "*.clf;;MAT files (*.mat)")
     if filename[0] == '': return
     if filename[1] == 'MAT files (*.mat)':
         self.data = pymat.load(filename[0])
     elif filename[1] == u'*.clf':
         data = readclf.readclf(filename[0])
     else: raise IOError('Cannot read this file format.')
     # this is to remember this name when we wanna save file
     self.makeLastDir(filename[0]) # extract filename from absolute path
     self.filename = os.path.basename(filename[0])
     # remove extension from name
     self.filename = os.path.splitext(self.filename)[0]
     # Separate all digital data and units    
     self.units = data['Units']
     del data['Units']
     self.data = data
     # # we need this attribute for speedup. it coresponds to 
     # # reduced data. see method reduce
     self.reducedData = self.data;self.truncatedData = self.data
     try:
         self.datalength = len(self.data[self.data.keys()[1]])
     except: self.datalength = 1
     self.setParameters()
     self.connect()
Esempio n. 2
0
 def load(self,filename):
     '''
     opens file manager, reads data from file,
     calls generateList to put into GUI
     '''
     headerexpr = self.settings.msWidget.getHeaderExpr()
     slengthexpr = self.settings.msWidget.getSampleLengthExpr()
     if filename[0] == '': return
     if filename[1] == 'MAT files (*.mat)':
         self.data = pymat.load(filename[0])
     elif filename[1] == u'*.clf':
         tup = readclf.readclf(filename[0],
             headerexpr=headerexpr,
             lengthexpr=slengthexpr)
         if tup==None:
             reply = QtGui.QMessageBox.warning(self,
             'Wrong header',
             BadHeaderMessage, QtGui.QMessageBox.Ok )
             IOError('Cannot read this file.')
         data,comments,length = tup
     else: raise IOError('Cannot read this file format.')
     # this is to remember this name when we wanna save file
     self.makeLastDir(filename[0]) # extract filename from absolute path
     self.filename = os.path.basename(filename[0])
     # remove extension from name
     self.filename = os.path.splitext(self.filename)[0]
     # Separate all digital data and units    
     units = data['Units']        
     del data['Units']
     self.data = data
     # self.setParameters()
     # self.connectParameters()
     isNew = True
     if self.filename in self.allData.keys():
         isNew = False
     self.allData[self.filename] = data
     # get one name from array to get length of the data
     key = data.keys()[0]
     l = self.data[key].shape[0]
     self.allSampleLengths[self.filename] = length
     self.allIndices[self.filename] = np.arange(l)
     self.allComments[self.filename] = comments
     self.allUnits[self.filename] = units
     self.addDataSet(self.filename,isNew)