mkpy.mkh5viewer module
- class mkpy.mkh5viewer.Application(parent=None, mkh5_f=None, tmp_yarf_f=None)[source]
Bases:
Frame
top level viewer frame
- class mkpy.mkh5viewer.Dashboard(parent, *args, **kwargs)[source]
Bases:
PanedWindow
wrapper around HeaderView, H5Nav
- class mkpy.mkh5viewer.DataView(parent, *args, **kwargs)[source]
Bases:
PanedWindow
wrapper around pygarv editor, traces and dblock datatable
- class mkpy.mkh5viewer.EventView(model, *args, **kwargs)[source]
Bases:
Frame
lightweight wrapper for regular expression event finding, same search mechanism as mkh5.event_table()
Bases:
Notebook
Tab 1 (default) is dblocks, other tabs are epochs
- class mkpy.mkh5viewer.H5View(parent, model, layer=None, *args, **kwargs)[source]
Bases:
Treeview
unified tabular viewer for data block (= a long epoch), events (a single sample epoch) and epoch tables
- update_model_view(e)[source]
handles clicks on H5view row.
Each row of self.h5view_df has a dblock_path and match_ticks column.
Selecting by mouse click or arrowing
update the main model to use the dblock at dblock_path
move the viewport to the relevant tick
switch the dashboard into event scroll mode and notify of the new event data
- class mkpy.mkh5viewer.Model(mkh5_f=None, tmp_yarf_f=None)[source]
Bases:
object
data model for the views
This is the Model in the mkh5viewer Model-View architecture
dblock_paths and epoch_tables are set once upon init when the mkh5 file is read.
The rest track datablock and index pointers, updated in response to UI events.
- Parameters
mkh5_f (string) – file path to current mkpy.mkh5 hdf5 format data file
- Variables
~mkh5.mkh5.mkh5 (object) –
mkh5
instance that exposes the hdf5 data and methodsdblock_paths (list of str) – catalogue of all hdf5 slashpaths to mkh5 dblocks
epoch_tables (list of str) – each string is a slash path ‘_epoch_tables/*’ to an mkh5 epoch table dataset
dbp_idx (uint) – index of model’s current dblock_path
dblock_path (string) – slash path to the active mkpy.mkh5 data set, e.g., sub01/dblock_0 or exp1/S07/dblock_7.
dblock (np.ndarray) – current dblock data streams
header (dict) – current dblock header
pg (PyGarv()) –
pg.yarf_docs (list) – item at pg.yarf_docs[idx] is a list of tests to run on dblock at dblock_paths[idx]
- export_yarf_docs(filename)[source]
scrape yarf doc test info from tr_docs and dump to YAML .yarf file
- get_pg_test_list()[source]
return this dblock’s tr_doc test list, e.g., for populating a UI test tree
- next_event(from_idx, direction, pygarv_type=None, event_col='log_evcodes')[source]
- return index of next or previous event in current
dblock model w/ pygarv type
- Parameters
from_idx (unint) – index in current data block to start from
direction (int) – 1 looks right, -1 looks left
pygarv_type (str (None, ‘good’ ‘bad’)) – None (default) ignores pygarv column, ‘good’ searches for pygarv == 0, bad searches pygarv > 0
event_col (str (‘log_evcodes’)) – name dblock column to search for events. usually default, perhaps ‘crw_evcodes’
- Return type
index of next event satisfying the criteria or from_idx if None are found
- class mkpy.mkh5viewer.PyGarvCatalogView(parent, *args, **kwargs)[source]
Bases:
Labelframe
viewer/chooser for available PyGarvTest tests
- class mkpy.mkh5viewer.PyGarvEditorDashboard(parent)[source]
Bases:
Frame
wrapper for Editor UI controls
- class mkpy.mkh5viewer.PyGarvTestView(parent, *args, **kwargs)[source]
Bases:
Labelframe
viewer + parameter value editor for PyGarvTest datablock test params
- class mkpy.mkh5viewer.PyGarvTreeView(parent, columns=None, *args, **kwargs)[source]
Bases:
Treeview
common container and styling wrapper for PyGarv catalog and dblock test views
- class mkpy.mkh5viewer.PyGarvView(parent, *args, **kwargs)[source]
Bases:
Labelframe
thin wrapper around PyGarvEditor model-view for selecting, editing, deleting pygarv tests
Fun facts
the mkh5 data file is not modified
View.model.pg maintains the local PyGarv() data model that tracks test results
pygarv tests are tracked and run “what if”
test results are are overlayed for viewing in the scope traces and table scope
test doc may be exported as yaml *.yarf
open an editor for new/existing tests and hands them off to Model.pygarv to dry run
Outline
on init …
pygarv (comes with a built in catalog of implemented tests)
walk the dblocks and scrape data for pygarv data stream and headers for any pygarv tests
user edits create, delete, update the in-memory test specs
when input validated for type, self.model.pg attemps to run the test
success on running updates the self.pg.pg.tr_docs w/ the test and triggers a view._update() cascade
failure returns the exception for handling by the viewer
Export button dumps the .yarf YAML (= yarf_docs) for the tr_docs
mini-console shows activity and messages
- class mkpy.mkh5viewer.TraceView(parent, model, *args, **kwargs)[source]
Bases:
Frame
trace view of data drawn on tk.Canvas wrapped in a tk.Label frame
- class Trace(parent, x=None, y=None, x_offset=0, y_offset=0, label=None, canvas_id=None, width=None, fill=None)[source]
Bases:
object
scalable x,y tk.Canvas grobs
The x and y are the 1-1 unscaled data, stretched into canvas_pts according to parent.x_scale, parent.x_scale
- Parameters
parent (TraceView object) – Assumed to have parent.x_scale, parent.y_scale, parent.canvas
- Variables
canvas_id (int (None)) – canvas item index if Trace is currently rendered, else None.
Construct:
my_line = Trace(parent_trace_view) # container only my_line = Trace(parent_trace_view, x=x_data, y=ydata) # ready to render my_rect = Trace(parent_trace_view, x=(x0,x1), y=(y0,y1)) # ready to render
Update, optionally with new x,y data
my_line.update() # rescale only my_line.update(x=x_data, y=y_data) # set x,y data and rescale
To render a Trace grob on a tk.canvas
my_line.canvas_id = canvas.create_line(my_trace.canvas_pts, …) my_rect.canvas_id = canvas.create_rectangle(my_trace.canvas_pts, …)
To delete a Trace grob from a tk.canvas
canvas.delete(my_trace.canvas_id) my_trace.canvas_id = None
- class TraceDashboard(parent, model, *args, **kwargs)[source]
Bases:
Frame
Status and UI controls for continuous vs. event/epoch scrolling
- Parameters
parent
model
- property anchor
The anchor value controls how to place the grid within the master when no row/column has any weight.
The default anchor is nw.
- property anchor_dblock_idx
- property anchor_event_data
- property anchor_vp_offset
- find_next_anchor(direction)[source]
look left or right for next event of current pygarv type
This calls Model.next_event() according to the dashboard settings.
- Parameters
direction (int) – -1 searches left, 1 searches right
- Returns
new_vp_idx – viewport left-edge index to view the found event after taking the anchor offset into account.
- Return type
uint
- property is_event_view
boolean True if scrolling by one of the event modes
- property poststim
- property poststim_dblock_idx
- property poststim_vp_offset
- property prestim
- property prestim_dblock_idx
- property prestim_vp_offset
- class TraceHScrollbar(parent, *args, **kwargs)[source]
Bases:
Scrollbar
derived scrollbar to update xview from model on set
- property position
- drag_vp_cursor(e)[source]
dragging mouse over moves viewport cursor and dblock selection
This modifies dblock view selection to drive the cursor, indirect but synchronizes dblock selection and cursor
- reset_scrollregion(*args)[source]
change the canvas scrollregion on zoom params or window changes y scrollregion always needs to include all traces. x scrollregion is canvas width … _update_vp() sets vp_len data points
- reset_trace_dashboard()[source]
pull info from the trace dashboard view controls and render
anchor marker
- reset_vp(vp_idx)[source]
set the TraceView viewport index and data slices of the current model.dblock
- Parameters
vp_idx (int) – dblock index (samples) of left edge of TraceView viewport
viewport start index values may come from keyboard/mouse TraceView navigation or
be derived from epoch data lookup during table navigation
The viewport length in samples is derived from the canvas
scrollregion fraction of the canvas width (== len(dblock) * x_scale)
- property viewport