Example #1
0
 def append_to_file(self, h5file,currentTrial):
     '''Returns True if successful '''
     if currentTrial<1:
         raise UserWarning('WARNING: No trials have been completed or currentTrial not updated.')
     resultsDataGroup = h5file.require_group('resultsData')
     resultsLabelsGroup = h5file.require_group('resultsLabels')
     for key,item in self.iteritems():
         dset = resultsDataGroup.create_dataset(key, data=item[:currentTrial])
     for key,item in self.labels.iteritems():
         # XXFIXME: Make sure items of self.labels are dictionaries
         utils.append_dict_to_HDF5(resultsLabelsGroup,key,item)
 def append_to_file(self, h5file, currentTrial):
     '''Returns True if successful '''
     if currentTrial < 1:
         raise UserWarning(
             'WARNING: No trials have been completed or currentTrial not updated.'
         )
     resultsDataGroup = h5file.require_group('resultsData')
     resultsLabelsGroup = h5file.require_group('resultsLabels')
     for key, item in self.iteritems():
         dset = resultsDataGroup.create_dataset(key,
                                                data=item[:currentTrial])
     for key, item in self.labels.iteritems():
         # XXFIXME: Make sure items of self.labels are dictionaries
         utils.append_dict_to_HDF5(resultsLabelsGroup, key, item)
Example #3
0
 def append_to_file(self,h5file,currentTrial):
     '''Append states definitions to open HDF5 file
     It ignores currentTrial'''
     statematGroup = h5file.create_group('/stateMatrix')
     utils.append_dict_to_HDF5(statematGroup,'eventsNames',self.eventsDict)
     utils.append_dict_to_HDF5(statematGroup,'outputsNames',self.outputsDict)
     utils.append_dict_to_HDF5(statematGroup,'statesNames',self.statesNameToIndex)
     utils.append_dict_to_HDF5(statematGroup,'extraTimersNames',self.extraTimersNameToIndex)
 def append_to_file(self,h5file,currentTrial):
     '''Append states definitions to open HDF5 file
     It ignores currentTrial'''
     statematGroup = h5file.create_group('/stateMatrix')
     utils.append_dict_to_HDF5(statematGroup,'eventsNames',self.eventsDict)
     utils.append_dict_to_HDF5(statematGroup,'outputsNames',self.outputsDict)
     utils.append_dict_to_HDF5(statematGroup,'statesNames',self.statesNameToIndex)
     utils.append_dict_to_HDF5(statematGroup,'extraTimersNames',self.extraTimersNameToIndex)
Example #5
0
 def append_to_file(self, h5file,currentTrial):
     '''Append parameters' history to an HDF5 file.
     It truncates data to the trial before currentTrial '''
     dataParent = 'resultsData'      # Parameters from each trial
     itemsParent = 'resultsLabels'   # Items in menu parameters
     sessionParent = 'sessionData'   # Parameters for the whole session
     descriptionAttr = 'Description'
     # FIXME: the contents of description should not be the label, but the
     #        description of the parameter (including its units)
     trialDataGroup = h5file.require_group(dataParent)
     menuItemsGroup = h5file.require_group(itemsParent)
     sessionDataGroup = h5file.require_group(sessionParent)
     
     # -- Append date/time and hostname --
     dset = sessionDataGroup.create_dataset('hostname', data=socket.gethostname())
     dateAndTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
     dset = sessionDataGroup.create_dataset('date', data=dateAndTime)
     
     # -- Append all other parameters --
     for key,item in self.iteritems():
         # -- Store parameters with history --
         if item.history_enabled():
             #h5file.createDataset(trialDataGroup, key, self.history[key], paramLabel)
             if key not in self.history:
                 raise ValueError('No history was recorded for "{0}". '.format(key) +\
                        'Did you use paramgui.Container.update_history() correctly?')
             dset = trialDataGroup.create_dataset(key, data=self.history[key][:currentTrial])
             dset.attrs['Description'] = item.get_label()
             if item.get_type()=='numeric':
                 dset.attrs['Units'] = item.get_units()
             # FIXME: not very ObjectOriented to use getType
             #        the object should be able to save itself
             if item.get_type()=='menu':
                 #h5file.createArray(menuItemsGroup, key, item.get_items(),
                 #                   '%s menu items'%paramLabel)
                 #menuItemsGroup.create_dataset(key, data=item.get_items())
                 menuList = item.get_items()
                 menuDict = dict(zip(menuList,range(len(menuList))))
                 utils.append_dict_to_HDF5(menuItemsGroup,key,menuDict)
                 dset.attrs['Description'] = '%s menu items'%item.get_label()
         else: # -- Store parameters without history (Session parameters) --
             if item.get_type()=='string':
                 dset = sessionDataGroup.create_dataset(key, data=np.string_(item.get_value()))
             else:
                 dset = trialDataGroup.create_dataset(key, data=item.get_value())
             dset.attrs['Description'] = item.get_label()