Skip to content

Instantly share code, notes, and snippets.

@mutterer
Created January 22, 2021 14:45
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 mutterer/18a52d743a8591fd1b85ef4a20cadfde to your computer and use it in GitHub Desktop.
Save mutterer/18a52d743a8591fd1b85ef4a20cadfde to your computer and use it in GitHub Desktop.
Read calibration from axiovision tif _meta.xml files
// reads and applies, the calibration, if any,
// from *_meta.xml files saved alongside
// *.tif files in Axiovision.
// jerome.mutterer@cnrs.fr
fname=getInfo("image.directory")+getInfo("image.filename");
if (File.exists(fname+"_meta.xml")) {
x=1;y=1;
s=split(File.openAsString(fname+"_meta.xml"),"\n");
for (i=0;i<s.length;i++) {
l=s[i];
if (l.indexOf('<Factor_0>')>0) xs=get();
else if (l.indexOf('<Factor_1>')>0) ys=get();
}
run("Properties...", "channels=1 slices=1 frames=1 pixel_width=&x pixel_height=&y");
Stack.setXUnit("micron");
}
function get() {
v=""+l.substring(l.indexOf('>')+1,l.lastIndexOf('<'));
v=v.replace(',','.');
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment