Skip to content

Instantly share code, notes, and snippets.

console.log('Hello LabJack')
var ljn = require('labjack-nodejs');
var NanoTimer = require('nanotimer')
var fs = require('fs')
var now = require('performance-now')
var path = require('path')
var mkdirp = require('mkdirp').mkdirp
@sofroniewn
sofroniewn / cartpole-experiment-1.py
Created March 18, 2017 20:00
CartPole-experiment-1.py
import gym
from gym import wrappers
env = gym.make('CartPole-v0')
env = wrappers.Monitor(env, './tmp/cartpole-experiment-1')
for i_episode in range(20):
observation = env.reset()
for t in range(100):
env.render()
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
@sofroniewn
sofroniewn / 3d-spots.ipynb
Last active January 31, 2019 21:06
3d-spot-detection
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sofroniewn
sofroniewn / napari-align_distribute.py
Created February 10, 2019 00:11
align and distribute code for napari
def align_shapes(self, index=True, axis=0, location=1, to_canvas=False):
"""Aligns selected shapes either in horizontal or vertical axis to
the left, center, right, or top, center, bottom. If to_canvas is True
then it aligns to the canvas.
Parameters
----------
index : bool, list, int
index of objects to be selected. Where True corresponds to all
objects, a list of integers to a list of objects, and a single
integer to that particular object.
@sofroniewn
sofroniewn / qtdims_tests.py
Created April 20, 2019 03:18
Tests for qtdims model
# This is in interactive test
from time import sleep
import threading
from napari.components import Dims
from napari.components._dims._constants import DimsMode
from napari.components._dims.view import QtDims
from napari.util import app_context
@sofroniewn
sofroniewn / qtviewer_tests.py
Created April 20, 2019 03:20
Tests for qtviewer
from skimage import data
from skimage.color import rgb2gray
from napari import Viewer
from napari.util import app_context
# THIS WILL NOT WORK UNTIL THERE IS SEPARATION BETWEEN MODEL AND VIEW!
def test_dims_and_ranges():
@sofroniewn
sofroniewn / range_slider_tests.py
Created April 20, 2019 03:21
Tests for range slider
"""
Interactive test for range slider.
"""
# starts the QT event loop
from napari._qt.range_slider.range_slider import QVRangeSlider
from napari.util import app_context
with app_context():
def _get_viewer_thumbnail(self):
"""Creat an overall thumbnail based on the layer thumbnails."""
thumbnail = np.zeros(layers.Layer._thumbnail_shape, dtype=np.uint8)
for layer in self.layers[::-1]:
if layer.blending == 'translucent':
f_dest = thumbnail[..., 3][..., None] / 255
f_source = 1 - layer.thumbnail[..., 3][..., None] / 255
elif layer.blending == 'additive':
f_dest = thumbnail[..., 3][..., None] / 255
def generate_3D_path_meshes_2D(path, p=(0, 0, 1)):
"""Generates list of mesh vertices and triangles from a path
Parameters
----------
path : (N, D) array
Vertices specifying the path where D is 2 or 3.
p : 3-tuple, optional
orthogonal vector for segment calculation in 3D.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.