Problem with batch converting nd2 with multiple series to TIFF

Hi all,

I’m having problems with my batch conversion macro, as when I attempt to convert a folder nd2 files with multiple series to TIFF, the resulting TIFF images are only comprised of the final series (eg, if nd2 had 3 series, only the third series would be converted to TIFF). Is there any way I can make the macro convert all of the individual series in one nd2 file to TIFF?

Here’s the batch conversion macro for reference:

dir1 = getDirectory("source directory");
  format = getFormat();
  dir2 = getDirectory("output directory");
  list = getFileList(dir1);
  setBatchMode(true);
  for (i=0; i<list.length; i++) {
     showProgress(i+1, list.length);
     open(dir1+list[i]);
     if (format=="8-bit TIFF" || format=="GIF")
        convertTo8Bit();
     saveAs(format, dir2+list[i]);
     close();
  }
 
  function getFormat() {
       formats = newArray("TIFF", "8-bit TIFF", "JPEG", "GIF", "PNG",
          "PGM", "BMP", "FITS", "Text Image", "ZIP", "Raw");
       Dialog.create("Batch Convert");
       Dialog.addChoice("Convert to: ", formats, "TIFF");
       Dialog.show();
       return Dialog.getChoice(); 
  }

  function convertTo8Bit() {
      if (bitDepth==24)
          run("8-bit Color", "number=256");
      else
          run("8-bit");
  }

Your macro is only iterating over the files in the directory, you will need to use something like bio-formats to go through the nd2 files to extract each series.

See Plugins->Bio-Formats->Bio-Formats Macro Extensions

Most likely you will need:

run("Bio-Formats Macro Extensions");

inside the for loop –

//get how many series are in the nd2 file
Ext.getSeriesCount(seriesCount)
//get the image for seriesNum
Ext.getSeries(seriesNum)

Chris

Hi there,
I do have the same problem : when I use the Process > Batch > Convert on a nd2 file with multiple series I only have one tiff image saved as an output. I’m a new user of imageJ and I write very simple macros, I tried to see if I can use your answer @cwood1967 to solve the problem but could’nt figure it out. Did you finally manage to make it works @dsmartin ? If so, would you help me on this please ?
Thanks a lot !
Elise