gui module¶
Main class for setting up user interface and instantiate network connections.
-
opeth.gui.
AUTOTRIGGER_CH
= None¶ Set to None to disable, otherwise TTL pulses will be generated if given channel is over threshold
-
opeth.gui.
CHANNELPLOTS_ANTIALIASED
= True¶ More professional display for per channel plots, but less visible
-
opeth.gui.
CHANNELPLOTS_VERTICAL_OFFSET
= 0.1¶ When histogram are presented with lines per channel, adjust the way they are plotted.
-
opeth.gui.
CHANNELS_PER_HISTPLOT
= 4¶ Channels per tetrode to be combined in histogram
-
opeth.gui.
COLUMN_INCREMENTS
= [3, 8, 12, 20, 25, 30, 42, 64, 90, 110, 120, 130, 1000]¶ A value in a given index means maximum number of plots displayed for the index number of columns
-
opeth.gui.
DEBUG
= False¶ Enable or disable debug mode
-
opeth.gui.
DEBUG_FPS
= False¶ Enable frame per sec debug prints
-
opeth.gui.
DEBUG_FPSREPORT_PERIOD
= 5¶ FPS debug print update frequency
-
opeth.gui.
DEBUG_TIMING
= False¶ Enable timing prints
-
opeth.gui.
DEFAULT_INI
= 'default.ini'¶ Config file name defaults
-
opeth.gui.
DEFAULT_SPIKE_THRESHOLD
= 3e-05¶ Spike threshold set as default parameter if no ini file found.
-
class
opeth.gui.
GuiClass
¶ Bases:
object
Main GUI handling class.
Creates windows:
- Main histogram window with parameters.
- Raw data window with real time plotted continuous scrolling waveform for overview.
- Debug window if
DEBUG
is True. - Spike analysis windows using
spike_gui.SpikeEvalGui
when corresponding button is pressed.
At startup as long as no data is present the histogram windows are not populated as the input data channel count is not known.
The main loop performing the most important periodic operations is in
update()
method, calling e.g.comm.CommProcess.timer_callback()
to collect data and based on that update plot data.-
rawdata_curves
¶ Top part waveforms of raw analog window
Type: list
-
ttlraw_curves
¶ Bottom part waveforms of raw analog window
Type: list
-
cp
¶ Interface and data collector to OE
Type: comm.CommProcess
-
dataproc
¶ Data processor instance working on
cp
’scolldata.Collector
dataType: colldata.DataProc
-
mainwin
¶ Main window with histogram and parameter setup window
Type: QtGui.QMainWindow
-
rawdatawin
¶ Real time raw analog data display with a continuously scrolling part and a TTL-aligned snapshot.
Type: pyqtgraph.GraphicsWindow
-
debugwin
¶ Opened only if
DEBUG
is True, displays some internal variables for debuggingType: QtGui.QWidget
-
spike_bin_ms
¶ Histogram bins, one row per channel, each row contains
ttl_range_ms
+ 1 number of bins for collecting spike offsets relative to event.Type: 2D np.ndarray
-
ttl_range_ms
¶ TTL range specified by start and end value in
event_roi
(warning: ifHISTOGRAM_BINSIZE
modified, it is not ms any more!)Type: int
-
event_roi
¶ Region of interest around event ([start, end] values in second around TTL pulse for spike search region and plotting e.g. [-0.02, 0.05] for default 20 ms before, 50 ms after)
Type: list of two float elements
-
configfname
¶ Name of config file for parameter setup storage.
PARAMFNAME
points to the file from where its initial value is read during program startup.Type: str
-
threshold_levels
¶ One row per tetrode, threshold level in uV. Same sign both for negative and positive spikes as in GUI, will be adjusted afterwards for spike detection.
Type: np.ndarray of floats
-
histplots
¶ Histogram plot collection for data updates - each element is a collection of per-channel histograms for a given tetrode.
Type: list of lists of plots
-
MAX_PLOT_PER_SEC
= 4¶ Perfomance limit through
earliest_hist_plot
-
change_event_roi
(new_roi, clear_plot=True, **kwargs)¶ Change region of interest around event (spike search range) and update plots.
-
clear_plot
()¶ Clear all displayed histograms
-
convert_strlist_to_ints
(str_in)¶ Convert a text entry of disabled channels to an integer list.
Parameters: str_in (str) – input string in the format 1-4, 17, 30-33
.Returns: a list of integers like [1,2,3,4,17,30,31,32,33]
.
-
disabled_channels
= None¶ A list of disabled channels starting with 0
-
display_brushcolors
= None¶ Histogram colors
-
display_linecolors
= None¶ Channel plot (line) colors
-
display_theme
= None¶ display theme
-
downsampling_rate
= None¶ Downsampling rate is calculated from sampling rate, target is 1kHz for raw data window
-
earliest_hist_plot
= None¶ Next histogram update time for performance cap
-
earliest_rawttl_plot
= None¶ Next raw analog TTL-aligned display time - lower window update rate limit
-
force_update
= None¶ Keep track of programmatic parameter changes to prevent infinite loops.
-
init_histwin
()¶ Initialize main histogram window and parameters with defaults.
Actual display will be updated in
populate_histwin()
once number of channels/channels per tetrode is known.
-
init_params
(paramcontainer, reset=False, **kwargs)¶ Prepare parameter setup part of main histogram window.
-
init_rawwin
()¶ Real time display of current waveform for visible feedback even when signal thresholds may be off.
-
init_spikewin
()¶ Single channel analysis window
-
initgraph
()¶ Called at startup to set up the main window with the parameter setup and the raw data window.
Only a placeholder text is displayed instead of histogram plots until the first set of data arrived and channel count becomes known.
-
load_params
()¶ Load parameters from config file
configfname
Called after file selection dialog when Load button pressed, and also when program is first loaded.
-
more_than_two_continuous
(intlist)¶ In order to reduce a string of ‘1, 2, 3, 4’ to ‘1-4’ return the longest series of numbers incrementing by one at the beginning of an intlist.
Helper function for
update_disabled_channels()
, the opposite ofconvert_strlist_to_ints()
(partially).Parameters: intlist (list) – a list of integers Returns: either the first element of intlist or a list of elements if more than two consecutive numbers were incrementing by one.
-
onChangeTheme
()¶
-
onClearPlot
()¶ Manually clear plots on button press.
-
onClose
(event)¶ Handler for closeEvent of main window (histogram window), should close all other windows before closing the main window.
-
onLoadParams
()¶
-
onOpenSpikeWin
()¶ Open new spike analysis window on button press.
-
onParamChange
(param, changes)¶ Called on any parameter change.
-
onResetParams
()¶ Remove saved parameters and reinit parameter setup. Called when corresponding button was pressed.
-
onSaveAsParams
()¶ Store parameter setup in file. Called when corresponding button pressed.
-
onSaveParams
()¶
-
populate_histwin
()¶ Create an array of dockable/movable histograms. The layout is determined by the number of necessary plot windows and the
COLUMN_INCREMENTS
variable.
-
populate_params
()¶ Update parameter setup after channel count is known.
-
populate_rawwin
()¶ Create as many raw analog display curves as necessary based on
nChannels
-
restore_params
()¶ Startup code performing parameter restoration.
-
save_params
()¶ Save parameters to
configfname
Called when Save or Save as buttons pressed.
-
set_threshold_levels
(value)¶ Parameter setup: update all the tetrode threshold level values simultaneously.
-
should_restore_params
= None¶ Automatic parameter reload should happen only on startup.
-
store_lastconfname
(fname)¶ Store
configfname
in filePARAMFNAME
and update config box display to show new file name.-
fname
¶ Path to new file - if left empty then will default to
DEFAULT_INI
.Type: str
-
-
timeas
= None¶ Profiling class
-
timing_start
= None¶ internal elapsed time measurement scheduler
Type: Debug
-
update
(**kwargs)¶ The main loop, processes input data and updates plots. Called periodically from a Qt timer.
On very first round with actual data present it calls
update_channelcnt()
to create the necessary amount of histogram plots.Periodically calls
comm.CommProcess.timer_callback()
to fetch new datacolldata.Collector.keep_last()
to drop old datacolldata.Collector.process_ttl()
to fetch region of interest around TTLcolldata.DataProc.compress()
to reduce complexity of the real time plotcolldata.DataProc.spikedetect()
to find spikes- update spike analysis windows
update_spikewins()
and updates real time plot data via
rawdata_curves
andttlraw_curves
-
spike_bin_ms
Histogram bins containing one row per channel of spike event counter bins (accumulating); first item per row contains the bin corresponding to start of trigger area (
event_roi
[0] ) and last one to the end (event_roi
[1] )Type: 2D numpy array
-
data_at_ttl
¶ Each row contains the same number of samples from different channels
Type: 2D numpy array
-
data_ts
¶ Timestamps of
data_at_ttl
samples around TTL (in seconds, used for binning)Type: 1D numpy array
-
data_ts_0
¶ Same array as data_ts, start offset removed (timestamp of first sample is 0), used for histogram generation (binning)
Type: 1D numpy array
-
data_ts_roi
¶ TTL timestamps with actual TTL event aligned to 0 (one ts for each sample - samples start earlier than TTL), used for plotting the time scale
Type: 1D numpy array
-
spike_pos
¶ each internal list contains sample index of spike events for a given channel (events over threshold, disabled channels not included)
Type: list of lists
-
update_cfgboxtitle
()¶ Update config box title to show the current config file, reduce length if necessary.
-
update_channelcnt
(nChannels)¶ Called when number of channels becomes known or changes.
Update the necessary display elements (number of histogram plots etc).
Parameters: nChannels (int) – number of input channels (as detected in first chunk of data received from OE)
-
update_disabled_channels
()¶ Called when list of disabled channels is entered; it parses the input string to understand and abbreviate series of numbers.
Uses
convert_strlist_to_ints()
and reproduces the string withmore_than_two_continuous()
in order to verify syntax and to combine input like1, 2, 3
to1-3
.
-
update_histograms
()¶ Update displayed histogram plots.
Types of histogram plots available:
- the normal histogram with e.g. 4 channels per tetrode combined
into a single histogram, channels indistinguishable
- same histogram but each channel with its own colour, a histogram
bar consisting of Ch1+Ch2+Ch3+Ch4 separated by colour (same outline as in previous case just 4 colours instead of 1)
Trick for display: 4 plots displayed, ch1 in front, ch1+ch2 aggregated behind etc.
- per channel: lines instead of bar graphs to make it possible to
distinguish between overlapping elements
-
update_plotcolors
()¶ Called when channels get disabled - no need to remove plots
-
update_plotstyle
()¶ If the plot style changes from one of the histogram plots to channel plot or vica versa, the channel colors are to be updated.
-
update_samplingrate
(sampling_rate, clear_plot=False)¶
-
update_spikewins
(data_ts, data, spike_ts, spike_pos)¶ Perform an update on spike windows.
-
update_threshold_levels
()¶ Update the internal threshold levels based on the UI parameters.
-
opeth.gui.
HIDE_AUX_CHANNELS
= True¶ Whether AUXiliary channels (in 35 channel case last 3 channels, in 70 channel case last 6) should be omitted.
-
opeth.gui.
HISTOGRAM_BINSIZE
= 0.001¶ Histogram bin size in seconds
-
opeth.gui.
MAX_CHANNELS_PER_PLOT
= 8¶ Maximal number of channels for a given histogram window/polytrode
-
opeth.gui.
MAX_TRIGGER_CHANNEL
= 8¶ TTL trigger channel is up to 8 for a BNC expansion board
-
opeth.gui.
NEGATIVE_THRESHOLD
= True¶ Inverted signal - positive threshold value in params mean negative threshold with falling edge detection
-
opeth.gui.
PARAMFNAME
= 'lastini.conf'¶ Last used ini file name stored in a file, will default to
DEFAULT_INI
if missing
-
opeth.gui.
RERECORD
= False¶ True if data is to be saved for debug purposes
-
opeth.gui.
SPIKEWIN
= False¶ Set to True if one spike analysis window is to be opened at start.
-
opeth.gui.
TRIGGER_HOLDOFF
= 0.001¶ Trigger holdoff in seconds
-
class
opeth.gui.
TimeMeasClass
¶ Bases:
object
Performance monitoring/profiling class. (Just for development.)
Maintains a dictionary of elapsed times and number of calls with separate identifier strings to make it possible to measure multiple overlapping time segments.
-
dump
()¶ Display all timer results.
-
reset
()¶ Restart all timers.
-
tic
(idstr)¶ Start timer.
Parameters: idstr (str) – Starts timer for given string id. Will be terminated by toc()
.
-
timespent
= None¶ Measurement array for elapsed time
-
-
opeth.gui.
main
()¶
-
opeth.gui.
sigint_handler
(*args)¶ Handler for the SIGINT signal in order to be able to quit pressing CTRL+C in console.