Skip to content

Instantly share code, notes, and snippets.

@dwaithe
Created May 21, 2020 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwaithe/526eb15b06fa88e4981d70d3c1a73b60 to your computer and use it in GitHub Desktop.
Save dwaithe/526eb15b06fa88e4981d70d3c1a73b60 to your computer and use it in GitHub Desktop.
Simple example script which shows how to convert .lsm files from one folder into another folder and save as ome.tiff
//File converter code. Converts lsm files to ome.tiff from and input folder to and output folder.
//Written by Dominic Waithe for Heinrich Klose (2017).
//You need to change these values to your folders of choice.
input_dir = "set/path/to/input/folder";
output_dir = "set/path/to/output/folder";
//Processing code begins:
//Collects list of files in input folder
list = getFileList(input_dir);
//The loop which runs through the folder looking for .lsm.
for (z = 0; z < list.length; z++){
if(endsWith(list[z], "lsm")==true){
//Opens the file using bioformats.
run("Bio-Formats Windowless Importer", "open=["+input_dir+list[z]+"]");
title = getTitle();
end = lengthOf(title)-4;
//This is where you can insert additional processing code.
//
//
//This is the code output section which saves the files to their new destination.
out_path = output_dir+substring(title,0,end)+".ome.tif";
run("OME-TIFF...", "save="+out_path+" export compression=Uncompressed");
run("Close All");
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment