Computer Assisted Medical Intervention Tool Kit  version 5.2
camitk::Slice Class Reference

Display a slice (i.e. More...

#include <Slice.h>

+ Inheritance diagram for camitk::Slice:
+ Collaboration diagram for camitk::Slice:

Public Types

enum  SliceOrientation {
  AXIAL , CORONAL , SAGITTAL , AXIAL_NEURO ,
  ARBITRARY
}
 Common slices orientation: axial, sagittal, coronal axial_neuro. More...
 

Public Member Functions

Constructors / Destructors

Constructor

 Slice (vtkSmartPointer< vtkImageData > volume, SliceOrientation AXIAL_ORIENTATION, vtkSmartPointer< vtkWindowLevelLookupTable > lookupTable=nullptr)
 
 ~Slice () override
 virtual destructor More...
 
InterfaceBitMap implementation
void setOriginalVolume (vtkSmartPointer< vtkImageData > img) override final
 set the original volume image data (the source vtkImageData before any reslice) and refresh the vtk pipeline More...
 
void setImageWorldTransform (vtkSmartPointer< vtkTransform >) override
 set the transformation for 3D image representation This is the transformation relative to the world. More...
 
vtkSmartPointer< vtkImageActor > get2DImageActor () const override
 Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 2D viewers. More...
 
vtkSmartPointer< vtkImageActor > get3DImageActor () const override
 Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 3D viewers. More...
 
vtkSmartPointer< vtkActor > getPickPlaneActor () const override
 Return the vtkActor visualizing the plane of the slices. More...
 
vtkSmartPointer< vtkActor > getPixelActor () override
 Return the vtkActor visualizing the picked pixels in the slices. More...
 
void pixelPicked (double, double, double) override
 This method is called when the associated plane has been picked in the InteractiveViewer, the given coordinates is position where the plane was picked. More...
 
void updatePickPlane () override final
 update the position of the plane surrounding the currently selected slice More...
 
int getNumberOfSlices () const override final
 Return the number of slices in the image data set. More...
 
int getSlice () const override
 Return the index of the current displayed slice. More...
 
void setSlice (int s) override final
 Set the current slice index. More...
 
void setSlice (double x, double y, double z) override
 Set the slice corresponding to the given real image (RAI) coordinates. More...
 
int getNumberOfColors () const override
 Return the number of colors in the images. More...
 
void setPixelRealPosition (double, double, double) override
 move the pixel selection green indicator (pixelActor) to the given real position More...
 
virtual void setArbitraryTransform (vtkSmartPointer< vtkTransform >) override
 Set the pointer to the arbitrary slice transformation. More...
 
vtkSmartPointer< vtkImageData > getImageData () const override
 get the current image data More...
 
- Public Member Functions inherited from camitk::InterfaceBitMap
virtual ~InterfaceBitMap ()=default
 virtual destructor More...
 

Protected Member Functions

Protected utility methods
void init ()
 Initialize Attributes. More...
 
void initActors ()
 Initialize actors and everything they need. More...
 
void reslicedToVolumeCoords (const double *ijk, double *xyz)
 Compute the volume coordinates (xyz) from the resliced coordinates (ijk) More...
 
void volumeToReslicedCoords (const double *xyz, double *ijk)
 Compute the resliced coordinates (ijk) from the volume coordinates (xyz) More...
 

Protected Attributes

Attributes / Members of the class
SliceOrientation sliceOrientation
 Direction of the reslice. More...
 
vtkSmartPointer< vtkImageData > originalVolume
 Smart pointer to the original volume to reslice (input of the vtk pipeline) More...
 
int currentSliceIndex
 Keep track of the slice number. More...
 
vtkSmartPointer< vtkWindowLevelLookupTable > lut
 Common lookup table. More...
 
double originalSpacing [3]
 Voxel size of the original image volume. More...
 
double originalSize [3]
 Real size (originalDimension * originalSpacing in x, y and z) of the original image. More...
 
vtkSmartPointer< vtkImageActor > image3DActor
 3D actor More...
 
vtkSmartPointer< vtkImageActor > image2DActor
 2D actor More...
 
Management of the arbitrary slice
vtkSmartPointer< vtkImageReslice > image2DReslicer
 The image reslicer computes the arbitrary slice pixels. More...
 

Used to visualize the current picking

vtkSmartPointer< vtkActor > pickPlaneActor
 Actor representing the pickPlane. More...
 
vtkSmartPointer< vtkUnstructuredGrid > pickPlaneActorPointSet
 the pick plane actor unstructured grid More...
 
vtkSmartPointer< vtkActor > pixelActor
 Actor representing a pixel, displayed over the image. More...
 
vtkSmartPointer< vtkUnstructuredGrid > pixelActorPointSet
 the pixel actor unstructured grid More...
 
void initPickPlaneActor ()
 init the pick plane actor More...
 
void initPixelActor ()
 Init the pixel actor for pixel picking. More...
 
void updatePixelActor (double x, double y, double z)
 Update the pixel actor position according to the specified pixel picked by the user i.e. More...
 
void updatePixelActor ()
 update the pixel actor to the middle of the current slice More...
 

manage extra prop associated with a Slice

TODO see extra prop management method section

QMap< QString, vtkSmartPointer< vtkProp > > extraProp
 The additional map for prop. More...
 
vtkSmartPointer< vtkProp > getProp (const QString &) override
 Return the vtkProp (actors, volumes and annotations) corresponding to the given name. More...
 
unsigned int getNumberOfProp () const override
 return the number of additional prop More...
 
vtkSmartPointer< vtkProp > getProp (unsigned int) override
 return an additional prop by its index More...
 
bool addProp (const QString &, vtkSmartPointer< vtkProp >) override
 insert an additional prop, defining it by its name (default visibility = false) More...
 
bool removeProp (const QString &) override
 remove a given additional prop. More...
 

Detailed Description

Display a slice (i.e.

an image or BitMap) of an ImageComponent. Helper class.

This class manages the visual representation of one slice of a volume image. The slice depends on the orientation and the currently selected slice index. A special case is the arbitrary orientation, where the orientation is not perpendicular to one of the axes, but can have any free orientation and translation.

A slice is represented in 2D and 3D thanks to:

  • image2DActor that provides a 2D representation (the slice in the world reference frame)
  • image3DActor that provides a 3D representation (the slice at this actual 3D position) Both are updated thanks to vtkImageActor::SetDisplayExtent.
Note
the setImageWorldTransform(...) methods is used to set the user transform of the image 3D actor.

Slice also manages two other actors to visualize user picking inside the image:

  • the picked plane actor (a wireframe box made of 4 quads around the picked plane) that shows the image border
  • the picked pixel actor (two wireframe quads centered on the currently picked pixel) that shows the position of the currently picked pixel. These two actors are build using unstructured grids.

The picked plane actor is defined by 8 points surrounding the current image plane. The points are set at the coordinates of the (red / blue / green) border of the current image plane. To make sure that the borders are visible in any specific orientation, four quads are build from this points. Each quad goes out of the image plane on both side (back and front).

The picked pixel actor is also made of 8 points that describes the cross centered on the currently picked pixel. The points are set at the coordinates of the (red / blue / green) cross around the picked pixel. To make sure that the cross is visible in any specific orientation, two quads are build from this 8 points Each quad goes out of the image plane on both side

Note
(easter egg) hit "t" on any slice viewer and move the camera around to see the quad geometries and how these extra actors are build.
Warning Be careful, the center of the first voxel, of image coordinates (0,0,0), is displayed at coordinates (0.0, 0.0, 0.0) → There is a small shift of half a pixel. The same occurs to the last pixel. Therefore, pixels of a 2D slice that are located on an image border are represented only by their half, or quarter depending on their coordinates.
*       3D Volume                         2D Slice
*       ________  /|\
*      /|      /|  |                      _______
*     /______ / | _|_slice     ===>      /       /        Displayed in
*    |  |____|_/|  |  number            /______ /         the window
*    | /     |//
*    |/______|/
*
*                                          ________________
*                                         | vtkLookUpTable |
*                                      ---|                |
*                                     |   |    lut         |
*                                     |   |________________|
*  setOriginalVolume(..)              |
*   |                                 | setLookUpTable
*   |                   setInput      |                                   __________________
*   |   ________________       _______v____________                      |  vtkImageActor   |
*   |  |  vtkImageData  |     | vtkImageMapToColor |                     |(setDisplayExtent)|
*   |_\|                |----\|                    |-------------------\ |                  |
*     /| originalVolume |----/|   imgToMapFilter   |-------------------/ |   image2DActor   |
*      |________________|     |____________________|     | |             |__________________|
*                                                        | |
*                                                        | |              _________________________            __________________
*                                                        | |             |  vtkTransformFilter     |          |  vtkImageActor   |
*                                                        |  -----------\ |(setWorldTransformation) | --------\|(setDisplayExtent)|
*                                                         -------------/ |                         | --------/|                  |
*                                                                        |                         |          |   image3DActor   |
*                                                                        |_________________________|          |__________________|
*
*
*
* 

Member Enumeration Documentation

◆ SliceOrientation

Common slices orientation: axial, sagittal, coronal axial_neuro.

Axial, Sagittal and Coronal orientation are given in Radiologist point of view. The neurologist point of view is displayed in axial_neuro.

The ImageComponent is supposed to be given in RAI orientation. (see the "Reorient Medical Image" Action Documentation).

RAI orientation (Right to left, Anterior to posterior, Inferior to superior)

AXIAL: from feet to head of the patient

Axial slice

CORONAL: from the front to back of the patient

Coronal slice

SAGITTAL: from the right to left of the patient

Sagittal slice

AXIAL_NEURO: from head to feet (other side of AXIAL)

ARBITRARY: any arbitrary orientation.

See also
ReorientImageExtension
Enumerator
AXIAL 
CORONAL 
SAGITTAL 
AXIAL_NEURO 
ARBITRARY 

Constructor & Destructor Documentation

◆ Slice()

camitk::Slice::Slice ( vtkSmartPointer< vtkImageData >  volume,
SliceOrientation  AXIAL_ORIENTATION,
vtkSmartPointer< vtkWindowLevelLookupTable >  lookupTable = nullptr 
)

References getNumberOfSlices(), init(), setOriginalVolume(), setSlice(), and sliceOrientation.

+ Here is the call graph for this function:

◆ ~Slice()

camitk::Slice::~Slice ( )
override

virtual destructor

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ addProp()

bool camitk::Slice::addProp ( const QString &  name,
vtkSmartPointer< vtkProp >  prop 
)
overridevirtual

insert an additional prop, defining it by its name (default visibility = false)

Returns
true if the additional prop was added (i.e. another additional prop of the same name does not exist)

Implements camitk::InterfaceBitMap.

References extraProp.

◆ get2DImageActor()

vtkSmartPointer< vtkImageActor > camitk::Slice::get2DImageActor ( ) const
overridevirtual

Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 2D viewers.

Implements camitk::InterfaceBitMap.

References image2DActor.

◆ get3DImageActor()

vtkSmartPointer< vtkImageActor > camitk::Slice::get3DImageActor ( ) const
overridevirtual

Return the vtkImageActor (vtkProp) representing a slice to be displayed in the 3D viewers.

Implements camitk::InterfaceBitMap.

References image3DActor.

◆ getImageData()

vtkSmartPointer< vtkImageData > camitk::Slice::getImageData ( ) const
overridevirtual

get the current image data

Implements camitk::InterfaceBitMap.

References originalVolume.

◆ getNumberOfColors()

int camitk::Slice::getNumberOfColors ( ) const
overridevirtual

Return the number of colors in the images.

If color is coded on 1 byte, the images are on 256 grey level. If color is coded on 2 bytes, the images are on 4096 grey level (not 65536).

Implements camitk::InterfaceBitMap.

References originalVolume.

◆ getNumberOfProp()

unsigned int camitk::Slice::getNumberOfProp ( ) const
overridevirtual

return the number of additional prop

Implements camitk::InterfaceBitMap.

References extraProp.

◆ getNumberOfSlices()

int camitk::Slice::getNumberOfSlices ( ) const
finaloverridevirtual

Return the number of slices in the image data set.

Implements camitk::InterfaceBitMap.

References AXIAL, AXIAL_NEURO, CORONAL, originalVolume, SAGITTAL, and sliceOrientation.

Referenced by setSlice(), and Slice().

+ Here is the caller graph for this function:

◆ getPickPlaneActor()

vtkSmartPointer< vtkActor > camitk::Slice::getPickPlaneActor ( ) const
overridevirtual

Return the vtkActor visualizing the plane of the slices.

Implements camitk::InterfaceBitMap.

References pickPlaneActor.

◆ getPixelActor()

vtkSmartPointer< vtkActor > camitk::Slice::getPixelActor ( )
overridevirtual

Return the vtkActor visualizing the picked pixels in the slices.

Implements camitk::InterfaceBitMap.

References pixelActor.

◆ getProp() [1/2]

vtkSmartPointer< vtkProp > camitk::Slice::getProp ( const QString &  name)
overridevirtual

Return the vtkProp (actors, volumes and annotations) corresponding to the given name.

Implements camitk::InterfaceBitMap.

References extraProp.

◆ getProp() [2/2]

vtkSmartPointer< vtkProp > camitk::Slice::getProp ( unsigned int  index)
overridevirtual

return an additional prop by its index

Implements camitk::InterfaceBitMap.

References extraProp.

◆ getSlice()

int camitk::Slice::getSlice ( ) const
overridevirtual

Return the index of the current displayed slice.

Implements camitk::InterfaceBitMap.

References currentSliceIndex.

◆ init()

void camitk::Slice::init ( )
protected

Initialize Attributes.

References currentSliceIndex, image2DActor, image2DReslicer, image3DActor, originalSpacing, originalVolume, pickPlaneActor, pickPlaneActorPointSet, pixelActor, and pixelActorPointSet.

Referenced by Slice(), and ~Slice().

+ Here is the caller graph for this function:

◆ initActors()

void camitk::Slice::initActors ( )
protected

Initialize actors and everything they need.

References ARBITRARY, image2DActor, image2DReslicer, image3DActor, initPickPlaneActor(), initPixelActor(), lut, originalVolume, sliceOrientation, updatePickPlane(), and updatePixelActor().

Referenced by setOriginalVolume().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initPickPlaneActor()

void camitk::Slice::initPickPlaneActor ( )
protected

init the pick plane actor

References ARBITRARY, AXIAL, AXIAL_NEURO, CORONAL, pickPlaneActor, pickPlaneActorPointSet, SAGITTAL, and sliceOrientation.

Referenced by initActors().

+ Here is the caller graph for this function:

◆ initPixelActor()

void camitk::Slice::initPixelActor ( )
protected

Init the pixel actor for pixel picking.

References ARBITRARY, AXIAL, AXIAL_NEURO, CORONAL, pixelActor, pixelActorPointSet, SAGITTAL, and sliceOrientation.

Referenced by initActors().

+ Here is the caller graph for this function:

◆ pixelPicked()

void camitk::Slice::pixelPicked ( double  x,
double  y,
double  z 
)
overridevirtual

This method is called when the associated plane has been picked in the InteractiveViewer, the given coordinates is position where the plane was picked.

Implements camitk::InterfaceBitMap.

◆ removeProp()

bool camitk::Slice::removeProp ( const QString &  name)
overridevirtual

remove a given additional prop.

Returns
true if effictively done

Implements camitk::InterfaceBitMap.

References extraProp.

◆ reslicedToVolumeCoords()

void camitk::Slice::reslicedToVolumeCoords ( const double *  ijk,
double *  xyz 
)
protected

Compute the volume coordinates (xyz) from the resliced coordinates (ijk)

Parameters
ijkgiven resliced coordinates (generally from a pixel picked in the pickPlane)
xyzoutput (should be allocated before calling this function) volume coordinates (with image at the origin in RAI convention) computed from the input

References originalSpacing.

◆ setArbitraryTransform()

void camitk::Slice::setArbitraryTransform ( vtkSmartPointer< vtkTransform >  transform)
overridevirtual

Set the pointer to the arbitrary slice transformation.

this should be done once, at initialization. For SingleImageComponent, it should be the same as the frame of the arbitrary slices (getTransform). This is the transformation relative to the 3D image (it is not parallel to one of the main axe, but has a specific rotation and translation relative to the vtkImage). This is only required for arbitrary orientation.

Implements camitk::InterfaceBitMap.

References image2DReslicer, and camitk::transform.

◆ setImageWorldTransform()

void camitk::Slice::setImageWorldTransform ( vtkSmartPointer< vtkTransform >  transform)
overridevirtual

set the transformation for 3D image representation This is the transformation relative to the world.

This is required to have the 3D actor properly positioned in world space

Implements camitk::InterfaceBitMap.

References image3DActor, and camitk::transform.

◆ setOriginalVolume()

void camitk::Slice::setOriginalVolume ( vtkSmartPointer< vtkImageData >  img)
finaloverridevirtual

set the original volume image data (the source vtkImageData before any reslice) and refresh the vtk pipeline

Implements camitk::InterfaceBitMap.

References initActors(), originalSize, originalSpacing, and originalVolume.

Referenced by Slice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPixelRealPosition()

void camitk::Slice::setPixelRealPosition ( double  x,
double  y,
double  z 
)
overridevirtual

move the pixel selection green indicator (pixelActor) to the given real position

Implements camitk::InterfaceBitMap.

References pixelActor, and updatePixelActor().

Referenced by setSlice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSlice() [1/2]

void camitk::Slice::setSlice ( double  x,
double  y,
double  z 
)
overridevirtual

Set the slice corresponding to the given real image (RAI) coordinates.

Implements camitk::InterfaceBitMap.

References AXIAL, AXIAL_NEURO, CORONAL, SAGITTAL, setPixelRealPosition(), setSlice(), sliceOrientation, and volumeToReslicedCoords().

+ Here is the call graph for this function:

◆ setSlice() [2/2]

void camitk::Slice::setSlice ( int  s)
finaloverridevirtual

Set the current slice index.

If the slice index is less than the first slice index, the first slice is displayed. If the slice index is more than the last slice index, the last slice is displayed.

Parameters
sthe index of the slice to display (base 0).

Implements camitk::InterfaceBitMap.

References AXIAL, AXIAL_NEURO, CORONAL, currentSliceIndex, getNumberOfSlices(), image2DActor, image3DActor, originalVolume, pixelActor, SAGITTAL, sliceOrientation, and updatePickPlane().

Referenced by setSlice(), and Slice().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updatePickPlane()

void camitk::Slice::updatePickPlane ( )
finaloverridevirtual

update the position of the plane surrounding the currently selected slice

Implements camitk::InterfaceBitMap.

References ARBITRARY, AXIAL, AXIAL_NEURO, CORONAL, currentSliceIndex, image2DActor, originalSize, originalSpacing, pickPlaneActorPointSet, SAGITTAL, and sliceOrientation.

Referenced by initActors(), and setSlice().

+ Here is the caller graph for this function:

◆ updatePixelActor() [1/2]

void camitk::Slice::updatePixelActor ( )
protected

update the pixel actor to the middle of the current slice

References originalSize.

Referenced by initActors(), and setPixelRealPosition().

+ Here is the caller graph for this function:

◆ updatePixelActor() [2/2]

void camitk::Slice::updatePixelActor ( double  x,
double  y,
double  z 
)
protected

Update the pixel actor position according to the specified pixel picked by the user i.e.

Compute and draw the bounding box around the selected pixel.

Parameters
xThe absciss value of the selected pixel
yThe ordinate value of the selected pixel
zThe depth value of the selected pixel. In the plane, it's always +/- 0.01 in order to the pixel actor to be visible over the slice.

References ARBITRARY, AXIAL, AXIAL_NEURO, CORONAL, image2DActor, image2DReslicer, originalSize, originalSpacing, pixelActorPointSet, SAGITTAL, and sliceOrientation.

◆ volumeToReslicedCoords()

void camitk::Slice::volumeToReslicedCoords ( const double *  xyz,
double *  ijk 
)
protected

Compute the resliced coordinates (ijk) from the volume coordinates (xyz)

Parameters
xyzgiven volume coordinates (with image at the origin in RAI convention)
ijkoutput (should be allocated before calling this function) resliced coordinates computed from the input

References originalSpacing.

Referenced by setSlice().

+ Here is the caller graph for this function:

Member Data Documentation

◆ currentSliceIndex

int camitk::Slice::currentSliceIndex
protected

Keep track of the slice number.

Referenced by getSlice(), init(), setSlice(), and updatePickPlane().

◆ extraProp

QMap<QString, vtkSmartPointer<vtkProp> > camitk::Slice::extraProp
protected

The additional map for prop.

Referenced by addProp(), getNumberOfProp(), getProp(), and removeProp().

◆ image2DActor

vtkSmartPointer<vtkImageActor> camitk::Slice::image2DActor
protected

◆ image2DReslicer

vtkSmartPointer<vtkImageReslice> camitk::Slice::image2DReslicer
protected

The image reslicer computes the arbitrary slice pixels.

Referenced by init(), initActors(), setArbitraryTransform(), and updatePixelActor().

◆ image3DActor

vtkSmartPointer<vtkImageActor> camitk::Slice::image3DActor
protected

◆ lut

vtkSmartPointer<vtkWindowLevelLookupTable> camitk::Slice::lut
protected

Common lookup table.

Referenced by initActors().

◆ originalSize

double camitk::Slice::originalSize[3]
protected

Real size (originalDimension * originalSpacing in x, y and z) of the original image.

Referenced by setOriginalVolume(), updatePickPlane(), and updatePixelActor().

◆ originalSpacing

double camitk::Slice::originalSpacing[3]
protected

Voxel size of the original image volume.

Used to compute point coordinates between real world and index world.

Referenced by init(), reslicedToVolumeCoords(), setOriginalVolume(), updatePickPlane(), updatePixelActor(), and volumeToReslicedCoords().

◆ originalVolume

vtkSmartPointer<vtkImageData> camitk::Slice::originalVolume
protected

Smart pointer to the original volume to reslice (input of the vtk pipeline)

Referenced by getImageData(), getNumberOfColors(), getNumberOfSlices(), init(), initActors(), setOriginalVolume(), and setSlice().

◆ pickPlaneActor

vtkSmartPointer<vtkActor> camitk::Slice::pickPlaneActor
protected

Actor representing the pickPlane.

Referenced by getPickPlaneActor(), init(), and initPickPlaneActor().

◆ pickPlaneActorPointSet

vtkSmartPointer<vtkUnstructuredGrid> camitk::Slice::pickPlaneActorPointSet
protected

the pick plane actor unstructured grid

Referenced by init(), initPickPlaneActor(), and updatePickPlane().

◆ pixelActor

vtkSmartPointer<vtkActor> camitk::Slice::pixelActor
protected

Actor representing a pixel, displayed over the image.

Referenced by getPixelActor(), init(), initPixelActor(), setPixelRealPosition(), and setSlice().

◆ pixelActorPointSet

vtkSmartPointer<vtkUnstructuredGrid> camitk::Slice::pixelActorPointSet
protected

the pixel actor unstructured grid

Referenced by init(), initPixelActor(), and updatePixelActor().

◆ sliceOrientation


The documentation for this class was generated from the following files: