Batch convert/save as one file format to TIFF?

plugin
scripting
macro
tiff
batch-processing
Tags: #<Tag:0x00007fa30a3219f0> #<Tag:0x00007fa30a3218b0> #<Tag:0x00007fa30a321770> #<Tag:0x00007fa30a321608> #<Tag:0x00007fa30a3213d8>

#1

Hello all,

I hope someone will be able to help me with my question.

For my work I have 986 files that are in the .oir (Olympus) format. Our institute got the chance to play around with a new Olympus confocal and I do not have access to their software. Eager to see how my images came out, I installed the Olympus plugin on ImageJ (technically I am running FIJI, version 1.51g) and was able to open the files and play around with them.

Now I want to stitch the files (as all 986 images are of one single sample) and it comes out really nicely with the ImageJ plugins when I did a test stitch with a few of the files. However, I have to convert the files from .oir to TIFF before I can do any stitching and I do so via the ‘save as’ feature.

Basically what I do is:

-Open ImageJ
-Plugins --> Olympus viewer --> DragDrop
-I then Drag/Drop some .oir files in DragDrop box
-File --> Save as --> TIFF
-Once in TIFF format I go ahead with the stitch plugins

As it is a bit of a cumbersome procedure, is there anyway that I can ‘mass save’ or ‘mass convert’ or ‘batch save’ or ‘batch convert’ all of these .oir files in one go to TIFF files? Is there a macro feature or special button somewhere in ImageJ that I can press that will assist with the above procedure? Once converted it will take a few buttons to then set up the stitching procedure and get myself what I hope will be a really nice image.

Alternatively is there a stitch plugin with ImageJ that can stitch alternative file formats?

I feel this feature will be useful for other file formats as well, in addition to .oir, such as Zeiss or Nikon or Leica file formats.

Thank you for your help.


#2

Dear @Gorion,

welcome to the forum!

There is a post by @ctrueden in another thread that might be helpful for you. Especially the Process_Folder.ijm macro. You can replace lines 28 and 29 with the loading mechanism of the Olympus plugin as recorded by the Plugins > Macros > Record command. For more information take a look at the Introduction to Macro Programming page of the ImageJ wiki.

Best,
Stefan


#3

The page http://imagej.net/Batch is intended to be the central resource describing how to do these sorts of things.


#4

Thank you both for your helpful reply. I had an attempt at using the macro creater to create what I had in mind but I didn’t have much luck. I will keep playing around with it and see if I can get it to work. Thank you again. :slight_smile:


#5

Hi,
although the thread is already a bit dated I add my solution below as so far I could not find a solution in the forum or the cited locations. The difficulty was to properly open the .oir file which spans over multiple physical files. The Olympus plugin “Drag and drop” did that but the macro recorder did not unveil the details. So after inspection of the plugin jar I came up with the following based on the batch processing examples (you may simply ignore the string manipulation for the output destination).

# @File(label = "Input directory", style = "directory") srcFile
# @File(label = "Output directory", style = "directory") dstFile
# @String(label = "File extension", value=".oir") ext
# @String(label = "File name contains", value = "") containString

import os
import re
from ij import IJ, ImagePlus

sphRex = re.compile("(G\\d+)")

def run():
  srcDir = srcFile.getAbsolutePath()
  dstDir = dstFile.getAbsolutePath()
  for root, directories, filenames in os.walk(srcDir):
    filenames.sort();
    for filename in filenames:
      # Check for file extension
      if not filename.endswith(ext):
        continue
      # Check for file name pattern
      if containString not in filename:
        continue
      process(srcDir, dstDir, root, filename)
 
def process(srcDir, dstDir, currentDir, fileName):
    spheroid = ""
    m = sphRex.search(fileName)
    
    if (m):
        spheroid = m.group(1)
    else:
        IJ.log("Unknown file name type: " + fileName)
        return

    outDir = os.path.join(dstDir, spheroid)
   
    # Saving the image
    if not os.path.exists(outDir):
        os.makedirs(outDir)
  
    IJ.log("Saving to " + outDir)

    # Opening the image
    inFile = os.path.join(srcDir, fileName)
    IJ.log("Open image file " + inFile)
    IJ.runPlugIn("_Viewer", inFile)

    # Save as TIFF sequence
    oCmd = "format=TIFF name=" + spheroid + " save=[" + outDir + "\\]"
    IJ.log("Save: " + oCmd)
    IJ.run("Image Sequence... ", oCmd)
    IJ.run("Close")

 
run()

#6

Thank you Gucki. I admit I didn’t have much luck after spending some time with it and so I left the macro aside for the time being. With this possible solution I will have a go at it and see how far I go. Thank you again for your contribution.


#8

Here is the complete tutorial on how to batch convert images to TIFF on Mac. You can read and follow.

Step 1: Free download and install WidsMob ImageConvert software on your computer.
Step 2: Choose “Open” to import your hundreds of pictures into its main interface.


Step 3: Apply photo effects to batch resize, rotate, rename, add border, text/image watermark. (Optional)
Step 4: Click “Start convert” to get a new window.

Step 5: Select “TIFF” from the “Format” drop-down menu.
Step 6: Click “Export” to start to convert Images to TIFF in batch quickly.

Well, that’s all. Quite easy, right?