Skip to content

Instantly share code, notes, and snippets.

@T4mmi
Last active July 20, 2021 17:15
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 T4mmi/738fe47234c3e93a018789cceaf2af29 to your computer and use it in GitHub Desktop.
Save T4mmi/738fe47234c3e93a018789cceaf2af29 to your computer and use it in GitHub Desktop.
Batch export ImageJ markers coordinates from TIFF metadata
macro "Batch export XY coordinates" {
/* Read images in a chosen directory and export measurements
XY coordinates (in pixels) in a .txt file with the same name */
dir = getDirectory("Choose a Directory "); // window to select the input directory
list = getFileList(dir); // list files in it
setBatchMode(true); // activate batch process
for (i=0; i<list.length; i++) { // loop over files
showProgress(i, list.length); // update progressbar
file_name = list[i];
if (endsWith(file_name, ".tif")) {
file_path = dir + file_name;
open(file_path); // open the current image
name = substring(file_name, 0, lastIndexOf(file_name, "."));
txt_path = dir+name+".txt";
run("Set Scale...", "distance=0 known=0 pixel=1 unit=pixel");
run("XY Coordinates...", "save=["+txt_path+"]");
close();
}
}
}
@Algasd
Copy link

Algasd commented Jul 20, 2021

Excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment