signature
stringlengths 8
3.44k
| body
stringlengths 0
1.41M
| docstring
stringlengths 1
122k
| id
stringlengths 5
17
|
|---|---|---|---|
def start(self):
|
self.StartTask()<EOL>
|
Begins generation -- immediately, if not using a trigger
|
f10583:c3:m1
|
def write(self,output):
|
w = c_int32()<EOL>self.WriteAnalogF64(self.npoints, <NUM_LIT:0>, <NUM_LIT>, DAQmx_Val_GroupByChannel,<EOL>output, w, None)<EOL>
|
Writes the data to be output to the device buffer
:param output: data to output
:type output: numpy.ndarray
|
f10583:c3:m2
|
def wait(self):
|
self.WaitUntilTaskDone(<NUM_LIT>)<EOL>
|
returns after the generation finishes
|
f10583:c3:m3
|
def stop(self):
|
<EOL>try:<EOL><INDENT>self.StopTask()<EOL>self.ClearTask()<EOL><DEDENT>except DAQError:<EOL><INDENT>pass<EOL><DEDENT>
|
Halts the Generation
|
f10583:c3:m4
|
def start(self):
|
self.StartTask()<EOL>if self.clock:<EOL><INDENT>self.clock.StartTask()<EOL><DEDENT>
|
Begins generation
|
f10583:c4:m1
|
def stop(self):
|
self.StopTask()<EOL>self.ClearTask()<EOL>if self.clock:<EOL><INDENT>self.clock.StopTask()<EOL>self.clock.ClearTask()<EOL><DEDENT>
|
Halts generation
|
f10583:c4:m2
|
def generated(self):
|
buf = c_uint64()<EOL>self.GetWriteTotalSampPerChanGenerated(buf)<EOL>return buf.value<EOL>
|
Reports the number of digital output pulses generated
|
f10583:c4:m3
|
def start(self):
|
self.StartTask()<EOL>
|
Begins the pulse train generation
|
f10583:c5:m1
|
def stop(self):
|
self.StopTask()<EOL>self.ClearTask()<EOL>
|
Halts the pulse train generation
|
f10583:c5:m2
|
def start(self):
|
raise NotImplementedError<EOL>
|
Abstract, must be implemented by subclass
|
f10584:c0:m1
|
def stop(self):
|
raise NotImplementedError<EOL>
|
Abstract, must be implemented by subclass
|
f10584:c0:m2
|
def reset_generation(self, trigger):
|
self.tone_lock.acquire()<EOL>npts = self.stim.size<EOL>try:<EOL><INDENT>self.aotask = AOTaskFinite(self.aochan, self.fs, npts, trigsrc=trigger)<EOL>self.aotask.write(self.stim)<EOL>if self.attenuator is not None:<EOL><INDENT>self.attenuator.SetAtten(self.atten)<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT>self.ngenerated +=<NUM_LIT:1><EOL>if self.stim_changed:<EOL><INDENT>new_gen = self.stim<EOL><DEDENT>else:<EOL><INDENT>new_gen = None<EOL><DEDENT>self.stim_changed = False<EOL><DEDENT>except:<EOL><INDENT>print('<STR_LIT>')<EOL>self.tone_lock.release()<EOL>raise<EOL><DEDENT>self.tone_lock.release()<EOL>return new_gen<EOL>
|
Re-arms the analog output according to current settings
:param trigger: name of the trigger terminal. ``None`` value means generation begins immediately on run
:type trigger: str
|
f10584:c0:m3
|
def set_stim(self, signal, fs, attenuation=<NUM_LIT:0>):
|
self.tone_lock.acquire()<EOL>self.stim = signal<EOL>self.fs = fs<EOL>self.atten = attenuation<EOL>self.stim_changed = True<EOL>self.tone_lock.release()<EOL>
|
Sets any vector as the next stimulus to be output. Does not call write to hardware
|
f10584:c0:m4
|
def get_samplerate(self):
|
return self.fs<EOL>
|
The current analog output(generation) samplerate
:returns: int -- samplerate (Hz)
|
f10584:c0:m5
|
def get_aidur(self):
|
return self.aitime<EOL>
|
The current input(recording) window duration
:returns: float -- window length (seconds)
|
f10584:c0:m6
|
def get_aifs(self):
|
return self.aifs<EOL>
|
The current analog input (recording) samplerate
:returns: int -- samplerate (Hz)
|
f10584:c0:m7
|
def set_aifs(self, fs):
|
self.aifs = fs<EOL>
|
Sets the current analog input (recording) samplerate
:param fs: recording samplerate (Hz)
:type fs: int
|
f10584:c0:m8
|
def set_aidur(self,dur):
|
self.aitime = dur<EOL>
|
Sets the current input(recording) window duration
:param dur: window length (seconds)
:type dur: float
|
f10584:c0:m9
|
def set_aochan(self, aochan):
|
self.aochan = aochan<EOL>
|
Sets the current analog output (generation) channel
:param aochan: AO channel name
:type aochan: str
|
f10584:c0:m10
|
def set_aichan(self, aichan):
|
self.aichan = aichan<EOL>
|
Sets the current analog input (recording) channel
:param aichan: AI channel name
:type aochan: str
|
f10584:c0:m11
|
def connect_attenuator(self, connect=True):
|
if connect:<EOL><INDENT>try:<EOL><INDENT>pa5 = win32com.client.Dispatch("<STR_LIT>")<EOL>success = pa5.ConnectPA5('<STR_LIT>', <NUM_LIT:1>)<EOL>if success == <NUM_LIT:1>:<EOL><INDENT>print('<STR_LIT>')<EOL>pass<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>errmsg = pa5.GetError()<EOL>print("<STR_LIT>", errmsg)<EOL>raise Exception("<STR_LIT>")<EOL><DEDENT><DEDENT>except:<EOL><INDENT>print("<STR_LIT>")<EOL>pa5 = None<EOL><DEDENT>self.attenuator = pa5<EOL><DEDENT>else:<EOL><INDENT>if self.attenuator:<EOL><INDENT>self.attenuator.setAtten(<NUM_LIT:0>)<EOL><DEDENT>self.attenuator = None<EOL><DEDENT>return self.attenuator<EOL>
|
Establish a connection to the TDT PA5 attenuator
|
f10584:c0:m12
|
def attenuator_connected(self):
|
return self.attenuator is not None<EOL>
|
Returns whether a connection to the attenuator has been established (bool)
|
f10584:c0:m13
|
def start_timer(self, reprate):
|
print('<STR_LIT>'.format(reprate))<EOL>self.trigger_task = DigitalOutTask(self.trigger_src, reprate)<EOL>self.trigger_task.start()<EOL>
|
Start the digital output task that serves as the acquistion trigger
|
f10584:c0:m14
|
def start(self):
|
<EOL>if self.aitask is not None:<EOL><INDENT>self.stop()<EOL>raise Exception("<STR_LIT>")<EOL><DEDENT>self.daq_lock.acquire()<EOL>self.ngenerated = <NUM_LIT:0><EOL>self.nacquired = <NUM_LIT:0><EOL>return self.reset()<EOL>
|
Writes output buffer and settings to device
:returns: numpy.ndarray -- if the first presentation of a novel stimulus, or None if a repeat stimulus
|
f10584:c1:m1
|
def run(self):
|
try:<EOL><INDENT>if self.aotask is None:<EOL><INDENT>print("<STR_LIT>")<EOL>return<EOL><DEDENT>self.daq_lock.acquire()<EOL>self.aotask.StartTask()<EOL>self.aitask.StartTask()<EOL>data = self.aitask.read()<EOL>self.nacquired += <NUM_LIT:1><EOL>self.aitask.stop()<EOL>self.aotask.stop()<EOL><DEDENT>except:<EOL><INDENT>print('<STR_LIT>')<EOL>self.daq_lock.release()<EOL>self.stop()<EOL>raise<EOL><DEDENT>return data<EOL>
|
Begins simultaneous generation/acquisition
:returns: numpy.ndarray -- read samples
|
f10584:c1:m2
|
def reset(self):
|
response_npts = int(self.aitime*self.aifs)<EOL>try:<EOL><INDENT>self.aitask = AITaskFinite(self.aichan, self.aifs, response_npts, trigsrc=self.trigger_dest)<EOL>new_gen = self.reset_generation("<STR_LIT>")<EOL><DEDENT>except:<EOL><INDENT>print('<STR_LIT>')<EOL>self.daq_lock.release()<EOL>self.stop()<EOL>raise<EOL><DEDENT>self.daq_lock.release()<EOL>return new_gen<EOL>
|
Rearms the gen/acq task, to the same channels as before
|
f10584:c1:m3
|
def stop(self):
|
try:<EOL><INDENT>self.aitask.stop()<EOL>self.aotask.stop()<EOL>pass<EOL><DEDENT>except: <EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>self.aitask = None<EOL>self.aotask = None<EOL>
|
Halts the acquisition, this must be called before resetting acquisition
|
f10584:c1:m4
|
def start_continuous(self, aichans, update_hz=<NUM_LIT:10>):
|
self.daq_lock.acquire()<EOL>self.ngenerated = <NUM_LIT:0> <EOL>npts = int(self.aifs/update_hz) <EOL>nchans = len(aichans)<EOL>self.aitask = AITask(aichans, self.aifs, npts*<NUM_LIT:5>*nchans)<EOL>self.aitask.register_callback(self._read_continuous, npts)<EOL>self.aitask.start()<EOL>
|
Begins a continuous analog generation, calling a provided function
at a rate of 10Hz
:param aichans: name of channel(s) to record (analog input) from
:type aichans: list<str>
:param update_hz: Rate (Hz) at which to read data from the device input buffer
:type update_hz: int
|
f10584:c2:m1
|
def set_read_function(self, fun):
|
self.on_read = fun<EOL>
|
Set the function to be executed for every read from the device buffer
:param fun: callable which must take a numpy.ndarray as the only positional argument
:type fun: function
|
f10584:c2:m2
|
def run(self):
|
self.aotask.StartTask()<EOL>self.aotask.wait() <EOL>self.aotask.stop()<EOL>self.aotask = None<EOL>
|
Executes the stimulus generation, and returns when completed
|
f10584:c2:m4
|
def start(self):
|
self.reset()<EOL>
|
Arms the analog output (generation) for the current settings
|
f10584:c2:m5
|
def reset(self):
|
try:<EOL><INDENT>new_gen = self.reset_generation("<STR_LIT>")<EOL><DEDENT>except:<EOL><INDENT>print('<STR_LIT>')<EOL>raise<EOL><DEDENT>return new_gen<EOL>
|
Re-arms the analog output (generation) to be preseneted again, for the current settings
|
f10584:c2:m6
|
def stop(self):
|
try:<EOL><INDENT>self.aotask.stop()<EOL><DEDENT>except: <EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>self.aotask = None<EOL>
|
Halts the analog output task
|
f10584:c2:m7
|
def stop_all(self):
|
if self.aotask is not None:<EOL><INDENT>self.aotask.stop()<EOL><DEDENT>self.aitask.stop()<EOL>self.daq_lock.release()<EOL>self.aitask = None<EOL>self.aotask = None<EOL>
|
Halts both the analog output and input tasks
|
f10584:c2:m8
|
def generation_count(self):
|
<EOL>return self.ngenerated<EOL>
|
Number of stimulus presentations
:returns: int -- number of analog output events
|
f10584:c2:m9
|
def recordingSelected(self, modelIndex):
|
<EOL>spath = self.exvocal.currentWavFile<EOL>fs, audio_signal = audioread(spath)<EOL>self.displayStim(audio_signal, fs)<EOL>if self.ui.tabGroup.currentWidget().objectName() == '<STR_LIT>':<EOL><INDENT>winsz = float(self.ui.windowszSpnbx.value())<EOL>self.display.setXlimits((<NUM_LIT:0>,winsz))<EOL><DEDENT>self.selectedWavFile = spath<EOL>self.onUpdate()<EOL>
|
On double click of wav file, load into display
|
f10590:c0:m44
|
def floatingStuff(self, floating):
|
pass<EOL>
|
Sets window flag appropriately when widget is floated/unfloated
:param floating: whether the widget is now on its own
:type floating: bool
|
f10591:c0:m1
|
def switchDisplay(self, display):
|
if display in self.displays:<EOL><INDENT>self.setWidget(self.displays[display])<EOL>self._current = display<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>"+ display)<EOL><DEDENT>
|
Switches the visible widget to the one named *display*
:param: the name of the desired display to show
:type: str
|
f10591:c0:m2
|
def current(self):
|
return self._current<EOL>
|
Name of the currently shown display
:returns: str -- name of widget displayed
|
f10591:c0:m3
|
def grabImage(self, index):
|
<EOL>raise NotImplementedError<EOL>
|
Gets a pixmap image of the item located at index
Must be implemented by subclass.
:param index: index of the item
:type index: :qtdoc:`QModelIndex`
:returns: :qtdoc:`QPixMap`
|
f10592:c0:m1
|
def cursor(self, index):
|
raise NotImplementedError<EOL>
|
Gets a line to draw to indicate where a drop will occur
Must be implemented by subclass.
:param index: index of the item
:type index: :qtdoc:`QModelIndex`
:returns: :qtdoc:`QLine`
|
f10592:c0:m2
|
def indexXY(self, index):
|
raise NotImplementedError<EOL>
|
Return the top left coordinates for the given *index*, relative
to self.
Must be implemented by subclass.
:param index: index of the item
:type index: :qtdoc:`QModelIndex`
:returns: (int, int) -- (x, y) coordinates
|
f10592:c0:m3
|
def mousePressEvent(self, event):
|
super(AbstractDragView, self).mousePressEvent(event)<EOL>self.dragStartPosition = event.pos()<EOL>
|
saves the drag position, so we know when a drag should be initiated
|
f10592:c0:m4
|
def mouseMoveEvent(self, event):
|
super(AbstractDragView, self).mouseMoveEvent(event)<EOL>if self.dragStartPosition is None or(event.pos() - self.dragStartPosition).manhattanLength() < QtGui.QApplication.startDragDistance():<EOL><INDENT>index = self.indexAt(event.pos())<EOL>cursor = self.model().data(index, CursorRole)<EOL>self.setCursor(cursor)<EOL>return<EOL><DEDENT>index = self.indexAt(self.dragStartPosition)<EOL>if not index.isValid():<EOL><INDENT>return<EOL><DEDENT>pixmap = self.grabImage(index)<EOL>selected = self.model().data(index, self.DragRole)<EOL>if selected is None:<EOL><INDENT>return<EOL><DEDENT>bstream = cPickle.dumps(selected)<EOL>mimeData = QtCore.QMimeData()<EOL>mimeData.setData("<STR_LIT>", bstream)<EOL>self.limbo_component = selected<EOL>self.originalPos = index<EOL>drag = QtGui.QDrag(self)<EOL>drag.setMimeData(mimeData)<EOL>painter = QtGui.QPainter(pixmap)<EOL>painter.setCompositionMode(painter.CompositionMode_DestinationIn)<EOL>painter.fillRect(pixmap.rect(), QtGui.QColor(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT>))<EOL>painter.end()<EOL>drag.setPixmap(pixmap)<EOL>x, y = self.indexXY(index)<EOL>drag.setHotSpot(QtCore.QPoint(event.x()-x, event.y()-y))<EOL>drag.setPixmap(pixmap)<EOL>self.model().removeItem(index)<EOL>result = drag.exec_(QtCore.Qt.MoveAction)<EOL>
|
Determines if a drag is taking place, and initiates it
|
f10592:c0:m5
|
def dragEnterEvent(self, event):
|
super(AbstractDragView, self).dragEnterEvent(event)<EOL>if event.mimeData().hasFormat("<STR_LIT>"):<EOL><INDENT>event.setDropAction(QtCore.Qt.MoveAction)<EOL>event.accept()<EOL><DEDENT>else:<EOL><INDENT>event.ignore()<EOL><DEDENT>
|
Determines if the widget under the mouse can recieve the drop
|
f10592:c0:m6
|
def dragMoveEvent(self, event):
|
super(AbstractDragView, self).dragMoveEvent(event)<EOL>if event.mimeData().hasFormat("<STR_LIT>"):<EOL><INDENT>self.dragline = self.cursor(event.pos())<EOL>self.viewport().update()<EOL>event.setDropAction(QtCore.Qt.MoveAction)<EOL>event.accept()<EOL><DEDENT>else:<EOL><INDENT>event.ignore()<EOL><DEDENT>
|
Determines if the widget under the mouse can recieve the drop
|
f10592:c0:m7
|
def dragLeaveEvent(self, event):
|
super(AbstractDragView, self).dragLeaveEvent(event)<EOL>self.dragline = None<EOL>self.viewport().update()<EOL>event.accept()<EOL>
|
Clears drop cursor line
|
f10592:c0:m8
|
def dropped(self, item, event):
|
raise NotImplementedError<EOL>
|
Deals with an item dropped on the view
Must be implemented by subclass
:param item: same item that was selected, and removed at the start of drag
:param event: Qt event obect passed from dropEvent
:type event: :qtdoc:`QDropEvent`
|
f10592:c0:m9
|
def dropEvent(self, event):
|
super(AbstractDragView, self).dropEvent(event)<EOL>self.dragStartPosition = None<EOL>self.dragline = None<EOL>self.originalPos = None<EOL>data = event.mimeData()<EOL>stream = data.retrieveData("<STR_LIT>",<EOL>QtCore.QVariant.ByteArray)<EOL>item = cPickle.loads(str(stream.toByteArray()))<EOL>self.dropped(item, event)<EOL>event.accept()<EOL>
|
Handles an item being dropped onto view, calls
dropped -- implemented by subclass
|
f10592:c0:m10
|
def childEvent(self, event):
|
super(AbstractDragView, self).childEvent(event)<EOL>if event.type() == QtCore.QEvent.ChildRemoved:<EOL><INDENT>if self.originalPos is not None:<EOL><INDENT>selected = self.limbo_component<EOL>self.model().insertItem(self.originalPos, selected)<EOL>self.originalPos = None<EOL>self.dragStartPosition = None<EOL>self.viewport().update()<EOL><DEDENT><DEDENT>
|
Catches items dropped off edge of view,
reinserts at original position
:param event: contains event parameters for child object events
:type event: :qtdoc:`QChildEvent`
|
f10592:c0:m11
|
def mouseReleaseEvent(self, event):
|
super(AbstractDragView, self).mouseReleaseEvent(event)<EOL>self.dragStartPosition = None<EOL>
|
Resets the drag start position
|
f10592:c0:m12
|
def values(self):
|
if self.ui.hzBtn.isChecked():<EOL><INDENT>fscale = SmartSpinBox.Hz<EOL><DEDENT>else:<EOL><INDENT>fscale = SmartSpinBox.kHz<EOL><DEDENT>if self.ui.msBtn.isChecked():<EOL><INDENT>tscale = SmartSpinBox.MilliSeconds<EOL><DEDENT>else:<EOL><INDENT>tscale = SmartSpinBox.Seconds<EOL><DEDENT>return fscale, tscale<EOL>
|
Gets the scales that the user chose
| For frequency: 1 = Hz, 1000 = kHz
| For time: 1 = seconds, 0.001 = ms
:returns: float, float -- frequency scaling, time scaling
|
f10595:c0:m1
|
def update_label(self):
|
current_file = str(self.selectedFiles()[<NUM_LIT:0>])<EOL>if not '<STR_LIT:.>' in current_file.split(os.path.sep)[-<NUM_LIT:1>]:<EOL><INDENT>current_file += '<STR_LIT>'<EOL><DEDENT>if os.path.isfile(current_file):<EOL><INDENT>self.setLabelText(QtGui.QFileDialog.Accept, '<STR_LIT>')<EOL><DEDENT>elif os.path.isdir(current_file):<EOL><INDENT>self.setLabelText(QtGui.QFileDialog.Accept, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>self.setLabelText(QtGui.QFileDialog.Accept, '<STR_LIT>')<EOL><DEDENT>
|
Updates the text on the accept button, to reflect if the
name of the data file will result in opening an existing file,
or creating a new one
|
f10597:c0:m1
|
def getfile(self):
|
current_file = str(self.selectedFiles()[<NUM_LIT:0>])<EOL>if os.path.isfile(current_file):<EOL><INDENT>print('<STR_LIT>', current_file)<EOL>if current_file.endswith('<STR_LIT>') or current_file.endswith('<STR_LIT>'):<EOL><INDENT>fmode = '<STR_LIT:r>'<EOL><DEDENT>else:<EOL><INDENT>fmode = '<STR_LIT:a>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not current_file.endswith('<STR_LIT>') and not current_file.endswith('<STR_LIT>'):<EOL><INDENT>current_file += '<STR_LIT>'<EOL><DEDENT>fmode = '<STR_LIT>'<EOL><DEDENT>return current_file, fmode<EOL>
|
Gets the full file path of the entered/selected file
:returns: str -- the name of the data file to open/create
|
f10597:c0:m2
|
def values(self):
|
result = {}<EOL>result['<STR_LIT>'] = self.ui.fontszSpnbx.value()<EOL>result['<STR_LIT>'] = self.ui.detailWidget.getCheckedDetails()<EOL>return result<EOL>
|
Gets user inputs
:returns: dict of inputs:
| *'fontsz'*: int -- font size for text throughout the GUI
| *'display_attributes'*: dict -- what attributes of stimuli to report as they are being presented
|
f10598:c0:m1
|
def comment(self):
|
return self.ui.commentTxtedt.toPlainText()<EOL>
|
Get the comment enters in this widget
:returns: str -- user entered comment
|
f10602:c0:m1
|
def setComment(self, msg):
|
self.ui.commentTxtedt.setPlainText(msg)<EOL>self.ui.commentTxtedt.moveCursor(QtGui.QTextCursor.End)<EOL>
|
Sets the widget text to *msg*
:param msg: overwrites any existing text with *msg*
:type msg: str
|
f10602:c0:m2
|
def maxRange(self):
|
try:<EOL><INDENT>x, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)<EOL>self.ui.frangeLowSpnbx.setValue(freqs[<NUM_LIT:0>])<EOL>self.ui.frangeHighSpnbx.setValue(freqs[-<NUM_LIT:1>])<EOL>print('<STR_LIT>', freqs[<NUM_LIT:0>], freqs[-<NUM_LIT:1>], freqs[<NUM_LIT:0>], freqs[-<NUM_LIT:1>])<EOL><DEDENT>except IOError:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>except KeyError:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>
|
Sets the maximum range for the currently selection calibration,
determined from its range of values store on file
|
f10604:c0:m1
|
def plotCurve(self):
|
try:<EOL><INDENT>attenuations, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)<EOL>self.pw = SimplePlotWidget(freqs, attenuations, parent=self)<EOL>self.pw.setWindowFlags(QtCore.Qt.Window)<EOL>self.pw.setLabels('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>self.pw.show()<EOL><DEDENT>except IOError:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>except KeyError:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL><DEDENT>
|
Shows a calibration curve, in a separate window, of the currently selected calibration
|
f10604:c0:m2
|
def values(self):
|
results = {}<EOL>results['<STR_LIT>'] = self.ui.calfileRadio.isChecked()<EOL>results['<STR_LIT>'] = str(self.ui.calChoiceCmbbx.currentText())<EOL>results['<STR_LIT>'] = (self.ui.frangeLowSpnbx.value(), self.ui.frangeHighSpnbx.value())<EOL>return results<EOL>
|
Gets the values the user input to this dialog
:returns: dict of inputs:
| *'use_calfile'*: bool, -- whether to apply calibration at all
| *'calname'*: str, -- the name of the calibration dataset to use
| *'frange'*: (int, int), -- (min, max) of the frequency range to apply calibration to
|
f10604:c0:m3
|
def conditional_accept(self):
|
if self.ui.calfileRadio.isChecked() and str(self.ui.calChoiceCmbbx.currentText()) == '<STR_LIT>':<EOL><INDENT>self.ui.noneRadio.setChecked(True)<EOL><DEDENT>if self.ui.calfileRadio.isChecked():<EOL><INDENT>try:<EOL><INDENT>x, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)<EOL><DEDENT>except IOError:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL>return<EOL><DEDENT>except KeyError:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL>return<EOL><DEDENT>if self.ui.frangeLowSpnbx.value() < freqs[<NUM_LIT:0>] orself.ui.frangeHighSpnbx.value() > freqs[-<NUM_LIT:1>]:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", <EOL>"<STR_LIT>".format(freqs[<NUM_LIT:0>], freqs[-<NUM_LIT:1>]))<EOL>return<EOL><DEDENT><DEDENT>self.accept()<EOL>
|
Accepts the inputs if all values are valid and congruent.
i.e. Valid datafile and frequency range within the given calibration dataset.
|
f10604:c0:m4
|
def values(self):
|
self.vals['<STR_LIT>'] = self.ui.nfftSpnbx.value()<EOL>self.vals['<STR_LIT>'] = str(self.ui.windowCmbx.currentText()).lower()<EOL>self.vals['<STR_LIT>'] = self.ui.overlapSpnbx.value()<EOL>return self.vals<EOL>
|
Gets the parameter values
:returns: dict of inputs:
| *'nfft'*: int -- length, in samples, of FFT chunks
| *'window'*: str -- name of window to apply to FFT chunks
| *'overlap'*: float -- percent overlap of windows
|
f10608:c0:m1
|
def verifyInputs(self, mode):
|
if len(self._aichans) < <NUM_LIT:1>:<EOL><INDENT>failmsg = "<STR_LIT>"<EOL>QtGui.QMessageBox.warning(self, "<STR_LIT>", failmsg)<EOL>return False<EOL><DEDENT>if mode == '<STR_LIT>':<EOL><INDENT>if self.ui.aifsSpnbx.value()*self.fscale > <NUM_LIT>:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", "<STR_LIT>")<EOL>return False<EOL><DEDENT><DEDENT>elif mode is not None:<EOL><INDENT>if self.ui.tabGroup.currentWidget().objectName() == '<STR_LIT>':<EOL><INDENT>self.ui.exploreStimEditor.saveToObject()<EOL>failmsg = self.ui.exploreStimEditor.verify(self.ui.windowszSpnbx.value())<EOL>if failmsg:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", failmsg)<EOL>return False<EOL><DEDENT><DEDENT>elif self.ui.tabGroup.currentWidget().objectName() == '<STR_LIT>':<EOL><INDENT>protocol_model = self.acqmodel.protocol_model()<EOL>failure = protocol_model.verify(float(self.ui.windowszSpnbx.value()))<EOL>if failure:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", failure)<EOL>return False<EOL><DEDENT><DEDENT>elif self.ui.tabGroup.currentWidget().objectName() == '<STR_LIT>':<EOL><INDENT>if len(self._aichans) > <NUM_LIT:1>:<EOL><INDENT>failmsg = "<STR_LIT>".format(len(self._aichans))<EOL>QtGui.QMessageBox.warning(self, "<STR_LIT>", failmsg)<EOL>return False<EOL><DEDENT>if self.ui.calibrationWidget.ui.savecalCkbx.isChecked() or not self.ui.calibrationWidget.currentSelection() == '<STR_LIT>':<EOL><INDENT>calibration_stimulus = self.acqmodel.calibration_stimulus('<STR_LIT>')<EOL>self.ui.calibrationWidget.saveToObject()<EOL><DEDENT>else:<EOL><INDENT>calibration_stimulus = self.acqmodel.calibration_stimulus('<STR_LIT>')<EOL><DEDENT>failmsg = calibration_stimulus.verify(float(self.ui.windowszSpnbx.value()))<EOL>if failmsg:<EOL><INDENT>QtGui.QMessageBox.warning(self, "<STR_LIT>", failmsg)<EOL>return False<EOL><DEDENT>failmsg = calibration_stimulus.verifyExpanded(samplerate=self.ui.aifsSpnbx.value())<EOL>if failmsg:<EOL><INDENT>failmsg = failmsg.replace('<STR_LIT>', '<STR_LIT>')<EOL>QtGui.QMessageBox.warning(self, "<STR_LIT>", failmsg)<EOL>return False<EOL><DEDENT><DEDENT>if self.advanced_options['<STR_LIT>'] and not self.acqmodel.attenuator_connection():<EOL><INDENT>failmsg = "<STR_LIT>"<EOL>QtGui.QMessageBox.warning(self, "<STR_LIT>", failmsg)<EOL>return False<EOL><DEDENT><DEDENT>return True<EOL>
|
Goes through and checks all stimuli and input settings are valid
and consistent. Prompts user with a message if there is a condition
that would prevent acquisition.
:param mode: The mode of acquisition trying to be run. Options are
'chart', or anthing else ('explore', 'protocol', 'calibration')
:type mode: str
:returns: bool -- Whether all inputs and stimuli are valid
|
f10610:c0:m1
|
def updateUnitLabels(self, tscale, fscale):
|
AbstractEditorWidget.updateScales(tscale, fscale)<EOL>SmartDelegate.updateScales(tscale, fscale)<EOL>AbstractEditorWidget.purgeDeletedWidgets()<EOL>self.tscale = tscale<EOL>time_inputs = self.timeInputs + AbstractEditorWidget.tunit_fields<EOL>for field in time_inputs:<EOL><INDENT>field.setScale(tscale)<EOL><DEDENT>self.fscale = fscale<EOL>frequency_inputs = self.frequencyInputs + AbstractEditorWidget.funit_fields<EOL>for field in frequency_inputs:<EOL><INDENT>field.setScale(fscale)<EOL><DEDENT>
|
When the GUI unit scale changes, it is neccessary to update
the unit labels on all fields throughout the GUI. This handles
The main window, and also notifys other windows to update
Only supports for conversion between two values :
* seconds and miliseconds for time
* Hz and kHz for frequency
:param tscale: Time scale to update to either 's' or 'ms'
:type tscale: str
:param fscale: Frequency scale to update to either 'Hz' or 'kHz'
:type fscale: str
|
f10610:c0:m2
|
def reset_device_channels(self):
|
<EOL>self.ui.aochanBox.clear()<EOL>devname = self.advanced_options['<STR_LIT>']<EOL>device_list = get_devices()<EOL>if devname in device_list:<EOL><INDENT>cnames = get_ao_chans(devname)<EOL>self.ui.aochanBox.addItems(cnames)<EOL>cnames = get_ai_chans(devname)<EOL>self._aichans = [chan for chan in self._aichans if chan in cnames]<EOL>self._aichan_details = {chan: deets for chan, deets in self._aichan_details.items() if chan in cnames}<EOL><DEDENT>elif devname == '<STR_LIT>' and len(device_list) > <NUM_LIT:0>:<EOL><INDENT>devname = device_list[<NUM_LIT:0>]<EOL>cnames = get_ao_chans(devname)<EOL>self.ui.aochanBox.addItems(cnames)<EOL>self.advanced_options['<STR_LIT>'] = devname<EOL>self._aichans = []<EOL>self._aichan_details = {}<EOL><DEDENT>else:<EOL><INDENT>self._aichans = []<EOL>self._aichan_details = {}<EOL><DEDENT>self.ui.chanNumLbl.setText(str(len(self._aichans)))<EOL>self.display.removeResponsePlot(*self.display.responseNameList())<EOL>self.display.addResponsePlot(*self._aichans)<EOL>for name, deets in self._aichan_details.items():<EOL><INDENT>self.display.setThreshold(deets['<STR_LIT>'], name)<EOL>self.display.setRasterBounds(deets['<STR_LIT>'], name)<EOL>self.display.setAbs(deets['<STR_LIT>'], name)<EOL><DEDENT>self.ui.trigchanBox.addItems(['<STR_LIT:/>'+devname+'<STR_LIT>', '<STR_LIT:/>'+devname+'<STR_LIT>'])<EOL>
|
Updates the input channel selection boxes based on the current
device name stored in this object
|
f10610:c0:m3
|
def saveInputs(self, fname):
|
<EOL>if not fname:<EOL><INDENT>return<EOL><DEDENT>appdir = systools.get_appdir()<EOL>if not os.path.isdir(appdir):<EOL><INDENT>os.makedirs(appdir)<EOL><DEDENT>fname = os.path.join(appdir, fname)<EOL>savedict = {}<EOL>savedict['<STR_LIT>'] = self.ui.binszSpnbx.value()<EOL>savedict['<STR_LIT>'] = self.ui.aifsSpnbx.value()<EOL>savedict['<STR_LIT>'] = self.tscale<EOL>savedict['<STR_LIT>'] = self.fscale<EOL>savedict['<STR_LIT>'] = self.saveformat<EOL>savedict['<STR_LIT>'] = self.ui.exploreStimEditor.repCount()<EOL>savedict['<STR_LIT>'] = self.ui.reprateSpnbx.value()<EOL>savedict['<STR_LIT>'] = self.ui.windowszSpnbx.value()<EOL>savedict['<STR_LIT>'] = self.specArgs<EOL>savedict['<STR_LIT>'] = self.viewSettings<EOL>savedict['<STR_LIT>'] = self.calvals<EOL>savedict['<STR_LIT>'] = self.acqmodel.calibration_template()<EOL>savedict['<STR_LIT>'] = self.ui.calibrationWidget.ui.nrepsSpnbx.value()<EOL>savedict['<STR_LIT>'] = self.ui.mphoneSensSpnbx.value()<EOL>savedict['<STR_LIT>'] = self.ui.mphoneDBSpnbx.value()<EOL>savedict['<STR_LIT>'] = Vocalization.paths<EOL>savedict['<STR_LIT>'] = self._aichans<EOL>savedict['<STR_LIT>'] = self._aichan_details<EOL>savedict['<STR_LIT>'] = self.ui.exploreStimEditor.saveTemplate()<EOL>savedict['<STR_LIT>'] = self.advanced_options<EOL>savedict['<STR_LIT>'] = StimulusView.getDefaults()<EOL>savedict['<STR_LIT>'] = TCFactory.defaultInputs<EOL>savedict = convert2native(savedict)<EOL>try:<EOL><INDENT>with open(fname, '<STR_LIT:w>') as jf:<EOL><INDENT>json.dump(savedict, jf)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>logger = logging.getLogger('<STR_LIT>')<EOL>logger.exception("<STR_LIT>".format(fname))<EOL><DEDENT>
|
Save the values in the input fields so they can be loaded
next time the GUI is run
:param fname: file path of location to store values at
:type fname: str
|
f10610:c0:m4
|
def loadInputs(self, fname):
|
inputsfname = os.path.join(systools.get_appdir(), fname)<EOL>try:<EOL><INDENT>with open(inputsfname, '<STR_LIT:r>') as jf:<EOL><INDENT>inputsdict = json.load(jf)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>logger = logging.getLogger('<STR_LIT>')<EOL>logger.warning("<STR_LIT>".format(inputsfname))<EOL>inputsdict = {}<EOL><DEDENT>self._thesholds = inputsdict.get('<STR_LIT>', {})<EOL>self.stashedAisr = inputsdict.get('<STR_LIT>', <NUM_LIT>)<EOL>self.ui.aifsSpnbx.setValue(self.stashedAisr)<EOL>self.ui.windowszSpnbx.setValue(inputsdict.get('<STR_LIT>', <NUM_LIT:0.1>))<EOL>self.ui.binszSpnbx.setValue(inputsdict.get('<STR_LIT>', <NUM_LIT>)) <EOL>self.saveformat = inputsdict.get('<STR_LIT>', '<STR_LIT>')<EOL>self.ui.exploreStimEditor.setReps((inputsdict.get('<STR_LIT>', <NUM_LIT:5>)))<EOL>self.ui.reprateSpnbx.setValue(inputsdict.get('<STR_LIT>', <NUM_LIT:1>))<EOL>self.specArgs = inputsdict.get('<STR_LIT>',{u'<STR_LIT>':<NUM_LIT>, u'<STR_LIT>':u'<STR_LIT>', u'<STR_LIT>':<NUM_LIT>, '<STR_LIT>':{'<STR_LIT>':None, '<STR_LIT:state>':None, '<STR_LIT>':None}})<EOL>SpecWidget.setSpecArgs(**self.specArgs)<EOL>self.viewSettings = inputsdict.get('<STR_LIT>', {'<STR_LIT>': <NUM_LIT:10>, '<STR_LIT>':{}})<EOL>self.ui.stimDetails.setDisplayAttributes(self.viewSettings['<STR_LIT>'])<EOL>font = QtGui.QFont()<EOL>font.setPointSize(self.viewSettings['<STR_LIT>'])<EOL>QtGui.QApplication.setFont(font)<EOL>self.ui.calibrationWidget.ui.nrepsSpnbx.setValue(inputsdict.get('<STR_LIT>', <NUM_LIT:5>))<EOL>self.calvals = inputsdict.get('<STR_LIT>', {'<STR_LIT>':<NUM_LIT>, '<STR_LIT>':<NUM_LIT:100>, <EOL>'<STR_LIT>':<NUM_LIT:0.1>, '<STR_LIT>':False, <EOL>'<STR_LIT>':(<NUM_LIT>, <NUM_LIT>), '<STR_LIT>': '<STR_LIT>'})<EOL>self.calvals['<STR_LIT>'] = False<EOL>self.calvals['<STR_LIT>'] = '<STR_LIT>'<EOL>self.ui.refDbSpnbx.setValue(self.calvals['<STR_LIT>'])<EOL>self.ui.mphoneSensSpnbx.setValue(inputsdict.get('<STR_LIT>', <NUM_LIT>))<EOL>self.ui.mphoneDBSpnbx.setValue(MPHONE_CALDB)<EOL>Vocalization.paths = inputsdict.get('<STR_LIT>', [])<EOL>self.tscale = inputsdict.get('<STR_LIT>', SmartSpinBox.MilliSeconds)<EOL>self.fscale = inputsdict.get('<STR_LIT>', SmartSpinBox.kHz)<EOL>try:<EOL><INDENT>self.updateUnitLabels(self.tscale, self.fscale)<EOL><DEDENT>except:<EOL><INDENT>self.tscale = '<STR_LIT>'<EOL>self.fscale = '<STR_LIT>'<EOL>self.updateUnitLabels(self.tscale, self.fscale)<EOL><DEDENT>cal_template = inputsdict.get('<STR_LIT>', None)<EOL>if cal_template is not None:<EOL><INDENT>try:<EOL><INDENT>self.acqmodel.load_calibration_template(cal_template)<EOL><DEDENT>except:<EOL><INDENT>logger = logging.getLogger('<STR_LIT>')<EOL>logger.exception("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger = logging.getLogger('<STR_LIT>')<EOL>logger.debug('<STR_LIT>')<EOL><DEDENT>if '<STR_LIT>' in inputsdict:<EOL><INDENT>self.ui.exploreStimEditor.loadTemplate(inputsdict['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>logger = logging.getLogger('<STR_LIT>')<EOL>logger.debug('<STR_LIT>')<EOL><DEDENT>TCFactory.defaultInputs.update(inputsdict.get('<STR_LIT>', TCFactory.defaultInputs))<EOL>self.advanced_options = {'<STR_LIT>':'<STR_LIT>', <EOL>'<STR_LIT>':<NUM_LIT>,<EOL>'<STR_LIT>': <NUM_LIT>,<EOL>'<STR_LIT>': <NUM_LIT:0.1>,<EOL>'<STR_LIT>': False }<EOL>if '<STR_LIT>' in inputsdict:<EOL><INDENT>self.advanced_options.update(inputsdict['<STR_LIT>'])<EOL><DEDENT>StimulusModel.setMaxVoltage(self.advanced_options['<STR_LIT>'], self.advanced_options['<STR_LIT>'])<EOL>self.display.setAmpConversionFactor(self.advanced_options['<STR_LIT>'])<EOL>if self.advanced_options['<STR_LIT>']:<EOL><INDENT>self.acqmodel.attenuator_connection(True)<EOL><DEDENT>else:<EOL><INDENT>self.acqmodel.attenuator_connection(False)<EOL><DEDENT>self._aichans = inputsdict.get('<STR_LIT>', [])<EOL>self._aichan_details = inputsdict.get('<STR_LIT>', {})<EOL>for name, deets in self._aichan_details.items():<EOL><INDENT>self._aichan_details[name]['<STR_LIT>'] = deets.get('<STR_LIT>', <NUM_LIT:5>)<EOL>self._aichan_details[name]['<STR_LIT>'] = deets.get('<STR_LIT>', <NUM_LIT:1>)<EOL>self._aichan_details[name]['<STR_LIT>'] = deets.get('<STR_LIT>', (<NUM_LIT:0.5>,<NUM_LIT>))<EOL>self._aichan_details[name]['<STR_LIT>'] = deets.get('<STR_LIT>', True)<EOL><DEDENT>self.reset_device_channels()<EOL>stim_defaults = inputsdict.get('<STR_LIT>', {})<EOL>for name, state in stim_defaults.items():<EOL><INDENT>StimulusView.updateDefaults(name, state)<EOL><DEDENT>
|
Load previsouly saved input values, and load them to GUI widgets
:param fname: file path where stashed input values are stored
:type fname: str
|
f10610:c0:m5
|
def closeEvent(self, event):
|
self.acqmodel.stop_listening() <EOL>self.saveInputs(self.inputsFilename)<EOL>settings = QtCore.QSettings("<STR_LIT>")<EOL>settings.setValue("<STR_LIT>", self.saveGeometry())<EOL>settings.setValue("<STR_LIT>", self.saveState())<EOL>logger = logging.getLogger('<STR_LIT>')<EOL>logger.info('<STR_LIT>')<EOL>self.garbage_timer.stop()<EOL>gc.enable()<EOL>
|
Closes listening threads and saves GUI data for later use.
Re-implemented from :qtdoc:`QWidget`
|
f10610:c0:m6
|
def headerData(self, section, orientation, role):
|
if role == QtCore.Qt.DisplayRole:<EOL><INDENT>if orientation == QtCore.Qt.Horizontal:<EOL><INDENT>return self.headers[section]<EOL><DEDENT><DEDENT>
|
Get the Header for the columns in the table
Required by view, see :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
:param section: column of header to return
:type section: int
|
f10612:c0:m1
|
def allHeaders(self):
|
return self.headers<EOL>
|
Gets all header text
:returns: list<str> all header text, in column order
|
f10612:c0:m2
|
def rowCount(self, parent=QtCore.QModelIndex()):
|
return self._testmodel.rowCount()<EOL>
|
Determines the numbers of rows the view will draw
Required by view, see :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
|
f10612:c0:m3
|
def columnCount(self, parent=QtCore.QModelIndex()):
|
return len(self.headers)<EOL>
|
Determines the numbers of columns the view will draw
Required by view, see :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
|
f10612:c0:m4
|
def data(self, index, role):
|
if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:<EOL><INDENT>test = self._testmodel.test(index.row())<EOL>col = index.column()<EOL>if col == <NUM_LIT:0>:<EOL><INDENT>item = test.userTag()<EOL><DEDENT>elif col == <NUM_LIT:1>:<EOL><INDENT>item = test.stimType()<EOL><DEDENT>elif col == <NUM_LIT:2>:<EOL><INDENT>item = test.repCount()<EOL><DEDENT>elif col == <NUM_LIT:3>:<EOL><INDENT>item = test.traceCount()<EOL><DEDENT>elif col == <NUM_LIT:4>:<EOL><INDENT>item = test.traceCount()*test.loopCount()*test.repCount()<EOL><DEDENT>elif col == <NUM_LIT:5>:<EOL><INDENT>item = test.samplerate()<EOL><DEDENT>return item<EOL><DEDENT>elif role == QtCore.Qt.UserRole: <EOL><INDENT>test = self._testmodel.test(index.row())<EOL>return QStimulusModel(test)<EOL><DEDENT>elif role == QtCore.Qt.UserRole + <NUM_LIT:1>: <EOL><INDENT>test = self._testmodel.test(index.row())<EOL>return test<EOL><DEDENT>elif role == CursorRole:<EOL><INDENT>col = index.column()<EOL>if not index.isValid():<EOL><INDENT>return QtGui.QCursor(QtCore.Qt.ArrowCursor)<EOL><DEDENT>elif col == <NUM_LIT:0>:<EOL><INDENT>return QtGui.QCursor(QtCore.Qt.IBeamCursor)<EOL><DEDENT>else:<EOL><INDENT>return cursors.openHand()<EOL><DEDENT><DEDENT>
|
Used by the view to determine data to present
See :qtdoc:`QAbstractItemModel<QAbstractItemModel.data>`,
and :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
|
f10612:c0:m5
|
def flags(self, index):
|
if index.column() == <NUM_LIT:0> or index.column == self.headers.index('<STR_LIT>'):<EOL><INDENT>return QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable<EOL><DEDENT>else:<EOL><INDENT>return QtCore.Qt.ItemIsEnabled<EOL><DEDENT>
|
Determines interaction allowed with table cells.
See :qtdoc:`QAbstractItemModel<QAbstractItemModel.flags>`,
and :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
|
f10612:c0:m6
|
def setData(self, index, value, role):
|
if role == QtCore.Qt.EditRole:<EOL><INDENT>if isinstance(value, QtCore.QVariant):<EOL><INDENT>value = value.toPyObject()<EOL><DEDENT>if index.column() == <NUM_LIT:0>:<EOL><INDENT>test = self._testmodel.test(index.row())<EOL>test.setUserTag(str(value))<EOL>return True<EOL><DEDENT>if index.column() == <NUM_LIT:2>:<EOL><INDENT>test = self._testmodel.test(index.row())<EOL>test.setRepCount(value)<EOL>return True<EOL><DEDENT><DEDENT>return False<EOL>
|
Sets data at *index* to *value* in underlying data structure
See :qtdoc:`QAbstractItemModel<QAbstractItemModel.setData>`,
and :qtdoc:`subclassing<qabstractitemmodel.subclassing>`
|
f10612:c0:m7
|
def removeItem(self, index):
|
self.removeTest(index.row())<EOL>
|
Alias for removeTest
|
f10612:c0:m8
|
def insertItem(self, index, item):
|
self.insertTest(item, index.row())<EOL>
|
Alias for insertTest
|
f10612:c0:m9
|
def removeTest(self, position):
|
self.beginRemoveRows(QtCore.QModelIndex(), position, position)<EOL>test = self._testmodel.remove(position)<EOL>self.endRemoveRows()<EOL>return test<EOL>
|
See :meth:`ProcotolModel<sparkle.run.protocol_model.ProtocolTabelModel.remove>`
|
f10612:c0:m10
|
def insertTest(self, stim, position):
|
if position == -<NUM_LIT:1>:<EOL><INDENT>position = self.rowCount()<EOL><DEDENT>self.beginInsertRows(QtCore.QModelIndex(), position, position)<EOL>self._testmodel.insert(stim, position)<EOL>self.endInsertRows()<EOL>
|
See :meth:`ProcotolModel<sparkle.run.protocol_model.ProtocolTabelModel.insert>`
|
f10612:c0:m11
|
def clearTests(self):
|
self.beginRemoveRows(QtCore.QModelIndex(), <NUM_LIT:0>, self.rowCount()-<NUM_LIT:1>)<EOL>self._testmodel.clear()<EOL>self.endRemoveRows()<EOL>
|
See :meth:`ProcotolModel<sparkle.run.protocol_model.ProtocolTabelModel.clear>`
|
f10612:c0:m12
|
def stimulusList(self):
|
return self._testmodel.allTests()<EOL>
|
See :meth:`ProcotolModel<sparkle.run.protocol_model.ProtocolTabelModel.allTests>`
|
f10612:c0:m13
|
def verify(self, windowSize=None):
|
return self._testmodel.verify(windowSize)<EOL>
|
See :meth:`ProcotolModel<sparkle.run.protocol_model.ProtocolTabelModel.verify>`
|
f10612:c0:m14
|
def paintEvent(self, event):
|
super(ProtocolView, self).paintEvent(event)<EOL>if self.dragline is not None:<EOL><INDENT>pen = QtGui.QPen(QtCore.Qt.blue)<EOL>painter = QtGui.QPainter(self.viewport())<EOL>painter.setPen(pen)<EOL>painter.drawLine(self.dragline)<EOL><DEDENT>
|
Adds cursor line for view if drag active. Passes event to superclass
see :qtdoc:`qtdocs<qabstractscrollarea.paintEvent>`
|
f10612:c1:m1
|
def dropped(self, item, event):
|
location = self.rowAt(event.pos().y())<EOL>if isinstance(item, StimFactory):<EOL><INDENT>factory = item<EOL>stim = factory.create()<EOL>if stim is not None:<EOL><INDENT>self.model().insertTest(stim, location)<EOL><DEDENT><DEDENT>elif event.source() == self:<EOL><INDENT>self.model().insertTest(item, location)<EOL><DEDENT>
|
Adds the dropped test *item* into the protocol list.
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.dropped>`
|
f10612:c1:m2
|
def grabImage(self, index):
|
<EOL>row_height = self.rowHeight(<NUM_LIT:0>)<EOL>y = (row_height*index.row()) + row_height - <NUM_LIT:5><EOL>x = self.width()<EOL>rect = QtCore.QRect(<NUM_LIT:5>,y,x,row_height)<EOL>pixmap = QtGui.QPixmap()<EOL>pixmap = pixmap.grabWidget(self, rect)<EOL>return pixmap<EOL>
|
Returns an image of the test row.
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.grabImage>`
|
f10612:c1:m3
|
def cursor(self, pos):
|
row = self.indexAt(pos).row()<EOL>if row == -<NUM_LIT:1>:<EOL><INDENT>row = self.model().rowCount()<EOL><DEDENT>row_height = self.rowHeight(<NUM_LIT:0>)<EOL>y = row_height*row<EOL>x = self.width()<EOL>return QtCore.QLine(<NUM_LIT:0>,y,x,y)<EOL>
|
Returns a line at the nearest row split between tests.
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.cursor>`
|
f10612:c1:m4
|
def mousePressEvent(self, event):
|
index = self.indexAt(event.pos())<EOL>if index.isValid():<EOL><INDENT>if index.column() == <NUM_LIT:0>:<EOL><INDENT>self.edit(index, QtGui.QAbstractItemView.DoubleClicked, event)<EOL><DEDENT>else:<EOL><INDENT>super(ProtocolView, self).mousePressEvent(event)<EOL><DEDENT><DEDENT>
|
Launches edit of cell if first column clicked, otherwise passes to super class
|
f10612:c1:m5
|
def mouseDoubleClickEvent(self, event):
|
if event.button() == QtCore.Qt.LeftButton:<EOL><INDENT>index = self.indexAt(event.pos())<EOL>if index.isValid():<EOL><INDENT>selectedStimModel = self.model().data(index, QtCore.Qt.UserRole)<EOL>self.stimEditor = selectedStimModel.showEditor()<EOL>self.stimEditor.show()<EOL><DEDENT><DEDENT>
|
Creates and shows editor for stimulus (test) selected
|
f10612:c1:m6
|
def indexXY(self, index):
|
<EOL>row = index.row()<EOL>if row == -<NUM_LIT:1>:<EOL><INDENT>row = self.model().rowCount()<EOL><DEDENT>y = self.rowHeight(<NUM_LIT:0>)*row<EOL>return <NUM_LIT:0>, y<EOL>
|
Coordinates for the test row at *index*
Re-implemented from :meth:`AbstractDragView<sparkle.gui.abstract_drag_view.AbstractDragView.indexXY>`
|
f10612:c1:m7
|
def setXlim(self, lim):
|
self.setXRange(*lim, padding=<NUM_LIT:0>)<EOL>
|
Sets the visible x-axis bounds to *lim*
:param lim: (min, max) for x-axis
:type lim: (float, float)
|
f10614:c0:m1
|
def setYlim(self, lim):
|
self.setYRange(*lim)<EOL>
|
Sets the visible y-axis bounds to *lim*
:param lim: (min, max) for y-axis
:type lim: (float, float)
|
f10614:c0:m2
|
def setTitle(self, title):
|
self.getPlotItem().setTitle(title)<EOL>
|
Sets a title for the plot
:param title: Title for top of plot
:type title: str
|
f10614:c0:m3
|
def getLabel(self, key):
|
axisItem = self.getPlotItem().axes[key]['<STR_LIT>']<EOL>return axisItem.label.toPlainText()<EOL>
|
Gets the label assigned to an axes
:param key:???
:type key: str
|
f10614:c0:m5
|
def updateData(self, axeskey, x, y):
|
if axeskey == '<STR_LIT>':<EOL><INDENT>self.stimPlot.setData(x,y)<EOL>ranges = self.viewRange()<EOL>self.rangeChange(self, ranges)<EOL><DEDENT>if axeskey == '<STR_LIT>':<EOL><INDENT>self.clearTraces()<EOL>if self._traceUnit == '<STR_LIT:A>':<EOL><INDENT>y = y * self._ampScalar<EOL><DEDENT>if self.zeroAction.isChecked():<EOL><INDENT>start_avg = np.mean(y[<NUM_LIT:5>:<NUM_LIT>])<EOL>y = y - start_avg<EOL><DEDENT>self.tracePlot.setData(x,y*self._polarity)<EOL><DEDENT>
|
Replaces the currently displayed data
:param axeskey: name of data plot to update. Valid options are 'stim' or 'response'
:type axeskey: str
:param x: index values associated with y to plot
:type x: numpy.ndarray
:param y: values to plot at x
:type y: numpy.ndarray
|
f10614:c1:m1
|
def appendData(self, axeskey, bins, ypoints):
|
if axeskey == '<STR_LIT>' and len(bins) > <NUM_LIT:0>:<EOL><INDENT>x, y = self.rasterPlot.getData()<EOL>bins = np.unique(bins)<EOL>ypoints = np.ones_like(bins)*self.rasterYslots[ypoints[<NUM_LIT:0>]]<EOL>x = np.append(x, bins)<EOL>y = np.append(y, ypoints)<EOL>self.rasterPlot.setData(x, y)<EOL><DEDENT>
|
Appends data to existing plotted data
:param axeskey: name of data plot to update. Valid options are 'stim' or 'response'
:type axeskey: str
:param bins: bins to plot a point for
:type bin: numpy.ndarray
:param ypoints: iteration number of raster, *should* match bins dimension, but really takes the first value in array for iteration number and plot row at proper place for included bins
:type ypoints: numpy.ndarray
|
f10614:c1:m4
|
def clearData(self, axeskey):
|
self.rasterPlot.clear()<EOL>
|
Clears the raster plot
|
f10614:c1:m5
|
def getThreshold(self):
|
y = self.threshLine.value()<EOL>return y<EOL>
|
Current Threshold value
:returns: float -- y values of the threshold line
|
f10614:c1:m6
|
def setThreshold(self, threshold):
|
self.threshLine.setValue(threshold)<EOL>self.threshold_field.setValue(threshold)<EOL>
|
Sets the current threshold
:param threshold: the y value to set the threshold line at
:type threshold: float
|
f10614:c1:m7
|
def setNreps(self, nreps):
|
self.nreps = nreps<EOL>self.updateRasterBounds()<EOL>
|
Sets the number of reps user by raster plot to determine where to
place data points
:param nreps: number of iterations before the raster will be cleared
:type nreps: int
|
f10614:c1:m8
|
def setRasterBounds(self, lims):
|
self.rasterBottom = lims[<NUM_LIT:0>]<EOL>self.rasterTop = lims[<NUM_LIT:1>]<EOL>self.updateRasterBounds()<EOL>
|
Sets the raster plot y-axis bounds, where in the plot the raster will appear between
:param lims: the (min, max) y-values for the raster plot to be placed between
:type lims: (float, float)
|
f10614:c1:m9
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.