Skip to content

Instantly share code, notes, and snippets.

Genevieve Buckley GenevieveBuckley

  • Monash University
  • Melbourne
View GitHub Profile
@GenevieveBuckley
GenevieveBuckley / overwrite_file_check.py
Last active Jan 9, 2018
ImageJ Jython script testing for the existence of an output file before writing to that file location. Graceful exit if user chooses to cancel the operation.
View overwrite_file_check.py
# @File (label = "Output directory", style = "directory") output_directory
import os
import csv
from ij.gui import YesNoCancelDialog
from java.awt import Frame
def main():
"""ImageJ Jython script testing for the existence of an output file before
writing to that file location.
@GenevieveBuckley
GenevieveBuckley / convert_ImagePlus_to_ImgPlus.py
Created Jan 9, 2018
ImageJ API scripting in Jython - how to convert to and from ImgPlus and ImagePlus. http://javadoc.scijava.org
View convert_ImagePlus_to_ImgPlus.py
"""Converting from ImagePlus to ImgPlus.
When an ImagePlus is made available by ImageJ 1.x,
you can pass it to ImgLib2 as an Img via ImageJFunctions.wrap(imp)
http://javadoc.scijava.org/ImgLib2/net/imglib2/img/display/imagej/ImageJFunctions.html
"""
from ij import IJ
from net.imglib2.img import ImagePlusAdapter
image = IJ.openImage() # opens a file picker, or you can add the filename string as an argument.
output = ImagePlusAdapter.wrapImgPlus(image) #
View ImageJParameters.java
/*
IMAGEJ PARAMETER NOTATION
https://imagej.net/Script_Parameters
Parameter declarations begin with #@ or //@. Each such line contains a single parameter declaration and nothing else.
//@type variableName // will declare an input of the indicated type, assigned to the specified name.
//@output type outputName // will declare the variable of the specified name as an output parameter with the given type.
*/
@GenevieveBuckley
GenevieveBuckley / create_gradient_image_for_watershed.py
Last active Jan 9, 2018
Watershed methods using Jython scripting and the ImageJ/ImgLib2/MorphoLibJ APIs. http://javadoc.scijava.org
View create_gradient_image_for_watershed.py
"""Calculating the gradient image that needs to go into Watershed."""
from ij import IJ
# operates on ImagePlus object: imp
IJ.run(imp, "Gradient (3D)", "use")
# modifies imp, returns None.
# YOU MUST MAKE A COPY OF IMP BEFORE YOU RUN THIS!
# This method also automatically displays the modified gradient image (unless you suppress it).
# Output image name is always "Rebinned" - change it to something better afterwards.
@GenevieveBuckley
GenevieveBuckley / files_matching_file_extension.py
Created Jun 19, 2018
Find files matching a specific file extension, via recursive search through input directory.
View files_matching_file_extension.py
def find_filenames(input_directory, file_extension):
"""Return list of filenames matching file extension."""
filelist = []
for root, _, files in os.walk(input_directory):
for file in files:
if file.endswith(file_extension):
filename = os.path.join(root, file)
filelist.append(filename)
return filelist
@GenevieveBuckley
GenevieveBuckley / gradient_edge_enhancement.py
Created Jun 19, 2018
Edge enhancement - sum of the absolute image gradient for all orientations.
View gradient_edge_enhancement.py
def gradient_of_image(image):
"""Direction agnostic."""
grad = np.gradient(image) # gradients for individual directions
grad = np.stack(grad, axis=-1) # from list of arrays to single numpy array
gradient_image = np.sum(abs(grad), axis=-1)
return gradient_image
View bokeh_utils.py
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
def scatter_with_hover(df, x, y,
fig=None, cols=None, name=None, marker='x',
fig_width=500, fig_height=500, **kwargs):
"""
Plots an interactive scatter plot of `x` vs `y` using bokeh, with automatic
tooltips showing columns from `df`.
@GenevieveBuckley
GenevieveBuckley / GitHub-Forking.md
Created Aug 8, 2018 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow
View GitHub-Forking.md

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@GenevieveBuckley
GenevieveBuckley / gui_automation_python.md
Last active Aug 8, 2018 — forked from diyan/gui_automation_python.md
Desktop GUI automation in Python
View gui_automation_python.md

Desktop

UI Automation. Desktop. Python

GUI toolkit agnostic

autopy - simple, cross-platform GUI automation toolkit. MIT - https://github.com/autopilot-rs/autopy

  • GUI toolkit agnostic
  • allows you to move mouse, take screenshots, show alerts, search for bitmaps on-screen
@GenevieveBuckley
GenevieveBuckley / imread
Created Aug 8, 2018 — forked from charlesreid1/imread
Results from using different imread() functions
View imread
In [1]: from skimage.io import imread as skimage_imread
In [2]: from matplotlib.pyplot import imread as plt_imread
In [3]: from scipy.ndimage import imread as scipy_imread
In [4]: skimage_imread('bulk_water_000.png')
Out[4]:
array([[[146, 125, 54, 255],
[146, 125, 54, 255],
You can’t perform that action at this time.