Class ImageData<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
AutoCloseable
,EventListener
,PathObjectHierarchyListener
,WorkflowListener
Currently, this is really the server (to access the image & its pixels) and the object hierarchy that represents detections. In addition, there is an ImageType - as some options may change depending on this.
One particularly significant example is that of Brightfield images in pathology, for which stain vectors are often required for effective stain separation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enum representing possible image types. -
Constructor Summary
ConstructorsConstructorDescriptionImageData
(ImageServer<T> server) Create a new ImageData with ImageType.UNKNOWN and a new PathObjectHierarchy.ImageData
(ImageServer<T> server, ImageData.ImageType type) Create a new ImageData with a specified type and creating a new object hierarchy.ImageData
(ImageServer<T> server, PathObjectHierarchy hierarchy) Create a new ImageData with ImageType.UNKNOWN.ImageData
(ImageServer<T> server, PathObjectHierarchy hierarchy, ImageData.ImageType type) Create a new ImageData with a specified server, hierarchy and type.ImageData
(ImageServerBuilder.ServerBuilder<T> serverBuilder, PathObjectHierarchy hierarchy, ImageData.ImageType type) Create a new ImageData with a lazily-loaded server, hierarchy and type. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new property change listener.void
close()
Close the server if it has been loaded.Get the stains defined for this image, or null if this is not a brightfield image suitable for color deconvolution.Get the object hierarchy.Get a workflow representing a history of the processing steps applied to the ImageData.Get the image typeGet the last path used to save this object;Get an unmodifiable map representing all known properties for this ImageData.getProperty
(String key) Get a specified property.Get the ImageServer, loading it if necessary.Get the ServerBuilde corresponding to the ImageServer associated with this ImageData.Get the metadata for the server.Get the path of the ImageServer.void
Notify listeners of a change in the hierarchy or its objects.boolean
Returns true if the image type is set to brightfield.boolean
Returns true if changes have been recorded since the last time this object was notified that it was saved.boolean
Returns true if the image type is set to fluorescence.boolean
isLoaded()
Query whether the corresponding ImageServer was lazy-loaded or not, IfisLoaded()
returns false, then calls togetServer()
will result in an attempt to load the server.removeProperty
(String key) Remove a specified property.void
Remove a property change listener.void
setChanged
(boolean isChanged) SetisChanged()
status.void
Set the color deconvolution stain vectors for the current image type.void
Set the image type.void
setLastSavedPath
(String path, boolean resetChanged) Set the last path used to save this object;setProperty
(String key, Object value) Set a property.toString()
void
updateServerMetadata
(ImageServerMetadata newMetadata) Update the ImageServer metadata.void
workflowUpdated
(Workflow workflow) Called whenever a Workflow has been updated in some way, such as a new step added.
-
Constructor Details
-
ImageData
public ImageData(ImageServerBuilder.ServerBuilder<T> serverBuilder, PathObjectHierarchy hierarchy, ImageData.ImageType type) Create a new ImageData with a lazily-loaded server, hierarchy and type. The server builder provides the ImageServer required to access pixels and metadata on demand.If the server is never requested, then the builder is not used - which can save time and resources.
- Parameters:
serverBuilder
- builder to create the ImageServerhierarchy
- an object hierarchy, or null to create a new onetype
- the image type, or null to default to ImageType.UNSET
-
ImageData
Create a new ImageData with a specified server, hierarchy and type.- Parameters:
server
- server to use to access pixels and metadatahierarchy
- an object hierarchy, or null to create a new onetype
- the image type, or null to default to ImageType.UNSET
-
ImageData
Create a new ImageData with a specified type and creating a new object hierarchy.- Parameters:
server
-type
-
-
ImageData
Create a new ImageData with ImageType.UNKNOWN.- Parameters:
server
-hierarchy
-
-
ImageData
Create a new ImageData with ImageType.UNKNOWN and a new PathObjectHierarchy.- Parameters:
server
-
-
-
Method Details
-
getHistoryWorkflow
Get a workflow representing a history of the processing steps applied to the ImageData.- Returns:
-
setColorDeconvolutionStains
Set the color deconvolution stain vectors for the current image type.If the type is not brightfield, an IllegalArgumentException is thrown.
- Parameters:
stains
-
-
updateServerMetadata
Update the ImageServer metadata. The benefit of using this method rather than manipulating the ImageServer directly is that it will fire a property change.- Parameters:
newMetadata
-
-
getServerMetadata
Get the metadata for the server.This is equivalent to
getServer().getMetadata()
, unless the server is being loaded lazily and it is possible to query the metadata without loading the server.- Returns:
-
isBrightfield
public boolean isBrightfield()Returns true if the image type is set to brightfield.- Returns:
-
isFluorescence
public boolean isFluorescence()Returns true if the image type is set to fluorescence.- Returns:
-
setImageType
Set the image type.- Parameters:
type
- the type of the image- Throws:
IllegalArgumentException
- if the type is not supported by the image; specifically, brightfield types using color deconvolution stains are currently only supported for RGB images.
-
isLoaded
public boolean isLoaded()Query whether the corresponding ImageServer was lazy-loaded or not, IfisLoaded()
returns false, then calls togetServer()
will result in an attempt to load the server.- Returns:
-
getServerBuilder
Get the ServerBuilde corresponding to the ImageServer associated with this ImageData.If the server has not yet been loaded, this will return a cached server builder if it is available and null otherwise.
- Returns:
- See Also:
-
getServer
Get the ImageServer, loading it if necessary.If no server is available and loading fails, this method may throw an unchecked exception.
- Returns:
-
getServerPath
Get the path of the ImageServer.- Returns:
-
getHierarchy
Get the object hierarchy.- Returns:
-
getImageType
Get the image type- Returns:
-
getColorDeconvolutionStains
Get the stains defined for this image, or null if this is not a brightfield image suitable for color deconvolution.- Returns:
-
addPropertyChangeListener
Add a new property change listener.- Parameters:
listener
-
-
removePropertyChangeListener
Remove a property change listener.- Parameters:
listener
-
-
getProperty
Get a specified property.- Parameters:
key
-- Returns:
-
setProperty
Set a property. Note that if properties are Serializable, they will be included in associated data files - otherwise they are stored only transiently.- Parameters:
key
-value
-- Returns:
-
removeProperty
Remove a specified property.- Parameters:
key
-- Returns:
-
getProperties
Get an unmodifiable map representing all known properties for this ImageData.- Returns:
-
getLastSavedPath
Get the last path used to save this object;- Returns:
-
isChanged
public boolean isChanged()Returns true if changes have been recorded since the last time this object was notified that it was saved.- Returns:
- See Also:
-
setChanged
public void setChanged(boolean isChanged) SetisChanged()
status.- Parameters:
isChanged
-
-
setLastSavedPath
Set the last path used to save this object;- Parameters:
path
-resetChanged
- If true, then the isChanged() flag will be reset to false;
-
hierarchyChanged
Description copied from interface:PathObjectHierarchyListener
Notify listeners of a change in the hierarchy or its objects.- Specified by:
hierarchyChanged
in interfacePathObjectHierarchyListener
- Parameters:
event
-
-
workflowUpdated
Description copied from interface:WorkflowListener
Called whenever a Workflow has been updated in some way, such as a new step added.- Specified by:
workflowUpdated
in interfaceWorkflowListener
- Parameters:
workflow
-
-
close
Close the server if it has been loaded. Note that this should not be called if the server is still in use.- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
toString
-