// This is a command line macro that processes
// all the ics images in a specified directory.
    x = getNumber("remove slices from bottom:", 10);
    y = getNumber("remove slices from top:", 10);
    dir = getArgument();
  if (dir=="")
      dir = getDirectory("Select a Directory");
  if (!(endsWith(dir, "/")||endsWith(dir, "\\")))
      dir = dir + "/";
      list = getFileList(dir);
      run("Set Measurements...", "area mean display redirect=None decimal=3");
  for (i=0; i<list.length; i++) {
     if (endsWith(list[i], ".ics")) {
         run("Open...", "path='"+dir+list[i]+"'");
         print (nSlices);
         w = (nSlices);
         t = w - x +1;
         run("Slice Remover", "first="+t+" last="+w+" increment=1");
        run("Slice Remover", "first=1 last="+y+" increment=1");
        run("Grouped ZProjector", "group=2 projection='Max Intensity'");
        run("Enhance Contrast", "saturated=0.1 normalize normalize_all");
        run("8-bit");
        list2 = list[i] + ".tif";
         run("Tiff...", "save='"+dir+list2+"'");
         run("Close");
         run("Close");
          }
  }