Any ImageJ experts who can help with deleting series in SCN format using macro?

I have hundreds of files in SCN formats that comes up as series in Fiji when i open the individual files. I want to write a macro to delete the series with the least file size such as the 233x220 (series 14) in the attached image and resave the modified file either in SCN format (preferable) or tif. If needed, i am OK with saving individual slices in TIF that is numbered in some logical way . I cannot find a way to access a specific series. The screnshot shown is what i get when i try to open the file in Fiji.ScreenShot_openquestion|616x500 .


I don’t have any image of this format, but I think you probably have to play with Bio-Formats Macro Extensions

run("Bio-Formats Macro Extensions");
dir = getDirectory("Choose the image directory");
list = getFileList(dir);

for (i=0; i<list.length; i++)

      for (s=0; s<seriesCount; s++)
         Ext.getSizeX(sizeX); //to get size
         Ext.getSeriesName(NameSerie); //to get name
         if ((sizeX*sizeY) > XXX) //if the series has the right size
            run("Bio-Formats Importer", "open=[" + dir + "\\" + list[i] + "] autoscale color_mode=Default split_channels view=Hyperstack stack_order=XYCZT series_" + s+1); //to open the wanted series


Bio-Formats currently doesnt write to SCN so you will likely have to use TIFF or OME-TIFF. Using the macro extensions you can select a single series and convert as above. However if you want all the series in a single file (minus the one you want to remove) then you will likely have to use a script.

An example jython script which loops through a file and converts every series as below. You can modify this pretty easily to remove the iterations over the series you want to remove:

from loci.plugins import BF
infile = "/Path/To/Input/infile.scn"
outfile = "/Path/To/Output/outfile.scn"

# parse metadata
from loci.formats import ImageReader
from loci.formats import ImageWriter
from loci.formats import MetadataTools
reader = ImageReader()
writer = ImageWriter()
omeMeta = MetadataTools.createOMEXMLMetadata()
seriesCount = reader.getSeriesCount()
for s in range(seriesCount):
  planeCount = reader.getImageCount()
  for p in range(planeCount):
    plane = reader.openBytes(p)
    writer.saveBytes(p, plane)