Skip to content

Instantly share code, notes, and snippets.

View bogovicj's full-sized avatar

John Bogovic bogovicj

  • HHMI Janelia Research Campus
  • Washington DC metro area
View GitHub Profile
@bogovicj
bogovicj / OptionalMapAbuse.java
Last active May 10, 2024 21:24
Use the map method to cause a side-effect if the optional is not-empty.
public T getValidateDefault(String parameter, Predicate<T> validator, T defaultValue) {
return getOptional(parameter).filter(validator)
.map(x -> {
allDefault = false;
return x;
}).orElse(defaultValue);
}
#@ File(styles="both") root
#@ String(value="/") datasetPath
/*
* If you used Fiji to export a multi-scale image with N5Viewer metadata using average downsampling
* between approximately March 13 and April 15 2024, the translation metadata may be incorrect.
*
* Running this script will correct the metadata.
*
* John Bogovic
#@ File(styles="both") root
#@ String(value="/") datasetPath
/*
* If you used Fiji to export a multi-scale an image with COSEM metadata using average downsampling
* between approximately March 13 and April 15 2024, the translation metadata may be incorrect.
*
* Running this script will correct the metadata.
*
* John Bogovic
#@ File(styles="both") root
#@ String(value="/") datasetPath
/*
* If you used Fiji to export a multi-scale OME-Zarr image using average downsampling
* between approximately March 13 and April 15 2024, the translation metadata may be incorrect.
*
* Running this script will correct the metadata.
*
* John Bogovic
@bogovicj
bogovicj / shapeDemo.groovy
Created April 2, 2024 14:12
ImageJ2 script that displays a Diamond or Hypersphere neighborhood for a given radius
#@ DatasetService ds
#@ UIService ui
#@ Long radius = 13
#@ String (choices={"Diamond", "Hypersphere"}, style="listBox") shapeType
/*
* Displays a Diamond or Hypersphere neighborhood for a given radius
*/
if( shapeType.equals("Diamond"))
shp = new DiamondShape(radius);
@bogovicj
bogovicj / skimage_affine.ipynb
Created March 20, 2024 14:06
Apply an affine or scaling transform with scikit-image
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogovicj
bogovicj / CompressionExamples.java
Created December 8, 2023 18:16
Create example n5 array datasets for a variety of compression methods.
package org.janelia.saalfeldlab.n5.generateExamples;
import org.janelia.saalfeldlab.n5.Bzip2Compression;
import org.janelia.saalfeldlab.n5.Compression;
import org.janelia.saalfeldlab.n5.GzipCompression;
import org.janelia.saalfeldlab.n5.Lz4Compression;
import org.janelia.saalfeldlab.n5.N5Writer;
import org.janelia.saalfeldlab.n5.RawCompression;
import org.janelia.saalfeldlab.n5.XzCompression;
import org.janelia.saalfeldlab.n5.blosc.BloscCompression;
@bogovicj
bogovicj / image_geometry.ipynb
Last active March 7, 2024 15:37
Image geometry and indexing in python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bogovicj
bogovicj / awsCredentialsCheck.groovy
Last active August 4, 2023 20:49
Fiji S3 credentials tests
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.AnonymousAWSCredentials;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ListObjectsV2Request;
@bogovicj
bogovicj / iterateRows.groovy
Created June 22, 2023 20:57
ImageJ2 script to perform an operation over the rows of a dataset
#@ Dataset img
/**
* Perform an operation on every row of the input image.
*
* This sets every pixel in the first row to have value zero,
* the second row will have value one, etc.
*
* https://forum.image.sc/t/best-way-to-iterate-over-columns-rows/82472
*/