{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import pylab as plt\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from objsimpy.stim.stim_sequence import InputTrace\n", "from objsimpy.som_results import show_preferred_stimulus_maps, show_preferred_stimuli_x_y\n", "from objsimpy.eval_sim_data import calc_response_strength2_PICKLED\n", "from objsimpy.eval_sim_data import calc_response_strength2, calc_preferred_stimuli_from_response\n", "from objsimpy.som_results import evaluate_single_sim, calc_response_selectivity\n", "from objsimpy.sim_data import SimInfo" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "simname = \"som02_example\"\n", "from objsimpy.config import SIMDATA_BASE_DIR, OBJSIM_DIR\n", "import os\n", "data_dir = os.path.join(SIMDATA_BASE_DIR, 'objsim', simname)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ls -l $data_dir" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import objsimpy.spike_file as spike_file" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "spike_file_name = os.path.join(data_dir, \"RepresentationLayerspikes.datTEST3.bin\")\n", "spikes = spike_file.read(spike_file_name)\n", "spike_times, neuron_numbers = spikes" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "t1 = 10000\n", "t2 = 110000\n", "plt.figure(figsize=(16, 5))\n", "plt.plot(spike_times[t1:t2], neuron_numbers[t1:t2], '.')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from objsimpy.stim.stim_sequence import read_input_file, InputTrace\n", "fname_input = os.path.join(data_dir, \"MovieScanInput0.inp.datTEST3\")\n", "input_trace = InputTrace(fname_input)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.plot(input_trace.nparray[t1:t2], '.')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "response_strength_pickle_file = os.path.join(data_dir, spike_file_name + \".response.pickle\")\n", "response_strength = calc_response_strength2_PICKLED(\n", " response_strength_pickle_file, \n", " spikes, \n", " input_trace,\n", " 100, 500,\n", " 10000,\n", " #reevaluate=True\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.plot(response_strength[:,200], '.')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim_info = SimInfo(os.path.join(data_dir, \"Sim.SimInfo\"))\n", "layer_name = \"RepresentationLayer\"\n", "input_name = \"MovieScanInput0\"\n", "layer_info = [l for l in sim_info.get_layers() if l.name==layer_name][0]\n", "n_neurons = layer_info.LayerDimensions['N']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "total_mean_response = response_strength.mean()\n", "print(total_mean_response)\n", "plt.plot(response_strength.argmax(axis=1), '.')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "preferred_stim = response_strength.argmax(axis=1)\n", "nx = sim_info.get_inputs()[0].NXPara\n", "ny = sim_info.get_inputs()[0].NYPara" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pref_stimuli, selectivity = calc_preferred_stimuli_from_response(response_strength)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from matplotlib.colors import Normalize\n", "from objsimpy.colormaps import cmap_color_circle\n", "norm = Normalize(vmin = 0.)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "preferences = [pref_stimuli // nx, pref_stimuli % nx]\n", "plt.imshow(preferences[0], origin = 'lower', interpolation = 'Nearest', cmap = cmap_color_circle(), norm = norm)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(preferences[1], origin = 'lower', interpolation = 'Nearest', cmap = cmap_color_circle(), norm = norm)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "stim_onsets = input_trace.get_stim_onset()\n", "stim_numbers = [onset[1] for onset in stim_onsets]\n", "plt.hist(stim_numbers, bins=list(range(-2,410)))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.5" } }, "nbformat": 4, "nbformat_minor": 2 }