SHARE
TWEET

Untitled

a guest Apr 21st, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // For all images in a folder, extract the middle slice and save it into a
  2. // subfolder.
  3. //
  4. // Written 2017 by Volker Baecker, Montpellier Ressource Imagerie
  5.  
  6.  
  7. var _FILE_EXTENSION = ".tif";
  8.  
  9. setBatchMode(true);
  10. dir = getDirectory("Select the input folder!");
  11. files = getFileList(dir);
  12. File.makeDirectory(dir + "/out");
  13. print("\\Clear");
  14. print("started extracting middle slices");
  15. for(i=0; i<files.length; i++) {
  16.     print("\\Update1:extracting image " + (i+1) + " of " + files.length);
  17.     file = files[i];
  18.     if (endsWith(file, _FILE_EXTENSION)) {
  19.         open(dir + "/" + file);
  20.         middleSlice = floor(nSlices / 2);
  21.         setSlice(middleSlice);
  22.         run("Duplicate...", " ");
  23.         resetMinAndMax();
  24.         save(dir + "/out/" + file);
  25.         close();
  26.         close();
  27.     }
  28. }
  29. print("finished extracting middle slices");
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top