/* BARlib.bsh * IJ BAR: https://github.com/tferr/Scripts#scripts * * Common BAR library to be placed in BAR/lib. This file hosts methods to * be used across all your scripts. To add this scripted classe, append the * following to your files: * addClassPath(bar.Utils.getBARDir()); * importCommands("lib/"); * BARlib(); * Then, initiate it using: * lib = new BARlib(); * lib.confirmLoading(); */ BARlib() { public class BARlib { /////////// UTILITIES /////////// /** Acknowledges accessibility to this file */ void confirmLoading() { ij.IJ.showMessage("BAR lib successfully loaded!"); } /** Returns text from the system clipboard or an empty string if no text was found */ String getCliboardText() { return bar.Utils.getClipboardText(); } /** Returns a random uuid */ String randomString() { import java.util.UUID; return UUID.randomUUID().toString(); } /////////// CALCULATIONS /////////// /** Smooths 1D data according to the specified window */ double[] getSimpleMovingAverage(double[] values, int window) { if (window<1) return values; svalues = new double[values.length]; for (i=0; i