de.unihalle.informatik.MiToBo.io.images
Class ImageWriterMTB

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDOperator
      extended by de.unihalle.informatik.MiToBo.core.operator.MTBOperator
          extended by de.unihalle.informatik.MiToBo.io.images.ImageWriterMTB
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator, loci.common.StatusReporter

@ALDAOperator(genericExecutionMode=ALL,
              level=APPLICATION)
public class ImageWriterMTB
extends MTBOperator
implements loci.common.StatusReporter

Image writer operator to store MTBImage or ImagePlus to disk along with the image history (.mph) file. This writer operator is based on Bio-Formats, thus the available formats depend on Bio-Formats (and its available extension). The format is determined by the given filename extension. Different formats allow different options, e.g. compression of images or framerate of movies. If options are set by the available setter-methods that are not applicable to the current format writer, the options are simply ignored.

The ImageWriterMTB.runOp(..) throws a special OverwriteException in case that the specified file already exists, but the overwrite-flag is set to false.

Author:
Oliver Gress

Nested Class Summary
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  java.lang.Integer codec
           
private  java.lang.String compression
           
private  de.unihalle.informatik.Alida.datatypes.ALDFileString fileName
           
private  java.lang.Integer fps
           
private  boolean ignoreInvalidStackSpec
           
private  ij.ImagePlus inputImagePlus
           
private  MTBImage inputMTBImage
           
private  boolean overwrite
           
private  java.lang.Integer quality
           
private  java.util.Vector<loci.common.StatusListener> statusListeners
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
ImageWriterMTB()
           
ImageWriterMTB(ij.ImagePlus imp, java.lang.String filename)
          Image file output operator for ImagePlus objects.
ImageWriterMTB(MTBImage img, java.lang.String filename)
          Image file output operator for MTBImage objects.
 
Method Summary
 void addStatusListener(loci.common.StatusListener listener)
           
 java.util.HashMap<java.lang.Integer,java.lang.String> getAvailableCodecs()
          Return available codecs for movie writers (see Bio-Formats package loci.formats.out.QTWriter) represented by a hashmap.
 java.lang.String[] getAvailableCompression()
          Get the available compression methods for the specified file format.
 java.util.HashMap<java.lang.Integer,java.lang.String> getAvailableQualities()
          Return available qualities for quicktime movie writers (see Bio-Formats package loci.formats.out.QTWriter) represented by a hashmap.
 java.lang.Integer getCodec()
          Get the codec (quicktime only)
 java.lang.String getCompression()
          Get the compression type
 java.lang.String getFileName()
          Get image filename
 java.lang.Integer getFps()
          Get the frames per second for movie writers (*.avi,*.mov).
 boolean getIgnoreInvalidStackSpecification()
          Get the flag to ignore an invalid stack specification.
 ij.ImagePlus getInputImagePlus()
          Get ImagePlus that has to be stored to disk
 MTBImage getInputMTBImage()
          Get MTBImage that has to be stored to disk
 boolean getOverwrite()
          Get the overwrite permission flag
 java.lang.Integer getQuality()
          Get the quality (quicktime only)
 void notifyListeners(loci.common.StatusEvent event)
           
protected  void operate()
           
 void removeStatusListener(loci.common.StatusListener listener)
           
 void setCodec(java.lang.Integer codec)
          Set the codec (quicktime only).
 void setCompression(java.lang.String compression)
          Set the compression type
 void setFileName(java.lang.String filename)
          Set image filename
 void setFps(java.lang.Integer fps)
          Set the frames per second for movie writers (*.avi,*.mov).
 void setIgnoreInvalidStackSpecification(boolean ignore)
          Set the flag to ignore an invalid stack specification.
 void setInputImagePlus(ij.ImagePlus imp)
          Set ImagePlus to store to disk
 void setInputMTBImage(MTBImage img)
          Set MTBImage to store to disk
 void setOverwrite(boolean overwrite)
          Set the overwrite permission flag
 void setQuality(java.lang.Integer quality)
          Set the quality (quicktime only).
 void validateCustom()
           
protected  void writeImagePlus(java.lang.String filename, ij.ImagePlus imp)
          Write ImagePlus to disk
protected  void writeMTBImage(java.lang.String filename, MTBImage img)
          Write an MTBImage to disk
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.operator.MTBOperator
readResolve
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
deserializeFromXmlFile, fieldContained, getALDPortHashAccessKey, getConstructionMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, isConfigured, parametersToXmlObject, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, runOp, runOp, runOp, serializeToXmlFile, setConstructionMode, setName, setParameter, setParametersFromXml, setParametersFromXml, setVerbose, toStringVerbose, unconfiguredItems, validate, validateGeneric, writeHistory, writeHistory, writeHistory, writeParametersToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codec

