Class NIFTIHeader
java.lang.Object
com.xinapse.multisliceimage.Analyze.ANZHeader
com.xinapse.multisliceimage.Analyze.NIFTIHeader
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
NIFTI2Header
This class represents a multi-dimensional NIFTI-1 image header file. The header file
may either:
- contain all the dimensional and descriptive information about a NIFTI-1 image, but none of the pixel data. This is the conventional Analyze 7.5 .img/.hdr file format.
- contain both the dimensional and descriptive information about a NIFTI-1 image, and also the pixel data. This is the new NIFTI-1 .nii file format.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
The default setting of whether NIFTI-1 images that haveqform
andsform
orientation both unset should be read as having an increasing a patient left coordinate value with stored pixel data column number, and whether NIFTI-1 images should be prevented from being written without orientation information.static final boolean
The default setting of whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.static final boolean
The default setting of whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.protected List<com.xinapse.multisliceimage.Analyze.ExtendedData>
The extended data, if present.protected byte[]
The NIFTI extension indicator, if present.static final String
The property value key for setting whether NIFTI-1 images that haveqform
andsform
orientation both unset should be read as having an increasing a patient left coordinate value with stored pixel data column number, and whether NIFTI-1 images should be prevented from being written without orientation information.protected byte[]
The magic number that is used to differentiate NIFTI-1, NIFTI-2 and Analyze 7.5 images.The NIFTI qform parameter.double
The NIFTI qoffset_x parameter.double
The NIFTI qoffset_y parameter.double
The NIFTI qoffset_z parameter.double
The NIFTI quatern_b parameter.double
The NIFTI quatern_c parameter.double
The NIFTI quatern_d parameter.static final String
The property value key for setting whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.static final String
The property value key for setting whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.The NIFTI sform parameter.double[]
The NIFTI srow_x parameter.double[]
The NIFTI srow_y parameter.double[]
The NIFTI srow_z parameter.Fields inherited from class com.xinapse.multisliceimage.Analyze.ANZHeader
AUXFILE_LEN, COMPRESSED_EXTENSION, COMPRESSED_UPPERCASE_EXTENSION, DESCRIPTION_LEN, EXTENSION, MAXDIM, UPPERCASE_EXTENSION, voxOffset
-
Constructor Summary
ModifierConstructorDescriptionprotected
NIFTIHeader
(boolean compressed) Creates a new NIFTIHeader.protected
NIFTIHeader
(ANZPixFormat dataType, boolean compressed, Long... dims) Creates a new NIFTIHeader.protected
NIFTIHeader
(NIFTIHeader header, boolean compressed) Creates a new NIFTI header, copying the information from an existing NIFTI header. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns an exact copy of this NIFTI-1 header.protected int
Returns the size of this NIFTI (NIFTI-1 or NIFTI-2) header.static boolean
Returns the user's preference about whether NIFTI-1 images with bothqform
andsform
orientations unset should be read as having the patient left coordinate increasing with stored pixel data column number, and whether NIFTI-1 images should be prevented from being written without orientation information.static boolean
Returns the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.static boolean
Returns the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.protected void
Read the NIFTI extensions from an InputStream.protected void
Read any NIFTI extensions from a RandomAccessFile.static void
savePreferredFSLCompatibleNIFTI
(boolean b) Saves the user's preference about whether NIFTI-1 images should be read as having the patient left coordinate increasing with stored pixel data column number.static void
savePreferredSaveFSLOrient
(boolean b) Saves the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.static void
savePreferredSaveSPMOrient
(boolean b) Saves the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.void
setImageOrientationPositionPatient
(org.jogamp.vecmath.Vector3f[] orientation, org.jogamp.vecmath.Point3f position, boolean force) toString()
Returns aString
representation of thisNIFTIHeader
.toString
(boolean html) Returns the string representation of this NIFTI-1 compliant image header, with optional presentation in HTML format.protected void
Write the NIFTI extensions to an OutputStream.protected void
Write the NIFTI extensions to a RandomAccessFile.Methods inherited from class com.xinapse.multisliceimage.Analyze.ANZHeader
getDBName, getDescription, getMinMax, setDBName, setDims, setDims, setMinMax, setNCols, setNFrames, setNRows, setNSlices
-
Field Details
-
SAVE_FSL_ORIENT_PROPERTY_KEY
The property value key for setting whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.- See Also:
-
SAVE_SPM_ORIENT_PROPERTY_KEY
The property value key for setting whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.- See Also:
-
FSL_COMPATIBLE_NIFTI_PROPERTY_KEY
The property value key for setting whether NIFTI-1 images that haveqform
andsform
orientation both unset should be read as having an increasing a patient left coordinate value with stored pixel data column number, and whether NIFTI-1 images should be prevented from being written without orientation information.- See Also:
-
DEFAULT_SAVE_FSL_ORIENT
public static final boolean DEFAULT_SAVE_FSL_ORIENTThe default setting of whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.- See Also:
-
DEFAULT_SAVE_SPM_ORIENT
public static final boolean DEFAULT_SAVE_SPM_ORIENTThe default setting of whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.- See Also:
-
DEFAULT_FSL_COMPATIBLE_NIFTI
public static final boolean DEFAULT_FSL_COMPATIBLE_NIFTIThe default setting of whether NIFTI-1 images that haveqform
andsform
orientation both unset should be read as having an increasing a patient left coordinate value with stored pixel data column number, and whether NIFTI-1 images should be prevented from being written without orientation information.- See Also:
-
qForm
The NIFTI qform parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
sForm
The NIFTI sform parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
quaternB
public double quaternBThe NIFTI quatern_b parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
quaternC
public double quaternCThe NIFTI quatern_c parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
quaternD
public double quaternDThe NIFTI quatern_d parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
qOffsetX
public double qOffsetXThe NIFTI qoffset_x parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
qOffsetY
public double qOffsetYThe NIFTI qoffset_y parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
qOffsetZ
public double qOffsetZThe NIFTI qoffset_z parameter. It is not recommended to manipulate this directly. Use the methods to set the image position and orientation in NIFTImage. -
sRowX
public double[] sRowXThe NIFTI srow_x parameter. This is usually set using the methodNIFTIImage.setSFormAffineTransform(AffineTransform3D)
. -
sRowY
public double[] sRowYThe NIFTI srow_y parameter. This is usually set using the methodNIFTIImage.setSFormAffineTransform(AffineTransform3D)
. -
sRowZ
public double[] sRowZThe NIFTI srow_z parameter. This is usually set using the methodNIFTIImage.setSFormAffineTransform(AffineTransform3D)
. -
magic
protected byte[] magicThe magic number that is used to differentiate NIFTI-1, NIFTI-2 and Analyze 7.5 images. -
extension
protected byte[] extensionThe NIFTI extension indicator, if present. -
extData
The extended data, if present.
-
-
Constructor Details
-
NIFTIHeader
protected NIFTIHeader(boolean compressed) Creates a new NIFTIHeader.- Parameters:
compressed
- whether the image should be compressed when written to disk.
-
NIFTIHeader
Creates a new NIFTIHeader.- Parameters:
dataType
- the ANZPixFormat for the pixel values.compressed
- whether the image should be compressed when written to disk.dims
- the image dimensions.- Throws:
ANZException
- if the header cannot be created.
-
NIFTIHeader
Creates a new NIFTI header, copying the information from an existing NIFTI header.- Parameters:
header
- the NIFTIHeader to use as a template.compressed
-true
if the new header is to be compressed.- Throws:
ANZException
- if the header cannot be created.
-
-
Method Details
-
getPreferredSaveFSLOrient
public static boolean getPreferredSaveFSLOrient()Returns the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible. FSL is not able to correctly display images with an orientation that is not in the expected orientation. If interoperating with FSL, it may be necessary to save images in an FSL-friendly orientation. If not set in the user's preferences, then the default is to save NIFTI-1 images with a radiological orientation.If the system property
"analyze.fslorient"
exists, and the property value is either"true"
or"false"
, then the user's preference is overridden by the property value.- Returns:
- whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.
-
savePreferredSaveFSLOrient
public static void savePreferredSaveFSLOrient(boolean b) Saves the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with FSL, where possible.- Parameters:
b
-true
if NIFTI-1 images should have an orientation that is compatible with FSL, where possible;false
otherwise.
-
getPreferredSaveSPMOrient
public static boolean getPreferredSaveSPMOrient()Returns the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible. SPM is not able to correctly display images with an orientation that is not in the expected orientation. If interoperating with SPM, it may be necessary to save images in an SPM-friendly orientation. If not set in the user's preferences, then the default is to save NIFTI-1 images with a radiological orientation.If the system property
"analyze.spmorient"
exists, and the property value is either"true"
or"false"
, then the user's preference is overridden by the property value.- Returns:
- whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.
-
savePreferredSaveSPMOrient
public static void savePreferredSaveSPMOrient(boolean b) Saves the user's preference about whether NIFTI-1 images should be saved with an orientation that is compatible with SPM, where possible.- Parameters:
b
-true
if NIFTI-1 images should have an orientation that is compatible with SPM, where possible;false
otherwise.
-
getPreferredFSLCompatibleNIFTI
public static boolean getPreferredFSLCompatibleNIFTI()Returns the user's preference about whether NIFTI-1 images with bothqform
andsform
orientations unset should be read as having the patient left coordinate increasing with stored pixel data column number, and whether NIFTI-1 images should be prevented from being written without orientation information. This may be necessary if interoperating with FSL.If not set in the user's preferences, then the default is to interpret NIFTI-1 images as axial with an increasing patient right coordinate with increasing column number.
If the system property
"nifti.fslcompatible"
exists, and the property value is either"true"
or"false"
, then the user's preference is overridden by the property value.- Returns:
- whether NIFTI-1 images with both
qform
andsform
unset should be interpreted as having an increasing left coordinate with stored pixel data column number.
-
savePreferredFSLCompatibleNIFTI
public static void savePreferredFSLCompatibleNIFTI(boolean b) Saves the user's preference about whether NIFTI-1 images should be read as having the patient left coordinate increasing with stored pixel data column number.- Parameters:
b
-true
if NIFTI-1 images should be read as having the patient left coordinate increasing with stored pixel data column number;false
otherwise.
-
readExtensions
Read any NIFTI extensions from a RandomAccessFile.- Parameters:
raf
- the RandomAccessFile from which to read the extensions.- Throws:
IOException
- if an I/O error occurs.
-
readExtensions
Read the NIFTI extensions from an InputStream.- Parameters:
s
- the InputStream.- Throws:
IOException
- if an I/O error occurs.
-
writeExtensions
Write the NIFTI extensions to an OutputStream.- Parameters:
s
- the OutputStream.- Throws:
IOException
- if an I/O error occurs.
-
writeExtensions
Write the NIFTI extensions to a RandomAccessFile.- Parameters:
raf
- the RandomAccessFile.- Throws:
IOException
- if an I/O error occurs.
-
getHeaderSize
protected int getHeaderSize()Returns the size of this NIFTI (NIFTI-1 or NIFTI-2) header.- Returns:
- the size of this NIFTI header.
-
setImageOrientationPositionPatient
public void setImageOrientationPositionPatient(org.jogamp.vecmath.Vector3f[] orientation, org.jogamp.vecmath.Point3f position, boolean force) -
toString
Returns aString
representation of thisNIFTIHeader
.- Overrides:
toString
in classANZHeader
- Returns:
- a
String
describing thisNIFTIHeader
.
-
toString
Returns the string representation of this NIFTI-1 compliant image header, with optional presentation in HTML format. -
clone
Returns an exact copy of this NIFTI-1 header.
-