diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..8657a99 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 089865a..1d623c3 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ Data/ >>>>>>> 73c6c9b7133534e9970e82c3c355c6f2e3fd1194 TestData/020217_right_25_2_export_final.mat TrialBanks/ +Controllers/dist +Controllers/build \ No newline at end of file diff --git a/.ipynb_checkpoints/Binary sequence creating-checkpoint.ipynb b/.ipynb_checkpoints/Binary sequence creating-checkpoint.ipynb new file mode 100644 index 0000000..a5d9bab --- /dev/null +++ b/.ipynb_checkpoints/Binary sequence creating-checkpoint.ipynb @@ -0,0 +1,7083 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import math\n", + "import matplotlib.pyplot as plt\n", + "import pickle\n", + "import os\n", + "from scipy import signal" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "%matplotlib notebook" + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": {}, + "outputs": [], + "source": [ + "#trialbank_loc = '/Volumes/lab-schaefera/working/warnert/Recordings/190222/2Hz_20Hz_corr_anti_corr_reorder.trialbank'\n", + "trialbank_loc = '/Volumes/lab-schaefera/working/warnert/Recordings/190121/full_trialbank.trialbank'" + ] + }, + { + "cell_type": "code", + "execution_count": 131, + "metadata": {}, + "outputs": [], + "source": [ + "trialbank = pickle.Unpickler(open(trialbank_loc, 'rb')).load()" + ] + }, + { + "cell_type": "code", + "execution_count": 133, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[4, [{'type': 'Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Near_40cm/plume_40cm_180328_9.mat', 'target_max': 1.0}, {'type': 'Anti Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Near_40cm/plume_40cm_180328_9.mat', 'target_max': 1.0}, {'type': 'Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Far_80cm/plume_80cm_180328_9.mat', 'target_max': 1.0}, {'type': 'Anti Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Far_80cm/plume_80cm_180328_9.mat', 'target_max': 1.0}], 'Trial Name']\n" + ] + } + ], + "source": [ + "params = trialbank[0]\n", + "print(params)\n", + "sampling_rate = 20000" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def shatter_pulse(sampling_rate, duration, frequency, duty, shatter_frequency, shatter_duty):\n", + "\n", + " if shatter_frequency < frequency:\n", + " raise ValueError('Shatter frequency must not be lower than major frequency.')\n", + "\n", + " t = np.linspace(0, duration, sampling_rate * duration, endpoint=False)\n", + "\n", + " guide_pulse, _ = square_pulse(sampling_rate, duration, frequency, duty)\n", + " shattered_pulse = (np.array(signal.square(2 * np.pi * shatter_frequency * t, duty=shatter_duty)) / 2) + 0.5\n", + "\n", + " return guide_pulse * shattered_pulse, t\n", + "def square_pulse(sampling_rate, duration, frequency, duty):\n", + " t = np.linspace(0, duration, sampling_rate * duration, endpoint=False)\n", + " return (np.array(signal.square(2 * np.pi * frequency * t, duty=duty)) / 2) + 0.5, t\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'fromDuty'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'fromDuty'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mfrequency\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'frequency'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mduty\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'duty'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'fromValues'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'fromDuty'" + ] + } + ], + "source": [ + "if params['fromDuty']:\n", + " frequency = params['frequency']\n", + " duty = params['duty']\n", + "else:\n", + " assert params['fromValues']\n", + " frequency = 1.0 / (params['pulse_width'] + params['pulse_delay'])\n", + " duty = params['pulse_width'] / (params['pulse_width'] + params['pulse_delay'])\n", + "\n", + "if params['fromLength']:\n", + " duration = params['length']\n", + "else:\n", + " assert params['fromRepeats']\n", + " if params['fromValues']:\n", + " duration = (params['pulse_width'] + params['pulse_delay']) * params['repeats']\n", + " else:\n", + " assert params['fromDuty']\n", + " duration = (1.0 / frequency) * params['repeats']\n", + "\n", + "if params['isClean']:\n", + " pulse, t = square_pulse(sampling_rate, duration, frequency, duty)\n", + "else:\n", + " assert params['isShatter']\n", + " pulse, t = shatter_pulse(sampling_rate, duration, frequency, duty, params['shatter_frequency'],\n", + " params['shatter_duty'])\n", + "print(pulse.shape)\n", + "# Attach onset and offset\n", + "onset = np.zeros(int(sampling_rate * params['onset']))\n", + "offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + "pulse = np.hstack((onset, pulse, offset))\n", + "\n", + "total_length = round(duration + params['onset'] + params['offset'], 10) # N.B. Have to round here due to floating point representation problem\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(2000,) (44000,) (2000,)\n" + ] + } + ], + "source": [ + "print(onset.shape, pulse.shape, offset.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2.2\n" + ] + } + ], + "source": [ + "print(total_length)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/warnert/miniconda3/envs/local/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning: object of type cannot be safely interpreted as an integer.\n", + " \"\"\"Entry point for launching an IPython kernel.\n" + ] + } + ], + "source": [ + "output =pulse, np.linspace(0, total_length, total_length*sampling_rate)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.plot(test[0])\n", + "plt.plot(plume)\n", + "np.save(os.path.join('/Users/warnert/Documents/GitHub/PulseBoy', 'test.npy'), plume)" + ] + }, + { + "cell_type": "code", + "execution_count": 169, + "metadata": {}, + "outputs": [], + "source": [ + "retest = np.load(os.path.join('/Users/warnert/Documents/GitHub/PulseBoy', 'test.npy'))" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [], + "source": [ + "params = {'onset': 0.0, 'offset':0.0, 'num_of_bins':8, 'bin_size':0.05,'value_to_binarise':256}" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": {}, + "outputs": [], + "source": [ + "def binary_pulse(sampling_rate, params):\n", + " '''\n", + " Creates a pulse from a value passed to it. Value should be less than the maximum \n", + " '''\n", + " binary = params['value_to_binarise']\n", + " \n", + " assert binary >= 0, 'Binary minimum should be zero'\n", + " assert binary <= 2**params['num_of_bins'] - 1, 'Binary maximum should be less than %s' % str(2**params['num_of_bins'])\n", + " bin_width = params['bin_size']*sampling_rate\n", + " binned = bin(binary)[2:]\n", + " while len(binned) < params['num_of_bins']:\n", + " binned = '0' + binned\n", + " bin_output = []\n", + " print(binned, bin_width)\n", + " onset = np.zeros(int(sampling_rate * params['onset']))\n", + " offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + " \n", + " \n", + " bin_pulse = [int(i) for i in binned for j in range(int(bin_width))]\n", + " total_length = round(params['onset'] + params['offset'] + len(bin_pulse)/sampling_rate, 10)\n", + " return np.hstack((onset, bin_pulse, offset)), np.linspace(0, total_length, total_length * sampling_rate)\n", + "\n", + " \n", + "#resampled = signal.resample(binary, int(len(binary) * (sampling_rate / params['data_fs'])))\n", + " \n", + "# onset = np.zeros(int(sampling_rate * params['onset']))\n", + "# offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + "# total_length = round(params['onset'] + params['offset'] + len(resampled)/sampling_rate, 10)\n", + "# return np.hstack((onset, resampled, offset)), np.linspace(0, total_length, total_length * sampling_rate)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "metadata": {}, + "outputs": [ + { + "ename": "AssertionError", + "evalue": "Binary maximum should be less than 256", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbin_pulse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbinary_pulse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20000\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbin_pulse\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbin_pulse\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mbinary_pulse\u001b[0;34m(sampling_rate, params)\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mbinary\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Binary minimum should be zero'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0mbinary\u001b[0m \u001b[0;34m<=\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'num_of_bins'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Binary maximum should be less than %s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'num_of_bins'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0mbin_width\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'bin_size'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0msampling_rate\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mbinned\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbinary\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAssertionError\u001b[0m: Binary maximum should be less than 256" + ] + } + ], + "source": [ + "bin_pulse = binary_pulse(20000, params)\n", + "plt.plot(bin_pulse[1], bin_pulse[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 177, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.plot(np.arange(0, len(full_pulse)/20000, 1/20000), full_pulse)\n", + "for i in range(255):\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 200, + "metadata": {}, + "outputs": [], + "source": [ + "def full_binary_sequence(sampling_rate, params):\n", + " \n", + " \n", + " bin_width = params['bin_size']*sampling_rate\n", + " \n", + " full_pulse = []\n", + " for i in range(2**num_of_bins):\n", + " bin_width = params['bin_size']*sampling_rate\n", + " binary = bin(i)[2:]\n", + " #print(binary)\n", + "\n", + " while len(binary) < num_of_bins:\n", + " binary = '0'+binary\n", + " bin_pulse = [int(i) for i in binary for j in range(int(bin_width))]\n", + " #print(bin_pulse)\n", + "\n", + " full_pulse.extend(bin_pulse)\n", + "\n", + " \n", + " onset = np.zeros(int(sampling_rate * params['onset']))\n", + " offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + " \n", + " \n", + " \n", + " total_length = round(params['onset'] + params['offset'] + len(full_pulse)/sampling_rate, 10)\n", + " return np.hstack((onset, full_pulse, offset)), np.linspace(0, total_length, total_length * sampling_rate)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 201, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/warnert/miniconda3/envs/local/lib/python3.7/site-packages/ipykernel_launcher.py:27: DeprecationWarning: object of type cannot be safely interpreted as an integer.\n" + ] + } + ], + "source": [ + "test = full_binary_sequence(20000, params)" + ] + }, + { + "cell_type": "code", + "execution_count": 203, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0\n", + "0.0\n", + "0.0\n", + "0.0\n" + ] + } + ], + "source": [ + "fig, ax = plt.subplots(5, 1, sharex=True)\n", + "avg_chans = []\n", + "for i in range(4):\n", + " chn_starts = plume_starts[i::10]\n", + " avg_chan = np.zeros(50000,)\n", + " print(avg_chan[0])\n", + " for j in chn_starts:\n", + " ax[i].plot(flow_baselined[j:j+50000], color='gray')\n", + " avg_chan = [i[0]+j for i, j in zip(flow_baselined[j:j+50000], avg_chan)]\n", + " avg_chan= [i/len(chn_starts) for i in avg_chan]\n", + " ax[i].plot(avg_chan)\n", + " ax[4].plot(avg_chan)\n", + " avg_chans.append(avg_chan)\n", + "ax[0].set_title('Channel plumes')\n", + "ax[4].set_title('Avg plumes')\n", + "plt.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0\n", + "0.0\n", + "0.0\n", + "0.0\n" + ] + } + ], + "source": [ + "fig, ax = plt.subplots(5, 1, sharex=True)\n", + "avg_anti_chans = []\n", + "for i in range(4):\n", + " chn_starts = plume_starts[i+6::10]\n", + " avg_chan = np.zeros(50000,)\n", + " print(avg_chan[0])\n", + " for j in chn_starts:\n", + " ax[i].plot(flow_baselined[j:j+50000], color='gray')\n", + " avg_chan = [i[0]+j for i, j in zip(flow_baselined[j:j+50000], avg_chan)]\n", + " avg_chan= [i/len(chn_starts) for i in avg_chan]\n", + " ax[i].plot(avg_chan)\n", + " ax[4].plot(avg_chan)\n", + " avg_anti_chans.append(avg_chan)\n", + "ax[0].set_title('Channel anti plumes')\n", + "ax[4].set_title('Avg anti plumes')\n", + "plt.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "for i, j in zip(avg_chans, avg_anti_chans):\n", + " med_i = np.median(i)\n", + " plt.plot(i/med_i, color='r')\n", + " med_j = np.median(j)\n", + " plt.plot([1-k/med_j for k in j], color='b')" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[-0.00557857 -0.00369847 -0.00447263 ... 0.29747743 0.29769862\n", + " 0.2979751 ]\n", + "50000\n", + "[-0.00206818 -0.00280337 -0.00348605 ... 0.20105517 0.2007926\n", + " 0.20066131]\n", + "50000\n", + "[-0.00440357 -0.00531314 -0.00597464 ... 0.18897464 0.19470763\n", + " 0.19377051]\n", + "50000\n", + "[-0.0024581 -0.00346786 -0.00424003 ... 0.2280057 0.22750081\n", + " 0.22681774]\n", + "50000\n" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], + "source": [] + }, + { + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/Binary sequence creating.ipynb b/Binary sequence creating.ipynb new file mode 100644 index 0000000..a5d9bab --- /dev/null +++ b/Binary sequence creating.ipynb @@ -0,0 +1,7083 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import math\n", + "import matplotlib.pyplot as plt\n", + "import pickle\n", + "import os\n", + "from scipy import signal" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "%matplotlib notebook" + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": {}, + "outputs": [], + "source": [ + "#trialbank_loc = '/Volumes/lab-schaefera/working/warnert/Recordings/190222/2Hz_20Hz_corr_anti_corr_reorder.trialbank'\n", + "trialbank_loc = '/Volumes/lab-schaefera/working/warnert/Recordings/190121/full_trialbank.trialbank'" + ] + }, + { + "cell_type": "code", + "execution_count": 131, + "metadata": {}, + "outputs": [], + "source": [ + "trialbank = pickle.Unpickler(open(trialbank_loc, 'rb')).load()" + ] + }, + { + "cell_type": "code", + "execution_count": 133, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[4, [{'type': 'Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Near_40cm/plume_40cm_180328_9.mat', 'target_max': 1.0}, {'type': 'Anti Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Near_40cm/plume_40cm_180328_9.mat', 'target_max': 1.0}, {'type': 'Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Far_80cm/plume_80cm_180328_9.mat', 'target_max': 1.0}, {'type': 'Anti Plume', 'onset': 0.1, 'offset': 0.1, 'shatter_frequency': 500.0, 'data_fs': 10000.0, 'data_path': 'Z:/working/marinc/Distance_box/Far_80cm/plume_80cm_180328_9.mat', 'target_max': 1.0}], 'Trial Name']\n" + ] + } + ], + "source": [ + "params = trialbank[0]\n", + "print(params)\n", + "sampling_rate = 20000" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def shatter_pulse(sampling_rate, duration, frequency, duty, shatter_frequency, shatter_duty):\n", + "\n", + " if shatter_frequency < frequency:\n", + " raise ValueError('Shatter frequency must not be lower than major frequency.')\n", + "\n", + " t = np.linspace(0, duration, sampling_rate * duration, endpoint=False)\n", + "\n", + " guide_pulse, _ = square_pulse(sampling_rate, duration, frequency, duty)\n", + " shattered_pulse = (np.array(signal.square(2 * np.pi * shatter_frequency * t, duty=shatter_duty)) / 2) + 0.5\n", + "\n", + " return guide_pulse * shattered_pulse, t\n", + "def square_pulse(sampling_rate, duration, frequency, duty):\n", + " t = np.linspace(0, duration, sampling_rate * duration, endpoint=False)\n", + " return (np.array(signal.square(2 * np.pi * frequency * t, duty=duty)) / 2) + 0.5, t\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "ename": "KeyError", + "evalue": "'fromDuty'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'fromDuty'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mfrequency\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'frequency'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mduty\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'duty'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'fromValues'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: 'fromDuty'" + ] + } + ], + "source": [ + "if params['fromDuty']:\n", + " frequency = params['frequency']\n", + " duty = params['duty']\n", + "else:\n", + " assert params['fromValues']\n", + " frequency = 1.0 / (params['pulse_width'] + params['pulse_delay'])\n", + " duty = params['pulse_width'] / (params['pulse_width'] + params['pulse_delay'])\n", + "\n", + "if params['fromLength']:\n", + " duration = params['length']\n", + "else:\n", + " assert params['fromRepeats']\n", + " if params['fromValues']:\n", + " duration = (params['pulse_width'] + params['pulse_delay']) * params['repeats']\n", + " else:\n", + " assert params['fromDuty']\n", + " duration = (1.0 / frequency) * params['repeats']\n", + "\n", + "if params['isClean']:\n", + " pulse, t = square_pulse(sampling_rate, duration, frequency, duty)\n", + "else:\n", + " assert params['isShatter']\n", + " pulse, t = shatter_pulse(sampling_rate, duration, frequency, duty, params['shatter_frequency'],\n", + " params['shatter_duty'])\n", + "print(pulse.shape)\n", + "# Attach onset and offset\n", + "onset = np.zeros(int(sampling_rate * params['onset']))\n", + "offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + "pulse = np.hstack((onset, pulse, offset))\n", + "\n", + "total_length = round(duration + params['onset'] + params['offset'], 10) # N.B. Have to round here due to floating point representation problem\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(2000,) (44000,) (2000,)\n" + ] + } + ], + "source": [ + "print(onset.shape, pulse.shape, offset.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2.2\n" + ] + } + ], + "source": [ + "print(total_length)" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/warnert/miniconda3/envs/local/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning: object of type cannot be safely interpreted as an integer.\n", + " \"\"\"Entry point for launching an IPython kernel.\n" + ] + } + ], + "source": [ + "output =pulse, np.linspace(0, total_length, total_length*sampling_rate)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.plot(test[0])\n", + "plt.plot(plume)\n", + "np.save(os.path.join('/Users/warnert/Documents/GitHub/PulseBoy', 'test.npy'), plume)" + ] + }, + { + "cell_type": "code", + "execution_count": 169, + "metadata": {}, + "outputs": [], + "source": [ + "retest = np.load(os.path.join('/Users/warnert/Documents/GitHub/PulseBoy', 'test.npy'))" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "metadata": {}, + "outputs": [], + "source": [ + "params = {'onset': 0.0, 'offset':0.0, 'num_of_bins':8, 'bin_size':0.05,'value_to_binarise':256}" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "metadata": {}, + "outputs": [], + "source": [ + "def binary_pulse(sampling_rate, params):\n", + " '''\n", + " Creates a pulse from a value passed to it. Value should be less than the maximum \n", + " '''\n", + " binary = params['value_to_binarise']\n", + " \n", + " assert binary >= 0, 'Binary minimum should be zero'\n", + " assert binary <= 2**params['num_of_bins'] - 1, 'Binary maximum should be less than %s' % str(2**params['num_of_bins'])\n", + " bin_width = params['bin_size']*sampling_rate\n", + " binned = bin(binary)[2:]\n", + " while len(binned) < params['num_of_bins']:\n", + " binned = '0' + binned\n", + " bin_output = []\n", + " print(binned, bin_width)\n", + " onset = np.zeros(int(sampling_rate * params['onset']))\n", + " offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + " \n", + " \n", + " bin_pulse = [int(i) for i in binned for j in range(int(bin_width))]\n", + " total_length = round(params['onset'] + params['offset'] + len(bin_pulse)/sampling_rate, 10)\n", + " return np.hstack((onset, bin_pulse, offset)), np.linspace(0, total_length, total_length * sampling_rate)\n", + "\n", + " \n", + "#resampled = signal.resample(binary, int(len(binary) * (sampling_rate / params['data_fs'])))\n", + " \n", + "# onset = np.zeros(int(sampling_rate * params['onset']))\n", + "# offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + "# total_length = round(params['onset'] + params['offset'] + len(resampled)/sampling_rate, 10)\n", + "# return np.hstack((onset, resampled, offset)), np.linspace(0, total_length, total_length * sampling_rate)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "metadata": {}, + "outputs": [ + { + "ename": "AssertionError", + "evalue": "Binary maximum should be less than 256", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mbin_pulse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbinary_pulse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20000\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbin_pulse\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbin_pulse\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mbinary_pulse\u001b[0;34m(sampling_rate, params)\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mbinary\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Binary minimum should be zero'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0;32massert\u001b[0m \u001b[0mbinary\u001b[0m \u001b[0;34m<=\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'num_of_bins'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Binary maximum should be less than %s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'num_of_bins'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 9\u001b[0m \u001b[0mbin_width\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'bin_size'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0msampling_rate\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0mbinned\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbinary\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAssertionError\u001b[0m: Binary maximum should be less than 256" + ] + } + ], + "source": [ + "bin_pulse = binary_pulse(20000, params)\n", + "plt.plot(bin_pulse[1], bin_pulse[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 177, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.plot(np.arange(0, len(full_pulse)/20000, 1/20000), full_pulse)\n", + "for i in range(255):\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 200, + "metadata": {}, + "outputs": [], + "source": [ + "def full_binary_sequence(sampling_rate, params):\n", + " \n", + " \n", + " bin_width = params['bin_size']*sampling_rate\n", + " \n", + " full_pulse = []\n", + " for i in range(2**num_of_bins):\n", + " bin_width = params['bin_size']*sampling_rate\n", + " binary = bin(i)[2:]\n", + " #print(binary)\n", + "\n", + " while len(binary) < num_of_bins:\n", + " binary = '0'+binary\n", + " bin_pulse = [int(i) for i in binary for j in range(int(bin_width))]\n", + " #print(bin_pulse)\n", + "\n", + " full_pulse.extend(bin_pulse)\n", + "\n", + " \n", + " onset = np.zeros(int(sampling_rate * params['onset']))\n", + " offset = np.zeros(int(sampling_rate * params['offset']))\n", + "\n", + " \n", + " \n", + " \n", + " total_length = round(params['onset'] + params['offset'] + len(full_pulse)/sampling_rate, 10)\n", + " return np.hstack((onset, full_pulse, offset)), np.linspace(0, total_length, total_length * sampling_rate)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 201, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/warnert/miniconda3/envs/local/lib/python3.7/site-packages/ipykernel_launcher.py:27: DeprecationWarning: object of type cannot be safely interpreted as an integer.\n" + ] + } + ], + "source": [ + "test = full_binary_sequence(20000, params)" + ] + }, + { + "cell_type": "code", + "execution_count": 203, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0\n", + "0.0\n", + "0.0\n", + "0.0\n" + ] + } + ], + "source": [ + "fig, ax = plt.subplots(5, 1, sharex=True)\n", + "avg_chans = []\n", + "for i in range(4):\n", + " chn_starts = plume_starts[i::10]\n", + " avg_chan = np.zeros(50000,)\n", + " print(avg_chan[0])\n", + " for j in chn_starts:\n", + " ax[i].plot(flow_baselined[j:j+50000], color='gray')\n", + " avg_chan = [i[0]+j for i, j in zip(flow_baselined[j:j+50000], avg_chan)]\n", + " avg_chan= [i/len(chn_starts) for i in avg_chan]\n", + " ax[i].plot(avg_chan)\n", + " ax[4].plot(avg_chan)\n", + " avg_chans.append(avg_chan)\n", + "ax[0].set_title('Channel plumes')\n", + "ax[4].set_title('Avg plumes')\n", + "plt.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0.0\n", + "0.0\n", + "0.0\n", + "0.0\n" + ] + } + ], + "source": [ + "fig, ax = plt.subplots(5, 1, sharex=True)\n", + "avg_anti_chans = []\n", + "for i in range(4):\n", + " chn_starts = plume_starts[i+6::10]\n", + " avg_chan = np.zeros(50000,)\n", + " print(avg_chan[0])\n", + " for j in chn_starts:\n", + " ax[i].plot(flow_baselined[j:j+50000], color='gray')\n", + " avg_chan = [i[0]+j for i, j in zip(flow_baselined[j:j+50000], avg_chan)]\n", + " avg_chan= [i/len(chn_starts) for i in avg_chan]\n", + " ax[i].plot(avg_chan)\n", + " ax[4].plot(avg_chan)\n", + " avg_anti_chans.append(avg_chan)\n", + "ax[0].set_title('Channel anti plumes')\n", + "ax[4].set_title('Avg anti plumes')\n", + "plt.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": {}, + "outputs": [ + { + "data": { + "application/javascript": [ + "/* Put everything inside the global mpl namespace */\n", + "window.mpl = {};\n", + "\n", + "\n", + "mpl.get_websocket_type = function() {\n", + " if (typeof(WebSocket) !== 'undefined') {\n", + " return WebSocket;\n", + " } else if (typeof(MozWebSocket) !== 'undefined') {\n", + " return MozWebSocket;\n", + " } else {\n", + " alert('Your browser does not have WebSocket support.' +\n", + " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", + " 'Firefox 4 and 5 are also supported but you ' +\n", + " 'have to enable WebSockets in about:config.');\n", + " };\n", + "}\n", + "\n", + "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", + " this.id = figure_id;\n", + "\n", + " this.ws = websocket;\n", + "\n", + " this.supports_binary = (this.ws.binaryType != undefined);\n", + "\n", + " if (!this.supports_binary) {\n", + " var warnings = document.getElementById(\"mpl-warnings\");\n", + " if (warnings) {\n", + " warnings.style.display = 'block';\n", + " warnings.textContent = (\n", + " \"This browser does not support binary websocket messages. \" +\n", + " \"Performance may be slow.\");\n", + " }\n", + " }\n", + "\n", + " this.imageObj = new Image();\n", + "\n", + " this.context = undefined;\n", + " this.message = undefined;\n", + " this.canvas = undefined;\n", + " this.rubberband_canvas = undefined;\n", + " this.rubberband_context = undefined;\n", + " this.format_dropdown = undefined;\n", + "\n", + " this.image_mode = 'full';\n", + "\n", + " this.root = $('
');\n", + " this._root_extra_style(this.root)\n", + " this.root.attr('style', 'display: inline-block');\n", + "\n", + " $(parent_element).append(this.root);\n", + "\n", + " this._init_header(this);\n", + " this._init_canvas(this);\n", + " this._init_toolbar(this);\n", + "\n", + " var fig = this;\n", + "\n", + " this.waiting = false;\n", + "\n", + " this.ws.onopen = function () {\n", + " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", + " fig.send_message(\"send_image_mode\", {});\n", + " if (mpl.ratio != 1) {\n", + " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", + " }\n", + " fig.send_message(\"refresh\", {});\n", + " }\n", + "\n", + " this.imageObj.onload = function() {\n", + " if (fig.image_mode == 'full') {\n", + " // Full images could contain transparency (where diff images\n", + " // almost always do), so we need to clear the canvas so that\n", + " // there is no ghosting.\n", + " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", + " }\n", + " fig.context.drawImage(fig.imageObj, 0, 0);\n", + " };\n", + "\n", + " this.imageObj.onunload = function() {\n", + " fig.ws.close();\n", + " }\n", + "\n", + " this.ws.onmessage = this._make_on_message_function(this);\n", + "\n", + " this.ondownload = ondownload;\n", + "}\n", + "\n", + "mpl.figure.prototype._init_header = function() {\n", + " var titlebar = $(\n", + " '
');\n", + " var titletext = $(\n", + " '
');\n", + " titlebar.append(titletext)\n", + " this.root.append(titlebar);\n", + " this.header = titletext[0];\n", + "}\n", + "\n", + "\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._init_canvas = function() {\n", + " var fig = this;\n", + "\n", + " var canvas_div = $('
');\n", + "\n", + " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", + "\n", + " function canvas_keyboard_event(event) {\n", + " return fig.key_event(event, event['data']);\n", + " }\n", + "\n", + " canvas_div.keydown('key_press', canvas_keyboard_event);\n", + " canvas_div.keyup('key_release', canvas_keyboard_event);\n", + " this.canvas_div = canvas_div\n", + " this._canvas_extra_style(canvas_div)\n", + " this.root.append(canvas_div);\n", + "\n", + " var canvas = $('');\n", + " canvas.addClass('mpl-canvas');\n", + " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", + "\n", + " this.canvas = canvas[0];\n", + " this.context = canvas[0].getContext(\"2d\");\n", + "\n", + " var backingStore = this.context.backingStorePixelRatio ||\n", + "\tthis.context.webkitBackingStorePixelRatio ||\n", + "\tthis.context.mozBackingStorePixelRatio ||\n", + "\tthis.context.msBackingStorePixelRatio ||\n", + "\tthis.context.oBackingStorePixelRatio ||\n", + "\tthis.context.backingStorePixelRatio || 1;\n", + "\n", + " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", + "\n", + " var rubberband = $('');\n", + " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", + "\n", + " var pass_mouse_events = true;\n", + "\n", + " canvas_div.resizable({\n", + " start: function(event, ui) {\n", + " pass_mouse_events = false;\n", + " },\n", + " resize: function(event, ui) {\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " stop: function(event, ui) {\n", + " pass_mouse_events = true;\n", + " fig.request_resize(ui.size.width, ui.size.height);\n", + " },\n", + " });\n", + "\n", + " function mouse_event_fn(event) {\n", + " if (pass_mouse_events)\n", + " return fig.mouse_event(event, event['data']);\n", + " }\n", + "\n", + " rubberband.mousedown('button_press', mouse_event_fn);\n", + " rubberband.mouseup('button_release', mouse_event_fn);\n", + " // Throttle sequential mouse events to 1 every 20ms.\n", + " rubberband.mousemove('motion_notify', mouse_event_fn);\n", + "\n", + " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", + " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", + "\n", + " canvas_div.on(\"wheel\", function (event) {\n", + " event = event.originalEvent;\n", + " event['data'] = 'scroll'\n", + " if (event.deltaY < 0) {\n", + " event.step = 1;\n", + " } else {\n", + " event.step = -1;\n", + " }\n", + " mouse_event_fn(event);\n", + " });\n", + "\n", + " canvas_div.append(canvas);\n", + " canvas_div.append(rubberband);\n", + "\n", + " this.rubberband = rubberband;\n", + " this.rubberband_canvas = rubberband[0];\n", + " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", + " this.rubberband_context.strokeStyle = \"#000000\";\n", + "\n", + " this._resize_canvas = function(width, height) {\n", + " // Keep the size of the canvas, canvas container, and rubber band\n", + " // canvas in synch.\n", + " canvas_div.css('width', width)\n", + " canvas_div.css('height', height)\n", + "\n", + " canvas.attr('width', width * mpl.ratio);\n", + " canvas.attr('height', height * mpl.ratio);\n", + " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", + "\n", + " rubberband.attr('width', width);\n", + " rubberband.attr('height', height);\n", + " }\n", + "\n", + " // Set the figure to an initial 600x600px, this will subsequently be updated\n", + " // upon first draw.\n", + " this._resize_canvas(600, 600);\n", + "\n", + " // Disable right mouse context menu.\n", + " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", + " return false;\n", + " });\n", + "\n", + " function set_focus () {\n", + " canvas.focus();\n", + " canvas_div.focus();\n", + " }\n", + "\n", + " window.setTimeout(set_focus, 100);\n", + "}\n", + "\n", + "mpl.figure.prototype._init_toolbar = function() {\n", + " var fig = this;\n", + "\n", + " var nav_element = $('
')\n", + " nav_element.attr('style', 'width: 100%');\n", + " this.root.append(nav_element);\n", + "\n", + " // Define a callback function for later on.\n", + " function toolbar_event(event) {\n", + " return fig.toolbar_button_onclick(event['data']);\n", + " }\n", + " function toolbar_mouse_event(event) {\n", + " return fig.toolbar_button_onmouseover(event['data']);\n", + " }\n", + "\n", + " for(var toolbar_ind in mpl.toolbar_items) {\n", + " var name = mpl.toolbar_items[toolbar_ind][0];\n", + " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", + " var image = mpl.toolbar_items[toolbar_ind][2];\n", + " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", + "\n", + " if (!name) {\n", + " // put a spacer in here.\n", + " continue;\n", + " }\n", + " var button = $('');\n", + " button.click(method_name, toolbar_event);\n", + " button.mouseover(tooltip, toolbar_mouse_event);\n", + " nav_element.append(button);\n", + " }\n", + "\n", + " // Add the status bar.\n", + " var status_bar = $('');\n", + " nav_element.append(status_bar);\n", + " this.message = status_bar[0];\n", + "\n", + " // Add the close button to the window.\n", + " var buttongrp = $('
');\n", + " var button = $('');\n", + " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", + " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", + " buttongrp.append(button);\n", + " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", + " titlebar.prepend(buttongrp);\n", + "}\n", + "\n", + "mpl.figure.prototype._root_extra_style = function(el){\n", + " var fig = this\n", + " el.on(\"remove\", function(){\n", + "\tfig.close_ws(fig, {});\n", + " });\n", + "}\n", + "\n", + "mpl.figure.prototype._canvas_extra_style = function(el){\n", + " // this is important to make the div 'focusable\n", + " el.attr('tabindex', 0)\n", + " // reach out to IPython and tell the keyboard manager to turn it's self\n", + " // off when our div gets focus\n", + "\n", + " // location in version 3\n", + " if (IPython.notebook.keyboard_manager) {\n", + " IPython.notebook.keyboard_manager.register_events(el);\n", + " }\n", + " else {\n", + " // location in version 2\n", + " IPython.keyboard_manager.register_events(el);\n", + " }\n", + "\n", + "}\n", + "\n", + "mpl.figure.prototype._key_event_extra = function(event, name) {\n", + " var manager = IPython.notebook.keyboard_manager;\n", + " if (!manager)\n", + " manager = IPython.keyboard_manager;\n", + "\n", + " // Check for shift+enter\n", + " if (event.shiftKey && event.which == 13) {\n", + " this.canvas_div.blur();\n", + " event.shiftKey = false;\n", + " // Send a \"J\" for go to next cell\n", + " event.which = 74;\n", + " event.keyCode = 74;\n", + " manager.command_mode();\n", + " manager.handle_keydown(event);\n", + " }\n", + "}\n", + "\n", + "mpl.figure.prototype.handle_save = function(fig, msg) {\n", + " fig.ondownload(fig, null);\n", + "}\n", + "\n", + "\n", + "mpl.find_output_cell = function(html_output) {\n", + " // Return the cell and output element which can be found *uniquely* in the notebook.\n", + " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", + " // IPython event is triggered only after the cells have been serialised, which for\n", + " // our purposes (turning an active figure into a static one), is too late.\n", + " var cells = IPython.notebook.get_cells();\n", + " var ncells = cells.length;\n", + " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", + " data = data.data;\n", + " }\n", + " if (data['text/html'] == html_output) {\n", + " return [cell, data, j];\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n", + "\n", + "// Register the function which deals with the matplotlib target/channel.\n", + "// The kernel may be null if the page has been refreshed.\n", + "if (IPython.notebook.kernel != null) {\n", + " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", + "}\n" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "for i, j in zip(avg_chans, avg_anti_chans):\n", + " med_i = np.median(i)\n", + " plt.plot(i/med_i, color='r')\n", + " med_j = np.median(j)\n", + " plt.plot([1-k/med_j for k in j], color='b')" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[-0.00557857 -0.00369847 -0.00447263 ... 0.29747743 0.29769862\n", + " 0.2979751 ]\n", + "50000\n", + "[-0.00206818 -0.00280337 -0.00348605 ... 0.20105517 0.2007926\n", + " 0.20066131]\n", + "50000\n", + "[-0.00440357 -0.00531314 -0.00597464 ... 0.18897464 0.19470763\n", + " 0.19377051]\n", + "50000\n", + "[-0.0024581 -0.00346786 -0.00424003 ... 0.2280057 0.22750081\n", + " 0.22681774]\n", + "50000\n" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + } + ], + "source": [] + }, + { + "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.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/README.md b/README.md index 43b6afd..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,2 +0,0 @@ -# PulseBoy -GUI tool for controlling NI pulse trains diff --git a/TestData/2_binary_pulses.trialbank b/TestData/2_binary_pulses.trialbank new file mode 100644 index 0000000..bdf06a4 Binary files /dev/null and b/TestData/2_binary_pulses.trialbank differ diff --git a/TestData/test.npy b/TestData/test.npy new file mode 100644 index 0000000..76dc0f7 Binary files /dev/null and b/TestData/test.npy differ diff --git a/TestData/testbinarytrialbank.trialbank b/TestData/testbinarytrialbank.trialbank new file mode 100644 index 0000000..789fe92 Binary files /dev/null and b/TestData/testbinarytrialbank.trialbank differ diff --git a/TestData/testbinarytrialbank_0.005_bin_size_10_bin.trialbank b/TestData/testbinarytrialbank_0.005_bin_size_10_bin.trialbank new file mode 100644 index 0000000..3dbc4a4 Binary files /dev/null and b/TestData/testbinarytrialbank_0.005_bin_size_10_bin.trialbank differ diff --git a/TestData/testbinarytrialbank_no_onsets.trialbank b/TestData/testbinarytrialbank_no_onsets.trialbank new file mode 100644 index 0000000..cedd434 Binary files /dev/null and b/TestData/testbinarytrialbank_no_onsets.trialbank differ diff --git a/TestData/testbinarytrialbank_no_onsets2.trialbank b/TestData/testbinarytrialbank_no_onsets2.trialbank new file mode 100644 index 0000000..eb727b2 Binary files /dev/null and b/TestData/testbinarytrialbank_no_onsets2.trialbank differ diff --git a/TestData/testbinarytrialbank_no_onsets3.trialbank b/TestData/testbinarytrialbank_no_onsets3.trialbank new file mode 100644 index 0000000..08c14c2 Binary files /dev/null and b/TestData/testbinarytrialbank_no_onsets3.trialbank differ diff --git a/TestData/testbinarytrialbank_shatter_small_onset.trialbank b/TestData/testbinarytrialbank_shatter_small_onset.trialbank new file mode 100644 index 0000000..6760aae Binary files /dev/null and b/TestData/testbinarytrialbank_shatter_small_onset.trialbank differ diff --git a/TestData/testbinarytrialbank_shatter_small_onset_0.005_bin_size.trialbank b/TestData/testbinarytrialbank_shatter_small_onset_0.005_bin_size.trialbank new file mode 100644 index 0000000..31c1435 Binary files /dev/null and b/TestData/testbinarytrialbank_shatter_small_onset_0.005_bin_size.trialbank differ diff --git a/TestData/testbinarytrialbank_shatter_small_onset_indicator_chan.trialbank b/TestData/testbinarytrialbank_shatter_small_onset_indicator_chan.trialbank new file mode 100644 index 0000000..5714e6f Binary files /dev/null and b/TestData/testbinarytrialbank_shatter_small_onset_indicator_chan.trialbank differ diff --git a/TestData/testbinarytrialbank_small_onset.trialbank b/TestData/testbinarytrialbank_small_onset.trialbank new file mode 100644 index 0000000..9b21126 Binary files /dev/null and b/TestData/testbinarytrialbank_small_onset.trialbank differ diff --git a/UI/BinaryValveWidget.ui b/UI/BinaryValveWidget.ui new file mode 100644 index 0000000..d5898d9 --- /dev/null +++ b/UI/BinaryValveWidget.ui @@ -0,0 +1,161 @@ + + + Form + + + + 0 + 0 + 905 + 113 + + + + + 0 + 0 + + + + + Lucida Console + + + + Form + + + + + + Offset + + + + + + + 0.05 + + + + + + + Shatter Pulse + + + true + + + + + + + Bin size + + + + + + + 8 + + + + + + + Number of bins + + + + + + + 1 + + + + + + + 2 + + + + + + + 0.1 + + + + + + + 0.1 + + + + + + + - + + + + + + + 500 + + + + + + + Value to binarise + + + + + + + Onset + + + + + + + Shatter (Hz) + + + + + + + Qt::Horizontal + + + + + + + 0.5 + + + + + + + Shatter Duty + + + + + + + + diff --git a/UI/NoiseValveWidget.ui b/UI/NoiseValveWidget.ui index c2e187e..7ac3f7c 100644 --- a/UI/NoiseValveWidget.ui +++ b/UI/NoiseValveWidget.ui @@ -6,7 +6,7 @@ 0 0 - 667 + 681 76 @@ -177,6 +177,13 @@ + + + + 1 + + + diff --git a/UI/PlumeValveWidget.ui b/UI/PlumeValveWidget.ui index 72be836..434b8c3 100644 --- a/UI/PlumeValveWidget.ui +++ b/UI/PlumeValveWidget.ui @@ -26,100 +26,107 @@ - + - 10000 + - - - + + - 0.1 + Data Sampling Rate - + + + + 1.0 + + + + + + + Qt::Horizontal + + + + Offset - - + + - Onset + Target Max. - + 0.1 - - + + - Shatter (Hz) + 0.1 - - + + - 500 + Onset - - + + - - + 10000 - + - Open Plume Data + Shatter (Hz) - - + + - - - + + - Data Sampling Rate + 500 - - + + - 1.0 + Open Plume Data - - + + - Target Max. - - - - - - - Qt::Horizontal + 1 diff --git a/UI/PulseBoyUI_v2.py b/UI/PulseBoyUI_v2.py new file mode 100644 index 0000000..f28308d --- /dev/null +++ b/UI/PulseBoyUI_v2.py @@ -0,0 +1,513 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'PulseBoyUI_v2.ui' +# +# Created by: PyQt5 UI code generator 5.9 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(1229, 809) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) + self.gridLayout.setObjectName("gridLayout") + self.label = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setFamily("Lucida Console") + font.setPointSize(12) + font.setBold(True) + font.setWeight(75) + self.label.setFont(font) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 0, 1, 1) + self.label_8 = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setFamily("Lucida Console") + font.setPointSize(12) + font.setBold(True) + font.setWeight(75) + self.label_8.setFont(font) + self.label_8.setObjectName("label_8") + self.gridLayout.addWidget(self.label_8, 2, 0, 1, 1) + self.valveBankScrollArea = QtWidgets.QScrollArea(self.centralwidget) + self.valveBankScrollArea.setWidgetResizable(True) + self.valveBankScrollArea.setObjectName("valveBankScrollArea") + self.valveBankContents = QtWidgets.QWidget() + self.valveBankContents.setGeometry(QtCore.QRect(0, 0, 18, 348)) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.valveBankContents.sizePolicy().hasHeightForWidth()) + self.valveBankContents.setSizePolicy(sizePolicy) + self.valveBankContents.setObjectName("valveBankContents") + self.valveBankLayout = QtWidgets.QVBoxLayout(self.valveBankContents) + self.valveBankLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) + self.valveBankLayout.setContentsMargins(0, 0, 0, 0) + self.valveBankLayout.setObjectName("valveBankLayout") + self.valveBankScrollArea.setWidget(self.valveBankContents) + self.gridLayout.addWidget(self.valveBankScrollArea, 1, 0, 1, 1) + self.viewWidgetTab = QtWidgets.QTabWidget(self.centralwidget) + self.viewWidgetTab.setObjectName("viewWidgetTab") + self.pulseTab = QtWidgets.QWidget() + self.pulseTab.setObjectName("pulseTab") + self.gridLayout_5 = QtWidgets.QGridLayout(self.pulseTab) + self.gridLayout_5.setObjectName("gridLayout_5") + self.graphicsView = PlotWidget(self.pulseTab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth()) + self.graphicsView.setSizePolicy(sizePolicy) + self.graphicsView.setObjectName("graphicsView") + self.gridLayout_5.addWidget(self.graphicsView, 0, 0, 1, 1) + self.viewWidgetTab.addTab(self.pulseTab, "") + self.analogDataTab = QtWidgets.QWidget() + self.analogDataTab.setObjectName("analogDataTab") + self.gridLayout_6 = QtWidgets.QGridLayout(self.analogDataTab) + self.gridLayout_6.setObjectName("gridLayout_6") + self.analogView = PlotWidget(self.analogDataTab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.analogView.sizePolicy().hasHeightForWidth()) + self.analogView.setSizePolicy(sizePolicy) + self.analogView.setObjectName("analogView") + self.gridLayout_6.addWidget(self.analogView, 0, 0, 1, 1) + self.viewWidgetTab.addTab(self.analogDataTab, "") + self.gridLayout.addWidget(self.viewWidgetTab, 3, 2, 1, 1) + self.trialBankTable = QtWidgets.QTableView(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.trialBankTable.sizePolicy().hasHeightForWidth()) + self.trialBankTable.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + self.trialBankTable.setFont(font) + self.trialBankTable.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.trialBankTable.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) + self.trialBankTable.setObjectName("trialBankTable") + self.trialBankTable.horizontalHeader().setStretchLastSection(False) + self.gridLayout.addWidget(self.trialBankTable, 3, 0, 1, 1) + self.setupTabs = QtWidgets.QTabWidget(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.setupTabs.sizePolicy().hasHeightForWidth()) + self.setupTabs.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + font.setPointSize(10) + self.setupTabs.setFont(font) + self.setupTabs.setObjectName("setupTabs") + self.hardwareTab = QtWidgets.QWidget() + self.hardwareTab.setObjectName("hardwareTab") + self.gridLayout_2 = QtWidgets.QGridLayout(self.hardwareTab) + self.gridLayout_2.setObjectName("gridLayout_2") + self.label_2 = QtWidgets.QLabel(self.hardwareTab) + self.label_2.setObjectName("label_2") + self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1) + self.analogInDevEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.analogInDevEdit.setObjectName("analogInDevEdit") + self.gridLayout_2.addWidget(self.analogInDevEdit, 3, 0, 1, 1) + self.digitalChannelsEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.digitalChannelsEdit.setObjectName("digitalChannelsEdit") + self.gridLayout_2.addWidget(self.digitalChannelsEdit, 1, 1, 1, 1) + self.digitalOutDevEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.digitalOutDevEdit.setObjectName("digitalOutDevEdit") + self.gridLayout_2.addWidget(self.digitalOutDevEdit, 1, 0, 1, 1) + self.analogChannelsLabel = QtWidgets.QLabel(self.hardwareTab) + self.analogChannelsLabel.setObjectName("analogChannelsLabel") + self.gridLayout_2.addWidget(self.analogChannelsLabel, 2, 1, 1, 1) + self.analogChannelsEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.analogChannelsEdit.setObjectName("analogChannelsEdit") + self.gridLayout_2.addWidget(self.analogChannelsEdit, 3, 1, 1, 1) + self.label_5 = QtWidgets.QLabel(self.hardwareTab) + self.label_5.setObjectName("label_5") + self.gridLayout_2.addWidget(self.label_5, 6, 0, 1, 1) + self.label_11 = QtWidgets.QLabel(self.hardwareTab) + self.label_11.setObjectName("label_11") + self.gridLayout_2.addWidget(self.label_11, 4, 0, 1, 1) + self.syncClockEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.syncClockEdit.setObjectName("syncClockEdit") + self.gridLayout_2.addWidget(self.syncClockEdit, 5, 0, 1, 1) + self.label_4 = QtWidgets.QLabel(self.hardwareTab) + self.label_4.setObjectName("label_4") + self.gridLayout_2.addWidget(self.label_4, 0, 1, 1, 1) + self.sampRateEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.sampRateEdit.setObjectName("sampRateEdit") + self.gridLayout_2.addWidget(self.sampRateEdit, 7, 0, 1, 1) + self.label_3 = QtWidgets.QLabel(self.hardwareTab) + self.label_3.setObjectName("label_3") + self.gridLayout_2.addWidget(self.label_3, 2, 0, 1, 1) + spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_2.addItem(spacerItem, 8, 0, 1, 1) + self.label_9 = QtWidgets.QLabel(self.hardwareTab) + self.label_9.setObjectName("label_9") + self.gridLayout_2.addWidget(self.label_9, 4, 1, 1, 1) + self.triggerInEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.triggerInEdit.setObjectName("triggerInEdit") + self.gridLayout_2.addWidget(self.triggerInEdit, 5, 1, 1, 1) + self.setupTabs.addTab(self.hardwareTab, "") + self.globalParametersTab = QtWidgets.QWidget() + self.globalParametersTab.setObjectName("globalParametersTab") + self.gridLayout_3 = QtWidgets.QGridLayout(self.globalParametersTab) + self.gridLayout_3.setObjectName("gridLayout_3") + self.shuffleOffsetlineEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.shuffleOffsetlineEdit.setObjectName("shuffleOffsetlineEdit") + self.gridLayout_3.addWidget(self.shuffleOffsetlineEdit, 6, 0, 1, 1) + self.label_16 = QtWidgets.QLabel(self.globalParametersTab) + self.label_16.setObjectName("label_16") + self.gridLayout_3.addWidget(self.label_16, 2, 1, 1, 1) + self.shuffleGrouplineEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.shuffleGrouplineEdit.setObjectName("shuffleGrouplineEdit") + self.gridLayout_3.addWidget(self.shuffleGrouplineEdit, 6, 1, 1, 1) + self.invertBlankcheckBox = QtWidgets.QCheckBox(self.globalParametersTab) + self.invertBlankcheckBox.setObjectName("invertBlankcheckBox") + self.gridLayout_3.addWidget(self.invertBlankcheckBox, 3, 0, 1, 1) + self.label_21 = QtWidgets.QLabel(self.globalParametersTab) + self.label_21.setObjectName("label_21") + self.gridLayout_3.addWidget(self.label_21, 5, 0, 1, 1) + self.blankValveEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.blankValveEdit.setObjectName("blankValveEdit") + self.gridLayout_3.addWidget(self.blankValveEdit, 3, 1, 1, 1) + spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_3.addItem(spacerItem1, 4, 0, 1, 1) + self.globalOnsetEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.globalOnsetEdit.setObjectName("globalOnsetEdit") + self.gridLayout_3.addWidget(self.globalOnsetEdit, 1, 0, 1, 1) + self.label_7 = QtWidgets.QLabel(self.globalParametersTab) + self.label_7.setObjectName("label_7") + self.gridLayout_3.addWidget(self.label_7, 0, 1, 1, 1) + self.globalOffsetEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.globalOffsetEdit.setObjectName("globalOffsetEdit") + self.gridLayout_3.addWidget(self.globalOffsetEdit, 1, 1, 1, 1) + spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_3.addItem(spacerItem2, 7, 0, 1, 1) + self.label_6 = QtWidgets.QLabel(self.globalParametersTab) + self.label_6.setObjectName("label_6") + self.gridLayout_3.addWidget(self.label_6, 0, 0, 1, 1) + self.label_20 = QtWidgets.QLabel(self.globalParametersTab) + self.label_20.setObjectName("label_20") + self.gridLayout_3.addWidget(self.label_20, 5, 1, 1, 1) + self.setupTabs.addTab(self.globalParametersTab, "") + self.experimentSetupTab = QtWidgets.QWidget() + self.experimentSetupTab.setObjectName("experimentSetupTab") + self.gridLayout_4 = QtWidgets.QGridLayout(self.experimentSetupTab) + self.gridLayout_4.setObjectName("gridLayout_4") + self.addTrialButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.addTrialButton.setObjectName("addTrialButton") + self.gridLayout_4.addWidget(self.addTrialButton, 2, 0, 1, 1) + self.pauseQueueButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.pauseQueueButton.setObjectName("pauseQueueButton") + self.gridLayout_4.addWidget(self.pauseQueueButton, 8, 1, 1, 1) + self.stopQueueButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.stopQueueButton.setObjectName("stopQueueButton") + self.gridLayout_4.addWidget(self.stopQueueButton, 8, 2, 1, 1) + self.randomiseTrialsButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.randomiseTrialsButton.setObjectName("randomiseTrialsButton") + self.gridLayout_4.addWidget(self.randomiseTrialsButton, 7, 0, 1, 1) + self.updateTrialButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.updateTrialButton.setObjectName("updateTrialButton") + self.gridLayout_4.addWidget(self.updateTrialButton, 2, 1, 1, 1) + self.moveUpButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.moveUpButton.setObjectName("moveUpButton") + self.gridLayout_4.addWidget(self.moveUpButton, 3, 1, 1, 1) + self.startQueueFromSelectedButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.startQueueFromSelectedButton.setObjectName("startQueueFromSelectedButton") + self.gridLayout_4.addWidget(self.startQueueFromSelectedButton, 9, 1, 1, 1) + self.startQueueButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.startQueueButton.setObjectName("startQueueButton") + self.gridLayout_4.addWidget(self.startQueueButton, 8, 0, 1, 1) + self.addValveButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.addValveButton.setObjectName("addValveButton") + self.gridLayout_4.addWidget(self.addValveButton, 0, 0, 1, 1) + self.moveDownButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.moveDownButton.setObjectName("moveDownButton") + self.gridLayout_4.addWidget(self.moveDownButton, 3, 2, 1, 1) + self.triggerWaitCheckBox = QtWidgets.QCheckBox(self.experimentSetupTab) + self.triggerWaitCheckBox.setObjectName("triggerWaitCheckBox") + self.gridLayout_4.addWidget(self.triggerWaitCheckBox, 9, 2, 1, 1) + self.removeTrialButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.removeTrialButton.setObjectName("removeTrialButton") + self.gridLayout_4.addWidget(self.removeTrialButton, 2, 2, 1, 1) + self.trialNameEdit = QtWidgets.QLineEdit(self.experimentSetupTab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.trialNameEdit.sizePolicy().hasHeightForWidth()) + self.trialNameEdit.setSizePolicy(sizePolicy) + self.trialNameEdit.setObjectName("trialNameEdit") + self.gridLayout_4.addWidget(self.trialNameEdit, 3, 0, 1, 1) + spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_4.addItem(spacerItem3, 1, 0, 1, 1) + self.runSelectedButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.runSelectedButton.setObjectName("runSelectedButton") + self.gridLayout_4.addWidget(self.runSelectedButton, 9, 0, 1, 1) + self.valveTypeCombo = QtWidgets.QComboBox(self.experimentSetupTab) + self.valveTypeCombo.setObjectName("valveTypeCombo") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.gridLayout_4.addWidget(self.valveTypeCombo, 0, 1, 1, 1) + spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_4.addItem(spacerItem4, 4, 0, 1, 1) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.label_10 = QtWidgets.QLabel(self.experimentSetupTab) + self.label_10.setObjectName("label_10") + self.horizontalLayout.addWidget(self.label_10) + self.repeatsBox = QtWidgets.QSpinBox(self.experimentSetupTab) + self.repeatsBox.setProperty("value", 1) + self.repeatsBox.setObjectName("repeatsBox") + self.horizontalLayout.addWidget(self.repeatsBox) + self.gridLayout_4.addLayout(self.horizontalLayout, 7, 1, 1, 1) + self.shuffleRepeatsBox = QtWidgets.QCheckBox(self.experimentSetupTab) + self.shuffleRepeatsBox.setObjectName("shuffleRepeatsBox") + self.gridLayout_4.addWidget(self.shuffleRepeatsBox, 7, 2, 1, 1) + self.closeValvesButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.closeValvesButton.setObjectName("closeValvesButton") + self.gridLayout_4.addWidget(self.closeValvesButton, 0, 2, 1, 1) + self.setupTabs.addTab(self.experimentSetupTab, "") + self.dataExportTab = QtWidgets.QWidget() + self.dataExportTab.setObjectName("dataExportTab") + self.gridLayout_7 = QtWidgets.QGridLayout(self.dataExportTab) + self.gridLayout_7.setObjectName("gridLayout_7") + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.label_18 = QtWidgets.QLabel(self.dataExportTab) + self.label_18.setObjectName("label_18") + self.horizontalLayout_3.addWidget(self.label_18) + self.label_15 = QtWidgets.QLabel(self.dataExportTab) + self.label_15.setObjectName("label_15") + self.horizontalLayout_3.addWidget(self.label_15) + self.gridLayout_7.addLayout(self.horizontalLayout_3, 10, 1, 1, 1) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.saveTrialStartscheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.saveTrialStartscheckBox.setChecked(True) + self.saveTrialStartscheckBox.setObjectName("saveTrialStartscheckBox") + self.horizontalLayout_2.addWidget(self.saveTrialStartscheckBox) + self.saveCameraVideocheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.saveCameraVideocheckBox.setChecked(True) + self.saveCameraVideocheckBox.setObjectName("saveCameraVideocheckBox") + self.horizontalLayout_2.addWidget(self.saveCameraVideocheckBox) + self.gridLayout_7.addLayout(self.horizontalLayout_2, 9, 1, 1, 1) + self.horizontalLayout_7 = QtWidgets.QHBoxLayout() + self.horizontalLayout_7.setObjectName("horizontalLayout_7") + self.trialStartsSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.trialStartsSuffixEdit.setObjectName("trialStartsSuffixEdit") + self.horizontalLayout_7.addWidget(self.trialStartsSuffixEdit) + self.cameraSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.cameraSuffixEdit.setObjectName("cameraSuffixEdit") + self.horizontalLayout_7.addWidget(self.cameraSuffixEdit) + self.gridLayout_7.addLayout(self.horizontalLayout_7, 11, 1, 1, 1) + self.exportPathEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.exportPathEdit.setText("") + self.exportPathEdit.setObjectName("exportPathEdit") + self.gridLayout_7.addWidget(self.exportPathEdit, 3, 1, 1, 1) + self.horizontalLayout_6 = QtWidgets.QHBoxLayout() + self.horizontalLayout_6.setObjectName("horizontalLayout_6") + self.trialNameSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.trialNameSuffixEdit.setObjectName("trialNameSuffixEdit") + self.horizontalLayout_6.addWidget(self.trialNameSuffixEdit) + self.pulseSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.pulseSuffixEdit.setObjectName("pulseSuffixEdit") + self.horizontalLayout_6.addWidget(self.pulseSuffixEdit) + self.gridLayout_7.addLayout(self.horizontalLayout_6, 8, 1, 1, 1) + self.label_12 = QtWidgets.QLabel(self.dataExportTab) + self.label_12.setObjectName("label_12") + self.gridLayout_7.addWidget(self.label_12, 3, 0, 1, 1) + spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_7.addItem(spacerItem5, 2, 1, 1, 1) + spacerItem6 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_7.addItem(spacerItem6, 12, 1, 1, 1) + self.horizontalLayout_4 = QtWidgets.QHBoxLayout() + self.horizontalLayout_4.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) + self.horizontalLayout_4.setSpacing(6) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.trialNameCheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.trialNameCheckBox.setChecked(True) + self.trialNameCheckBox.setObjectName("trialNameCheckBox") + self.horizontalLayout_4.addWidget(self.trialNameCheckBox) + self.pulseCheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.pulseCheckBox.setObjectName("pulseCheckBox") + self.horizontalLayout_4.addWidget(self.pulseCheckBox) + self.gridLayout_7.addLayout(self.horizontalLayout_4, 5, 1, 1, 1) + self.horizontalLayout_5 = QtWidgets.QHBoxLayout() + self.horizontalLayout_5.setObjectName("horizontalLayout_5") + self.label_14 = QtWidgets.QLabel(self.dataExportTab) + self.label_14.setObjectName("label_14") + self.horizontalLayout_5.addWidget(self.label_14) + self.label_13 = QtWidgets.QLabel(self.dataExportTab) + self.label_13.setObjectName("label_13") + self.horizontalLayout_5.addWidget(self.label_13) + self.gridLayout_7.addLayout(self.horizontalLayout_5, 7, 1, 1, 1) + self.exportPathDirButton = QtWidgets.QPushButton(self.dataExportTab) + self.exportPathDirButton.setObjectName("exportPathDirButton") + self.gridLayout_7.addWidget(self.exportPathDirButton, 3, 2, 1, 1) + self.setupTabs.addTab(self.dataExportTab, "") + self.cameraTab = QtWidgets.QWidget() + self.cameraTab.setObjectName("cameraTab") + self.gridLayout_8 = QtWidgets.QGridLayout(self.cameraTab) + self.gridLayout_8.setObjectName("gridLayout_8") + spacerItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_8.addItem(spacerItem7, 3, 0, 1, 2) + spacerItem8 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_8.addItem(spacerItem8, 10, 0, 1, 2) + self.label_19 = QtWidgets.QLabel(self.cameraTab) + self.label_19.setObjectName("label_19") + self.gridLayout_8.addWidget(self.label_19, 5, 1, 1, 1) + self.cameraSaveIconBox = QtWidgets.QCheckBox(self.cameraTab) + self.cameraSaveIconBox.setChecked(True) + self.cameraSaveIconBox.setObjectName("cameraSaveIconBox") + self.gridLayout_8.addWidget(self.cameraSaveIconBox, 7, 0, 1, 1) + self.label_17 = QtWidgets.QLabel(self.cameraTab) + self.label_17.setObjectName("label_17") + self.gridLayout_8.addWidget(self.label_17, 5, 0, 1, 1) + self.cameraSaveIntervalEdit = QtWidgets.QLineEdit(self.cameraTab) + self.cameraSaveIntervalEdit.setObjectName("cameraSaveIntervalEdit") + self.gridLayout_8.addWidget(self.cameraSaveIntervalEdit, 6, 0, 1, 1) + self.numberCamerasEdit = QtWidgets.QLineEdit(self.cameraTab) + self.numberCamerasEdit.setObjectName("numberCamerasEdit") + self.gridLayout_8.addWidget(self.numberCamerasEdit, 6, 1, 1, 1) + self.launchCameraButton = QtWidgets.QPushButton(self.cameraTab) + self.launchCameraButton.setObjectName("launchCameraButton") + self.gridLayout_8.addWidget(self.launchCameraButton, 4, 0, 1, 2) + self.blackAndWhiteBox = QtWidgets.QCheckBox(self.cameraTab) + self.blackAndWhiteBox.setChecked(True) + self.blackAndWhiteBox.setObjectName("blackAndWhiteBox") + self.gridLayout_8.addWidget(self.blackAndWhiteBox, 7, 1, 1, 1) + self.showStreamcheckBox = QtWidgets.QCheckBox(self.cameraTab) + self.showStreamcheckBox.setChecked(True) + self.showStreamcheckBox.setObjectName("showStreamcheckBox") + self.gridLayout_8.addWidget(self.showStreamcheckBox, 8, 1, 1, 1) + self.closeCamerasButton = QtWidgets.QPushButton(self.cameraTab) + self.closeCamerasButton.setObjectName("closeCamerasButton") + self.gridLayout_8.addWidget(self.closeCamerasButton, 8, 0, 1, 1) + self.updateCamerasButton = QtWidgets.QPushButton(self.cameraTab) + self.updateCamerasButton.setObjectName("updateCamerasButton") + self.gridLayout_8.addWidget(self.updateCamerasButton, 9, 0, 1, 1) + self.setupTabs.addTab(self.cameraTab, "") + self.gridLayout.addWidget(self.setupTabs, 1, 2, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtWidgets.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1229, 21)) + self.menubar.setObjectName("menubar") + self.menuFile = QtWidgets.QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtWidgets.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.actionSave = QtWidgets.QAction(MainWindow) + self.actionSave.setObjectName("actionSave") + self.actionLoad = QtWidgets.QAction(MainWindow) + self.actionLoad.setObjectName("actionLoad") + self.actionSave_Configuration = QtWidgets.QAction(MainWindow) + self.actionSave_Configuration.setObjectName("actionSave_Configuration") + self.menuFile.addAction(self.actionSave) + self.menuFile.addAction(self.actionLoad) + self.menuFile.addAction(self.actionSave_Configuration) + self.menubar.addAction(self.menuFile.menuAction()) + + self.retranslateUi(MainWindow) + self.viewWidgetTab.setCurrentIndex(0) + self.setupTabs.setCurrentIndex(1) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) + self.label.setText(_translate("MainWindow", "Valve Bank")) + self.label_8.setText(_translate("MainWindow", "Trial Bank")) + self.viewWidgetTab.setTabText(self.viewWidgetTab.indexOf(self.pulseTab), _translate("MainWindow", "Pulses")) + self.viewWidgetTab.setTabText(self.viewWidgetTab.indexOf(self.analogDataTab), _translate("MainWindow", "Analog Data")) + self.label_2.setText(_translate("MainWindow", "Digital Out Device")) + self.analogInDevEdit.setText(_translate("MainWindow", "dev2/ai4")) + self.digitalChannelsEdit.setText(_translate("MainWindow", "4")) + self.digitalOutDevEdit.setText(_translate("MainWindow", "dev2/port0/line0:3")) + self.analogChannelsLabel.setText(_translate("MainWindow", "Analog Channels")) + self.analogChannelsEdit.setText(_translate("MainWindow", "1")) + self.label_5.setText(_translate("MainWindow", "Sampling Rate")) + self.label_11.setText(_translate("MainWindow", "Synchronisation Clock")) + self.syncClockEdit.setText(_translate("MainWindow", "/dev2/ai/SampleClock")) + self.label_4.setText(_translate("MainWindow", "Digital Channels")) + self.sampRateEdit.setText(_translate("MainWindow", "20000")) + self.label_3.setText(_translate("MainWindow", "Analog Input Device")) + self.label_9.setText(_translate("MainWindow", "Trigger In Source")) + self.triggerInEdit.setText(_translate("MainWindow", "cDAQ1Mod2/ai3")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.hardwareTab), _translate("MainWindow", "Hardware")) + self.shuffleOffsetlineEdit.setText(_translate("MainWindow", "0")) + self.label_16.setText(_translate("MainWindow", "Blank valve indexes (0 indexing)")) + self.shuffleGrouplineEdit.setText(_translate("MainWindow", "1")) + self.invertBlankcheckBox.setText(_translate("MainWindow", "Invert blank off state")) + self.label_21.setText(_translate("MainWindow", "Shuffle offset")) + self.globalOnsetEdit.setText(_translate("MainWindow", "0")) + self.label_7.setText(_translate("MainWindow", "Offset")) + self.globalOffsetEdit.setText(_translate("MainWindow", "0")) + self.label_6.setText(_translate("MainWindow", "Onset")) + self.label_20.setText(_translate("MainWindow", "Shuffle group size")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.globalParametersTab), _translate("MainWindow", "Global Parameters")) + self.addTrialButton.setText(_translate("MainWindow", "Add To Trials")) + self.pauseQueueButton.setText(_translate("MainWindow", "Pause Queue")) + self.stopQueueButton.setText(_translate("MainWindow", "Stop Queue")) + self.randomiseTrialsButton.setText(_translate("MainWindow", "Randomise trials")) + self.updateTrialButton.setText(_translate("MainWindow", "Update Trial")) + self.moveUpButton.setText(_translate("MainWindow", "Move Up")) + self.startQueueFromSelectedButton.setText(_translate("MainWindow", "Start Queue from Selected")) + self.startQueueButton.setText(_translate("MainWindow", "Start Queue")) + self.addValveButton.setText(_translate("MainWindow", "Add Valve")) + self.moveDownButton.setText(_translate("MainWindow", "Move Down")) + self.triggerWaitCheckBox.setText(_translate("MainWindow", "Wait for trigger")) + self.removeTrialButton.setText(_translate("MainWindow", "Remove Trial")) + self.trialNameEdit.setText(_translate("MainWindow", "Trial Name")) + self.runSelectedButton.setText(_translate("MainWindow", "Run Selected")) + self.valveTypeCombo.setItemText(0, _translate("MainWindow", "Simple")) + self.valveTypeCombo.setItemText(1, _translate("MainWindow", "Binary")) + self.valveTypeCombo.setItemText(2, _translate("MainWindow", "Anti Plume")) + self.valveTypeCombo.setItemText(3, _translate("MainWindow", "Noise")) + self.valveTypeCombo.setItemText(4, _translate("MainWindow", "Plume")) + self.label_10.setText(_translate("MainWindow", "Repeats")) + self.shuffleRepeatsBox.setText(_translate("MainWindow", "Shuffle repeats")) + self.closeValvesButton.setText(_translate("MainWindow", "Close all valves")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.experimentSetupTab), _translate("MainWindow", "Experiment")) + self.label_18.setText(_translate("MainWindow", "Time suffix")) + self.label_15.setText(_translate("MainWindow", "Camera suffix")) + self.saveTrialStartscheckBox.setText(_translate("MainWindow", "Save trial start times")) + self.saveCameraVideocheckBox.setText(_translate("MainWindow", "Save camera video")) + self.trialStartsSuffixEdit.setText(_translate("MainWindow", "trial_starts")) + self.cameraSuffixEdit.setText(_translate("MainWindow", "camera")) + self.trialNameSuffixEdit.setText(_translate("MainWindow", "trial_name")) + self.pulseSuffixEdit.setText(_translate("MainWindow", "data")) + self.label_12.setText(_translate("MainWindow", "Save path")) + self.trialNameCheckBox.setText(_translate("MainWindow", "Save trial names")) + self.pulseCheckBox.setText(_translate("MainWindow", "Save pulses")) + self.label_14.setText(_translate("MainWindow", "Name suffix")) + self.label_13.setText(_translate("MainWindow", "Pulse suffix")) + self.exportPathDirButton.setText(_translate("MainWindow", "...")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.dataExportTab), _translate("MainWindow", "Data")) + self.label_19.setText(_translate("MainWindow", "Number of cameras")) + self.cameraSaveIconBox.setText(_translate("MainWindow", "Camera save icon")) + self.label_17.setText(_translate("MainWindow", "Camera save interval (s)")) + self.cameraSaveIntervalEdit.setText(_translate("MainWindow", "600")) + self.numberCamerasEdit.setText(_translate("MainWindow", "2")) + self.launchCameraButton.setText(_translate("MainWindow", "Launch camera(s)")) + self.blackAndWhiteBox.setText(_translate("MainWindow", "Black and white")) + self.showStreamcheckBox.setText(_translate("MainWindow", "Show stream")) + self.closeCamerasButton.setText(_translate("MainWindow", "Close cameras(s)")) + self.updateCamerasButton.setText(_translate("MainWindow", "Update camera(s)")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.cameraTab), _translate("MainWindow", "Cameras")) + self.menuFile.setTitle(_translate("MainWindow", "File")) + self.actionSave.setText(_translate("MainWindow", "Save")) + self.actionLoad.setText(_translate("MainWindow", "Load")) + self.actionSave_Configuration.setText(_translate("MainWindow", "Save Configuration")) + +from pyqtgraph import PlotWidget diff --git a/UI/PulseBoyUI_v2.ui b/UI/PulseBoyUI_v2.ui new file mode 100644 index 0000000..9c64997 --- /dev/null +++ b/UI/PulseBoyUI_v2.ui @@ -0,0 +1,942 @@ + + + MainWindow + + + + 0 + 0 + 1229 + 809 + + + + MainWindow + + + + + + + + Lucida Console + 12 + 75 + true + + + + Valve Bank + + + + + + + + Lucida Console + 12 + 75 + true + + + + Trial Bank + + + + + + + true + + + + + 0 + 0 + 18 + 348 + + + + + 0 + 0 + + + + + QLayout::SetFixedSize + + + + + + + + + 0 + + + + Pulses + + + + + + + 0 + 0 + + + + + + + + + Analog Data + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + + Lucida Console + + + + Qt::DefaultContextMenu + + + QAbstractItemView::SelectRows + + + false + + + + + + + + 0 + 0 + + + + + Lucida Console + 10 + + + + 0 + + + + Hardware + + + + + + Carrier flow out device + + + + + + + Control carrier flow + + + + + + + dev2/port0/line0:3 + + + + + + + 4 + + + + + + + dev2/ai4 + + + + + + + 1 + + + + + + + Sampling Rate + + + + + + + Synchronisation Clock + + + + + + + /dev2/ai/SampleClock + + + + + + + Digital Channels + + + + + + + 20000 + + + + + + + Analog Channels + + + + + + + Trigger In Source + + + + + + + Digital Out Device + + + + + + + cDAQ1Mod2/ai3 + + + + + + + Analog Input Device + + + + + + + dev2/port0/line5 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Global Parameters + + + + + + 0 + + + + + + + Blank valve indexes (0 indexing) + + + + + + + 1 + + + + + + + Invert blank off state + + + + + + + Shuffle offset + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0 + + + + + + + Offset + + + + + + + 0 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Onset + + + + + + + Shuffle group size + + + + + + + + Experiment + + + + + + Close all valves + + + + + + + Randomise trials + + + + + + + Run Selected + + + + + + + Move Up + + + + + + + Start Queue from Selected + + + + + + + + + Repeats + + + + + + + 1000000 + + + 1 + + + + + + + + + Start Queue + + + + + + + Shuffle repeats + + + + + + + Add Valve + + + + + + + Wait for trigger + + + + + + + + Simple + + + + + Binary + + + + + Anti Plume + + + + + Noise + + + + + Plume + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Update Trial + + + + + + + Move Down + + + + + + + + 0 + 0 + + + + Trial Name + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Remove Trial + + + + + + + Add To Trials + + + + + + + Pause Queue + + + + + + + Stop Queue + + + + + + + + Data + + + + + + + + Time suffix + + + + + + + Camera suffix + + + + + + + + + + + Save trial start times + + + true + + + + + + + Save camera video + + + true + + + + + + + + + + + trial_starts + + + + + + + camera + + + + + + + + + + + + + + + + + + trial_name + + + + + + + data + + + + + + + + + Save path + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 6 + + + QLayout::SetDefaultConstraint + + + + + Save trial names + + + true + + + + + + + Save pulses + + + + + + + + + + + Name suffix + + + + + + + Pulse suffix + + + + + + + + + ... + + + + + + + + Cameras + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Number of cameras + + + + + + + Camera save icon + + + true + + + + + + + Camera save interval (s) + + + + + + + 600 + + + + + + + 2 + + + + + + + Launch camera(s) + + + + + + + Black and white + + + true + + + + + + + Show stream + + + true + + + + + + + Close cameras(s) + + + + + + + Update camera(s) + + + + + + + + + + + + + 0 + 0 + 1229 + 21 + + + + + File + + + + + + + + + + + Save + + + + + Load + + + + + Save Configuration + + + + + + PlotWidget + QGraphicsView +
pyqtgraph
+
+
+ + +
diff --git a/UI/SimpleValveWidget.ui b/UI/SimpleValveWidget.ui index 17ebf8f..150021a 100644 --- a/UI/SimpleValveWidget.ui +++ b/UI/SimpleValveWidget.ui @@ -6,7 +6,7 @@ 0 0 - 846 + 1421 113 @@ -255,6 +255,13 @@
+ + + + 1 + + +
diff --git a/UI/binaryValveDesign.py b/UI/binaryValveDesign.py new file mode 100644 index 0000000..a470d54 --- /dev/null +++ b/UI/binaryValveDesign.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'BinaryValveWidget.ui' +# +# Created by: PyQt5 UI code generator 5.9 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(905, 113) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + Form.setFont(font) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setObjectName("gridLayout") + self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 2, 1, 1, 1) + self.binsizeEdit = QtWidgets.QLineEdit(Form) + self.binsizeEdit.setObjectName("binsizeEdit") + self.gridLayout.addWidget(self.binsizeEdit, 3, 3, 1, 1) + self.shatterBox = QtWidgets.QCheckBox(Form) + self.shatterBox.setChecked(True) + self.shatterBox.setObjectName("shatterBox") + self.gridLayout.addWidget(self.shatterBox, 1, 6, 1, 1) + self.label_5 = QtWidgets.QLabel(Form) + self.label_5.setObjectName("label_5") + self.gridLayout.addWidget(self.label_5, 2, 3, 1, 1) + self.numofbinsEdit = QtWidgets.QLineEdit(Form) + self.numofbinsEdit.setObjectName("numofbinsEdit") + self.gridLayout.addWidget(self.numofbinsEdit, 1, 3, 1, 1) + self.label_4 = QtWidgets.QLabel(Form) + self.label_4.setObjectName("label_4") + self.gridLayout.addWidget(self.label_4, 0, 3, 1, 1) + self.position = QtWidgets.QLabel(Form) + self.position.setObjectName("position") + self.gridLayout.addWidget(self.position, 0, 0, 1, 1) + self.valuetobinariseEdit = QtWidgets.QLineEdit(Form) + self.valuetobinariseEdit.setObjectName("valuetobinariseEdit") + self.gridLayout.addWidget(self.valuetobinariseEdit, 1, 5, 1, 1) + self.onsetEdit = QtWidgets.QLineEdit(Form) + self.onsetEdit.setObjectName("onsetEdit") + self.gridLayout.addWidget(self.onsetEdit, 1, 1, 1, 1) + self.offsetEdit = QtWidgets.QLineEdit(Form) + self.offsetEdit.setObjectName("offsetEdit") + self.gridLayout.addWidget(self.offsetEdit, 3, 1, 1, 1) + self.removeButton = QtWidgets.QToolButton(Form) + self.removeButton.setObjectName("removeButton") + self.gridLayout.addWidget(self.removeButton, 1, 0, 1, 1) + self.shatterEdit = QtWidgets.QLineEdit(Form) + self.shatterEdit.setObjectName("shatterEdit") + self.gridLayout.addWidget(self.shatterEdit, 1, 7, 1, 1) + self.label_3 = QtWidgets.QLabel(Form) + self.label_3.setObjectName("label_3") + self.gridLayout.addWidget(self.label_3, 0, 5, 1, 1) + self.label = QtWidgets.QLabel(Form) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 1, 1, 1) + self.label_6 = QtWidgets.QLabel(Form) + self.label_6.setObjectName("label_6") + self.gridLayout.addWidget(self.label_6, 0, 7, 1, 1) + self.line_2 = QtWidgets.QFrame(Form) + self.line_2.setFrameShape(QtWidgets.QFrame.HLine) + self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_2.setObjectName("line_2") + self.gridLayout.addWidget(self.line_2, 4, 1, 1, 7) + self.shatterDutyEdit = QtWidgets.QLineEdit(Form) + self.shatterDutyEdit.setObjectName("shatterDutyEdit") + self.gridLayout.addWidget(self.shatterDutyEdit, 3, 7, 1, 1) + self.label_7 = QtWidgets.QLabel(Form) + self.label_7.setObjectName("label_7") + self.gridLayout.addWidget(self.label_7, 2, 7, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.label_2.setText(_translate("Form", "Offset")) + self.binsizeEdit.setText(_translate("Form", "0.05")) + self.shatterBox.setText(_translate("Form", "Shatter Pulse")) + self.label_5.setText(_translate("Form", "Bin size")) + self.numofbinsEdit.setText(_translate("Form", "8")) + self.label_4.setText(_translate("Form", "Number of bins")) + self.position.setText(_translate("Form", "1")) + self.valuetobinariseEdit.setText(_translate("Form", "2")) + self.onsetEdit.setText(_translate("Form", "0.1")) + self.offsetEdit.setText(_translate("Form", "0.1")) + self.removeButton.setText(_translate("Form", "-")) + self.shatterEdit.setText(_translate("Form", "500")) + self.label_3.setText(_translate("Form", "Value to binarise")) + self.label.setText(_translate("Form", "Onset")) + self.label_6.setText(_translate("Form", "Shatter (Hz)")) + self.shatterDutyEdit.setText(_translate("Form", "0.5")) + self.label_7.setText(_translate("Form", "Shatter Duty")) + diff --git a/UI/mainDesign.py b/UI/mainDesign.py new file mode 100644 index 0000000..8034e8c --- /dev/null +++ b/UI/mainDesign.py @@ -0,0 +1,526 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'PulseBoyUI_v2.ui' +# +# Created by: PyQt5 UI code generator 5.9 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(1229, 809) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) + self.gridLayout.setObjectName("gridLayout") + self.label = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setFamily("Lucida Console") + font.setPointSize(12) + font.setBold(True) + font.setWeight(75) + self.label.setFont(font) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 0, 1, 1) + self.label_8 = QtWidgets.QLabel(self.centralwidget) + font = QtGui.QFont() + font.setFamily("Lucida Console") + font.setPointSize(12) + font.setBold(True) + font.setWeight(75) + self.label_8.setFont(font) + self.label_8.setObjectName("label_8") + self.gridLayout.addWidget(self.label_8, 2, 0, 1, 1) + self.valveBankScrollArea = QtWidgets.QScrollArea(self.centralwidget) + self.valveBankScrollArea.setWidgetResizable(True) + self.valveBankScrollArea.setObjectName("valveBankScrollArea") + self.valveBankContents = QtWidgets.QWidget() + self.valveBankContents.setGeometry(QtCore.QRect(0, 0, 18, 348)) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.valveBankContents.sizePolicy().hasHeightForWidth()) + self.valveBankContents.setSizePolicy(sizePolicy) + self.valveBankContents.setObjectName("valveBankContents") + self.valveBankLayout = QtWidgets.QVBoxLayout(self.valveBankContents) + self.valveBankLayout.setSizeConstraint(QtWidgets.QLayout.SetFixedSize) + self.valveBankLayout.setContentsMargins(0, 0, 0, 0) + self.valveBankLayout.setObjectName("valveBankLayout") + self.valveBankScrollArea.setWidget(self.valveBankContents) + self.gridLayout.addWidget(self.valveBankScrollArea, 1, 0, 1, 1) + self.viewWidgetTab = QtWidgets.QTabWidget(self.centralwidget) + self.viewWidgetTab.setObjectName("viewWidgetTab") + self.pulseTab = QtWidgets.QWidget() + self.pulseTab.setObjectName("pulseTab") + self.gridLayout_5 = QtWidgets.QGridLayout(self.pulseTab) + self.gridLayout_5.setObjectName("gridLayout_5") + self.graphicsView = PlotWidget(self.pulseTab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth()) + self.graphicsView.setSizePolicy(sizePolicy) + self.graphicsView.setObjectName("graphicsView") + self.gridLayout_5.addWidget(self.graphicsView, 0, 0, 1, 1) + self.viewWidgetTab.addTab(self.pulseTab, "") + self.analogDataTab = QtWidgets.QWidget() + self.analogDataTab.setObjectName("analogDataTab") + self.gridLayout_6 = QtWidgets.QGridLayout(self.analogDataTab) + self.gridLayout_6.setObjectName("gridLayout_6") + self.analogView = PlotWidget(self.analogDataTab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.analogView.sizePolicy().hasHeightForWidth()) + self.analogView.setSizePolicy(sizePolicy) + self.analogView.setObjectName("analogView") + self.gridLayout_6.addWidget(self.analogView, 0, 0, 1, 1) + self.viewWidgetTab.addTab(self.analogDataTab, "") + self.gridLayout.addWidget(self.viewWidgetTab, 3, 2, 1, 1) + self.trialBankTable = QtWidgets.QTableView(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.trialBankTable.sizePolicy().hasHeightForWidth()) + self.trialBankTable.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + self.trialBankTable.setFont(font) + self.trialBankTable.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) + self.trialBankTable.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) + self.trialBankTable.setObjectName("trialBankTable") + self.trialBankTable.horizontalHeader().setStretchLastSection(False) + self.gridLayout.addWidget(self.trialBankTable, 3, 0, 1, 1) + self.setupTabs = QtWidgets.QTabWidget(self.centralwidget) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.setupTabs.sizePolicy().hasHeightForWidth()) + self.setupTabs.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + font.setPointSize(10) + self.setupTabs.setFont(font) + self.setupTabs.setObjectName("setupTabs") + self.hardwareTab = QtWidgets.QWidget() + self.hardwareTab.setObjectName("hardwareTab") + self.gridLayout_2 = QtWidgets.QGridLayout(self.hardwareTab) + self.gridLayout_2.setObjectName("gridLayout_2") + self.label_22 = QtWidgets.QLabel(self.hardwareTab) + self.label_22.setObjectName("label_22") + self.gridLayout_2.addWidget(self.label_22, 9, 1, 1, 1) + self.carrierControlBox = QtWidgets.QCheckBox(self.hardwareTab) + self.carrierControlBox.setObjectName("carrierControlBox") + self.gridLayout_2.addWidget(self.carrierControlBox, 10, 0, 1, 1) + self.digitalOutDevEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.digitalOutDevEdit.setObjectName("digitalOutDevEdit") + self.gridLayout_2.addWidget(self.digitalOutDevEdit, 1, 0, 1, 1) + self.digitalChannelsEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.digitalChannelsEdit.setObjectName("digitalChannelsEdit") + self.gridLayout_2.addWidget(self.digitalChannelsEdit, 1, 1, 1, 1) + self.analogInDevEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.analogInDevEdit.setObjectName("analogInDevEdit") + self.gridLayout_2.addWidget(self.analogInDevEdit, 3, 0, 1, 1) + self.analogChannelsEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.analogChannelsEdit.setObjectName("analogChannelsEdit") + self.gridLayout_2.addWidget(self.analogChannelsEdit, 3, 1, 1, 1) + self.label_5 = QtWidgets.QLabel(self.hardwareTab) + self.label_5.setObjectName("label_5") + self.gridLayout_2.addWidget(self.label_5, 6, 0, 1, 1) + self.label_11 = QtWidgets.QLabel(self.hardwareTab) + self.label_11.setObjectName("label_11") + self.gridLayout_2.addWidget(self.label_11, 4, 0, 1, 1) + self.syncClockEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.syncClockEdit.setObjectName("syncClockEdit") + self.gridLayout_2.addWidget(self.syncClockEdit, 5, 0, 1, 1) + self.label_4 = QtWidgets.QLabel(self.hardwareTab) + self.label_4.setObjectName("label_4") + self.gridLayout_2.addWidget(self.label_4, 0, 1, 1, 1) + self.sampRateEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.sampRateEdit.setObjectName("sampRateEdit") + self.gridLayout_2.addWidget(self.sampRateEdit, 7, 0, 1, 1) + self.analogChannelsLabel = QtWidgets.QLabel(self.hardwareTab) + self.analogChannelsLabel.setObjectName("analogChannelsLabel") + self.gridLayout_2.addWidget(self.analogChannelsLabel, 2, 1, 1, 1) + self.label_9 = QtWidgets.QLabel(self.hardwareTab) + self.label_9.setObjectName("label_9") + self.gridLayout_2.addWidget(self.label_9, 4, 1, 1, 1) + self.label_2 = QtWidgets.QLabel(self.hardwareTab) + self.label_2.setObjectName("label_2") + self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1) + self.triggerInEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.triggerInEdit.setObjectName("triggerInEdit") + self.gridLayout_2.addWidget(self.triggerInEdit, 5, 1, 1, 1) + self.label_3 = QtWidgets.QLabel(self.hardwareTab) + self.label_3.setObjectName("label_3") + self.gridLayout_2.addWidget(self.label_3, 2, 0, 1, 1) + self.carrierDeviceEdit = QtWidgets.QLineEdit(self.hardwareTab) + self.carrierDeviceEdit.setObjectName("carrierDeviceEdit") + self.gridLayout_2.addWidget(self.carrierDeviceEdit, 10, 1, 1, 1) + spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_2.addItem(spacerItem, 8, 0, 1, 1) + self.setupTabs.addTab(self.hardwareTab, "") + self.globalParametersTab = QtWidgets.QWidget() + self.globalParametersTab.setObjectName("globalParametersTab") + self.gridLayout_3 = QtWidgets.QGridLayout(self.globalParametersTab) + self.gridLayout_3.setObjectName("gridLayout_3") + self.shuffleOffsetlineEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.shuffleOffsetlineEdit.setObjectName("shuffleOffsetlineEdit") + self.gridLayout_3.addWidget(self.shuffleOffsetlineEdit, 6, 0, 1, 1) + self.label_16 = QtWidgets.QLabel(self.globalParametersTab) + self.label_16.setObjectName("label_16") + self.gridLayout_3.addWidget(self.label_16, 2, 1, 1, 1) + self.shuffleGrouplineEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.shuffleGrouplineEdit.setObjectName("shuffleGrouplineEdit") + self.gridLayout_3.addWidget(self.shuffleGrouplineEdit, 6, 1, 1, 1) + self.invertBlankcheckBox = QtWidgets.QCheckBox(self.globalParametersTab) + self.invertBlankcheckBox.setObjectName("invertBlankcheckBox") + self.gridLayout_3.addWidget(self.invertBlankcheckBox, 3, 0, 1, 1) + self.label_21 = QtWidgets.QLabel(self.globalParametersTab) + self.label_21.setObjectName("label_21") + self.gridLayout_3.addWidget(self.label_21, 5, 0, 1, 1) + self.blankValveEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.blankValveEdit.setObjectName("blankValveEdit") + self.gridLayout_3.addWidget(self.blankValveEdit, 3, 1, 1, 1) + spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_3.addItem(spacerItem1, 4, 0, 1, 1) + self.globalOnsetEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.globalOnsetEdit.setObjectName("globalOnsetEdit") + self.gridLayout_3.addWidget(self.globalOnsetEdit, 1, 0, 1, 1) + self.label_7 = QtWidgets.QLabel(self.globalParametersTab) + self.label_7.setObjectName("label_7") + self.gridLayout_3.addWidget(self.label_7, 0, 1, 1, 1) + self.globalOffsetEdit = QtWidgets.QLineEdit(self.globalParametersTab) + self.globalOffsetEdit.setObjectName("globalOffsetEdit") + self.gridLayout_3.addWidget(self.globalOffsetEdit, 1, 1, 1, 1) + spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_3.addItem(spacerItem2, 7, 0, 1, 1) + self.label_6 = QtWidgets.QLabel(self.globalParametersTab) + self.label_6.setObjectName("label_6") + self.gridLayout_3.addWidget(self.label_6, 0, 0, 1, 1) + self.label_20 = QtWidgets.QLabel(self.globalParametersTab) + self.label_20.setObjectName("label_20") + self.gridLayout_3.addWidget(self.label_20, 5, 1, 1, 1) + self.setupTabs.addTab(self.globalParametersTab, "") + self.experimentSetupTab = QtWidgets.QWidget() + self.experimentSetupTab.setObjectName("experimentSetupTab") + self.gridLayout_4 = QtWidgets.QGridLayout(self.experimentSetupTab) + self.gridLayout_4.setObjectName("gridLayout_4") + self.closeValvesButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.closeValvesButton.setObjectName("closeValvesButton") + self.gridLayout_4.addWidget(self.closeValvesButton, 0, 2, 1, 1) + self.randomiseTrialsButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.randomiseTrialsButton.setObjectName("randomiseTrialsButton") + self.gridLayout_4.addWidget(self.randomiseTrialsButton, 7, 0, 1, 1) + self.runSelectedButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.runSelectedButton.setObjectName("runSelectedButton") + self.gridLayout_4.addWidget(self.runSelectedButton, 9, 0, 1, 1) + self.moveUpButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.moveUpButton.setObjectName("moveUpButton") + self.gridLayout_4.addWidget(self.moveUpButton, 3, 1, 1, 1) + self.startQueueFromSelectedButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.startQueueFromSelectedButton.setObjectName("startQueueFromSelectedButton") + self.gridLayout_4.addWidget(self.startQueueFromSelectedButton, 9, 1, 1, 1) + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.label_10 = QtWidgets.QLabel(self.experimentSetupTab) + self.label_10.setObjectName("label_10") + self.horizontalLayout.addWidget(self.label_10) + self.repeatsBox = QtWidgets.QSpinBox(self.experimentSetupTab) + self.repeatsBox.setMaximum(1000000) + self.repeatsBox.setProperty("value", 1) + self.repeatsBox.setObjectName("repeatsBox") + self.horizontalLayout.addWidget(self.repeatsBox) + self.gridLayout_4.addLayout(self.horizontalLayout, 7, 1, 1, 1) + self.startQueueButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.startQueueButton.setObjectName("startQueueButton") + self.gridLayout_4.addWidget(self.startQueueButton, 8, 0, 1, 1) + self.shuffleRepeatsBox = QtWidgets.QCheckBox(self.experimentSetupTab) + self.shuffleRepeatsBox.setObjectName("shuffleRepeatsBox") + self.gridLayout_4.addWidget(self.shuffleRepeatsBox, 7, 2, 1, 1) + self.addValveButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.addValveButton.setObjectName("addValveButton") + self.gridLayout_4.addWidget(self.addValveButton, 0, 0, 1, 1) + self.triggerWaitCheckBox = QtWidgets.QCheckBox(self.experimentSetupTab) + self.triggerWaitCheckBox.setObjectName("triggerWaitCheckBox") + self.gridLayout_4.addWidget(self.triggerWaitCheckBox, 9, 2, 1, 1) + self.valveTypeCombo = QtWidgets.QComboBox(self.experimentSetupTab) + self.valveTypeCombo.setObjectName("valveTypeCombo") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.valveTypeCombo.addItem("") + self.gridLayout_4.addWidget(self.valveTypeCombo, 0, 1, 1, 1) + spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_4.addItem(spacerItem3, 4, 0, 1, 1) + self.updateTrialButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.updateTrialButton.setObjectName("updateTrialButton") + self.gridLayout_4.addWidget(self.updateTrialButton, 2, 1, 1, 1) + self.moveDownButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.moveDownButton.setObjectName("moveDownButton") + self.gridLayout_4.addWidget(self.moveDownButton, 3, 2, 1, 1) + self.trialNameEdit = QtWidgets.QLineEdit(self.experimentSetupTab) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.trialNameEdit.sizePolicy().hasHeightForWidth()) + self.trialNameEdit.setSizePolicy(sizePolicy) + self.trialNameEdit.setObjectName("trialNameEdit") + self.gridLayout_4.addWidget(self.trialNameEdit, 3, 0, 1, 1) + spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_4.addItem(spacerItem4, 1, 0, 1, 1) + self.removeTrialButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.removeTrialButton.setObjectName("removeTrialButton") + self.gridLayout_4.addWidget(self.removeTrialButton, 2, 2, 1, 1) + self.addTrialButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.addTrialButton.setObjectName("addTrialButton") + self.gridLayout_4.addWidget(self.addTrialButton, 2, 0, 1, 1) + self.pauseQueueButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.pauseQueueButton.setObjectName("pauseQueueButton") + self.gridLayout_4.addWidget(self.pauseQueueButton, 8, 1, 1, 1) + self.stopQueueButton = QtWidgets.QPushButton(self.experimentSetupTab) + self.stopQueueButton.setObjectName("stopQueueButton") + self.gridLayout_4.addWidget(self.stopQueueButton, 8, 2, 1, 1) + self.setupTabs.addTab(self.experimentSetupTab, "") + self.dataExportTab = QtWidgets.QWidget() + self.dataExportTab.setObjectName("dataExportTab") + self.gridLayout_7 = QtWidgets.QGridLayout(self.dataExportTab) + self.gridLayout_7.setObjectName("gridLayout_7") + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.label_18 = QtWidgets.QLabel(self.dataExportTab) + self.label_18.setObjectName("label_18") + self.horizontalLayout_3.addWidget(self.label_18) + self.label_15 = QtWidgets.QLabel(self.dataExportTab) + self.label_15.setObjectName("label_15") + self.horizontalLayout_3.addWidget(self.label_15) + self.gridLayout_7.addLayout(self.horizontalLayout_3, 10, 1, 1, 1) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.saveTrialStartscheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.saveTrialStartscheckBox.setChecked(True) + self.saveTrialStartscheckBox.setObjectName("saveTrialStartscheckBox") + self.horizontalLayout_2.addWidget(self.saveTrialStartscheckBox) + self.saveCameraVideocheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.saveCameraVideocheckBox.setChecked(True) + self.saveCameraVideocheckBox.setObjectName("saveCameraVideocheckBox") + self.horizontalLayout_2.addWidget(self.saveCameraVideocheckBox) + self.gridLayout_7.addLayout(self.horizontalLayout_2, 9, 1, 1, 1) + self.horizontalLayout_7 = QtWidgets.QHBoxLayout() + self.horizontalLayout_7.setObjectName("horizontalLayout_7") + self.trialStartsSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.trialStartsSuffixEdit.setObjectName("trialStartsSuffixEdit") + self.horizontalLayout_7.addWidget(self.trialStartsSuffixEdit) + self.cameraSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.cameraSuffixEdit.setObjectName("cameraSuffixEdit") + self.horizontalLayout_7.addWidget(self.cameraSuffixEdit) + self.gridLayout_7.addLayout(self.horizontalLayout_7, 11, 1, 1, 1) + self.exportPathEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.exportPathEdit.setText("") + self.exportPathEdit.setObjectName("exportPathEdit") + self.gridLayout_7.addWidget(self.exportPathEdit, 3, 1, 1, 1) + self.horizontalLayout_6 = QtWidgets.QHBoxLayout() + self.horizontalLayout_6.setObjectName("horizontalLayout_6") + self.trialNameSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.trialNameSuffixEdit.setObjectName("trialNameSuffixEdit") + self.horizontalLayout_6.addWidget(self.trialNameSuffixEdit) + self.pulseSuffixEdit = QtWidgets.QLineEdit(self.dataExportTab) + self.pulseSuffixEdit.setObjectName("pulseSuffixEdit") + self.horizontalLayout_6.addWidget(self.pulseSuffixEdit) + self.gridLayout_7.addLayout(self.horizontalLayout_6, 8, 1, 1, 1) + self.label_12 = QtWidgets.QLabel(self.dataExportTab) + self.label_12.setObjectName("label_12") + self.gridLayout_7.addWidget(self.label_12, 3, 0, 1, 1) + spacerItem5 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_7.addItem(spacerItem5, 2, 1, 1, 1) + spacerItem6 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_7.addItem(spacerItem6, 12, 1, 1, 1) + self.horizontalLayout_4 = QtWidgets.QHBoxLayout() + self.horizontalLayout_4.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) + self.horizontalLayout_4.setSpacing(6) + self.horizontalLayout_4.setObjectName("horizontalLayout_4") + self.trialNameCheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.trialNameCheckBox.setChecked(True) + self.trialNameCheckBox.setObjectName("trialNameCheckBox") + self.horizontalLayout_4.addWidget(self.trialNameCheckBox) + self.pulseCheckBox = QtWidgets.QCheckBox(self.dataExportTab) + self.pulseCheckBox.setObjectName("pulseCheckBox") + self.horizontalLayout_4.addWidget(self.pulseCheckBox) + self.gridLayout_7.addLayout(self.horizontalLayout_4, 5, 1, 1, 1) + self.horizontalLayout_5 = QtWidgets.QHBoxLayout() + self.horizontalLayout_5.setObjectName("horizontalLayout_5") + self.label_14 = QtWidgets.QLabel(self.dataExportTab) + self.label_14.setObjectName("label_14") + self.horizontalLayout_5.addWidget(self.label_14) + self.label_13 = QtWidgets.QLabel(self.dataExportTab) + self.label_13.setObjectName("label_13") + self.horizontalLayout_5.addWidget(self.label_13) + self.gridLayout_7.addLayout(self.horizontalLayout_5, 7, 1, 1, 1) + self.exportPathDirButton = QtWidgets.QPushButton(self.dataExportTab) + self.exportPathDirButton.setObjectName("exportPathDirButton") + self.gridLayout_7.addWidget(self.exportPathDirButton, 3, 2, 1, 1) + self.setupTabs.addTab(self.dataExportTab, "") + self.cameraTab = QtWidgets.QWidget() + self.cameraTab.setObjectName("cameraTab") + self.gridLayout_8 = QtWidgets.QGridLayout(self.cameraTab) + self.gridLayout_8.setObjectName("gridLayout_8") + spacerItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_8.addItem(spacerItem7, 3, 0, 1, 2) + spacerItem8 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + self.gridLayout_8.addItem(spacerItem8, 10, 0, 1, 2) + self.label_19 = QtWidgets.QLabel(self.cameraTab) + self.label_19.setObjectName("label_19") + self.gridLayout_8.addWidget(self.label_19, 5, 1, 1, 1) + self.cameraSaveIconBox = QtWidgets.QCheckBox(self.cameraTab) + self.cameraSaveIconBox.setChecked(True) + self.cameraSaveIconBox.setObjectName("cameraSaveIconBox") + self.gridLayout_8.addWidget(self.cameraSaveIconBox, 7, 0, 1, 1) + self.label_17 = QtWidgets.QLabel(self.cameraTab) + self.label_17.setObjectName("label_17") + self.gridLayout_8.addWidget(self.label_17, 5, 0, 1, 1) + self.cameraSaveIntervalEdit = QtWidgets.QLineEdit(self.cameraTab) + self.cameraSaveIntervalEdit.setObjectName("cameraSaveIntervalEdit") + self.gridLayout_8.addWidget(self.cameraSaveIntervalEdit, 6, 0, 1, 1) + self.numberCamerasEdit = QtWidgets.QLineEdit(self.cameraTab) + self.numberCamerasEdit.setObjectName("numberCamerasEdit") + self.gridLayout_8.addWidget(self.numberCamerasEdit, 6, 1, 1, 1) + self.launchCameraButton = QtWidgets.QPushButton(self.cameraTab) + self.launchCameraButton.setObjectName("launchCameraButton") + self.gridLayout_8.addWidget(self.launchCameraButton, 4, 0, 1, 2) + self.blackAndWhiteBox = QtWidgets.QCheckBox(self.cameraTab) + self.blackAndWhiteBox.setChecked(True) + self.blackAndWhiteBox.setObjectName("blackAndWhiteBox") + self.gridLayout_8.addWidget(self.blackAndWhiteBox, 7, 1, 1, 1) + self.showStreamcheckBox = QtWidgets.QCheckBox(self.cameraTab) + self.showStreamcheckBox.setChecked(True) + self.showStreamcheckBox.setObjectName("showStreamcheckBox") + self.gridLayout_8.addWidget(self.showStreamcheckBox, 8, 1, 1, 1) + self.closeCamerasButton = QtWidgets.QPushButton(self.cameraTab) + self.closeCamerasButton.setObjectName("closeCamerasButton") + self.gridLayout_8.addWidget(self.closeCamerasButton, 8, 0, 1, 1) + self.updateCamerasButton = QtWidgets.QPushButton(self.cameraTab) + self.updateCamerasButton.setObjectName("updateCamerasButton") + self.gridLayout_8.addWidget(self.updateCamerasButton, 9, 0, 1, 1) + self.setupTabs.addTab(self.cameraTab, "") + self.gridLayout.addWidget(self.setupTabs, 1, 2, 1, 1) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtWidgets.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1229, 21)) + self.menubar.setObjectName("menubar") + self.menuFile = QtWidgets.QMenu(self.menubar) + self.menuFile.setObjectName("menuFile") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtWidgets.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.actionSave = QtWidgets.QAction(MainWindow) + self.actionSave.setObjectName("actionSave") + self.actionLoad = QtWidgets.QAction(MainWindow) + self.actionLoad.setObjectName("actionLoad") + self.actionSave_Configuration = QtWidgets.QAction(MainWindow) + self.actionSave_Configuration.setObjectName("actionSave_Configuration") + self.menuFile.addAction(self.actionSave) + self.menuFile.addAction(self.actionLoad) + self.menuFile.addAction(self.actionSave_Configuration) + self.menubar.addAction(self.menuFile.menuAction()) + + self.retranslateUi(MainWindow) + self.viewWidgetTab.setCurrentIndex(0) + self.setupTabs.setCurrentIndex(0) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) + self.label.setText(_translate("MainWindow", "Valve Bank")) + self.label_8.setText(_translate("MainWindow", "Trial Bank")) + self.viewWidgetTab.setTabText(self.viewWidgetTab.indexOf(self.pulseTab), _translate("MainWindow", "Pulses")) + self.viewWidgetTab.setTabText(self.viewWidgetTab.indexOf(self.analogDataTab), _translate("MainWindow", "Analog Data")) + self.label_22.setText(_translate("MainWindow", "Carrier flow out device")) + self.carrierControlBox.setText(_translate("MainWindow", "Control carrier flow")) + self.digitalOutDevEdit.setText(_translate("MainWindow", "dev2/port0/line0:3")) + self.digitalChannelsEdit.setText(_translate("MainWindow", "4")) + self.analogInDevEdit.setText(_translate("MainWindow", "dev2/ai4")) + self.analogChannelsEdit.setText(_translate("MainWindow", "1")) + self.label_5.setText(_translate("MainWindow", "Sampling Rate")) + self.label_11.setText(_translate("MainWindow", "Synchronisation Clock")) + self.syncClockEdit.setText(_translate("MainWindow", "/dev2/ai/SampleClock")) + self.label_4.setText(_translate("MainWindow", "Digital Channels")) + self.sampRateEdit.setText(_translate("MainWindow", "20000")) + self.analogChannelsLabel.setText(_translate("MainWindow", "Analog Channels")) + self.label_9.setText(_translate("MainWindow", "Trigger In Source")) + self.label_2.setText(_translate("MainWindow", "Digital Out Device")) + self.triggerInEdit.setText(_translate("MainWindow", "cDAQ1Mod2/ai3")) + self.label_3.setText(_translate("MainWindow", "Analog Input Device")) + self.carrierDeviceEdit.setText(_translate("MainWindow", "dev2/port0/line5")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.hardwareTab), _translate("MainWindow", "Hardware")) + self.shuffleOffsetlineEdit.setText(_translate("MainWindow", "0")) + self.label_16.setText(_translate("MainWindow", "Blank valve indexes (0 indexing)")) + self.shuffleGrouplineEdit.setText(_translate("MainWindow", "1")) + self.invertBlankcheckBox.setText(_translate("MainWindow", "Invert blank off state")) + self.label_21.setText(_translate("MainWindow", "Shuffle offset")) + self.globalOnsetEdit.setText(_translate("MainWindow", "0")) + self.label_7.setText(_translate("MainWindow", "Offset")) + self.globalOffsetEdit.setText(_translate("MainWindow", "0")) + self.label_6.setText(_translate("MainWindow", "Onset")) + self.label_20.setText(_translate("MainWindow", "Shuffle group size")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.globalParametersTab), _translate("MainWindow", "Global Parameters")) + self.closeValvesButton.setText(_translate("MainWindow", "Close all valves")) + self.randomiseTrialsButton.setText(_translate("MainWindow", "Randomise trials")) + self.runSelectedButton.setText(_translate("MainWindow", "Run Selected")) + self.moveUpButton.setText(_translate("MainWindow", "Move Up")) + self.startQueueFromSelectedButton.setText(_translate("MainWindow", "Start Queue from Selected")) + self.label_10.setText(_translate("MainWindow", "Repeats")) + self.startQueueButton.setText(_translate("MainWindow", "Start Queue")) + self.shuffleRepeatsBox.setText(_translate("MainWindow", "Shuffle repeats")) + self.addValveButton.setText(_translate("MainWindow", "Add Valve")) + self.triggerWaitCheckBox.setText(_translate("MainWindow", "Wait for trigger")) + self.valveTypeCombo.setItemText(0, _translate("MainWindow", "Simple")) + self.valveTypeCombo.setItemText(1, _translate("MainWindow", "Binary")) + self.valveTypeCombo.setItemText(2, _translate("MainWindow", "Anti Plume")) + self.valveTypeCombo.setItemText(3, _translate("MainWindow", "Noise")) + self.valveTypeCombo.setItemText(4, _translate("MainWindow", "Plume")) + self.updateTrialButton.setText(_translate("MainWindow", "Update Trial")) + self.moveDownButton.setText(_translate("MainWindow", "Move Down")) + self.trialNameEdit.setText(_translate("MainWindow", "Trial Name")) + self.removeTrialButton.setText(_translate("MainWindow", "Remove Trial")) + self.addTrialButton.setText(_translate("MainWindow", "Add To Trials")) + self.pauseQueueButton.setText(_translate("MainWindow", "Pause Queue")) + self.stopQueueButton.setText(_translate("MainWindow", "Stop Queue")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.experimentSetupTab), _translate("MainWindow", "Experiment")) + self.label_18.setText(_translate("MainWindow", "Time suffix")) + self.label_15.setText(_translate("MainWindow", "Camera suffix")) + self.saveTrialStartscheckBox.setText(_translate("MainWindow", "Save trial start times")) + self.saveCameraVideocheckBox.setText(_translate("MainWindow", "Save camera video")) + self.trialStartsSuffixEdit.setText(_translate("MainWindow", "trial_starts")) + self.cameraSuffixEdit.setText(_translate("MainWindow", "camera")) + self.trialNameSuffixEdit.setText(_translate("MainWindow", "trial_name")) + self.pulseSuffixEdit.setText(_translate("MainWindow", "data")) + self.label_12.setText(_translate("MainWindow", "Save path")) + self.trialNameCheckBox.setText(_translate("MainWindow", "Save trial names")) + self.pulseCheckBox.setText(_translate("MainWindow", "Save pulses")) + self.label_14.setText(_translate("MainWindow", "Name suffix")) + self.label_13.setText(_translate("MainWindow", "Pulse suffix")) + self.exportPathDirButton.setText(_translate("MainWindow", "...")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.dataExportTab), _translate("MainWindow", "Data")) + self.label_19.setText(_translate("MainWindow", "Number of cameras")) + self.cameraSaveIconBox.setText(_translate("MainWindow", "Camera save icon")) + self.label_17.setText(_translate("MainWindow", "Camera save interval (s)")) + self.cameraSaveIntervalEdit.setText(_translate("MainWindow", "600")) + self.numberCamerasEdit.setText(_translate("MainWindow", "2")) + self.launchCameraButton.setText(_translate("MainWindow", "Launch camera(s)")) + self.blackAndWhiteBox.setText(_translate("MainWindow", "Black and white")) + self.showStreamcheckBox.setText(_translate("MainWindow", "Show stream")) + self.closeCamerasButton.setText(_translate("MainWindow", "Close cameras(s)")) + self.updateCamerasButton.setText(_translate("MainWindow", "Update camera(s)")) + self.setupTabs.setTabText(self.setupTabs.indexOf(self.cameraTab), _translate("MainWindow", "Cameras")) + self.menuFile.setTitle(_translate("MainWindow", "File")) + self.actionSave.setText(_translate("MainWindow", "Save")) + self.actionLoad.setText(_translate("MainWindow", "Load")) + self.actionSave_Configuration.setText(_translate("MainWindow", "Save Configuration")) + +from pyqtgraph import PlotWidget diff --git a/UI/noiseValveWidget.py b/UI/noiseValveWidget.py new file mode 100644 index 0000000..02f4af0 --- /dev/null +++ b/UI/noiseValveWidget.py @@ -0,0 +1,125 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'NoiseValveWidget.ui' +# +# Created by: PyQt5 UI code generator 5.9 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(681, 76) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + Form.setFont(font) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setObjectName("gridLayout") + self.lengthEdit = QtWidgets.QLineEdit(Form) + self.lengthEdit.setEnabled(False) + self.lengthEdit.setObjectName("lengthEdit") + self.gridLayout.addWidget(self.lengthEdit, 1, 9, 1, 1) + self.onsetEdit = QtWidgets.QLineEdit(Form) + self.onsetEdit.setObjectName("onsetEdit") + self.gridLayout.addWidget(self.onsetEdit, 1, 1, 1, 1) + self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 0, 2, 1, 1) + self.label = QtWidgets.QLabel(Form) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 1, 1, 1) + self.offsetEdit = QtWidgets.QLineEdit(Form) + self.offsetEdit.setObjectName("offsetEdit") + self.gridLayout.addWidget(self.offsetEdit, 1, 2, 1, 1) + self.line_2 = QtWidgets.QFrame(Form) + self.line_2.setFrameShape(QtWidgets.QFrame.HLine) + self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_2.setObjectName("line_2") + self.gridLayout.addWidget(self.line_2, 2, 1, 1, 9) + self.label_7 = QtWidgets.QLabel(Form) + self.label_7.setObjectName("label_7") + self.gridLayout.addWidget(self.label_7, 0, 7, 1, 1) + self.label_6 = QtWidgets.QLabel(Form) + self.label_6.setObjectName("label_6") + self.gridLayout.addWidget(self.label_6, 0, 6, 1, 1) + self.seedEdit = QtWidgets.QLineEdit(Form) + self.seedEdit.setObjectName("seedEdit") + self.gridLayout.addWidget(self.seedEdit, 1, 4, 1, 1) + self.ampMaxEdit = QtWidgets.QLineEdit(Form) + self.ampMaxEdit.setObjectName("ampMaxEdit") + self.gridLayout.addWidget(self.ampMaxEdit, 1, 7, 1, 1) + self.repeatsEdit = QtWidgets.QLineEdit(Form) + self.repeatsEdit.setObjectName("repeatsEdit") + self.gridLayout.addWidget(self.repeatsEdit, 0, 9, 1, 1) + self.frequencyEdit = QtWidgets.QLineEdit(Form) + self.frequencyEdit.setObjectName("frequencyEdit") + self.gridLayout.addWidget(self.frequencyEdit, 1, 3, 1, 1) + self.repeatsRadio = QtWidgets.QRadioButton(Form) + self.repeatsRadio.setChecked(True) + self.repeatsRadio.setAutoExclusive(False) + self.repeatsRadio.setObjectName("repeatsRadio") + self.gridLayout.addWidget(self.repeatsRadio, 0, 8, 1, 1) + self.ampMinEdit = QtWidgets.QLineEdit(Form) + self.ampMinEdit.setObjectName("ampMinEdit") + self.gridLayout.addWidget(self.ampMinEdit, 1, 6, 1, 1) + self.lengthRadio = QtWidgets.QRadioButton(Form) + self.lengthRadio.setAutoExclusive(False) + self.lengthRadio.setObjectName("lengthRadio") + self.gridLayout.addWidget(self.lengthRadio, 1, 8, 1, 1) + self.label_8 = QtWidgets.QLabel(Form) + self.label_8.setObjectName("label_8") + self.gridLayout.addWidget(self.label_8, 0, 5, 1, 1) + self.label_4 = QtWidgets.QLabel(Form) + self.label_4.setObjectName("label_4") + self.gridLayout.addWidget(self.label_4, 0, 3, 1, 1) + self.shatterHzEdit = QtWidgets.QLineEdit(Form) + self.shatterHzEdit.setObjectName("shatterHzEdit") + self.gridLayout.addWidget(self.shatterHzEdit, 1, 5, 1, 1) + self.label_5 = QtWidgets.QLabel(Form) + self.label_5.setObjectName("label_5") + self.gridLayout.addWidget(self.label_5, 0, 4, 1, 1) + self.removeButton = QtWidgets.QToolButton(Form) + self.removeButton.setObjectName("removeButton") + self.gridLayout.addWidget(self.removeButton, 1, 0, 1, 1) + self.position = QtWidgets.QLabel(Form) + self.position.setObjectName("position") + self.gridLayout.addWidget(self.position, 0, 0, 1, 1) + + self.retranslateUi(Form) + self.repeatsRadio.clicked.connect(self.lengthRadio.toggle) + self.lengthRadio.clicked.connect(self.repeatsRadio.toggle) + self.repeatsRadio.toggled['bool'].connect(self.repeatsEdit.setEnabled) + self.lengthRadio.toggled['bool'].connect(self.lengthEdit.setEnabled) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.lengthEdit.setText(_translate("Form", "1")) + self.onsetEdit.setText(_translate("Form", "0.1")) + self.label_2.setText(_translate("Form", "Offset")) + self.label.setText(_translate("Form", "Onset")) + self.offsetEdit.setText(_translate("Form", "0.1")) + self.label_7.setText(_translate("Form", "Amp Max (/1)")) + self.label_6.setText(_translate("Form", "Amp Min (/1)")) + self.seedEdit.setText(_translate("Form", "1")) + self.ampMaxEdit.setText(_translate("Form", "0.9")) + self.repeatsEdit.setText(_translate("Form", "5")) + self.frequencyEdit.setText(_translate("Form", "20")) + self.repeatsRadio.setText(_translate("Form", "Repeats")) + self.ampMinEdit.setText(_translate("Form", "0.1")) + self.lengthRadio.setText(_translate("Form", "Length (s)")) + self.label_8.setText(_translate("Form", "Shatter (Hz)")) + self.label_4.setText(_translate("Form", "Frequncy (Hz)")) + self.shatterHzEdit.setText(_translate("Form", "500")) + self.label_5.setText(_translate("Form", "Seed")) + self.removeButton.setText(_translate("Form", "-")) + self.position.setText(_translate("Form", "1")) + diff --git a/UI/plumeValveWidget.py b/UI/plumeValveWidget.py new file mode 100644 index 0000000..33c157a --- /dev/null +++ b/UI/plumeValveWidget.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'PlumeValveWidget.ui' +# +# Created by: PyQt5 UI code generator 5.9 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(848, 76) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + Form.setFont(font) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setObjectName("gridLayout") + self.plumeDataLabel = QtWidgets.QLabel(Form) + self.plumeDataLabel.setObjectName("plumeDataLabel") + self.gridLayout.addWidget(self.plumeDataLabel, 1, 5, 1, 1) + self.label_5 = QtWidgets.QLabel(Form) + self.label_5.setObjectName("label_5") + self.gridLayout.addWidget(self.label_5, 0, 6, 1, 1) + self.targetMaxEdit = QtWidgets.QLineEdit(Form) + self.targetMaxEdit.setObjectName("targetMaxEdit") + self.gridLayout.addWidget(self.targetMaxEdit, 1, 7, 1, 1) + self.line_2 = QtWidgets.QFrame(Form) + self.line_2.setFrameShape(QtWidgets.QFrame.HLine) + self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_2.setObjectName("line_2") + self.gridLayout.addWidget(self.line_2, 2, 2, 1, 6) + self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 0, 3, 1, 1) + self.label_3 = QtWidgets.QLabel(Form) + self.label_3.setObjectName("label_3") + self.gridLayout.addWidget(self.label_3, 0, 7, 1, 1) + self.offsetEdit = QtWidgets.QLineEdit(Form) + self.offsetEdit.setObjectName("offsetEdit") + self.gridLayout.addWidget(self.offsetEdit, 1, 3, 1, 1) + self.onsetEdit = QtWidgets.QLineEdit(Form) + self.onsetEdit.setObjectName("onsetEdit") + self.gridLayout.addWidget(self.onsetEdit, 1, 2, 1, 1) + self.label = QtWidgets.QLabel(Form) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 2, 1, 1) + self.dataSamplingRateEdit = QtWidgets.QLineEdit(Form) + self.dataSamplingRateEdit.setObjectName("dataSamplingRateEdit") + self.gridLayout.addWidget(self.dataSamplingRateEdit, 1, 6, 1, 1) + self.label_8 = QtWidgets.QLabel(Form) + self.label_8.setObjectName("label_8") + self.gridLayout.addWidget(self.label_8, 0, 4, 1, 1) + self.removeButton = QtWidgets.QToolButton(Form) + self.removeButton.setObjectName("removeButton") + self.gridLayout.addWidget(self.removeButton, 1, 0, 1, 1) + self.shatterHzEdit = QtWidgets.QLineEdit(Form) + self.shatterHzEdit.setObjectName("shatterHzEdit") + self.gridLayout.addWidget(self.shatterHzEdit, 1, 4, 1, 1) + self.openPlumeDataButton = QtWidgets.QPushButton(Form) + self.openPlumeDataButton.setObjectName("openPlumeDataButton") + self.gridLayout.addWidget(self.openPlumeDataButton, 0, 5, 1, 1) + self.position = QtWidgets.QLabel(Form) + self.position.setObjectName("position") + self.gridLayout.addWidget(self.position, 0, 0, 1, 1) + + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.plumeDataLabel.setText(_translate("Form", "-")) + self.label_5.setText(_translate("Form", "Data Sampling Rate")) + self.targetMaxEdit.setText(_translate("Form", "1.0")) + self.label_2.setText(_translate("Form", "Offset")) + self.label_3.setText(_translate("Form", "Target Max.")) + self.offsetEdit.setText(_translate("Form", "0.1")) + self.onsetEdit.setText(_translate("Form", "0.1")) + self.label.setText(_translate("Form", "Onset")) + self.dataSamplingRateEdit.setText(_translate("Form", "10000")) + self.label_8.setText(_translate("Form", "Shatter (Hz)")) + self.removeButton.setText(_translate("Form", "-")) + self.shatterHzEdit.setText(_translate("Form", "500")) + self.openPlumeDataButton.setText(_translate("Form", "Open Plume Data")) + self.position.setText(_translate("Form", "1")) + diff --git a/UI/simpleValveWidget.py b/UI/simpleValveWidget.py new file mode 100644 index 0000000..21c5fd1 --- /dev/null +++ b/UI/simpleValveWidget.py @@ -0,0 +1,174 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'SimpleValveWidget.ui' +# +# Created by: PyQt5 UI code generator 5.9 +# +# WARNING! All changes made in this file will be lost! + +from PyQt5 import QtCore, QtGui, QtWidgets + +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(1421, 113) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) + Form.setSizePolicy(sizePolicy) + font = QtGui.QFont() + font.setFamily("Lucida Console") + Form.setFont(font) + self.gridLayout = QtWidgets.QGridLayout(Form) + self.gridLayout.setObjectName("gridLayout") + self.shatterHzEdit = QtWidgets.QLineEdit(Form) + self.shatterHzEdit.setEnabled(False) + self.shatterHzEdit.setObjectName("shatterHzEdit") + self.gridLayout.addWidget(self.shatterHzEdit, 3, 7, 1, 1) + self.repeatsRadio = QtWidgets.QRadioButton(Form) + self.repeatsRadio.setChecked(True) + self.repeatsRadio.setAutoExclusive(False) + self.repeatsRadio.setObjectName("repeatsRadio") + self.gridLayout.addWidget(self.repeatsRadio, 1, 9, 1, 1) + self.lengthRadio = QtWidgets.QRadioButton(Form) + self.lengthRadio.setAutoExclusive(False) + self.lengthRadio.setObjectName("lengthRadio") + self.gridLayout.addWidget(self.lengthRadio, 3, 9, 1, 1) + self.cleanRadio = QtWidgets.QRadioButton(Form) + self.cleanRadio.setChecked(True) + self.cleanRadio.setAutoExclusive(False) + self.cleanRadio.setObjectName("cleanRadio") + self.gridLayout.addWidget(self.cleanRadio, 1, 6, 1, 1) + self.shatterRadio = QtWidgets.QRadioButton(Form) + self.shatterRadio.setAutoExclusive(False) + self.shatterRadio.setObjectName("shatterRadio") + self.gridLayout.addWidget(self.shatterRadio, 3, 6, 1, 1) + self.label_7 = QtWidgets.QLabel(Form) + self.label_7.setObjectName("label_7") + self.gridLayout.addWidget(self.label_7, 2, 5, 1, 1) + self.label_4 = QtWidgets.QLabel(Form) + self.label_4.setObjectName("label_4") + self.gridLayout.addWidget(self.label_4, 0, 4, 1, 1) + self.shatterDutyEdit = QtWidgets.QLineEdit(Form) + self.shatterDutyEdit.setEnabled(False) + self.shatterDutyEdit.setObjectName("shatterDutyEdit") + self.gridLayout.addWidget(self.shatterDutyEdit, 3, 8, 1, 1) + self.label_9 = QtWidgets.QLabel(Form) + self.label_9.setObjectName("label_9") + self.gridLayout.addWidget(self.label_9, 2, 8, 1, 1) + self.label_8 = QtWidgets.QLabel(Form) + self.label_8.setObjectName("label_8") + self.gridLayout.addWidget(self.label_8, 2, 7, 1, 1) + self.pulseWidthEdit = QtWidgets.QLineEdit(Form) + self.pulseWidthEdit.setObjectName("pulseWidthEdit") + self.gridLayout.addWidget(self.pulseWidthEdit, 1, 4, 1, 1) + self.repeatsEdit = QtWidgets.QLineEdit(Form) + self.repeatsEdit.setObjectName("repeatsEdit") + self.gridLayout.addWidget(self.repeatsEdit, 1, 10, 1, 1) + self.pulseDutyEdit = QtWidgets.QLineEdit(Form) + self.pulseDutyEdit.setEnabled(False) + self.pulseDutyEdit.setObjectName("pulseDutyEdit") + self.gridLayout.addWidget(self.pulseDutyEdit, 3, 5, 1, 1) + self.pulseDelayEdit = QtWidgets.QLineEdit(Form) + self.pulseDelayEdit.setObjectName("pulseDelayEdit") + self.gridLayout.addWidget(self.pulseDelayEdit, 1, 5, 1, 1) + self.line_2 = QtWidgets.QFrame(Form) + self.line_2.setFrameShape(QtWidgets.QFrame.HLine) + self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_2.setObjectName("line_2") + self.gridLayout.addWidget(self.line_2, 4, 0, 1, 11) + self.fromValuesRadio = QtWidgets.QRadioButton(Form) + self.fromValuesRadio.setChecked(True) + self.fromValuesRadio.setAutoExclusive(False) + self.fromValuesRadio.setObjectName("fromValuesRadio") + self.gridLayout.addWidget(self.fromValuesRadio, 1, 3, 1, 1) + self.fromDutyRadio = QtWidgets.QRadioButton(Form) + self.fromDutyRadio.setAutoExclusive(False) + self.fromDutyRadio.setObjectName("fromDutyRadio") + self.gridLayout.addWidget(self.fromDutyRadio, 3, 3, 1, 1) + self.label_6 = QtWidgets.QLabel(Form) + self.label_6.setObjectName("label_6") + self.gridLayout.addWidget(self.label_6, 0, 5, 1, 1) + self.label_2 = QtWidgets.QLabel(Form) + self.label_2.setObjectName("label_2") + self.gridLayout.addWidget(self.label_2, 0, 2, 1, 1) + self.offsetEdit = QtWidgets.QLineEdit(Form) + self.offsetEdit.setObjectName("offsetEdit") + self.gridLayout.addWidget(self.offsetEdit, 1, 2, 1, 1) + self.lengthEdit = QtWidgets.QLineEdit(Form) + self.lengthEdit.setEnabled(False) + self.lengthEdit.setObjectName("lengthEdit") + self.gridLayout.addWidget(self.lengthEdit, 3, 10, 1, 1) + self.onsetEdit = QtWidgets.QLineEdit(Form) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.onsetEdit.sizePolicy().hasHeightForWidth()) + self.onsetEdit.setSizePolicy(sizePolicy) + self.onsetEdit.setObjectName("onsetEdit") + self.gridLayout.addWidget(self.onsetEdit, 1, 1, 1, 1) + self.label = QtWidgets.QLabel(Form) + self.label.setObjectName("label") + self.gridLayout.addWidget(self.label, 0, 1, 1, 1) + self.frequencyEdit = QtWidgets.QLineEdit(Form) + self.frequencyEdit.setEnabled(False) + self.frequencyEdit.setObjectName("frequencyEdit") + self.gridLayout.addWidget(self.frequencyEdit, 3, 4, 1, 1) + self.label_5 = QtWidgets.QLabel(Form) + self.label_5.setObjectName("label_5") + self.gridLayout.addWidget(self.label_5, 2, 4, 1, 1) + self.removeButton = QtWidgets.QToolButton(Form) + self.removeButton.setObjectName("removeButton") + self.gridLayout.addWidget(self.removeButton, 2, 0, 1, 1) + self.position = QtWidgets.QLabel(Form) + self.position.setObjectName("position") + self.gridLayout.addWidget(self.position, 0, 0, 2, 1) + + self.retranslateUi(Form) + self.fromValuesRadio.clicked.connect(self.fromDutyRadio.toggle) + self.fromDutyRadio.clicked.connect(self.fromValuesRadio.toggle) + self.cleanRadio.clicked.connect(self.shatterRadio.toggle) + self.shatterRadio.clicked.connect(self.cleanRadio.toggle) + self.repeatsRadio.clicked.connect(self.lengthRadio.toggle) + self.lengthRadio.clicked.connect(self.repeatsRadio.toggle) + self.fromValuesRadio.toggled['bool'].connect(self.pulseWidthEdit.setEnabled) + self.fromValuesRadio.toggled['bool'].connect(self.pulseDelayEdit.setEnabled) + self.fromDutyRadio.toggled['bool'].connect(self.frequencyEdit.setEnabled) + self.fromDutyRadio.toggled['bool'].connect(self.pulseDutyEdit.setEnabled) + self.shatterRadio.toggled['bool'].connect(self.shatterHzEdit.setEnabled) + self.shatterRadio.toggled['bool'].connect(self.shatterDutyEdit.setEnabled) + self.repeatsRadio.toggled['bool'].connect(self.repeatsEdit.setEnabled) + self.lengthRadio.toggled['bool'].connect(self.lengthEdit.setEnabled) + QtCore.QMetaObject.connectSlotsByName(Form) + + def retranslateUi(self, Form): + _translate = QtCore.QCoreApplication.translate + Form.setWindowTitle(_translate("Form", "Form")) + self.shatterHzEdit.setText(_translate("Form", "500")) + self.repeatsRadio.setText(_translate("Form", "Repeats")) + self.lengthRadio.setText(_translate("Form", "Length (s)")) + self.cleanRadio.setText(_translate("Form", "Clean")) + self.shatterRadio.setText(_translate("Form", "Shatter")) + self.label_7.setText(_translate("Form", "Duty (/1)")) + self.label_4.setText(_translate("Form", "Pulse Width (s)")) + self.shatterDutyEdit.setText(_translate("Form", "0.5")) + self.label_9.setText(_translate("Form", "Duty (/1)")) + self.label_8.setText(_translate("Form", "Frequency (Hz)")) + self.pulseWidthEdit.setText(_translate("Form", "0.1")) + self.repeatsEdit.setText(_translate("Form", "5")) + self.pulseDutyEdit.setText(_translate("Form", "0.5")) + self.pulseDelayEdit.setText(_translate("Form", "0.1")) + self.fromValuesRadio.setText(_translate("Form", "From Values")) + self.fromDutyRadio.setText(_translate("Form", "From Duty")) + self.label_6.setText(_translate("Form", "Pulse Delay (s)")) + self.label_2.setText(_translate("Form", "Offset")) + self.offsetEdit.setText(_translate("Form", "0.1")) + self.lengthEdit.setText(_translate("Form", "1")) + self.onsetEdit.setText(_translate("Form", "0.1")) + self.label.setText(_translate("Form", "Onset")) + self.frequencyEdit.setText(_translate("Form", "5")) + self.label_5.setText(_translate("Form", "Frequency (Hz)")) + self.removeButton.setText(_translate("Form", "-")) + self.position.setText(_translate("Form", "1")) + diff --git a/pulseboi.code-workspace b/pulseboi.code-workspace new file mode 100644 index 0000000..bd32c09 --- /dev/null +++ b/pulseboi.code-workspace @@ -0,0 +1,19 @@ +{ + "folders": [ + { + "path": "." + }, + { + "path": "..\\PyPulse" + }, + { + "path": "..\\daqface" + }, + { + "path": "..\\vipy" + } + ], + "settings": { + "python.pythonPath": "c:\\Users\\warnert\\Documents\\WinPython-64bit-3.6.3.0Qt5\\python-3.6.3.amd64\\python.exe" + } +} \ No newline at end of file