@Parameter(label="Video codec",
           required=false,
           direction=IN,
           mode=ADVANCED,
           dataIOOrder=8,
           description="Video codec (quicktime only)")
private java.lang.Integer codec

compression

@Parameter(label="Image compression",
           required=false,
           direction=IN,
           mode=ADVANCED,
           dataIOOrder=6,
           description="Image compression")
private java.lang.String compression

fileName

@Parameter(label="Filename",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=3,
           description="Image filename")
private de.unihalle.informatik.Alida.datatypes.ALDFileString fileName

fps

@Parameter(label="Fps",
           required=false,
           direction=IN,
           mode=ADVANCED,
           dataIOOrder=7,
           description="Frames per second for movies")
private java.lang.Integer fps

ignoreInvalidStackSpec

@Parameter(label="Ignore stack specifications",
           required=true,
           direction=IN,
           mode=ADVANCED,
           dataIOOrder=5,
           description="Flag to ignore an invalid specification of the stack")
private boolean ignoreInvalidStackSpec

inputImagePlus

@Parameter(label="Input ImagePlus",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=2,
           description="ImagePlus to save")
private transient ij.ImagePlus inputImagePlus

inputMTBImage

@Parameter(label="Input MTBImage",
           required=false,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=1,
           description="MTBImage to save")
private transient MTBImage inputMTBImage

overwrite

@Parameter(label="overwrite",
           required=true,
           direction=IN,
           mode=STANDARD,
           dataIOOrder=4,
           description="Overwrite permission flag")
private boolean overwrite

quality

@Parameter(label="Video quality",
           required=false,
           direction=IN,
           mode=ADVANCED,
           dataIOOrder=9,
           description="Video quality (quicktime only)")
private java.lang.Integer quality

statusListeners

private transient java.util.Vector<loci.common.StatusListener> statusListeners
Constructor Detail

ImageWriterMTB

public ImageWriterMTB()
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ImageWriterMTB

public ImageWriterMTB(ij.ImagePlus imp,
                      java.lang.String filename)
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Image file output operator for ImagePlus objects.

Parameters:
imp - image to write to disk
filename - filename to write the image to. The extension specifies the output format.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ImageWriterMTB

public ImageWriterMTB(MTBImage img,
                      java.lang.String filename)
               throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Image file output operator for MTBImage objects.

Parameters:
img - image to write to disk
filename - filename to write the image to. The extension specifies the output format.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

addStatusListener

public void addStatusListener(loci.common.StatusListener listener)
Specified by:
addStatusListener in interface loci.common.StatusReporter

getAvailableCodecs

public java.util.HashMap<java.lang.Integer,java.lang.String> getAvailableCodecs()
                                                                         throws loci.formats.FormatException
Return available codecs for movie writers (see Bio-Formats package loci.formats.out.QTWriter) represented by a hashmap. The key is the integer codec ID and the value a string with the codec's name. Only quicktime writers have the codec option, for any other writers (.avi or any non-movie format), this method returns null. This method will also return null, if the filename has not been specified yet.

Throws:
loci.formats.FormatException

getAvailableCompression

public java.lang.String[] getAvailableCompression()
                                           throws loci.formats.FormatException
Get the available compression methods for the specified file format. Returns null if no compression options are available or the filename has not been specified yet.

Throws:
loci.formats.FormatException

getAvailableQualities

public java.util.HashMap<java.lang.Integer,java.lang.String> getAvailableQualities()
                                                                            throws loci.formats.FormatException
Return available qualities for quicktime movie writers (see Bio-Formats package loci.formats.out.QTWriter) represented by a hashmap. The key is the integer quality ID and the value a string specifying the quality. Only quicktime writers have this option, for any other writers (.avi or any non-movie format), this method returns null. This method will also return null, if the filename has not been specified yet.

Throws:
loci.formats.FormatException

getCodec

public java.lang.Integer getCodec()
Get the codec (quicktime only)

Returns:
quicktime movie codec ID (see Bio-Formats package loci.formats.out.QTWriter) or null

getCompression

public java.lang.String getCompression()
                                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Get the compression type

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

getFileName

public java.lang.String getFileName()
Get image filename


getFps

