Skip to content

Instantly share code, notes, and snippets.

View jdmanton's full-sized avatar

James Manton jdmanton

  • MRC Laboratory of Molecular Biology
  • UK
View GitHub Profile
@jdmanton
jdmanton / MMFastAcquire.bsh
Created October 30, 2023 17:50
Circumvent pauses in Micromanager's MDA timelapse acquisitions by continuously streaming cameras and throwing away blank frames
// Circumvent pauses in MDA timelapse acquisitions by continuously streaming cameras and throwing away blank frames
// James Manton
// jmanton@mrc-lmb.cam.ac.uk
// 2023-10-30
import ij.gui.*;
import ij.gui.GenericDialog;
import org.micromanager.data.Datastore;
import org.micromanager.data.Coords;
import mmcorej.TaggedImage;
@jdmanton
jdmanton / wordle_2022.txt
Created January 22, 2022 01:18
Wordle 2022
01 Jan rebus
02 Jan boost
03 Jan truss
04 Jan siege
05 Jan tiger
06 Jan banal
07 Jan slump
08 Jan crank
09 Jan gorge
10 Jan query
@jdmanton
jdmanton / calc_date_factors.R
Last active February 2, 2021 01:34
Calculate factors of dates in given range and see how many are consecutive pairs
library(numbers)
dates <- seq(as.Date("2021-01-01"), as.Date("2021-12-31"), by="days")
# For European-style dates
# nums <- sapply(dates, function(x) as.numeric(gsub("-", "", as.character(x, format="%d-%m-%Y"))))
# For ISO-style dates
nums <- sapply(dates, function(x) as.numeric(gsub("-", "", x)))
@jdmanton
jdmanton / debayer.ijm
Last active January 5, 2020 16:58
Basic debayering macro, originally for Chang'E-4 Moon data
setBatchMode(true);
id = getImageID();
title = getTitle();
make_colour_channel("R", 0, 0);
selectImage(id);
make_colour_channel("G1", -1, 0);
selectImage(id);
make_colour_channel("G2", 0, -1);
selectImage(id);
@jdmanton
jdmanton / Deskew_LSFM_data.bsh
Created December 27, 2019 00:56
ImageJ/Fiji script for deskewing stage-scan light sheet data (inc. OPM)
# Light sheet deskewing software, using Erik Meijering's TransformJ plugin suite
# James Manton, 2019
import ij.ImagePlus;
import imagescience.image.Image;
import imagescience.transform.Affine;
import imagescience.transform.Transform;
import ij.measure.Calibration;
pkgs <- c('flycircuit', 'nat.mouselight', 'fishatlas', 'insectbrainr', 'neuromorphr', 'vfbr', 'drvid', 'fafbseg', 'neuprintr', 'catmaid', 'elmr', 'nat.utils', 'nat.amira', 'nabor', 'nat.nblast', 'nat.h5reg', 'deformetricar', 'nat.templatebrains', 'nat.flybrains')
# nat.ants not available
lapply(pkgs, require, character.only=T)
pkgs_fns <- lapply(pkgs, function(x) lsf.str(getNamespace(x)))
num_fns <- sapply(pkgs_fns, length)
names(num_fns) <- pkgs
total_num_fns <- sum(num_fns)
@jdmanton
jdmanton / initialism.tex
Last active August 29, 2015 14:27
LaTeX macro to define a command that produces the full name on first use, then on subsequent uses produces just an initialism
\documentclass{minimal}
\makeatletter
\newcommand{\initial}[3]{%
\expandafter\newif\csname ifswitch#1\endcsname%
\@namedef{long#1}{#2}%
\@namedef{short#1}{#3}%
\expandafter\newcommand\csname #1\endcsname{\expandafter\csname ifswitch#1\endcsname\csname short#1\endcsname\else\csname long#1\endcsname{} (\csname short#1\endcsname)\csname switch#1true\endcsname \fi}
}
\makeatother
@jdmanton
jdmanton / radon_image.m
Last active August 29, 2015 14:19
Radon image reconstruction
radon_image = imread('downloaded_profile_photo.jpg');
angles = linspace(0, 180, size(radon_image, 2));
reconstructed_image = iradon(radon_image, angles);
figure
imshow(reconstructed_image, [])
@jdmanton
jdmanton / quick_start.R
Created September 20, 2014 18:57
Quick-start NBLAST clustering of Fru LHNs
if(!require(devtools)) install.packages('devtools')
devtools::install_github(c('gphys', 'nat', 'frulhns'), 'jefferis')
devtools::install_github('nat.nblast', 'jefferislab')
library(frulhns)
library(nat)
library(nat.nblast)
# Open a 3D viewer that we can pan, rotate and zoom
nopen3d()