object ImageIO
Implements methods for reading and writing D-dimensional images
WARNING! WE ARE USING an LPS WORLD COORDINATE SYSTEM
VTK file format does not indicate the orientation of the image. Therefore, when reading from VTK, we assume that it is in RAI orientation. Hence, no magic is done, the same information (coordinates) present in the VTK file header are directly mapped to our coordinate system.
This is also the case when writing VTK. Our image domain information (origin, spacing ..) is mapped directly into the written VTK file header.
This is however not the case for Nifti files! Nifti file headers contain an affine transform from the ijk image coordinates to an RAS World Coordinate System (therefore supporting different image orientations). In order to read Nifti files coherently, we need to adapt the obtained RAS coordinates to our LPS system :
This is done by mirroring the first two dimensions of each point after applying the affine transform
The same mirroring is done again when writing an image to the Nifti format.
Important for oblique images : The Nifti standard supports oblique images, that is images with a bounding box rotated compared to the world dimensions. Scalismo does not support such images. For such images, we offer the user a possibility to resample the image to a domain aligned with the world dimensions and with an RAI orientation. The integrity of the oblique image will be contained in the resampled one. This functionality can be activated by setting a flag appropriately in the scalismo.io.ImageIO.read3DScalarImage method.
Note on Nifti's qform and sform :
As mentioned above, the Nifti header contains a transform from the unit ijk grid to the RAS world coordinates of the grid. This transform can be encoded in 2 entries of the Nifti header, the qform and the sform. In some files, these 2 entries can both be present, and in some cases could even indicate different transforms. In Scalismo, when such a case happens, we favour the sform entry by default. If you wish instead to favour the qform transform, you can do so by setting a flag appropriately in the scalismo.io.ImageIO.read3DScalarImage method.
Documentation on orientation :
http://www.grahamwideman.com/gw/brain/orientation/orientterms.htm
http://www.slicer.org/slicerWiki/index.php/Coordinate_systems
http://brainder.org/2012/09/23/the-nifti-file-format/
- Alphabetic
- By Inheritance
- ImageIO
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- trait WriteNifti[D] extends AnyRef
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def read2DScalarImage[S](file: File)(implicit arg0: Scalar[S], arg1: ClassTag[S], arg2: scala.reflect.api.JavaUniverse.TypeTag[S]): Try[DiscreteImage[_2D, S]]
Read a 2D Scalar Image
Read a 2D Scalar Image
- S
Voxel type of the image
- file
image file to be read
- def read2DScalarImageAsType[S](file: File)(implicit arg0: Scalar[S], arg1: scala.reflect.api.JavaUniverse.TypeTag[S], arg2: ClassTag[S]): Try[DiscreteImage[_2D, S]]
Read a 2D Scalar Image, and possibly convert it to the requested voxel type.
Read a 2D Scalar Image, and possibly convert it to the requested voxel type.
This method is similar to the read2DScalarImage method, except that it will convert the image to the requested voxel type if the type in the file is different, whereas read2DScalarImage will throw an exception in that case.
- S
Voxel type of the image
- file
image file to be read
- def read3DScalarImage[S](file: File, resampleOblique: Boolean = false, favourQform: Boolean = false)(implicit arg0: Scalar[S], arg1: scala.reflect.api.JavaUniverse.TypeTag[S], arg2: ClassTag[S]): Try[DiscreteImage[_3D, S]]
Read a 3D Scalar Image
Read a 3D Scalar Image
- S
Voxel type of the image
- file
image file to be read
- resampleOblique
flag to resample oblique images. This is only required when reading Nifti files containing an oblique image. See documentation above ImageIO.
- favourQform
flag to favour the qform Nifti header entry over the sform one (which is by default favoured). See documentation above ImageIO.
- def read3DScalarImageAsType[S](file: File, resampleOblique: Boolean = false, favourQform: Boolean = false)(implicit arg0: Scalar[S], arg1: scala.reflect.api.JavaUniverse.TypeTag[S], arg2: ClassTag[S]): Try[DiscreteImage[_3D, S]]
Read a 3D Scalar Image, and possibly convert it to the requested voxel type.
Read a 3D Scalar Image, and possibly convert it to the requested voxel type.
This method is similar to the read3DScalarImage method, except that it will convert the image to the requested voxel type if the type in the file is different, whereas read3DScalarImage will throw an exception in that case.
- S
Voxel type of the image
- file
image file to be read
- resampleOblique
flag to resample oblique images. This is only required when reading Nifti files containing an oblique image. See documentation above ImageIO.
- favourQform
flag to favour the qform Nifti header entry over the sform one (which is by default favoured). See documentation above ImageIO.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def writeNifti[S](img: DiscreteImage[_3D, S], file: File)(implicit arg0: Scalar[S], arg1: scala.reflect.api.JavaUniverse.TypeTag[S], arg2: ClassTag[S]): Try[Unit]
- def writeVTK[D, S](img: DiscreteImage[D, S], file: File)(implicit arg0: NDSpace[D], arg1: CanConvertToVtk[D], arg2: Scalar[S], arg3: scala.reflect.api.JavaUniverse.TypeTag[S], arg4: ClassTag[S]): Try[Unit]
- implicit object DiscreteScalarImage3DNifti extends WriteNifti[_3D]
- object ScalarType extends Enumeration
An enumeration comprising all the data types that we can read and write, in VTK and Nifti formats.