public java.lang.Integer getFps()
Get the frames per second for movie writers (*.avi,*.mov). Null for non-movie writers

Returns:
frames per second or null

getIgnoreInvalidStackSpecification

public boolean getIgnoreInvalidStackSpecification()
Get the flag to ignore an invalid stack specification. See the setIgnoreInvalidStackSpecification(.)-method for more explanation


getInputImagePlus

public ij.ImagePlus getInputImagePlus()
Get ImagePlus that has to be stored to disk


getInputMTBImage

public MTBImage getInputMTBImage()
Get MTBImage that has to be stored to disk


getOverwrite

public boolean getOverwrite()
Get the overwrite permission flag


getQuality

public java.lang.Integer getQuality()
Get the quality (quicktime only)

Returns:
quicktime movie quality ID(see Bio-Formats package loci.formats.out.QTWriter) or null

notifyListeners

public void notifyListeners(loci.common.StatusEvent event)
Specified by:
notifyListeners in interface loci.common.StatusReporter

operate

protected void operate()
                throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                       de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException,
                       OverwriteException
Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
OverwriteException

removeStatusListener

public void removeStatusListener(loci.common.StatusListener listener)
Specified by:
removeStatusListener in interface loci.common.StatusReporter

setCodec

public void setCodec(java.lang.Integer codec)
              throws loci.formats.FormatException
Set the codec (quicktime only). If the writer is not quicktime, the parameter is not assigned.

Parameters:
codec - the quicktime codec ID (see Bio-Formats package loci.formats.out.QTWriter)
Throws:
loci.formats.FormatException

setCompression

public void setCompression(java.lang.String compression)
Set the compression type


setFileName

public void setFileName(java.lang.String filename)
Set image filename


setFps

public void setFps(java.lang.Integer fps)
            throws loci.formats.FormatException
Set the frames per second for movie writers (*.avi,*.mov). If the filename has not been specified yet or the writer is not a movie writer, the parameter is not assigned!

Parameters:
fps - frames per second of the written movie file (fps must be larger 0, otherwise validation fails)
Throws:
loci.formats.FormatException

setIgnoreInvalidStackSpecification

public void setIgnoreInvalidStackSpecification(boolean ignore)
Set the flag to ignore an invalid stack specification. This might happen if slices are added or removed from an image stack, then the stack size does not match the product of size in Z, T and C dimension. If the flag is set to 'ignore'(true), then the image stack is simply written as a stack, not a hyperstack. Default is false.


setInputImagePlus

public void setInputImagePlus(ij.ImagePlus imp)
Set ImagePlus to store to disk


setInputMTBImage

public void setInputMTBImage(MTBImage img)
Set MTBImage to store to disk


setOverwrite

public void setOverwrite(boolean overwrite)
Set the overwrite permission flag


setQuality

public void setQuality(java.lang.Integer quality)
                throws loci.formats.FormatException
Set the quality (quicktime only). If the writer is not quicktime, the parameter is not assigned.

Parameters:
quality - quicktime movie quality ID (see Bio-Formats package loci.formats.out.QTWriter)
Throws:
loci.formats.FormatException

validateCustom

public void validateCustom()
                    throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Overrides:
validateCustom in class de.unihalle.informatik.Alida.operator.ALDOperator
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

writeImagePlus

protected void writeImagePlus(java.lang.String filename,
                              ij.ImagePlus imp)
                       throws java.lang.RuntimeException,
                              loci.formats.FormatException,
                              java.io.IOException,
                              loci.common.services.DependencyException,
                              loci.common.services.ServiceException,
                              ome.xml.model.enums.EnumerationException,
                              de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                              de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Write ImagePlus to disk

Throws:
java.lang.RuntimeException
loci.formats.FormatException
java.io.IOException
loci.common.services.DependencyException
loci.common.services.ServiceException
ome.xml.model.enums.EnumerationException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

writeMTBImage

protected void writeMTBImage(java.lang.String filename,
                             MTBImage img)
                      throws loci.common.services.DependencyException,
                             loci.common.services.ServiceException,
                             de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                             java.lang.RuntimeException,
                             loci.formats.FormatException,
                             java.io.IOException,
                             ome.xml.model.enums.EnumerationException,
                             de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
Write an MTBImage to disk

Throws:
loci.common.services.DependencyException
loci.common.services.ServiceException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
java.lang.RuntimeException
loci.formats.FormatException
java.io.IOException
ome.xml.model.enums.EnumerationException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException