Class PatientSlice
- java.lang.Object
-
- gov.nih.mipav.view.PatientSlice
-
public class PatientSlice extends java.lang.Object
PatientSlice provides oriented or non-oriented interface to the ModelImage data for rendering, with LUT changes.The PatientSlice class should be used any time a 2D slice of the ModelImage is needed for rendering purposes.
The PatientSlice class can be used to extract any axial, coronal, sagittal slice from the ModelImage, or slices in the native file coordinates.
The PatientSlice class can also be used to extract diagonal slices through the ModelImage. This is done by setting the four corners of the diagonal cut-plane, using file coordinates for the four points of the cut-plane bounding box.
The PatientSlice.showUsingOrientation() function extracts a 2D slice from the ModelImage into a 2D packed-int array. This array can be passed to the BufferImage class for viewing 2D images, or it can be passed to the Texture2D class to create texture-mapped polygons. Or the 2D array can be used for algorithms that operate on the 2D ModelImage slices.
- See Also:
FileInfoBase.java
,ModelStorageBase.java
,ViewJComponentEditImage.java
,ViewJComponentTriImage.java
,ViewJComponentTriSliceImage.java
,PlaneRender.java
,MipavCoordinateSystems.java
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
hasThreshold1
Flag indicating whether to use the threshold1 value:.private boolean
hasThreshold2
Flag indicating whether to use the threshold2 value:.private ModelImage
imageA
imageA:.private ModelImage
imageActive
The current active image:.private ModelImage
imageB
imageB:.private float[]
imageBufferA
The imageBuffer that stores the current ModelImage slice data for imageA:.private float[]
imageBufferB
The imageBuffer that stores the current ModelImage slice data for imageB:.private float[]
imageBufferColocalize
colocalization imageBuffer:.private ModelImage
imageColocalize
colocalization image:.private int[]
localImageExtents
image extents in the local coordinate system:.private ModelLUT
LUTa
ModelLUT lookup table for gray-scale ModelImages: imageA lut.private ModelLUT
LUTb
ModelLUT lookup table for gray-scale ModelImages: imageB lut.private float[]
m_afMask
Mask data when a surface is loaded into the SurfaceRender, for blending with the PlaneRender image.private float[]
m_afNormColor
Color normalization factor:.private int[]
m_aiRGBIndexBufferA
lookup table for mapping ModelImage data values to color for imageA:.private int[]
m_aiRGBIndexBufferB
lookup table for mapping ModelImage data values to color for imageB:.private WildMagic.LibFoundation.Mathematics.ColorRGB[]
m_akOffset
Color offset factor:.private boolean
m_bAxisAligned
Flag indicating whether the slice is axis-aligned or diagonal (for RFA probe rotataions).private boolean
m_bInterpolate
Flag indicating whether to do TriLinear interpolation when exporting a diagonal slice:.private boolean
m_bShowDiagonal
Flag indicating whether or not the slice represents an axis-aligned orientation or a diagonal orientation through the ModelImage volume: true when the RFA probe is activated in the SurfaceRender:.private boolean
m_bUpdateImage
Flag indicating whether the slice or LUT changed:.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kFilePoint
current slice positions in FileCoordinates:.private WildMagic.LibFoundation.Mathematics.Vector3f[]
m_kFourCorners
The rotated non-axis aligned corners of the slice, from the RFA probe rotation in the SurfaceRender:.private WildMagic.LibFoundation.Mathematics.Vector3f
m_kPatientPoint
current slice positions in local coordinates:.private int
orientation
This indicates which of the Patient coordinate systems the slice represents: either AXIAL, SAGITTAL, CORONAL, or UNKNOWN.private ModelRGB
RGBTA
ModelRGB lookup table for color ModelImages: imageA rgb table.private ModelRGB
RGBTB
ModelRGB lookup table for color ModelImages: imageB rgb table.private int
slice
The 2D slice to extract from the ModelImage:.private float
threshold1
Threshold value:.private float
threshold2
Threshold value:.private int
timeSliceA
For 4D data, the timeSlice multiplier for imageA:.private int
timeSliceB
For 4D data, the timeSlice multiplier for imageB:.private boolean
useBlueThreshold
Flag indicating whether to threshold the blue color channel:.private boolean
useGreenThreshold
Flag indicating whether to threshold the green color channel:.private boolean
useRedThreshold
Flag indicating whether to threshold the red color channel:.
-
Constructor Summary
Constructors Constructor Description PatientSlice(ModelImage _imageA, ModelLUT _LUTa, ModelImage _imageB, ModelLUT _LUTb, int _orientation)
Constructs a PatientSlice with the given ModelImages, LUTs, and orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
axisAligned()
Determines if a slice is axis-aligned, based on the m_kFourCorners[] four corners of the slice in 3D Model space.private void
calcMaxNormColors(ModelImage kImage, int index)
calculates the color normalization factors.private void
center()
Calculate the volume center in PatientCoordinates and set the z-value for this slice.void
disposeLocal()
Default dispose.private void
fillImageBuffer(int slice, boolean bShowMask)
Gets the image data based on the orientation, either AXIAL, CORONAL, SAGITTAL, UNKNOWN_ORIENT, or a diagonal slice if the plane is a diagonal cut-plane through the ModelImage.void
finalize()
Clean up memory used by the component.ModelStorageBase
getActiveLookupTable()
Returns the ModelLUT or ModelRGB based on which image is currently active, either imageA or imageB and they type of image (color or grayscale).boolean
getAxisAligned()
Returns whether the current slice is axis-aligned or rotated.private float
getBufferValue(boolean logMagDisplay, boolean isComplexBuffer, float[] imageBuffer, int ind4)
Helper method for calculating complex values.WildMagic.LibFoundation.Mathematics.Vector3f
getCenter()
Return the current center of the volume in FileCoordinates.private void
getColorMapped(ModelRGB modelRGBT, int[] RGBIndexBuffer, int imageIndex, float[] imageBuffer, int index, WildMagic.LibFoundation.Mathematics.ColorRGBA colorMapped)
Get the color from the RGB lookup table:int[]
getExtents()
Returns the local image extents for the PatientSlice orientation.ModelLUT
getLUTa()
Accessor that returns the LUT for image A.ModelLUT
getLUTb()
Accessor that returns the LUT for image B.int
getOrientation()
This indicates which of the 3 tri-image components we are currently in; either AXIAL, SAGITTAL, or CORONAL.ModelRGB
getRGBTa()
Accessor that returns the RGBT for image A.ModelRGB
getRGBTb()
Accessor that returns the RGBT for image B.void
setActiveImage(ModelImage kImage)
Sets which image is currently active.void
setBuffers(float[] imgBufferA, float[] imgBufferB)
The frame in which the image(s) is displayed, allocates the memory and uses this method to pass the references to the buffers.void
setCenter(int i, int j, int k)
DOCUMENT ME!void
setDiagonalVerts(WildMagic.LibFoundation.Mathematics.Vector3f[] fourCorners)
Sets the four corners of the bounding box for this slice in FileCoordinates so that the volume data can be exported along a diagonal slice, based on the positions of the input bounding box.void
setHasThreshold1(boolean hasThreshold1)
Sets the hasThreshold1 for setPaintBuffers.void
setHasThreshold2(boolean hasThreshold2)
Sets the hasThreshold2 for setPaintBuffers.void
setImageA(ModelImage image)
Sets imageA.void
setImageB(ModelImage image)
Sets imageB.void
setImageColocalize(ModelImage imageColocalize)
Sets the colocalize image.void
setImageExtents()
void
setInterpolate(boolean bInterpolate)
Sets the export flag for displaying diagonal to use TriLinear interpolation of the volume data.void
setLUTa(ModelLUT LUT)
Accessor that sets the LUT for image A.void
setLUTb(ModelLUT LUT)
Accessor that sets the LUT for image B.void
setRGBTA(ModelRGB RGBT)
Causes the data to be redrawn with new RGBTA values:void
setRGBTB(ModelRGB RGBT)
Causes the data to be redrawn with new RGBTB values:void
setShowDiagonal(boolean bDiagonal)
Sets the export for this Slice to be along a diagonal.void
setThresholdColors(boolean useRedThreshold, boolean useGreenThreshold, boolean useBlueThreshold)
Sets the booleans for using thresholds in showUsingOrientation.void
setThresholds(float threshold1, float threshold2)
Sets the thresholds.boolean
showUsingOrientation(int tSlice, int[] bufferA, int[] bufferB, boolean forceShow, boolean bShowMask)
For generating the display of one or two ModelImages (imageA and imageB).boolean
showUsingOrientation(int tSlice, int[] bufferA, int[] bufferB, boolean forceShow, boolean bBlend, float fAlpha, boolean bShowMask)
For generating the display of one or two ModelImages (imageA and imageB).boolean
updateSlice(int newSlice)
updates the slice value when the wheel is moved or the page_up, page_down keys are pressed.
-
-
-
Field Detail
-
hasThreshold1
private boolean hasThreshold1
Flag indicating whether to use the threshold1 value:.
-
hasThreshold2
private boolean hasThreshold2
Flag indicating whether to use the threshold2 value:.
-
imageA
private ModelImage imageA
imageA:.
-
imageActive
private ModelImage imageActive
The current active image:.
-
imageB
private ModelImage imageB
imageB:.
-
imageBufferA
private float[] imageBufferA
The imageBuffer that stores the current ModelImage slice data for imageA:.
-
imageBufferB
private float[] imageBufferB
The imageBuffer that stores the current ModelImage slice data for imageB:.
-
imageBufferColocalize
private float[] imageBufferColocalize
colocalization imageBuffer:.
-
imageColocalize
private ModelImage imageColocalize
colocalization image:.
-
localImageExtents
private int[] localImageExtents
image extents in the local coordinate system:.
-
LUTa
private ModelLUT LUTa
ModelLUT lookup table for gray-scale ModelImages: imageA lut.
-
LUTb
private ModelLUT LUTb
ModelLUT lookup table for gray-scale ModelImages: imageB lut.
-
m_afMask
private float[] m_afMask
Mask data when a surface is loaded into the SurfaceRender, for blending with the PlaneRender image. Included here for rendering performance
-
m_afNormColor
private float[] m_afNormColor
Color normalization factor:.
-
m_aiRGBIndexBufferA
private int[] m_aiRGBIndexBufferA
lookup table for mapping ModelImage data values to color for imageA:.
-
m_aiRGBIndexBufferB
private int[] m_aiRGBIndexBufferB
lookup table for mapping ModelImage data values to color for imageB:.
-
m_akOffset
private WildMagic.LibFoundation.Mathematics.ColorRGB[] m_akOffset
Color offset factor:.
-
m_bAxisAligned
private boolean m_bAxisAligned
Flag indicating whether the slice is axis-aligned or diagonal (for RFA probe rotataions).
-
m_bInterpolate
private boolean m_bInterpolate
Flag indicating whether to do TriLinear interpolation when exporting a diagonal slice:.
-
m_bShowDiagonal
private boolean m_bShowDiagonal
Flag indicating whether or not the slice represents an axis-aligned orientation or a diagonal orientation through the ModelImage volume: true when the RFA probe is activated in the SurfaceRender:.
-
m_bUpdateImage
private boolean m_bUpdateImage
Flag indicating whether the slice or LUT changed:.
-
m_kFilePoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kFilePoint
current slice positions in FileCoordinates:.
-
m_kFourCorners
private WildMagic.LibFoundation.Mathematics.Vector3f[] m_kFourCorners
The rotated non-axis aligned corners of the slice, from the RFA probe rotation in the SurfaceRender:.
-
m_kPatientPoint
private WildMagic.LibFoundation.Mathematics.Vector3f m_kPatientPoint
current slice positions in local coordinates:.
-
orientation
private int orientation
This indicates which of the Patient coordinate systems the slice represents: either AXIAL, SAGITTAL, CORONAL, or UNKNOWN.
-
RGBTA
private ModelRGB RGBTA
ModelRGB lookup table for color ModelImages: imageA rgb table.
-
RGBTB
private ModelRGB RGBTB
ModelRGB lookup table for color ModelImages: imageB rgb table.
-
slice
private int slice
The 2D slice to extract from the ModelImage:.
-
threshold1
private float threshold1
Threshold value:.
-
threshold2
private float threshold2
Threshold value:.
-
timeSliceA
private int timeSliceA
For 4D data, the timeSlice multiplier for imageA:.
-
timeSliceB
private int timeSliceB
For 4D data, the timeSlice multiplier for imageB:.
-
useBlueThreshold
private boolean useBlueThreshold
Flag indicating whether to threshold the blue color channel:.
-
useGreenThreshold
private boolean useGreenThreshold
Flag indicating whether to threshold the green color channel:.
-
useRedThreshold
private boolean useRedThreshold
Flag indicating whether to threshold the red color channel:.
-
-
Constructor Detail
-
PatientSlice
public PatientSlice(ModelImage _imageA, ModelLUT _LUTa, ModelImage _imageB, ModelLUT _LUTb, int _orientation)
Constructs a PatientSlice with the given ModelImages, LUTs, and orientation. The orientation parameter may take on any of the following values: FileInfoBase.AXIAL, FileInfoBase.CORONAL, FileInfoBase.SAGITTAL, or FileInfoBase.UNKNOWN_ORIENT- Parameters:
_imageA
- Model of the image that will be displayed_LUTa
- LUT used to display imageA_imageB
- Model of the image that will be displayed_LUTb
- LUT used to display imageB_orientation
- display orientation of the image
-
-
Method Detail
-
disposeLocal
public void disposeLocal()
Default dispose.
-
finalize
public void finalize() throws java.lang.Throwable
Clean up memory used by the component.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
- if there is a problem encountered during memory clean-up- See Also:
#disposeLocal(boolean)
-
getActiveLookupTable
public ModelStorageBase getActiveLookupTable()
Returns the ModelLUT or ModelRGB based on which image is currently active, either imageA or imageB and they type of image (color or grayscale).- Returns:
- the active LUT/RGB table.
-
getAxisAligned
public boolean getAxisAligned()
Returns whether the current slice is axis-aligned or rotated.- Returns:
- true when axis-aligned, false otherwise.
-
getCenter
public WildMagic.LibFoundation.Mathematics.Vector3f getCenter()
Return the current center of the volume in FileCoordinates.- Returns:
- volume center in FileCoordinates
-
getExtents
public int[] getExtents()
Returns the local image extents for the PatientSlice orientation.- Returns:
- image extents in local coordinates.
-
getLUTa
public ModelLUT getLUTa()
Accessor that returns the LUT for image A.- Returns:
- LUTa
-
getLUTb
public ModelLUT getLUTb()
Accessor that returns the LUT for image B.- Returns:
- LUTb
-
getOrientation
public int getOrientation()
This indicates which of the 3 tri-image components we are currently in; either AXIAL, SAGITTAL, or CORONAL.- Returns:
- The orientation, either AXIAL, SAGITTAL, or CORONAL.
-
getRGBTa
public ModelRGB getRGBTa()
Accessor that returns the RGBT for image A.- Returns:
- RGBTA
-
getRGBTb
public ModelRGB getRGBTb()
Accessor that returns the RGBT for image B.- Returns:
- RGBTB
-
setActiveImage
public void setActiveImage(ModelImage kImage)
Sets which image is currently active.- Parameters:
kImage
- the currently active image.
-
setBuffers
public void setBuffers(float[] imgBufferA, float[] imgBufferB)
The frame in which the image(s) is displayed, allocates the memory and uses this method to pass the references to the buffers.- Parameters:
imgBufferA
- storage buffer used to display image AimgBufferB
- storage buffer used to display image B
-
setCenter
public void setCenter(int i, int j, int k)
DOCUMENT ME!- Parameters:
i
- FileCoordinates volume center ij
- FileCoordinates volume center jk
- FileCoordinates volume center k
-
setImageExtents
public void setImageExtents()
-
setDiagonalVerts
public void setDiagonalVerts(WildMagic.LibFoundation.Mathematics.Vector3f[] fourCorners)
Sets the four corners of the bounding box for this slice in FileCoordinates so that the volume data can be exported along a diagonal slice, based on the positions of the input bounding box.- Parameters:
fourCorners
- the bounding box of the diagonal slice in FileCoordinates
-
setHasThreshold1
public void setHasThreshold1(boolean hasThreshold1)
Sets the hasThreshold1 for setPaintBuffers.- Parameters:
hasThreshold1
- whether the paint buffer has a threshold1
-
setHasThreshold2
public void setHasThreshold2(boolean hasThreshold2)
Sets the hasThreshold2 for setPaintBuffers.- Parameters:
hasThreshold2
- whether the paint buffer has a threshold2
-
setImageA
public void setImageA(ModelImage image)
Sets imageA.- Parameters:
image
- imageA
-
setImageB
public void setImageB(ModelImage image)
Sets imageB.- Parameters:
image
- imageB
-
setImageColocalize
public void setImageColocalize(ModelImage imageColocalize)
Sets the colocalize image.- Parameters:
imageColocalize
- the colocalization image
-
setInterpolate
public void setInterpolate(boolean bInterpolate)
Sets the export flag for displaying diagonal to use TriLinear interpolation of the volume data.- Parameters:
bInterpolate
- when true use TriLinear interpolation of the volume data
-
setLUTa
public void setLUTa(ModelLUT LUT)
Accessor that sets the LUT for image A.- Parameters:
LUT
- New LUTa
-
setLUTb
public void setLUTb(ModelLUT LUT)
Accessor that sets the LUT for image B.- Parameters:
LUT
- New LUTb
-
setRGBTA
public void setRGBTA(ModelRGB RGBT)
Causes the data to be redrawn with new RGBTA values:- Parameters:
RGBT
- the new RGBT for imageA
-
setRGBTB
public void setRGBTB(ModelRGB RGBT)
Causes the data to be redrawn with new RGBTB values:- Parameters:
RGBT
- the new RGBT for imageB
-
setShowDiagonal
public void setShowDiagonal(boolean bDiagonal)
Sets the export for this Slice to be along a diagonal.- Parameters:
bDiagonal
- if true, render this slice as a diagonal
-
setThresholdColors
public void setThresholdColors(boolean useRedThreshold, boolean useGreenThreshold, boolean useBlueThreshold)
Sets the booleans for using thresholds in showUsingOrientation.- Parameters:
useRedThreshold
- whether to threshold the red paint bufferuseGreenThreshold
- whether to threshold the green paint bufferuseBlueThreshold
- whether to threshold the blue paint buffer
-
setThresholds
public void setThresholds(float threshold1, float threshold2)
Sets the thresholds.- Parameters:
threshold1
- the first thresholdthreshold2
- the second threshold
-
showUsingOrientation
public boolean showUsingOrientation(int tSlice, int[] bufferA, int[] bufferB, boolean forceShow, boolean bBlend, float fAlpha, boolean bShowMask)
For generating the display of one or two ModelImages (imageA and imageB). Images may be oriented or non-oriented, axis-aligned or diagonal cut plans through the ModelImage volume.- Parameters:
tSlice
- t (time) slice to showbufferA
- the outbuffer for imageAbufferB
- the outbuffer for imageBforceShow
- when true the image is re-rendered regardless of whether the slice value displayed or LUT has changed.bBlend
- when true bufferA and bufferB are blended togetherfAlpha
- the blend factor for blending bufferA and bufferB@bShowMask
- when true the surface voxel mask (if any) is blended into the buffer.- Returns:
- boolean to indicate whether or not the show function updated
-
showUsingOrientation
public boolean showUsingOrientation(int tSlice, int[] bufferA, int[] bufferB, boolean forceShow, boolean bShowMask)
For generating the display of one or two ModelImages (imageA and imageB). Images may be oriented or non-oriented, axis-aligned or diagonal cut plans through the ModelImage volume.- Parameters:
tSlice
- t (time) slice to showbufferA
- the outbuffer for imageAbufferB
- the outbuffer for imageBforceShow
- when true the image is re-rendered regardless of whether the slice value displayed or LUT has changed.bShowMask
- when true the surface voxel mask (if any) is blended into the buffer.- Returns:
- boolean to indicate whether or not the show function updated
-
getBufferValue
private float getBufferValue(boolean logMagDisplay, boolean isComplexBuffer, float[] imageBuffer, int ind4)
Helper method for calculating complex values. Performing isComplexBuffer and logMagDsplay checks elsewhere improves performance.
-
updateSlice
public boolean updateSlice(int newSlice)
updates the slice value when the wheel is moved or the page_up, page_down keys are pressed. Does bounds checking and comparison with the current slice value. Sets the new position and updates the triImageFrame.- Parameters:
newSlice
- the new slice value- Returns:
- true if the slice is updated and the image should be re-rendered, false otherwise
-
axisAligned
private boolean axisAligned()
Determines if a slice is axis-aligned, based on the m_kFourCorners[] four corners of the slice in 3D Model space.- Returns:
- true when the slice is axis-aligned, false otherwise.
-
calcMaxNormColors
private void calcMaxNormColors(ModelImage kImage, int index)
calculates the color normalization factors.- Parameters:
kImage
- the model image from which the normalization factors are calculatedindex
- index for storing one of two colors normalization factors
-
center
private void center()
Calculate the volume center in PatientCoordinates and set the z-value for this slice.
-
fillImageBuffer
private void fillImageBuffer(int slice, boolean bShowMask)
Gets the image data based on the orientation, either AXIAL, CORONAL, SAGITTAL, UNKNOWN_ORIENT, or a diagonal slice if the plane is a diagonal cut-plane through the ModelImage.- Parameters:
slice
- data slize
-
getColorMapped
private void getColorMapped(ModelRGB modelRGBT, int[] RGBIndexBuffer, int imageIndex, float[] imageBuffer, int index, WildMagic.LibFoundation.Mathematics.ColorRGBA colorMapped)
Get the color from the RGB lookup table:- Parameters:
modelRGBT
- the color lookup tableRGBIndexBuffer
- the color lookup table index bufferimageIndex
- which color normalization factor to useimageBuffer
- the imageBuffer the LUT is changingindex
- the current imageBuffer pixelcolorMapped
- the new color value
-
-