Class ImageName

java.lang.Object
com.xinapse.multisliceimage.ImageName

public abstract class ImageName extends Object
Class to add extensions, prefixes and suffices to image file and URL names. This class understands the nature of image file name extensions such as ".img" and ".hdr" and takes care of constructing the correct file names.
  • Method Details

    • addExtension

      public static String addExtension(File f, String extension)
      Adds an extension to a File to create the name for a new file with the given extension. For example, if the supplied File has a path "/path/AnImage.hdr", with the extension "roi", the returned String will be "/path/AnImage.roi". If the File has a path "/path/AnImage", then the returned String will also be "/path/AnImage.roi".
      Parameters:
      f - the File to be extended.
      extension - the extension to be added.
      Returns:
      the file name with the extension added.
    • addExtension

      public static String addExtension(String name, String extension)
      Adds an extension to a file or URL name String to create the name for a new file or URL with the given extension. For example, if the supplied name is "/path/AnImage.hdr", with the extension "roi", the returned String will be "/path/AnImage.roi". If the name is "/path/AnImage", then the returned String will also be "/path/AnImage.roi".
      Parameters:
      name - the file or URL name to be extended.
      extension - the extension to be added.
      Returns:
      the file name with the extension added.
    • addSuffix

      public static String addSuffix(File f, String suffix)
      Adds a suffix to a File name to create the name for a new File with the given suffix. For example, if the supplied File has a path "/path/AnImage.hdr", with the suffix "Masked", the returned String will be "/path/AnImageMasked.hdr". If the File has a path "/path/AnImage", then the returned String will be "/path/AnImageMasked".
      Parameters:
      f - the File to be which the suffix is to be added.
      suffix - the suffix to be added
      Returns:
      the file name with the suffix added.
    • addSuffix

      public static String addSuffix(String name, String suffix)
      Adds a suffix to a file or URL name to create the name for a new file or URL with the given suffix. For example, if the supplied name is "/path/AnImage.hdr", with the suffix "Masked", the returned String will be "/path/AnImageMasked.hdr". If the name is "/path/AnImage", then the returned String will also be "/path/AnImageMasked".
      Parameters:
      name - the name of the file or URL to be which the suffix is to be added.
      suffix - the suffix to be added.
      Returns:
      the file or URL with the suffix added.
    • addPrefix

      public static String addPrefix(File f, String prefix)
      Adds a prefix to a File name to create the name for a new File with the given prefix. For example, if the supplied File has a path "/path/AnImage.hdr", with the prefix "Masked", the returned String will be "/path/MaskedAnImage.hdr". If the File has a path "/path/AnImage", then the returned String will be "/path/MaskedAnImage".
      Parameters:
      f - the File to be which the prefix is to be added.
      prefix - the prefix to be added.
      Returns:
      the file name with the prefix added.
    • addPrefix

      public static String addPrefix(String name, String prefix)
      Adds a prefix to a file or URL name to create the name for a new file or URL with the given prefix. For example, if the supplied name is "/path/AnImage.hdr", with the prefix "Masked", the returned String will be "/path/MaskedAnImage.hdr". If the name is "/path/MaskedAnImage", then the returned String will also be "/path/MaskedAnImage".
      Parameters:
      name - the name of the file or URL to which the prefix is to be added.
      prefix - the prefix to be added.
      Returns:
      the file or URL with the prefix added.
    • removePrefix

      public static String removePrefix(String name, String prefix) throws IllegalArgumentException
      Removed a prefix from a file or URL name to create the name for a new file or URL with the given prefix removed. For example, if the supplied name is "/path/MaskedAnImage.hdr", with the prefix "Masked", the returned String will be "/path/AnImage.hdr". If the image does not have the supplied prefix, then the original name is returned.
      Parameters:
      name - the name of the file or URL from which the prefix is to be removed.
      prefix - the prefix to be removed.
      Returns:
      the file or URL with the prefix added.
      Throws:
      IllegalArgumentException
    • getLastPathComponent

      public static String getLastPathComponent(String name)
      Returns the last path component of a file or URL name.
      Parameters:
      name - the file or URL name.
      Returns:
      the actual file name of a file or URL name.
    • removeExtension

      public static String removeExtension(String name)
      Remove any extension ".img", ".hdr", ".img.gz", etc. associated with Analyze, NIFTI or DICOM files, from the name.
      Parameters:
      name - the file name from which to remove the image-related extension.
      Returns:
      the file name, with the image-related extension removed.