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, de.unihalle.informatik.Alida.operator.events.ALDOperatorExecutionProgressEventListener, EventListener, loci.common.StatusReporter

@ALDMetaInfo(export=MANDATORY)
@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
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, operatorExecutionEventlistenerList, portHashAccess, verbose, versionProvider
 
Constructor Summary
ImageWriterMTB()
           
ImageWriterMTB(ij.ImagePlus imp, String filename)
          Image file output operator for ImagePlus objects.
ImageWriterMTB(MTBImage img, String filename)
          Image file output operator for MTBImage objects.
 
Method Summary
 void addStatusListener(loci.common.StatusListener listener)
           
 HashMap<Integer,String> getAvailableCodecs()
          Return available codecs for movie writers (see Bio-Formats package loci.formats.out.QTWriter) represented by a hashmap.
 String[] getAvailableCompression()
          Get the available compression methods for the specified file format.
 HashMap<Integer,String> getAvailableQualities()
          Return available qualities for quicktime movie writers (see Bio-Formats package loci.formats.out.QTWriter) represented by a hashmap.
 Integer getCodec()
          Get the codec (quicktime only)
 String getCompression()
          Get the compression type
 String getFileName()
          Get image filename
 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
 Integer getQuality()
          Get the quality (quicktime only)
 void notifyListeners(loci.common.StatusEvent event)
           
protected  void operate()
           
protected  Object readResolve()
          Init function for deserialized objects.
 void removeStatusListener(loci.common.StatusListener listener)
           
 void setCodec(Integer codec)
          Set the codec (quicktime only).
 void setCompression(String compression)
          Set the compression type
 void setFileName(String filename)
          Set image filename
 void setFps(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(Integer quality)
          Set the quality (quicktime only).
 void validateCustom()
           
protected  void writeImagePlus(String filename, ij.ImagePlus imp)
          Write ImagePlus to disk
protected  void writeMTBImage(String filename, MTBImage img)
          Write an MTBImage to disk
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
addOperatorExecutionProgressEventListener, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getHidingMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, runOp, runOp, runOp, setConstructionMode, setHidingMode, setName, setParameter, setVerbose, toStringVerbose, unconfiguredItems, validate, validateGeneric, writeHistory, writeHistory, writeHistory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageWriterMTB

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

ImageWriterMTB

public ImageWriterMTB(MTBImage img,
                      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

ImageWriterMTB

public ImageWriterMTB(ij.ImagePlus imp,
                      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
Method Detail

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

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

writeMTBImage

protected void writeMTBImage(String filename,
                             MTBImage img)
                      throws loci.common.services.DependencyException,
                             loci.common.services.ServiceException,
                             de.unihalle.informatik.Alida.exceptions.ALDOperatorException,
                             RuntimeException,
                             loci.formats.FormatException,
                             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
RuntimeException
loci.formats.FormatException
IOException
ome.xml.model.enums.EnumerationException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException

writeImagePlus

protected void writeImagePlus(String filename,
                              ij.ImagePlus imp)
                       throws RuntimeException,
                              loci.formats.FormatException,
                              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:
RuntimeException
loci.formats.FormatException
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

getAvailableCompression

public 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

getAvailableCodecs

public HashMap<Integer,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

getAvailableQualities

public HashMap<Integer,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

setInputMTBImage

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


getInputMTBImage

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


setInputImagePlus

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


getInputImagePlus

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


setFileName

public void setFileName(String filename)
Set image filename


getFileName

public String getFileName()
Get image filename


setCompression

public void setCompression(String compression)
Set the compression type


getCompression

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

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

setQuality

public void setQuality(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

getQuality

public Integer getQuality()
Get the quality (quicktime only)

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

setCodec

public void setCodec(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

getCodec

public Integer getCodec()
Get the codec (quicktime only)

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

setFps

public void setFps(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

getFps

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

Returns:
frames per second or null

setOverwrite

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


getOverwrite

public boolean getOverwrite()
Get the overwrite permission flag


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.


getIgnoreInvalidStackSpecification

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


addStatusListener

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

notifyListeners

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

removeStatusListener

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

readResolve

protected Object readResolve()
Description copied from class: MTBOperator
Init function for deserialized objects.

This function is called on an instance of this class being deserialized from file, prior to handing the instance over to the user. It takes care of a proper initialization of transient member variables as they are not initialized to the default values during deserialization.

Overrides:
readResolve in class MTBOperator
Returns:
Updated deserialized object.


Copyright © 2010–2015 Martin Luther University Halle-Wittenberg. All rights reserved.