Skip to content

Instantly share code, notes, and snippets.

View tlambert03's full-sized avatar

Talley Lambert tlambert03

View GitHub Profile
@tlambert03
tlambert03 / ClipboardActionTransformations.xml
Last active August 13, 2019 17:59
Remote Desktop keymap
<?xml version="1.0" encoding="utf-8" ?>
<!-- transformation for clipboard actions (cut copy paste) -->
<!-- layout specific -->
<layouts>
<!-- Dvorak X C V are not on same physical position as on US keyboard. -->
<layout name="com.apple.keylayout.Dvorak">
<transformations>
<!-- Command+X to Control+X -->
<transform>
<from command="1" key="B" />
import os
import dask.array as da
from dask import delayed
from skimage.io import imread
from skimage.external import tifffile as tf
from glob import glob
import re
delayed_read = delayed(imread)
@tlambert03
tlambert03 / getting_started_with_napari_from_scratch.md
Last active April 13, 2020 15:54
a minimal guide to getting up and running with a python environment and napari.

getting started with napari

This describes how to get started with napari in a full python environment, from scratch.

Install anaconda or miniconda

There are many ways to get python on your computer. You can just go to https://www.python.org/downloads/ to get python, but anaconda is nice for two reasons:

  1. It provides a built in "environment" manager (called conda) that allows you to create isolated virtual environments (which are basically just folders somewhere on your computer that have, among other things, a handful of packages that you have installed). Virtual environments are useful because you can easily create multiple environments with different combinations of packages and versions without messing up your "root" environment (more on this below).
  2. For some combinations of packages, it can be hard to get them all working together, so Anaconda ships with a complete working environment that already contains [the main packages in the scientific python stack](https://docs.anaconda.com/an
"""
example of using napari to show model predictions as they update.
requires stuff from https://github.com/jni/noise2self
"""
import torch
from torch.utils.data import DataLoader, Dataset
from torchvision import datasets, transforms
import napari
from mask import Masker
@tlambert03
tlambert03 / bootstrap
Last active December 16, 2020 23:04
bootstrap new OS X install:
#!/bin/zsh
## RUN WITH:
# curl https://bit.ly/33mby8d -o bootstrap
# chmod +x bootstrap
# ./bootstrap
###############################################################################
# Install Xcode command line tools
###############################################################################
STYLES = {
"double": {
"TOP": ("╔", "╤", "╗", "═"),
"MID": ("╟", "┼", "╢", "─"),
"BOT": ("╚", "╧", "╝", "═"),
"V": ("║", "│"),
},
"heavy": {
"TOP": ("┏", "┯", "┓", "━"),
"MID": ("┠", "┼", "┨", "─"),
@tlambert03
tlambert03 / error.md
Created April 29, 2021 12:03
zarpaint bug
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/miniconda3/envs/napdev/lib/python3.9/site-packages/magicgui/widgets/_bases/value_widget.py in (*x=(False,))
     42         self.changed = EventEmitter(source=self, type="changed")
     43         self._widget._mgui_bind_change_callback(
---> 44             lambda *x: self.changed(value=x[0] if x else None)
        x = (False,)
        global self.changed = undefined
        global value = undefined
@tlambert03
tlambert03 / napari_events_table.py
Created May 11, 2021 15:38
iter_events in napari
from dataclasses import dataclass
from typing import Optional, Type
import napari
import inspect
from napari.utils.events import EventedModel
from napari.utils.settings._defaults import BaseNapariSettings
from napari.components.viewer_model import ViewerModel
@tlambert03
tlambert03 / nic_cleanup.py
Last active August 2, 2021 20:48
nic cleanup
import os
import sys
import time
from pathlib import Path
SAFE_WORD = "delete" # if this word is in the filename, it won't be deleted
def find_userd(noinput=False):
# detect user directory
@tlambert03
tlambert03 / img_protocols.py
Last active July 14, 2021 03:25
analysis protocols chalkboard
from typing import Generic, TypeVar, Any, Literal, Union, overload
import numpy as np
DType = TypeVar("DType")
Shape = TypeVar("Shape")
class Array(Generic[Shape, DType]): ...
# a way to temporarily discuss shapes,
# until we can use PEP 646