Class PatientSlice

java.lang.Object
gov.nih.mipav.view.PatientSlice

public class PatientSlice extends 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:
  • invalid reference
    FileInfoBase.java
  • invalid reference
    ModelStorageBase.java
  • invalid reference
    ViewJComponentEditImage.java
  • invalid reference
    ViewJComponentTriImage.java
  • invalid reference
    ViewJComponentTriSliceImage.java
  • invalid reference
    PlaneRender.java
  • invalid reference
    MipavCoordinateSystems.java
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Flag indicating whether to use the threshold1 value:.
    private boolean
    Flag indicating whether to use the threshold2 value:.
    private ModelImage
    imageA:.
    private ModelImage
    The current active image:.
    private ModelImage
    imageB:.
    private float[]
    The imageBuffer that stores the current ModelImage slice data for imageA:.
    private float[]
    The imageBuffer that stores the current ModelImage slice data for imageB:.
    private float[]
    colocalization imageBuffer:.
    private ModelImage
    colocalization image:.
    private int[]
    image extents in the local coordinate system:.
    private ModelLUT
    ModelLUT lookup table for gray-scale ModelImages: imageA lut.
    private ModelLUT
    ModelLUT lookup table for gray-scale ModelImages: imageB lut.
    private float[]
    Mask data when a surface is loaded into the SurfaceRender, for blending with the PlaneRender image.
    private float[]
    Color normalization factor:.
    private int[]
    lookup table for mapping ModelImage data values to color for imageA:.
    private int[]
    lookup table for mapping ModelImage data values to color for imageB:.
    private WildMagic.LibFoundation.Mathematics.ColorRGB[]
    Color offset factor:.
    private boolean
    Flag indicating whether the slice is axis-aligned or diagonal (for RFA probe rotataions).
    private boolean
    Flag indicating whether to do TriLinear interpolation when exporting a diagonal slice:.
    private boolean
    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
    Flag indicating whether the slice or LUT changed:.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    current slice positions in FileCoordinates:.
    private WildMagic.LibFoundation.Mathematics.Vector3f[]
    The rotated non-axis aligned corners of the slice, from the RFA probe rotation in the SurfaceRender:.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    current slice positions in local coordinates:.
    private int
    This indicates which of the Patient coordinate systems the slice represents: either AXIAL, SAGITTAL, CORONAL, or UNKNOWN.
    private ModelRGB
    ModelRGB lookup table for color ModelImages: imageA rgb table.
    private ModelRGB
    ModelRGB lookup table for color ModelImages: imageB rgb table.
    private int
    The 2D slice to extract from the ModelImage:.
    private float
    Threshold value:.
    private float
    Threshold value:.
    private int
    For 4D data, the timeSlice multiplier for imageA:.
    private int
    For 4D data, the timeSlice multiplier for imageB:.
    private boolean
    Flag indicating whether to threshold the blue color channel:.
    private boolean
    Flag indicating whether to threshold the green color channel:.
    private boolean
    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

    Modifier and Type
    Method
    Description
    private boolean
    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
    Calculate the volume center in PatientCoordinates and set the z-value for this slice.
    void
    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
    Clean up memory used by the component.
    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
    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
    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[]
    Returns the local image extents for the PatientSlice orientation.
    Accessor that returns the LUT for image A.
    Accessor that returns the LUT for image B.
    int
    This indicates which of the 3 tri-image components we are currently in; either AXIAL, SAGITTAL, or CORONAL.
    Accessor that returns the RGBT for image A.
    Accessor that returns the RGBT for image B.
    void
    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
    Sets imageA.
    void
    Sets imageB.
    void
    setImageColocalize(ModelImage imageColocalize)
    Sets the colocalize image.
    void
     
    void
    setInterpolate(boolean bInterpolate)
    Sets the export flag for displaying diagonal to use TriLinear interpolation of the volume data.
    void
    Accessor that sets the LUT for image A.
    void
    Accessor that sets the LUT for image B.
    void
    Causes the data to be redrawn with new RGBTA values:
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • 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 Details

    • disposeLocal

      public void disposeLocal()
      Default dispose.
    • finalize

      public void finalize() throws Throwable
      Clean up memory used by the component.
      Overrides:
      finalize in class Object
      Throws:
      Throwable - if there is a problem encountered during memory clean-up
      See Also:
      • invalid reference
        #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 A
      imgBufferB - storage buffer used to display image B
    • setCenter

      public void setCenter(int i, int j, int k)
      DOCUMENT ME!
      Parameters:
      i - FileCoordinates volume center i
      j - FileCoordinates volume center j
      k - 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 buffer
      useGreenThreshold - whether to threshold the green paint buffer
      useBlueThreshold - whether to threshold the blue paint buffer
    • setThresholds

      public void setThresholds(float threshold1, float threshold2)
      Sets the thresholds.
      Parameters:
      threshold1 - the first threshold
      threshold2 - 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 show
      bufferA - the outbuffer for imageA
      bufferB - the outbuffer for imageB
      forceShow - 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 together
      fAlpha - 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 show
      bufferA - the outbuffer for imageA
      bufferB - the outbuffer for imageB
      forceShow - 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 calculated
      index - 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 table
      RGBIndexBuffer - the color lookup table index buffer
      imageIndex - which color normalization factor to use
      imageBuffer - the imageBuffer the LUT is changing
      index - the current imageBuffer pixel
      colorMapped - the new color value