Documentation ¶
Overview ¶
Package netview provides the NetView interactive 3D network viewer, implemented in the GoGi 3D framework.
Index ¶
- Constants
- Variables
- func NetVarsList(net emer.Network, layEven bool) []string
- type LayData
- type LayMesh
- func (lm *LayMesh) Set(sc *gi3d.Scene, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, ...)
- func (lm *LayMesh) Set2D(sc *gi3d.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, ...)
- func (lm *LayMesh) Set4D(sc *gi3d.Scene, init bool, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, ...)
- func (lm *LayMesh) Size2D() (nVtx, nIdx int)
- func (lm *LayMesh) Size4D() (nVtx, nIdx int)
- func (lm *LayMesh) Sizes() (nVtx, nIdx int, hasColor bool)
- func (lm *LayMesh) Update(sc *gi3d.Scene, vtxAry, normAry, texAry, clrAry mat32.ArrayF32, ...)
- type LayName
- type LayObj
- type NetData
- func (nd *NetData) Config()
- func (nd *NetData) CounterRec(recno int) string
- func (nd *NetData) Init(net emer.Network, max int)
- func (nd *NetData) OpenJSON(filename gi.FileName) error
- func (nd *NetData) ReadJSON(r io.Reader) error
- func (nd *NetData) RecIdx(recno int) int
- func (nd *NetData) Record(ctrs string)
- func (nd *NetData) SaveJSON(filename gi.FileName) error
- func (nd *NetData) SelectedUnitTable() *etable.Table
- func (nd *NetData) UnitVal(laynm string, vnm string, uidx1d int, recno int) (float32, bool)
- func (nd *NetData) UpdateVarRange()
- func (nd *NetData) VarRange(vnm string) (float32, float32, bool)
- func (nd *NetData) WriteJSON(w io.Writer) error
- type NetView
- func (nv *NetView) Config()
- func (nv *NetView) ConfigLabels(labs []string) bool
- func (nv *NetView) Counters() *gi.Label
- func (nv *NetView) Defaults()
- func (nv *NetView) GoUpdate()
- func (nv *NetView) HasLayers() bool
- func (nv *NetView) IsConfiged() bool
- func (nv *NetView) LabelByName(lab string) *gi3d.Text2D
- func (nv *NetView) LayerByName(lay string) *gi3d.Group
- func (nv *NetView) NetLay() *gi.Layout
- func (nv *NetView) OpenWeights(filename gi.FileName)
- func (nv *NetView) PlotSelectedUnit() (*gi.Window, *etable.Table, *eplot.Plot2D)
- func (nv *NetView) ReadLock()
- func (nv *NetView) ReadUnlock()
- func (nv *NetView) RecBkwd() bool
- func (nv *NetView) RecFastBkwd() bool
- func (nv *NetView) RecFastFwd() bool
- func (nv *NetView) RecFullBkwd() bool
- func (nv *NetView) RecFwd() bool
- func (nv *NetView) RecTrackLatest() bool
- func (nv *NetView) Record(counters string)
- func (nv *NetView) Render2D()
- func (nv *NetView) SaveWeights(filename gi.FileName)
- func (nv *NetView) Scene() *gi3d.Scene
- func (nv *NetView) SetCounters(ctrs string)
- func (nv *NetView) SetMaxRecs(max int)
- func (nv *NetView) SetNet(net emer.Network)
- func (nv *NetView) SetVar(vr string)
- func (nv *NetView) ShowAllParams() string
- func (nv *NetView) ShowNonDefaultParams() string
- func (nv *NetView) Toolbar() *gi.ToolBar
- func (nv *NetView) ToolbarConfig()
- func (nv *NetView) UnitVal(lay emer.Layer, idx []int) (raw, scaled float32, clr gist.Color, hasval bool)
- func (nv *NetView) Update()
- func (nv *NetView) UpdateImpl()
- func (nv *NetView) UpdateRecNo()
- func (nv *NetView) VarScaleUpdate(varNm string) bool
- func (nv *NetView) VarsConfig()
- func (nv *NetView) VarsLay() *gi.Frame
- func (nv *NetView) VarsListUpdate()
- func (nv *NetView) VarsUpdate()
- func (nv *NetView) ViewConfig()
- func (nv *NetView) ViewDefaults()
- func (nv *NetView) Viewbar() *gi.ToolBar
- func (nv *NetView) ViewbarConfig()
- type Params
- type VarParams
Constants ¶
const NaNSub = -1.11e-37
NaNSub is used to replace NaN values for saving -- JSON doesn't handle nan's
Variables ¶
var KiT_LayMesh = kit.Types.AddType(&LayMesh{}, nil)
var KiT_LayName = kit.Types.AddType(&LayName{}, nil)
var KiT_LayObj = kit.Types.AddType(&LayObj{}, LayObjProps)
var KiT_NetData = kit.Types.AddType(&NetData{}, NetDataProps)
var KiT_NetView = kit.Types.AddType(&NetView{}, NetViewProps)
var LayObjProps = ki.Props{ "EnumType:Flag": gi.KiT_NodeFlags, }
var MinUnitHeight = float32(1.0e-6)
MinUnitHeight ensures that there is always at least some dimensionality to the unit cubes -- affects transparency rendering etc
var NetDataProps = ki.Props{ "CallMethods": ki.PropSlice{ {"SaveJSON", ki.Props{ "desc": "save recorded network view data to file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".netdat,.netdat.gz", }}, }, }}, {"OpenJSON", ki.Props{ "desc": "open recorded network view data from file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".netdat,.netdat.gz", }}, }, }}, }, }
var NetViewProps = ki.Props{ "max-width": -1, "max-height": -1, "CallMethods": ki.PropSlice{ {"SaveWeights", ki.Props{ "desc": "save network weights to file", "icon": "file-save", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".wts,.wts.gz", }}, }, }}, {"OpenWeights", ki.Props{ "desc": "open network weights from file", "icon": "file-open", "Args": ki.PropSlice{ {"File Name", ki.Props{ "ext": ".wts,.wts.gz", }}, }, }}, }, }
Functions ¶
Types ¶
type LayData ¶ added in v1.0.0
type LayData struct { LayName string `desc:"the layer name"` NUnits int `desc:"cached number of units"` Data []float32 `desc:"the full data, Ring.Max * len(Vars) * NUnits in that order"` }
LayData maintains a record of all the data for a given layer
type LayMesh ¶
type LayMesh struct { gi3d.MeshBase Lay emer.Layer `desc:"layer that we render"` Shape etensor.Shape `desc:"current shape that has been constructed -- if same, just update"` View *NetView `desc:"netview that we're in"` }
LayMesh is a gi3d.Mesh that represents a layer -- it is dynamically updated using the Update method which only resets the essential Vertex elements. The geometry is literal in the layer size: 0,0,0 lower-left corner and increasing X,Z for the width and height of the layer, in unit (1) increments per unit.. NetView applies an overall scaling to make it fit within the larger view.
func AddNewLayMesh ¶
AddNewLayMesh adds LayMesh mesh to given scene for given layer
type LayName ¶ added in v1.0.0
type LayName struct { gi3d.Text2D NetView *NetView `copy:"-" json:"-" xml:"-" view:"-" desc:"our netview"` }
LayName is the Layer name as a Text2D within the NetView
func (*LayName) ConnectEvents3D ¶ added in v1.0.0
type LayObj ¶ added in v1.0.0
type LayObj struct { gi3d.Solid LayName string `desc:"name of the layer we represent"` NetView *NetView `copy:"-" json:"-" xml:"-" view:"-" desc:"our netview"` }
LayObj is the Layer 3D object within the NetView
func (*LayObj) ConnectEvents3D ¶ added in v1.0.0
type NetData ¶ added in v1.0.0
type NetData struct { Net emer.Network `json:"-" desc:"the network that we're viewing"` PrjnLay string `desc:"name of the layer with unit for viewing projections (connection / synapse-level values)"` PrjnUnIdx int `desc:"1D index of unit within PrjnLay for for viewing projections"` PrjnType string `` /* 191-byte string literal not displayed */ Vars []string `desc:"the list of variables saved -- copied from NetView"` VarIdxs map[string]int `desc:"index of each variable in the Vars slice"` Ring ringidx.Idx `` /* 141-byte string literal not displayed */ LayData map[string]*LayData `desc:"the layer data -- map keyed by layer name"` MinPer []float32 `desc:"min values for each Ring.Max * variable"` MaxPer []float32 `desc:"max values for each Ring.Max * variable"` MinVar []float32 `desc:"min values for variable"` MaxVar []float32 `desc:"max values for variable"` Counters []string `desc:"counter strings"` }
NetData maintains a record of all the network data that has been displayed up to a given maximum number of records (updates), using efficient ring index logic with no copying to store in fixed-sized buffers.
func (*NetData) Config ¶ added in v1.0.0
func (nd *NetData) Config()
Config configures the data storage for given network only re-allocates if needed.
func (*NetData) CounterRec ¶ added in v1.0.0
CounterRec returns counter string for given record, which is -1 for current (last) record, or in [0..Len-1] for prior records.
func (*NetData) RecIdx ¶ added in v1.0.0
RecIdx returns record index for given record number, which is -1 for current (last) record, or in [0..Len-1] for prior records.
func (*NetData) Record ¶ added in v1.0.0
Record records the current full set of data from the network, and the given counters string
func (*NetData) SelectedUnitTable ¶ added in v1.1.56
SelectedUnitTable returns a table with all of the data for the currently-selected unit.
func (*NetData) UnitVal ¶ added in v1.0.0
UnitVal returns the value for given layer, variable name, unit index, and record number, which is -1 for current (last) record, or in [0..Len-1] for prior records. Returns false if value unavailable for any reason (including recorded as such as NaN).
func (*NetData) UpdateVarRange ¶ added in v1.0.0
func (nd *NetData) UpdateVarRange()
UpdateVarRange updates the range for variables
type NetView ¶
type NetView struct { gi.Layout Net emer.Network `desc:"the network that we're viewing"` Var string `desc:"current variable that we're viewing"` Vars []string `desc:"the list of variables to view"` VarParams map[string]*VarParams `desc:"parameters for the list of variables to view"` CurVarParams *VarParams `json:"-" xml:"-" view:"-" desc:"current var params -- only valid during Update of display"` Params Params `desc:"parameters controlling how the view is rendered"` ColorMap *colormap.Map `desc:"color map for mapping values to colors -- set by name in Params"` RecNo int `desc:"record number to display -- use -1 to always track latest, otherwise in range [0..Data.Ring.Len-1]"` LastCtrs string `desc:"last non-empty counters string provided -- re-used if no new one"` Data NetData `desc:"contains all the network data with history"` DataMu sync.RWMutex `view:"-" copy:"-" json:"-" xml:"-" desc:"mutex on data access"` }
NetView is a GoGi Widget that provides a 3D network view using the GoGi gi3d 3D framework.
func AddNewNetView ¶
AddNewNetView adds a new NetView to given parent node, with given name.
func (*NetView) ConfigLabels ¶ added in v1.0.0
ConfigLabels ensures that given label gi3d.Text2D objects are created and initialized in a top-level group called Labels. Use LabelByName() to get a given label, and LayerByName() to get a Layer group, whose Pose can be copied to put a label in position relative to a layer. Default alignment is Left, Top. Returns true set of labels was changed (mods).
func (*NetView) GoUpdate ¶
func (nv *NetView) GoUpdate()
GoUpdate is the update call to make from another go routine it does the proper blocking to coordinate with GUI updates generated on the main GUI thread.
func (*NetView) IsConfiged ¶
IsConfiged returns true if widget is fully configured
func (*NetView) LabelByName ¶ added in v1.0.0
LabelByName returns given Text2D label (see ConfigLabels). nil if not found.
func (*NetView) LayerByName ¶ added in v1.0.0
LayerByName returns the gi3d.Group that represents layer of given name. nil if not found.
func (*NetView) OpenWeights ¶
OpenWeights opens the network weights -- when called with giv.CallMethod it will auto-prompt for filename
func (*NetView) PlotSelectedUnit ¶ added in v1.1.56
PlotSelectedUnit opens a window with a plot of all the data for the currently-selected unit. Useful for replaying detailed trace for units of interest.
func (*NetView) ReadLock ¶ added in v1.0.6
func (nv *NetView) ReadLock()
ReadLock locks data for reading -- call ReadUnlock when done. Call this surrounding calls to UnitVal.
func (*NetView) ReadUnlock ¶ added in v1.0.6
func (nv *NetView) ReadUnlock()
ReadUnlock unlocks data for reading.
func (*NetView) RecBkwd ¶ added in v1.0.0
RecBkwd move view record 1 steps backward. Returns true if updated.
func (*NetView) RecFastBkwd ¶ added in v1.0.0
RecFastBkwd move view record N (default 10) steps backward. Returns true if updated.
func (*NetView) RecFastFwd ¶ added in v1.0.0
RecFastFwd move view record N (default 10) steps forward. Returns true if updated.
func (*NetView) RecFullBkwd ¶ added in v1.1.0
RecFullBkwd move view record to start of history.
func (*NetView) RecFwd ¶ added in v1.0.0
RecFwd move view record 1 step forward. Returns true if updated.
func (*NetView) RecTrackLatest ¶ added in v1.0.0
RecTrackLatest sets view to track latest record (-1). Returns true if updated.
func (*NetView) Record ¶ added in v1.0.0
Record records the current state of the network, along with provided counters string, which is displayed at the bottom of the view to show the current state of the counters. The NetView displays this recorded data when Update is next called.
func (*NetView) SaveWeights ¶
SaveWeights saves the network weights -- when called with giv.CallMethod it will auto-prompt for filename
func (*NetView) SetCounters ¶
SetCounters sets the counters widget view display at bottom of netview
func (*NetView) SetMaxRecs ¶ added in v1.0.0
SetMaxRecs sets the maximum number of records that are maintained (default 210) resets the current data in the process
func (*NetView) ShowAllParams ¶
ShowAllParams shows a dialog of all the parameters in the network.
func (*NetView) ShowNonDefaultParams ¶
ShowNonDefaultParams shows a dialog of all the parameters that are not at their default values in the network. Useful for setting params.
func (*NetView) ToolbarConfig ¶
func (nv *NetView) ToolbarConfig()
func (*NetView) UnitVal ¶
func (nv *NetView) UnitVal(lay emer.Layer, idx []int) (raw, scaled float32, clr gist.Color, hasval bool)
UnitVal returns the raw value, scaled value, and color representation for given unit of given layer scaled is in range -1..1
func (*NetView) Update ¶
func (nv *NetView) Update()
Update updates the display based on current state of network. This version is for calling within main window eventloop goroutine -- use GoUpdate version for calling outside of main goroutine.
func (*NetView) UpdateImpl ¶
func (nv *NetView) UpdateImpl()
UpdateImpl does the guts of updating -- backend for Update or GoUpdate
func (*NetView) UpdateRecNo ¶ added in v1.0.0
func (nv *NetView) UpdateRecNo()
UpdateRecNo updates the record number viewing
func (*NetView) VarScaleUpdate ¶
VarScaleUpdate updates display of the scaling params for given variable (use nv.Var for current) returns true if any setting changed (update always triggered)
func (*NetView) VarsListUpdate ¶
func (nv *NetView) VarsListUpdate()
VarsListUpdate updates the list of network variables
func (*NetView) VarsUpdate ¶
func (nv *NetView) VarsUpdate()
VarsUpdate updates the selection status of the variables and the view range state too
func (*NetView) ViewDefaults ¶
func (nv *NetView) ViewDefaults()
ViewDefaults are the default 3D view params
func (*NetView) ViewbarConfig ¶
func (nv *NetView) ViewbarConfig()
type Params ¶
type Params struct { PrjnType string `` /* 150-byte string literal not displayed */ MaxRecs int `min:"1" desc:"maximum number of records to store to enable rewinding through prior states"` UnitSize float32 `min:"0.1" max:"1" step:"0.1" def:"0.9" desc:"size of a single unit, where 1 = full width and no space.. .9 default"` LayNmSize float32 `min:"0.01" max:".1" step:"0.01" def:"0.05" desc:"size of the layer name labels -- entire network view is unit sized"` ColorMap giv.ColorMapName `desc:"name of color map to use"` ZeroAlpha float32 `` /* 158-byte string literal not displayed */ NetView *NetView `copy:"-" json:"-" xml:"-" view:"-" desc:"our netview, for update method"` NFastSteps int `desc:"the number of records to jump for fast forward/backward"` }
Params holds parameters controlling how the view is rendered
type VarParams ¶
type VarParams struct { Var string `desc:"name of the variable"` ZeroCtr bool `` /* 139-byte string literal not displayed */ Range minmax.Range32 `view:"inline" desc:"range to display"` MinMax minmax.F32 `view:"inline" desc:"if not using fixed range, this is the actual range of data"` }
VarParams holds parameters for display of each variable