ax = plt.subplot(3, 1, 2) nplt.timeseries_from_epoch([val['resp']], epoch, ax=ax) raster = rec['resp'].extract_epoch(epoch) ax = plt.subplot(3, 1, 3) plt.imshow(raster[:, 0, :]) plt.tight_layout() # see what a "traditional" NEMS model looks like nems_modelname = "ozgf.fs100.ch18-ld-sev_dlog-wc.18x2.g-do.2x15-lvl.1-dexp.1_init-basic" xfspec, ctx = load_model_xform(cellid, batch=batch, modelname=nems_modelname) nplt.quickplot(ctx) ex = gui.browse_xform_fit(ctx, xfspec) ## batch, cellid = 308, 'AMT018a-09-1' modelname = 'ozgf.fs100.ch18-ld-sev_dlog-wc.18x4.g-fir.2x15x2-relu.2-wc.2x1-lvl.1-dexp.1_init.tf.rb5-tf.n' xfspec, ctx = fit_model_xform(cellid, batch=batch, modelname=modelname) nplt.quickplot(ctx) ex = gui.browse_xform_fit(ctx, xfspec) ###Plot complexity of model versus how effective it was batch = 308 metric = 'r_test' metric2 = 'n_parms' metric3 = 'se_test' query = "SELECT {0}, {1}, {2}, {3} FROM NarfResults WHERE batch = 308".format( metric, metric2, metric3, 'modelname')
def launch_model_browser(self, ctx, xfspec): """Launches the model browser and keeps a reference so it's not garbage collected.""" self.model_browser = editors.browse_xform_fit(ctx, xfspec)
from nems.gui.editors import browse_xform_fit import nems.xform_helper as xhelp from nems.xforms import normalize_sig from nems_lbhb.gcmodel.figures.simulation import (build_toy_stp_cell, build_toy_gc_cell, build_toy_LN_cell) _DEFAULT_CELL = 'TAR009d-42-1' _DEFAULT_BATCH = 289 _DEFAULT_MODEL = 'ozgf.fs100.ch18-ld-contrast.ms30.cont.n.off0-sev_dlog.f-wc.18x3.g-fir.3x15-lvl.1-ctk3-dsig.d_gc2.PF' if __name__ == 'main': xfspec, ctx = xhelp.load_model_xform(_DEFAULT_CELL, _DEFAULT_BATCH, _DEFAULT_MODEL) val = ctx['val'] # val = normalize_sig(val, 'stim', 'minmax')['rec'] # val = normalize_sig(val, 'resp', 'minmax')['rec'] #gc_sim = build_toy_gc_cell(0, 0, 0, -0.5) #base, amp, shift, kappa #gc_sim[-2]['fn_kwargs']['compute_contrast'] = True stp_sim = build_toy_stp_cell([0, 0.1], [0.08, 0.08]) #u, tau #LN_sim = build_toy_LN_cell() ctx['val'] = stp_sim.evaluate(val) ctx['modelspec'] = stp_sim browse_xform_fit(ctx, xfspec)
batch = 289 cellid = 'TAR009d-42-1' modelname = "ozgf.fs100.ch18-ld-sev_dlog.f-wc.18x3.g-stp.3-fir.3x15-lvl.1-dexp.1_init-basic" batch, cellid = 308, 'AMT018a-09-1' modelname = 'ozgf.fs100.ch18-ld-sev_dlog-wc.18x4.g-fir.2x15x2-relu.2-wc.2x1-lvl.1-dexp.1_tf.n.rb10' modelname2 = 'ozgf.fs100.ch18-ld-sev_dlog-wc.18x4.g-fir.2x15x2-relu.2-wc.2x1-lvl.1-dexp.1_tf.n.rb5' modelname2 = None GUI = True xfspec, ctx = xhelp.load_model_xform(cellid, batch, modelname) if GUI: # interactive model browser (matplotlib embedded Qt) ex = gui.browse_xform_fit(ctx, xfspec) if modelname2 is not None: xfspec2, ctx2 = xhelp.load_model_xform(cellid, batch, modelname2) ex2 = gui.browse_xform_fit(ctx2, xfspec2, control_widget=ex.editor.global_controls) #aw = browse_context(ctx, rec='val', signals=['stim', 'pred', 'resp']) #aw = browse_context(ctx, signals=['state', 'psth', 'pred', 'resp']) else: # static model summary plot (matplotlib native) #ctx['modelspec'][1]['plot_fn_idx']=2 time_range = (0, 5)
# ---------------------------------------------------------------------------- # GENERATE PLOTS # GOAL: Plot the predictions made by your results vs the real response. # Compare performance of results with other metrics. logging.info('Generating summary plot...') # set modelspec to plot psth for big vs. small pupil modelspec[0]['plot_fn_idx'] = 5 # Generate a summary plot modelspec.quickplot(rec=val, epoch='REFERENCE', include_input=False) #plot timeseries seperately overides quickplot errors epoch_bounds = val['resp'].get_epoch_bounds('REFERENCE') possible_occurrences = np.arange(epoch_bounds.shape[1]) occurrence = possible_occurrences[0] time_range = epoch_bounds[occurrence] nems.plots.timeseries.timeseries_from_signals( signals=[val['resp'], val['pred']], channels=0, no_legend=False, time_range=time_range, rec=val, sig_name=None) if USE_GUI: # interactive gui ex = gui.browse_xform_fit({'modelspec': modelspec, 'val': val}, [])