Skip to content

Instantly share code, notes, and snippets.

View GenevieveBuckley's full-sized avatar

Genevieve Buckley GenevieveBuckley

  • Monash University
  • Melbourne
View GitHub Profile
@GenevieveBuckley
GenevieveBuckley / napari_threshold_segmentation.py
Created July 20, 2022 03:01
Choose a threshold value using a magicgui widget in napari.
"""Choose a threshold value using a magicgui widget in napari.
Based on the magicgui excample script napari_parameter_sweep.py
https://github.com/napari/magicgui/blob/main/examples/napari_param_sweep.py
"""
import napari
import skimage.data
import skimage.filters
from napari.layers import Image
from napari.types import LabelsData
class CupyContextManager:
def __init__(self):
self.previous_np = None
def __enter__(self):
self.previous_np = globals().get("np")
import cupy as np
globals()["np"] = np
return np
@GenevieveBuckley
GenevieveBuckley / 2022-03-10-janeliainference-workstationANNA-linkingPythonWithCUDA10.md
Created March 10, 2022 05:03
Janelia inference, Workstation ANNA, linking Python to CUDA 10 installation

There's some kind of problem linking python to the existing CUDA 10 installation (CUDA 10.0 lives at C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\)

(base) C:\Users\CryoEM>conda activate CNNectome

(CNNectome) C:\Users\CryoEM>ipython
Python 3.6.12 |Anaconda, Inc.| (default, Sep  9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
@GenevieveBuckley
GenevieveBuckley / 20220224-malis-pipinstall-error-workstation.txt
Created February 24, 2022 07:15
Malis pip installation error on Windows workstation (required for CNNectome Janelia project)
(CNNectome) C:\Users\CryoEM\Documents\GitHub\OpenOrganelle\CNNectome>pip install malis[malis_loss]@git+https://github.com/neptunes5thmoon/malis.git@fix_setup
Collecting malis[malis_loss]@ git+https://github.com/neptunes5thmoon/malis.git@fix_setup
Cloning https://github.com/neptunes5thmoon/malis.git (to revision fix_setup) to c:\users\cryoem\appdata\local\temp\pip-install-835bihd5\malis_d558e69fd2aa477b8a3ada5875704cf7
Running command git clone -q https://github.com/neptunes5thmoon/malis.git 'C:\Users\CryoEM\AppData\Local\Temp\pip-install-835bihd5\malis_d558e69fd2aa477b8a3ada5875704cf7'
Running command git checkout -b fix_setup --track origin/fix_setup
branch 'fix_setup' set up to track 'origin/fix_setup'.
Switched to a new branch 'fix_setup'
Resolved https://github.com/neptunes5thmoon/malis.git to commit 2a54eed480edc8b0e9948f24b1193a58c5714d2d
WARNING: malis 1.0 does not provide the extra 'malis_loss'
@GenevieveBuckley
GenevieveBuckley / env_CNNectome_M1Mac.txt
Created February 14, 2022 00:23
Conda environment file for CNNectome on an M1 Mac
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-arm64
@EXPLICIT
https://conda.anaconda.org/conda-forge/osx-arm64/c-ares-1.18.1-h3422bc3_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-arm64/ca-certificates-2021.10.8-h4653dfc_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-arm64/libcxx-12.0.1-h168391b_1.tar.bz2
https://conda.anaconda.org/conda-forge/osx-arm64/libev-4.33-h642e427_1.tar.bz2
https://conda.anaconda.org/conda-forge/osx-arm64/libffi-3.4.2-h3422bc3_5.tar.bz2
https://conda.anaconda.org/conda-forge/osx-arm64/libzlib-1.2.11-hee7b306_1013.tar.bz2
@GenevieveBuckley
GenevieveBuckley / hlg-steps.md
Created December 10, 2021 09:28
Steps to implement a new high level graph in Dask

So, you want to make a new high level graph layer class?

Step 1:

It's common to want to convert something Dask already does, and convert it to use high level graph under the hood.

First you need to find the place in the code where the dask task dictionary is created. Typically this looks like a variable called dsk or dsk_out that is a dictionary mapping the key names to individual tasks.

Found it? Great, this is the spot we're going to insert an instance of your (new, not yet created) high level graph class, eg: dsk_out = MyNewLayer(input_args, ...)

@GenevieveBuckley
GenevieveBuckley / hacky-dask-map-overlap.ipynb
Created November 11, 2021 05:22
Experimenting with a hacky dask map_overlap
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GenevieveBuckley
GenevieveBuckley / itkImagePython.py
Created October 29, 2021 06:07
itkImagePython hacks
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 4.0.2
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
import os
import six
import collections
@GenevieveBuckley
GenevieveBuckley / nuke-and-reinstall-conda.sh
Created October 12, 2021 23:18
Nuke and reinstall conda script
#!/bin/bash
# Fernando's nuke and reinstall conda script
# https://twitter.com/fperez_org/status/1447996737063317512
# Download and install miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/Downloads/miniconda.sh
bash ~/Downloads/miniconda.sh -b -p $HOME/local/conda
conda config --add channels conda-forge
@GenevieveBuckley
GenevieveBuckley / match_dask_keys.py
Created September 9, 2021 05:40
Mater Dask keys, ignoring token strings
def match_key(key, keylist):
# key to match
key = list(key)
key[0] = key[0].rsplit('-', 1)[0] # remove token
# search for matches
for k in keylist:
temp = list(k)
temp[0] = temp[0].rsplit('-', 1)[0] # remove token
if temp == key:
return tuple(k)