Package com.xinapse.multisliceimage
Class ImageName
java.lang.Object
com.xinapse.multisliceimage.ImageName
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 Summary
Modifier and TypeMethodDescriptionstatic String
addExtension
(File f, String extension) Adds an extension to a File to create the name for a new file with the given extension.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.static String
Adds a prefix to a File name to create the name for a new File with the given prefix.static String
Adds a prefix to a file or URL name to create the name for a new file or URL with the given prefix.static String
Adds a suffix to a File name to create the name for a new File with the given suffix.static String
Adds a suffix to a file or URL name to create the name for a new file or URL with the given suffix.static String
getLastPathComponent
(String name) Returns the last path component of a file or URL name.static String
removeExtension
(String name) Remove any extension ".img", ".hdr", ".img.gz", etc.static String
removePrefix
(String name, String prefix) Removed a prefix from a file or URL name to create the name for a new file or URL with the given prefix removed.
-
Method Details
-
addExtension
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
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
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
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
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
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
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
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
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.
-