Class WriteIntoDirectory

Object
org.anchoranalysis.test.image.WriteIntoDirectory

public class WriteIntoDirectory
extends Object
Writes one or more stacks/objects/channels into a directory during testing.

Any checked-exceptions thrown during writing stacks are converted into run-time exceptions, to make it easy to temporarily use this class in a test for debugging with minimal alteration of functions.

Author:
Owen Feehan
  • Constructor Summary

    Constructors 
    Constructor Description
    WriteIntoDirectory​(Path directory)
    Creates a new WriteIntoDirectory instance with directory printing enabled.
    WriteIntoDirectory​(Path directory, boolean printDirectoryToConsole)  
  • Method Summary

    Modifier and Type Method Description
    Path getDirectory()
    The directory in which stacks and other outputs are written.
    void writeChannel​(String outputName, Channel channel)
    Writes a Channel to the output directory.
    void writeList​(String outputName, List<DisplayStack> stacks, boolean always2D)
    Writes a list of display-stacks.
    void writeObject​(String outputName, org.anchoranalysis.image.voxel.object.ObjectMask object)
    Writes an ObjectMask to the output directory.
    void writeObjects​(String outputName, org.anchoranalysis.image.voxel.object.ObjectCollection objects)
    Writes the outline of objects on a blank RGB image, inferring dimensions of the image to center the object.
    void writeObjects​(String outputName, org.anchoranalysis.image.voxel.object.ObjectCollection objects, Stack background)
    Writes the outline of objects on a background.
    void writeStack​(String outputName, DisplayStack stack)
    Writes a DisplayStack to the output directory.
    void writeVoxels​(String outputName, org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxels)
    Writes Voxels to the output directory.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WriteIntoDirectory

      public WriteIntoDirectory​(Path directory)
      Creates a new WriteIntoDirectory instance with directory printing enabled.

      This constructor sets printDirectoryToConsole to true, meaning the directory path will be printed to the console when the first output is written.

      Parameters:
      directory - the directory in which stacks and other outputs will be written. It should be a valid, writable directory path.
    • WriteIntoDirectory

      public WriteIntoDirectory​(Path directory, boolean printDirectoryToConsole)
  • Method Details

    • writeStack

      public void writeStack​(String outputName, DisplayStack stack)
      Writes a DisplayStack to the output directory.
      Parameters:
      outputName - The name to use for the output file.
      stack - The DisplayStack to write.
    • writeObject

      public void writeObject​(String outputName, org.anchoranalysis.image.voxel.object.ObjectMask object) throws SetOperationFailedException
      Writes an ObjectMask to the output directory.
      Parameters:
      outputName - The name to use for the output file.
      object - The ObjectMask to write.
      Throws:
      SetOperationFailedException - If the operation fails.
    • writeObjects

      public void writeObjects​(String outputName, org.anchoranalysis.image.voxel.object.ObjectCollection objects)
      Writes the outline of objects on a blank RGB image, inferring dimensions of the image to center the object.
      Parameters:
      outputName - output-name
      objects - the objects to draw an outline for
    • writeObjects

      public void writeObjects​(String outputName, org.anchoranalysis.image.voxel.object.ObjectCollection objects, Stack background)
      Writes the outline of objects on a background.
      Parameters:
      outputName - output-name
      objects - the objects to draw an outline for
      background - the background
    • writeVoxels

      public void writeVoxels​(String outputName, org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxels)
      Writes Voxels to the output directory.
      Parameters:
      outputName - The name to use for the output file.
      voxels - The Voxels to write.
    • writeChannel

      public void writeChannel​(String outputName, Channel channel)
      Writes a Channel to the output directory.
      Parameters:
      outputName - The name to use for the output file.
      channel - The Channel to write.
    • writeList

      public void writeList​(String outputName, List<DisplayStack> stacks, boolean always2D) throws org.anchoranalysis.io.output.error.OutputWriteFailedException
      Writes a list of display-stacks.
      Parameters:
      outputName - the output-name
      stacks - the list of display-stacks
      always2D - if true, the stacks are guaranteed to always to have only one z-slice (which can influence the output format).
      Throws:
      org.anchoranalysis.io.output.error.OutputWriteFailedException - if the stacks cannot be successfully written to the file-system.
    • getDirectory

      public Path getDirectory()
      The directory in which stacks and other outputs are written.

      This directory is used as the root location for all file outputs generated by this class. It should be a valid, writable directory path.

      If printDirectoryToConsole is set to true, this directory path will be printed to the console when the first output is written.

      See Also:
      printDirectoryToConsole