Skip to content

Instantly share code, notes, and snippets.

View jefferis's full-sized avatar

Gregory Jefferis jefferis

View GitHub Profile
@jefferis
jefferis / jfrc_mesh_test.json
Last active January 10, 2021 23:32
neuroglancer layer to add a brain mesh
{
"source": "precomputed://https://spine.janelia.org/files/eric/jfrc_mesh_test",
"type": "segmentation",
"objectAlpha": 0.25,
"loadSkeletons": false,
"segments": [
"1"
],
"hiddenSegments": [
"2"
@jefferis
jefferis / reduceddps.R
Last active April 2, 2018 15:44
Some code for making (multiple) dotprops objects from skeletonised images. Originally used with output of Nick Masse's image dimension reduction. Input would be matlab .mat file from the Masse code. Then tries to fine one or more connected components based on a radius threshold.
#' Make R dotprops from matlab output of Masse image_dimension_reduction()
#'
#'
as.dotprops.masseidr<-function(f,subsample=0.1,reg=NULL,k=5,regopts=NULL,...) {
stopifnot(require(R.matlab))
x=readMat(f)
dots=t(do.call(cbind,x$dots))
if(subsample!=1){
idxs=sample(nrow(dots),round(nrow(dots)*subsample))
dots=dots[idxs,]
@jefferis
jefferis / emlhtractsummary.R
Created December 21, 2017 16:52
Summary of EM tracts connecting to the LH.
library(xtable)
#Sheet 6 from LHN Tract summary spreadsheet
data <- as.data.frame(read.csv("~/Desktop/lhntractdata.csv"))
#remove total row
data<- data[1:(nrow(data)-1),]
#cols_wanted for table & round
cols_wanted <- c(1,2,3,4,19,20)
@jefferis
jefferis / neuron2440471.json
Created March 29, 2017 17:16
catmaid_get_connectors_between(post_skids = 'name:neuron 2440471')
[
[
7867892,
[
421686.0,
234501.0,
172060.0
],
7858835,
23829,
@jefferis
jefferis / untar.R
Last active November 27, 2016 19:03
untarring fafb tiles
#' Untar a folder of FAFB tar files to a destination disk
#'
#' @param src The src folder (typically representing a whole drive)
#' @param dest The dest folder (will be created if required)
#'
#' @return
#' @export
untar_fafb <- function(src, dest){
if(!file.exists(src)) stop("No src folder: ", src)
if(!file.exists(dest)) {
@jefferis
jefferis / README.md
Last active February 2, 2022 09:04
Install packages/data useful for flyconnectome team

Install all jlab R packages

This gist will let you efficiently install all the R packages and data suggested for the flyconnectome team

Start a clean R session and do:

if(!require("devtools")) install.packages("devtools")
devtools::source_gist("fdd1e5b6e009ff49e66be466a104fd92", filename = "install_flyconnectome_all.R")
@jefferis
jefferis / README.md
Last active June 1, 2016 20:01
Install all Jlab

Install all jlab R packages

This gist will let you efficiently install all the packages main Jefferis Lab R packages.

Start a clean R session and do:

if(!require("devtools")) install.packages("devtools")
devtools::source_gist("52cf9ff123e5107cd96ab2bbbe85a29e")
@jefferis
jefferis / mungerhelp.txt
Created April 18, 2016 15:06
munger.pl help
Usage: /usr/local/bin/munger [OPTIONS] <PICFILE/DIR> [<PICFILE2/DIR2> ...]
Version: 1.21
A wrapper script for CMTK registration software. For more on CMTK see:
http://www.nitrc.org/projects/cmtk/
-h print this help
-v verbose (provide extra feed back at runtime)
-t test run (no commands are actually run)
-g debug: prints every command run by myexec and the return value
@jefferis
jefferis / FlyCircuitStartupNat.R
Created October 9, 2015 16:14
flycircuit neurons with nat
library(flycircuit)
# download NBLAST all by all score matrix (used e.g. for hierarchical clustering)
# this downloads a single 2Gb file to your machine as a one-off
fc_download_data('http://flybrain.mrc-lmb.cam.ac.uk/si/nblast/flycircuit/allbyallblastcv4.5.ff',
type='ff')
# set that as default all by all score matrix
options('flycircuit.scoremat'="allbyallblastcv4.5.ff")
# load neuron list
# the actual neuron data will be downloaded and cached to your machine on demand
@jefferis
jefferis / readObj.R
Created April 3, 2015 18:35
rgl::readOBJ (still not available on osx due to unrelated errors with latest rgl package)
# straight from:
# https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/rgl/R/obj.R?revision=1197&root=rgl
# see:
# https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/rgl/DESCRIPTION?revision=1234&root=rgl
# for authorship/license information
readOBJ <- function(con, ...) {
lines <- readLines(con)
instrs <- sub(" .*", "", lines)
vertices <- read.table(textConnection(lines[instrs == "v"]),
col.names = c("instr", "x", "y", "z"),