signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def set_calibration_reps(self, reps): | self.bs_calibrator.set_reps(reps)<EOL>self.tone_calibrator.set_reps(reps)<EOL> | Sets the number of repetitions for calibration stimuli
:param reps: Number of times a unique stimulus is presented in calibration operations
:type reps: int | f10676:c0:m11 |
def load_data_file(self, fname, filemode='<STR_LIT:a>'): | self.close_data()<EOL>self.datafile = open_acqdata(fname, filemode=filemode)<EOL>self.explorer.set(datafile=self.datafile)<EOL>self.protocoler.set(datafile=self.datafile)<EOL>self.charter.set(datafile=self.datafile)<EOL>self.bs_calibrator.set(datafile=self.datafile)<EOL>self.tone_calibrator.set(datafile=self.datafile)<... | Opens an existing data file to append to
:param fname: File path of the location for the data file to open
:type fname: str | f10676:c0:m12 |
def current_data_file(self): | return self.datafile.filename<EOL> | Name of the currently employed data file
:returns: str -- File name of the open data file | f10676:c0:m13 |
def set_threshold(self, threshold): | self.explorer.set_threshold(threshold)<EOL>self.protocoler.set_threshold(threshold)<EOL> | Sets spike detection threshold
:param threshold: electrical potential to determine spikes (V)
:type threshold: float | f10676:c0:m14 |
def set(self, **kwargs): | self.explorer.set(**kwargs)<EOL>self.protocoler.set(**kwargs)<EOL>self.tone_calibrator.set(**kwargs)<EOL>self.charter.set(**kwargs)<EOL>self.bs_calibrator.set(**kwargs)<EOL>self.mphone_calibrator.set(**kwargs)<EOL> | Sets acquisition parameters for all acquisition types
See :meth:`AbstractAcquisitionRunner<sparkle.run.abstract_acquisition.AbstractAcquisitionRunner.set>` | f10676:c0:m15 |
def current_stim(self): | return self.explorer.current_signal()<EOL> | The signal of the current search stimulus
:returns: numpy.ndarray -- the voltage signal of the output | f10676:c0:m17 |
def run_explore(self, interval): | return self.explorer.run(interval)<EOL> | Runs the explore operation
:param interval: The repetition interval between stimuli presentations (seconds)
:type interval: float
:returns: :py:class:`threading.Thread` -- the acquisition thread | f10676:c0:m18 |
def setup_protocol(self, interval): | return self.protocoler.setup(interval)<EOL> | Sets up the protocol operation for the current settings
:param interval: The repetition interval between stimuli presentations (seconds)
:type interval: float | f10676:c0:m19 |
def protocol_total_count(self): | return self.protocoler.count()<EOL> | The number of stimuli presentations (including reps) for the current protocol contents
:returns: int -- number of presentations | f10676:c0:m20 |
def run_protocol(self): | return self.protocoler.run()<EOL> | Runs the protocol operation with the current settings
:returns: :py:class:`threading.Thread` -- the acquisition thread | f10676:c0:m21 |
def set_mphone_calibration(self, sens, db): | self.bs_calibrator.set_mphone_calibration(sens, db)<EOL>self.tone_calibrator.set_mphone_calibration(sens, db)<EOL> | Sets the microphone calibration, for the purpose of calculating recorded dB levels
:param sens: microphone sensitivity (V)
:type sens: float
:param db: dB SPL that the calibration was measured at
:type db: int | f10676:c0:m22 |
def set_calibration_by_index(self, idx): | self.selected_calibration_index = idx<EOL> | Sets the calibration stimulus by it's index in the list of calibration stimuli, with tone curve always being last | f10676:c0:m23 |
def calibration_total_count(self): | if self.selected_calibration_index == <NUM_LIT:2>:<EOL><INDENT>return self.tone_calibrator.count()<EOL><DEDENT>else:<EOL><INDENT>return self.bs_calibrator.count()<EOL><DEDENT> | The number of stimuli presentations (including reps) for the current calibration selected
:returns: int -- number of presentations | f10676:c0:m24 |
def run_calibration(self, interval, applycal): | if self.selected_calibration_index == <NUM_LIT:2>:<EOL><INDENT>self.tone_calibrator.apply_calibration(applycal)<EOL>self.tone_calibrator.setup(interval)<EOL>return self.tone_calibrator.run()<EOL><DEDENT>else:<EOL><INDENT>self.bs_calibrator.set_stim_by_index(self.selected_calibration_index)<EOL>self.bs_calibrator.apply_... | Runs the calibration operation with the current settings
:param interval: The repetition interval between stimuli presentations (seconds)
:type interval: float
:param applycal: Whether to apply a previous saved calibration to this run
:type applycal: bool
:returns: :py:class:`th... | f10676:c0:m25 |
def start_chart(self): | self.charter.start_chart()<EOL> | Starts the chart acquistion | f10676:c0:m27 |
def stop_chart(self): | self.charter.stop_chart()<EOL> | Halts the chart acquisition | f10676:c0:m28 |
def run_chart_protocol(self, interval): | self.charter.setup(interval)<EOL>return self.charter.run()<EOL> | Runs the stimuli presentation during a chart acquisition
:param interval: The repetition interval between stimuli presentations (seconds)
:type interval: float
:returns: :py:class:`threading.Thread` -- the acquisition thread | f10676:c0:m29 |
def process_calibration(self, save=True, calf=<NUM_LIT>): | if self.selected_calibration_index == <NUM_LIT:2>:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>results, calname, freq, db = self.bs_calibrator.process_calibration(save)<EOL><DEDENT>return calname, db<EOL> | Processes a completed calibration
:param save: Wether to save this calibration to file
:type save: bool
:param calf: Frequency for which to reference attenuation curve from
:type calf: int
:returns: str -- name of a saved calibration | f10676:c0:m30 |
def halt(self): | self.explorer.halt()<EOL>self.protocoler.halt()<EOL>self.bs_calibrator.halt()<EOL>self.tone_calibrator.halt()<EOL>self.charter.halt()<EOL>self.mphone_calibrator.halt()<EOL> | Halts any/all running operations | f10676:c0:m32 |
def close_data(self): | <EOL>if self.datafile is not None:<EOL><INDENT>if self.datafile.filemode != '<STR_LIT:r>':<EOL><INDENT>self.datafile.set_metadata('<STR_LIT>', {'<STR_LIT>': self.current_cellid})<EOL><DEDENT>self.datafile.close()<EOL>self.datafile = None<EOL><DEDENT> | Closes the current data file | f10676:c0:m33 |
def protocol_model(self): | return self.protocoler.protocol_model<EOL> | Gets the model for the protocol operation
:returns: :class:`ProtocolModel<sparkle.run.protocol_model.ProtocolTabelModel>` | f10676:c0:m34 |
def calibration_stimulus(self, mode): | if mode == '<STR_LIT>':<EOL><INDENT>return self.tone_calibrator.stimulus<EOL><DEDENT>elif mode =='<STR_LIT>':<EOL><INDENT>return self.bs_calibrator.stimulus<EOL><DEDENT> | Gets the stimulus model for calibration
:param mode: Type of stimulus to get: tone or noise
:type mode: str
:returns: :class:`StimulusModel<sparkle.stim.stimulus_model.StimulusModel>` | f10676:c0:m36 |
def explore_genrate(self): | return self.explorer.stimulus().samplerate()<EOL> | Gets the ouput samplerate for the search operation
:returns: int -- the outgoing samplerate | f10676:c0:m37 |
def calibration_genrate(self): | return self.bs_calibrator.stimulus.samplerate()<EOL> | Gets the ouput samplerate for the calibration operation
:returns: int -- the outgoing samplerate | f10676:c0:m38 |
def calibration_range(self): | return self.tone_calibrator.stimulus.autoParamRanges()<EOL> | Gets the range of the frequencies and intensities in the calibration tone curve
:returns: list -- nested list of frequencies and intensities | f10676:c0:m39 |
def calibration_template(self): | temp = {}<EOL>temp['<STR_LIT>'] = self.tone_calibrator.stimulus.templateDoc()<EOL>comp_doc = []<EOL>for calstim in self.bs_calibrator.get_stims():<EOL><INDENT>comp_doc.append(calstim.stateDict())<EOL><DEDENT>temp['<STR_LIT>'] = comp_doc<EOL>return temp<EOL> | Gets the template documentation for the both the tone curve calibration and noise calibration
:returns: dict -- all information necessary to recreate calibration objects | f10676:c0:m40 |
def load_calibration_template(self, template): | self.tone_calibrator.stimulus.clearComponents()<EOL>self.tone_calibrator.stimulus.loadFromTemplate(template['<STR_LIT>'], self.tone_calibrator.stimulus)<EOL>comp_doc = template['<STR_LIT>']<EOL>for state, calstim in zip(comp_doc, self.bs_calibrator.get_stims()):<EOL><INDENT>calstim.loadState(state)<EOL><DEDENT> | Reloads calibration settings from saved template doc
:param template: Values for calibration stimuli (see calibration_template function)
:type template: dict | f10676:c0:m41 |
def clear_protocol(self): | self.protocoler.clear()<EOL> | Clears all tests from the protocol acquisition | f10676:c0:m42 |
def set_group_comment(self, comment): | self.protocoler.set_comment(self.current_cellid, comment)<EOL> | Sets a comment for the last executed protocol group, to be saved
as doc to the appropriate place in the data file. | f10676:c0:m43 |
def attenuator_connection(self, connect=True): | <EOL>acquisition_modules = [self.explorer, self.protocoler, self.bs_calibrator, self.tone_calibrator, self.charter]<EOL>if connect:<EOL><INDENT>if not acquisition_modules[<NUM_LIT:0>].player.attenuator_connected():<EOL><INDENT>for module in acquisition_modules:<EOL><INDENT>success = module.player.connect_attenuator()<E... | Checks the connection to the attenuator, and attempts to connect if not connected.
Will also set an appropriate ouput minimum for stimuli, if connection successful
:returns: bool - whether there is a connection | f10676:c0:m44 |
def get_stimuli_models(): | package_path = os.path.dirname(__file__)<EOL>mod = '<STR_LIT:.>'.join(get_stimuli_models.__module__.split('<STR_LIT:.>'))<EOL>if mod == '<STR_LIT:__main__>':<EOL><INDENT>mod = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>mod = mod + '<STR_LIT:.>'<EOL><DEDENT>module_files = glob.glob(package_path+os.sep+'<STR_LIT>')<EOL>mo... | Returns all subclasses of AbstractStimulusComponent in python files,
in this package | f10679:m0 |
def get_component(comp_name, class_list): | for comp_class in class_list:<EOL><INDENT>if comp_class.name == comp_name:<EOL><INDENT>return comp_class()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT> | Returns an implementation of the class refered to by *comp_name*
if it is in *class_list* | f10681:m0 |
def setUserTag(self, tag): | self._userTag = tag<EOL> | Sets a string, significant to the user | f10681:c0:m1 |
def userTag(self): | return self._userTag<EOL> | Returns a saved string, set by user | f10681:c0:m2 |
def setStimType(self, t): | self._stimType = t<EOL> | Sets the stimulus type this model represents, intention is to determine editor type | f10681:c0:m3 |
def stimType(self): | return self._stimType<EOL> | Stimulus type of this model (e.g. custom, tuning curve) | f10681:c0:m4 |
def setReferenceVoltage(self, caldb, calv): | self.caldb = caldb<EOL>self.calv = calv<EOL> | Sets the reference point to determine what outgoing voltage will produce what intensity,
used to calculate the proper output amplitude of components
:param caldb: calibration intensity in dbSPL
:type caldb: float
:param calv: calibration voltage that was used to record the intensity pr... | f10681:c0:m5 |
def setCalibration(self, dbBoostArray, frequencies, frange): | if dbBoostArray is not None and frequencies is not None:<EOL><INDENT>logger = logging.getLogger('<STR_LIT>')<EOL>if dbBoostArray.shape != frequencies.shape:<EOL><INDENT>logger.error("<STR_LIT>")<EOL>return<EOL><DEDENT>if frange is None:<EOL><INDENT>frange = (frequencies[<NUM_LIT:0>], frequencies[-<NUM_LIT:1>])<EOL><DED... | Sets the calibration to use with this stimulus,
creates a filter that will be applied to output signal generated by this model.
Set arguments to `None` to clear calibration.
:param dbBoostArray: frequency response of the system (in dB)
:type dbBoostArray: numpy.ndarray
:param f... | f10681:c0:m6 |
def updateCalibration(self): | if self.samplerate() != self._calibration_fs:<EOL><INDENT>self.setCalibration(self._attenuationVector, self._calFrequencies, self._calFrange)<EOL><DEDENT> | Updates the current calibration according to intenal values. For example, if the stimulus samplerate changes
the calibration needs to be recalculated. | f10681:c0:m7 |
@staticmethod<EOL><INDENT>def clearCache():<DEDENT> | StimulusModel.kernelCache = {}<EOL> | clears the calibration filters stored in the cache | f10681:c0:m8 |
def samplerate(self): | rates = []<EOL>for track in self._segments:<EOL><INDENT>for component in track:<EOL><INDENT>if component.__class__.__name__ == '<STR_LIT>':<EOL><INDENT>if component.samplerate() is not None:<EOL><INDENT>rates.append(component.samplerate())<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if len(set(rates)) > <NUM_LIT:1>:<EOL><INDEN... | Returns the generation rate for this stimulus
:returns: int -- the output samplerate (Hz) | f10681:c0:m9 |
def setAutoParams(self, params): | self._autoParams = params<EOL> | Overwrites the AutoParameterModel for this stimulus
:param params: model to assign
:type params: :class:`AutoParameterModel<sparkle.stim.auto_parameter_model.AutoParameterModel>` | f10681:c0:m10 |
def autoParams(self): | return self._autoParams<EOL> | Returns the AutoParameterModel for this stimulus, which holds the auto-test information
:returns: :class:`AutoParameterModel<sparkle.stim.auto_parameter_model.AutoParameterModel>` | f10681:c0:m11 |
def rowCount(self): | return len(self._segments)<EOL> | Returns the number of tracks
:returns: int -- number of rows | f10681:c0:m12 |
def columnCount(self, row=None): | if row is not None:<EOL><INDENT>wholerow = self._segments[row]<EOL>return len(wholerow)<EOL><DEDENT>else:<EOL><INDENT>column_lengths = [len(x) for x in self._segments]<EOL>return max(column_lengths)<EOL><DEDENT> | Returns the number of components in a track,
or the max number of components in any row, if none given
:param row: track to get count for
:type row: int
:returns: int -- number of components for *row* | f10681:c0:m13 |
def componentCount(self): | return sum([self.columnCountForRow(x) for x in range(self.rowCount())])<EOL> | Returns the total number of components in stimulus
:returns: number of components (not including expanded auto-params) | f10681:c0:m15 |
def component(self, row, col): | try:<EOL><INDENT>comp = self._segments[row][col]<EOL><DEDENT>except:<EOL><INDENT>print('<STR_LIT>')<EOL>return None<EOL><DEDENT>return comp<EOL> | Gets the components for the location
:param row: track the component is in
:type row: int
:param col: the ith member of the track
:type col: int
:returns: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>` | f10681:c0:m16 |
def insertComponent(self, comp, row=<NUM_LIT:0>, col=<NUM_LIT:0>): | if row > len(self._segments) -<NUM_LIT:1>:<EOL><INDENT>self.insertEmptyRow()<EOL><DEDENT>self._segments[row].insert(col, comp)<EOL>self.updateCalibration()<EOL> | Inserts component into model
:param comp: Component to insert into the stimulus
:type comp: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`
:param row: Track number to place comp in
:type row: int
:param col: location in track to ins... | f10681:c0:m17 |
def overwriteComponent(self, comp, row, col): | self._segments[row][col] = comp<EOL>self.updateCalibration()<EOL> | Overwrites the component at the specficied location with a provided one.
:param comp: New component to insert
:type comp: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`
:param row: track location of existing component to overwrite
:type row... | f10681:c0:m18 |
def insertEmptyRow(self): | self._segments.append([])<EOL> | Appends an empty track at the end | f10681:c0:m19 |
def removeLastRow(self): | lastrow = self._segments.pop(len(self._segments)-<NUM_LIT:1>)<EOL>if len(lastrow) > <NUM_LIT:0>:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT> | Removes the last track | f10681:c0:m20 |
def removeRow(self, row): | self._segments.pop(row)<EOL> | Removes the track at row, empty or not | f10681:c0:m21 |
def removeComponent(self, row,col): | self._segments[row].pop(col)<EOL>if self.columnCountForRow(-<NUM_LIT:1>) == <NUM_LIT:0>:<EOL><INDENT>self.removeRow(len(self._segments)-<NUM_LIT:1>)<EOL><DEDENT>self.updateCalibration()<EOL> | Removes the component at the given location
:param row: track location of existing component to remove
:type row: int
:param col: location in track of existing component to remove
:type col: int | f10681:c0:m22 |
def clearComponents(self): | self._segments = []<EOL>self._autoParams.clearParameters()<EOL> | Removes all components | f10681:c0:m23 |
def indexByComponent(self, component): | for row, rowcontents in enumerate(self._segments):<EOL><INDENT>if component in rowcontents:<EOL><INDENT>column = rowcontents.index(component)<EOL>return (row, column)<EOL><DEDENT><DEDENT> | Returns a location for the given component, or None if
it is not in the model
:param component: Component to get index for
:type component: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`
:returns: (int, int) -- (row, column) of component | f10681:c0:m24 |
def traceCount(self): | nsegs = sum([len(track) for track in self._segments])<EOL>if nsegs == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>ntraces = <NUM_LIT:1><EOL>for irow in range(self._autoParams.nrows()):<EOL><INDENT>ntraces = ntraces*self._autoParams.numSteps(irow)<EOL><DEDENT>return ntraces<EOL> | The number of unique stimului for this stimulus object
:returns: int -- The expanded trace count | f10681:c0:m25 |
def loopCount(self): | return self._nloops<EOL> | The number of times to run through a set of autoparameters
:returns: the number of times the auto-parameters and looped through | f10681:c0:m26 |
def setLoopCount(self, count): | self._nloops = count<EOL> | Sets the number of times to loop through an entire set of autoparameters | f10681:c0:m27 |
def repCount(self): | return self._nreps<EOL> | Returns the number of repetitions each unique stimulus is presented | f10681:c0:m28 |
def setRepCount(self, count): | if count > <NUM_LIT:0>:<EOL><INDENT>self._nreps = count<EOL><DEDENT> | Sets the number of repetitions each unique stimulus is presented | f10681:c0:m29 |
def contains(self, stimtype): | for track in self._segments:<EOL><INDENT>for component in track:<EOL><INDENT>if component.__class__.__name__ == stimtype:<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>return False<EOL> | Returns whether the specified stimlus type is a component in this stimulus
:param stimtype: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>` subclass class name to test for membership in the components of this stimulus
:type stimtype: str
:returns: b... | f10681:c0:m30 |
def purgeAutoSelected(self): | params = self._autoParams.allData()<EOL>for p in params:<EOL><INDENT>comps_to_remove = []<EOL>for comp in p['<STR_LIT>']:<EOL><INDENT>if self.indexByComponent(comp) is None:<EOL><INDENT>comps_to_remove.append(comp)<EOL><DEDENT><DEDENT>for orphaned in comps_to_remove:<EOL><INDENT>p['<STR_LIT>'].remove(orphaned)<EOL><DED... | Clears out orphaned auto parameters | f10681:c0:m31 |
def cleanComponents(self): | for row in self._segments:<EOL><INDENT>for comp in row:<EOL><INDENT>comp.clean()<EOL><DEDENT><DEDENT> | Removes and references to UI objects from components. Allows them to be serializable | f10681:c0:m32 |
def autoParamRanges(self): | return self._autoParams.ranges()<EOL> | Returns the expanded auto parameters, individually
See :meth:`AutoParameterModel<sparkle.stim.auto_parameter_model.AutoParameterModel.ranges>` | f10681:c0:m33 |
def expandFunction(self, func, args=[]): | <EOL>params = self._autoParams.allData()<EOL>steps = self.autoParamRanges()<EOL>ntraces = <NUM_LIT:1><EOL>for p in steps:<EOL><INDENT>ntraces = ntraces*len(p)<EOL><DEDENT>varylist = [[None for x in range(len(params))] for y in range(ntraces)]<EOL>x = <NUM_LIT:1><EOL>for iset, step_set in enumerate(steps):<EOL><INDENT>f... | applies the given function to each of this stimulus's memerships when autoparamters are applied
:param func: callable to execute for each version of the stimulus
:type instancemethod:
:param args: arguments to feed to func
:type args: list
:returns: list<results of *func*>, one ... | f10681:c0:m34 |
def setReorderFunc(self, func, name=None): | self.reorder = func<EOL>self.reorderName = name<EOL> | Sets the function that reorders the expanded signals of this stimulus
:param func: a function which takes the template doc as an argument
:type func: callable
:param name: a name to assign the function (for documentation purposes)
:type name: str | f10681:c0:m35 |
def expandedStim(self): | logger = logging.getLogger('<STR_LIT>')<EOL>logger.debug("<STR_LIT>")<EOL>signals = self.expandFunction(self.signal)<EOL>docs = self.expandFunction(self.componentDoc)<EOL>overloads = []<EOL>for s, d in zip(signals, docs):<EOL><INDENT>d['<STR_LIT>'] = s[<NUM_LIT:2>]<EOL>overloads.append(s[<NUM_LIT:2>])<EOL><DEDENT>signa... | Apply the autoparameters to this stimulus and return a list of
the resulting stimuli, a complimentary list of doc dictionaries, and
a complimentary list of undesired attenuations.
:returns: list<numpy.ndarray>, list<dict>, list<float> -- the signals, their doc, undesired attenuations (dB) | f10681:c0:m36 |
def templateDoc(self): | doc = dict(list(self.componentDoc(False).items()) + list(self.testDoc().items()))<EOL>autoparams = copy.deepcopy(self._autoParams.allData())<EOL>for p in autoparams:<EOL><INDENT>selection = p['<STR_LIT>']<EOL>serializable_selection = []<EOL>for component in selection:<EOL><INDENT>idx = self.indexByComponent(component)<... | JSON serializable template to will all necessary details to recreate this
stimulus in another session.
:returns: dict | f10681:c0:m37 |
@staticmethod<EOL><INDENT>def loadFromTemplate(template, stim=None):<DEDENT> | if stim is None:<EOL><INDENT>stim = StimulusModel()<EOL><DEDENT>stim.setRepCount(template['<STR_LIT>'])<EOL>stim.setUserTag(template.get('<STR_LIT>', '<STR_LIT>'))<EOL>component_classes = get_stimuli_models()<EOL>for comp_doc in template['<STR_LIT>']:<EOL><INDENT>comp = get_component(comp_doc['<STR_LIT>'], component_cl... | Loads the stimlus to the state provided by a template
:param template: dict that includes all info nesessary to recreate stim
:type template: dict
:param stim: Stimulus to apply to, creates a new model if None
:type stim: StimulusModel | f10681:c0:m38 |
def duration(self): | durs = []<EOL>for track in self._segments:<EOL><INDENT>durs.append(sum([comp.duration() for comp in track]))<EOL><DEDENT>return max(durs)<EOL> | The duration of this stimulus
:returns: float -- duration in seconds | f10681:c0:m40 |
def signal(self, force_fs=False): | assert None not in self.voltage_limits, '<STR_LIT>'<EOL>if force_fs:<EOL><INDENT>samplerate = force_fs<EOL><DEDENT>else:<EOL><INDENT>samplerate = self.samplerate()<EOL><DEDENT>track_signals = []<EOL>max_db = max([comp.intensity() for t in self._segments for comp in t])<EOL>atten = <NUM_LIT:0><EOL>for track in self._seg... | The current stimulus in signal representation, this is the sum
of its components
:param force_fs: Allow to use a different samplerate than the default, should be used to recreate historical signals only
:type force_fs: int
:returns: numpy.ndarray -- voltage signal for this stimulus | f10681:c0:m41 |
def componentDoc(self, starttime=True): | samplerate = self.samplerate()<EOL>doc_list = []<EOL>for row, track in enumerate(self._segments):<EOL><INDENT>start_time = <NUM_LIT:0><EOL>for col, component in enumerate(track):<EOL><INDENT>info = component.stateDict()<EOL>info['<STR_LIT>'] = component.name<EOL>if starttime:<EOL><INDENT>info['<STR_LIT>'] = start_time<... | The documentation for the components, as a dict
:returns dict -- values are the generation samplerate, and a list of
the individual component docs | f10681:c0:m42 |
def updateComponentStartVals(self): | self._autoParams.updateComponentStartVals()<EOL> | Go through selected components for each auto parameter and set the
start value | f10681:c0:m44 |
def containsPval(self, paramName, value): | <EOL>params = self._autoParams.allData()<EOL>steps = self.autoParamRanges()<EOL>pnames = [p['<STR_LIT>'] for p in params]<EOL>if paramName in pnames:<EOL><INDENT>pidx = pnames.index(paramName)<EOL>return value in steps[pidx]<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT> | Returns true if *value* for parameter type *paramName* is in the
auto parameters
:param paramName: the name of the auto-parameter to match, e.g. 'frequency'
:type paramName: str
:param value: the value of the parameter to search for
:returns: bool | f10681:c0:m45 |
def warning(self): | signals, docs, overs = self.expandedStim()<EOL>if np.any(np.array(overs) > <NUM_LIT:0>):<EOL><INDENT>msg = '<STR_LIT>'.format(np.amax(overs))<EOL>return msg<EOL><DEDENT>return <NUM_LIT:0><EOL> | Checks Stimulus for any warning conditions
:returns: str -- warning message, if any, 0 otherwise | f10681:c0:m46 |
def verifyExpanded(self, samplerate): | results = self.expandFunction(self.verifyComponents, args=(samplerate,))<EOL>msg = [x for x in results if x]<EOL>if len(msg) > <NUM_LIT:0>:<EOL><INDENT>return msg[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT> | Checks the expanded parameters for invalidating conditions
:param samplerate: generation samplerate (Hz), passed on to component verification
:type samplerate: int
:returns: str -- error message, if any, 0 otherwise | f10681:c0:m47 |
def verifyComponents(self, samplerate): | <EOL>components = [comp for track in self._segments for comp in track]<EOL>for comp in components:<EOL><INDENT>msg = comp.verify(samplerate=samplerate)<EOL>if msg:<EOL><INDENT>return msg<EOL><DEDENT><DEDENT>return <NUM_LIT:0><EOL> | Checks the current components for invalidating conditions
:param samplerate: generation samplerate (Hz), passed on to component verification
:type samplerate: int
:returns: str -- error message, if any, 0 otherwise | f10681:c0:m48 |
def verify(self, windowSize=None): | if self.samplerate() is None:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>msg = self._autoParams.verify()<EOL>if msg:<EOL><INDENT>return msg<EOL><DEDENT>if self.traceCount() == <NUM_LIT:0>:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>if windowSize is not None:<EOL><INDENT>durations = self.expandFunction(self.duration)<EO... | Checks the stimulus, including expanded parameters for invalidating conditions
:param windowSize: acquistion (recording) window size (seconds)
:type windowSize: float
:returns: str -- error message, if any, 0 otherwise | f10681:c0:m49 |
def amplitude(self, caldb, calv, atten=<NUM_LIT:0>): | amp = (<NUM_LIT:10> ** (float(self._intensity+atten-caldb)/<NUM_LIT:20>)*calv)<EOL>return amp<EOL> | Calculates the voltage amplitude for this stimulus, using
internal intensity value and the given reference intensity & voltage
:param caldb: calibration intensity in dbSPL
:type caldb: float
:param calv: calibration voltage that was used to record the intensity provided
:type ca... | f10682:c0:m8 |
def signal(self, fs, atten, caldb, calv): | raise NotImplementedError<EOL> | Creates a signal representation of this stimulus, in the
form of a vector of numbers representing electric potential.
caldb and calv are used to determine the amplitude of the
signal.
Must be implemented by subclass
:param fs: Generation samplerate (Hz) at which this signal wil... | f10682:c0:m9 |
def verify(self, **kwargs): | if '<STR_LIT>' in kwargs:<EOL><INDENT>if kwargs['<STR_LIT>'] < self._duration:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT><DEDENT>if self._risefall > self._duration:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>return <NUM_LIT:0><EOL> | Checks this component for invalidating conditions
:returns: str -- message if error, 0 otherwise | f10682:c0:m10 |
def auto_details(self): | return {'<STR_LIT>':{'<STR_LIT>':'<STR_LIT:s>', '<STR_LIT>':<NUM_LIT:0.>, '<STR_LIT>':<NUM_LIT>},<EOL>'<STR_LIT>':{'<STR_LIT>':'<STR_LIT>', '<STR_LIT>':<NUM_LIT:0>, '<STR_LIT>':<NUM_LIT>}, <EOL>'<STR_LIT>':{'<STR_LIT>':'<STR_LIT:s>', '<STR_LIT>':<NUM_LIT:0>, '<STR_LIT>':<NUM_LIT:0.1>}}<EOL> | A collection of the parameter names that are available to
be set using auto-paramter manipulation.
Subclasses should re-implement and add to this list
:returns: dict<dict> -- {'parametername': {'label':str, 'unit':str, 'min':float, 'max':float},} | f10682:c0:m11 |
def stateDict(self): | state = {<EOL>'<STR_LIT>' : self._duration,<EOL>'<STR_LIT>' : self._intensity,<EOL>'<STR_LIT>' : self._risefall,<EOL>'<STR_LIT>' : self.name<EOL>}<EOL>return state<EOL> | Saves internal values to be loaded later
:returns: dict -- {'parametername': value, ...} | f10682:c0:m12 |
def loadState(self, state): | self._duration = state['<STR_LIT>']<EOL>self._intensity = state['<STR_LIT>']<EOL>self._risefall = state['<STR_LIT>']<EOL> | Loads previously saved values to this component.
:param state: return value from `stateDict`
:type state: dict | f10682:c0:m13 |
def nrows(self): | return len(self._parameters)<EOL> | The number of auto-parameters
:returns: int -- parameter count | f10683:c0:m1 |
def clearParameters(self): | self._parameters = []<EOL> | Clears all parameters out of this model | f10683:c0:m2 |
def param(self, row): | return self._parameters[row]<EOL> | Gets the parameter indexed by *row*
:param row: the ith parameter number
:type row: int
:returns: dict -- the parameter | f10683:c0:m3 |
def selection(self, row): | return self._parameters[row]['<STR_LIT>']<EOL> | Gets the component selection for parameter number *row*
:param row: the ith parameter number
:type row: int
:returns: list<:class:`AbstractStimulusComponent<sparkle.stim.abstract_component.AbstractStimulusComponent>`> | f10683:c0:m4 |
def allData(self): | return self._parameters<EOL> | Gets a list of all the parameters in this model
:returns: list<dict> -- all parameters | f10683:c0:m5 |
def toggleSelection(self, row, component): | selection = self._parameters[row]['<STR_LIT>']<EOL>if component in selection:<EOL><INDENT>selection.remove(component)<EOL><DEDENT>else:<EOL><INDENT>selection.append(component)<EOL><DEDENT> | Toggles the *component* in or out of the selection
for parameter *row*
:param row: the ith parameter number
:type row: int
:param component: the component to toggle its selection membership
:type component: :class:`AbstractStimulusComponent<sparkle.stim.abstract_component.Abstr... | f10683:c0:m6 |
def setVerifiedValue(self, row, field, value): | if self._parameters[row]['<STR_LIT>'] == '<STR_LIT:filename>':<EOL><INDENT>return <EOL><DEDENT>if field == '<STR_LIT>':<EOL><INDENT>self.setParamValue(row, parameter=value)<EOL><DEDENT>elif field in ['<STR_LIT:start>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>if self.checkLimits(row, value):<EOL><INDENT>kwd = {field : va... | Sets the *value* for *field* in the parameter
indexed by *row*, only if the value is within set limits
:param row: the ith parameter number
:type row: int
:param field: detail of the parameter to set
:type field: str
:param value: pre-scaled value to assign to field | f10683:c0:m7 |
def setParamValue(self, row, **kwargs): | param = self._parameters[row]<EOL>for key, val in list(kwargs.items()):<EOL><INDENT>param[key] = val<EOL><DEDENT> | Sets the arguments as field=val for parameter
indexed by *row*
:param row: the ith parameter number
:type row: int | f10683:c0:m8 |
def paramValue(self, row, field): | if field == '<STR_LIT>':<EOL><INDENT>return self.numSteps(row)<EOL><DEDENT>if field in ['<STR_LIT:start>', '<STR_LIT>', '<STR_LIT>'] and self._parameters[row]['<STR_LIT>'] == '<STR_LIT:filename>':<EOL><INDENT>return '<STR_LIT:->'<EOL><DEDENT>else:<EOL><INDENT>param = self._parameters[row]<EOL>return param[field]<EOL><D... | Gets the value for *field* for parameter indexed by
*row*
:param row: the ith parameter number
:type row: int
:param field: detail of the parameter to set
:type field: str
:returns: value -- type appropriate to parameter | f10683:c0:m9 |
def overwriteParam(self, row, param): | if row == -<NUM_LIT:1>:<EOL><INDENT>row = self.nrows() - <NUM_LIT:1><EOL><DEDENT>self._parameters[row] = param<EOL> | Assigns *param* to index *row*, overwritting the
parameter at that location
:param row: the ith parameter number
:type row: int
:param param: parameter to set
:type param: dict | f10683:c0:m10 |
def numSteps(self, row): | param = self._parameters[row]<EOL>return self.nStepsForParam(param)<EOL> | Gets the number of steps for the parameter at
index *row* will yeild | f10683:c0:m11 |
def nStepsForParam(self, param): | if param['<STR_LIT>'] == '<STR_LIT:filename>':<EOL><INDENT>return len(param['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>if param['<STR_LIT>'] > <NUM_LIT:0>:<EOL><INDENT>if abs(param['<STR_LIT:start>'] - param['<STR_LIT>']) < param['<STR_LIT>']:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>nsteps = np.around(abs(param['<S... | Gets the number of steps *parameter* will yeild
:param param: parameter to get the expansion count for
:type param: dict | f10683:c0:m12 |
def getDetail(self, row, detail_field): | param = self._parameters[row]<EOL>param_type = param['<STR_LIT>']<EOL>components = param['<STR_LIT>']<EOL>if len(components) == <NUM_LIT:0> or param_type == '<STR_LIT>':<EOL><INDENT>return None<EOL><DEDENT>matching_details = []<EOL>for comp in components:<EOL><INDENT>alldetails = comp.auto_details()<EOL>if not param_ty... | Gets the value of the detail *detail_field* of paramter
at index *row* from its selected components `auto_details`.
All of the selected components value for *detail_field* must
match
:param row: the ith parameter number
:type row: int
:param detail_field: auto_details me... | f10683:c0:m13 |
def isFieldValid(self, row, field): | param = self._parameters[row]<EOL>if param['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT>if field == '<STR_LIT>':<EOL><INDENT>return self.numSteps(row) != <NUM_LIT:0><EOL><DEDENT>if param['<STR_LIT>'] == '<STR_LIT:filename>':<EOL><INDENT>return True<EOL><DEDENT>if field == '<STR_LIT>':<EOL><INDENT>r... | Verifies the value in *field* for parameter at index
*row*
:param row: the ith parameter number
:type row: int
:param field: detail of the parameter to check
:type field: str
:returns: bool -- True if valid | f10683:c0:m14 |
def findFileParam(self, comp): | for p in self._parameters:<EOL><INDENT>if p['<STR_LIT>'] == '<STR_LIT:filename>' and comp in p['<STR_LIT>']:<EOL><INDENT>return p['<STR_LIT>']<EOL><DEDENT><DEDENT> | Finds the filename auto-parameter that component *comp* is
in, and returns all the filenames for that parameter. Notes this
assumes that *comp* will only be in a single filename auto-parameter.
:param comp: Component to search parameter membership for
:type comp: :class:`AbstractStimulu... | f10683:c0:m15 |
def checkLimits(self, row, value): | <EOL>param = self._parameters[row]<EOL>components = param['<STR_LIT>']<EOL>if len(components) == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>ptype = param['<STR_LIT>']<EOL>mins = []<EOL>maxs = []<EOL>for comp in components:<EOL><INDENT>try:<EOL><INDENT>details = comp.auto_details()[ptype]<EOL>mins.append(details[... | Check that *value* is within the minimum and maximum allowable
range for the parameter at index *row*
:param row: the ith parameter number
:type row: int
:param value: the candidate value to for start or stop fields
:returns: bool -- True if *value* within range | f10683:c0:m16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.