Skip to content

Instantly share code, notes, and snippets.

View bnorthan's full-sized avatar

Brian Northan bnorthan

View GitHub Profile
@bnorthan
bnorthan / ExtractPSF.py
Created December 9, 2020 15:21
Extract PSF Tweaked for forum question
#@ OpService ops
#@ ImgPlus beads
#@OUTPUT ImgPlus thresholded
#@OUTPUT ImgPlus points
#@OUTPUT ImgPlus psf
from net.imglib2.algorithm.labeling.ConnectedComponents import StructuringElement
from net.imglib2.roi.labeling import LabelRegions
# reference
package com.example;
import java.io.IOException;
import net.imagej.Dataset;
import net.imagej.ImageJ;
import net.imagej.ImgPlus;
import net.imagej.ops.filter.pad.PadInputFFTMethods;
import net.imglib2.RandomAccessibleInterval;
@bnorthan
bnorthan / DeconWithHalfPSF.py
Last active September 12, 2019 17:58
This script deconvolves with a theoretical PSF that has the lower half zeroed as an attempt to deconvolve images form a section cutting device.
#@ OpService ops
#@ UIService ui
#@ ImgPlus img
#@ Integer numIterations(value=20)
#@ Float numericalAperture(value=0.25)
#@ Float wavelength(value=705)
#@ Float riImmersion(value=1.00)
#@ Float riSample(value=1.5)
#@ Float xySpacing(value=570)
#@ Float zSpacing(value=1700)
@bnorthan
bnorthan / Birthday.m
Created August 16, 2019 22:37
How many people in the room have the same birthday
for i=1:365
% let's simulate 1000 times
for j=1:1000
% make a vector of random numbers (1 to 365) i times
test=randi(365,[1 i]);
% test if there is a duplicate
dupbirthday(i,j)=~(length(test) == length(unique(test)));
end
end
@bnorthan
bnorthan / DeconvolutionTest.java
Created December 14, 2018 12:37
Non-Circulant ops deconvolution test
package com.example;
import net.imagej.ImageJ;
import net.imagej.ops.deconvolve.RichardsonLucyF;
import net.imagej.ops.filter.convolve.ConvolveFFTF;
import net.imglib2.Point;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.algorithm.region.hypersphere.HyperSphere;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImgFactory;
@bnorthan
bnorthan / SaturationDetection.java
Created January 29, 2018 17:04
Saturation detection command modified to also return Huang threshold
package com.tnia.commands;
import net.imagej.ImgPlus;
import net.imagej.ops.OpService;
import net.imagej.ops.special.computer.BinaryComputerOp;
import net.imglib2.IterableInterval;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.histogram.Histogram1d;
import net.imglib2.realtransform.AffineTransform2D;
import net.imglib2.type.NativeType;
@bnorthan
bnorthan / InteractiveEquationTest.java
Last active January 5, 2018 21:03
Ops Equation Interactive test
package net.imagej.ops.experiments.equation;
import net.imagej.ImageJ;
import net.imglib2.FinalDimensions;
import net.imglib2.type.numeric.real.DoubleType;
public class InteractiveEquationTest {
final static ImageJ ij = new ImageJ();
@bnorthan
bnorthan / OpsDeconvolve.java
Last active December 27, 2017 03:44
Deconvolution with theoretical PSF
public class InteractiveDeconvolveTheoreticalTest<T extends RealType<T> & NativeType<T>> {
final static ImageJ ij = new ImageJ();
public static <T extends RealType<T> & NativeType<T>> void main(final String[] args) throws IOException {
String libPathProperty = System.getProperty("java.library.path");
System.out.println("Lib path:" + libPathProperty);
ij.launch(args);
@bnorthan
bnorthan / DeconWithGrid.groovy
Created December 27, 2017 02:49
Create a "grid" image and deconvolve it using the RIchardson Lucy algorithm with several different options.
// @OpService ops
// @UIService ui
// @ConvertService convert
// @DatasetService data
import net.imglib2.type.numeric.real.FloatType;
import net.imagej.ops.Op
import net.imglib2.outofbounds.OutOfBoundsConstantValueFactory
import net.imagej.ops.deconvolve.RichardsonLucyF
import net.imglib2.util.Util