Class FileInfoMinc
- java.lang.Object
-
- gov.nih.mipav.model.structures.ModelSerialCloneable
-
- gov.nih.mipav.model.file.FileInfoBase
-
- gov.nih.mipav.model.file.FileInfoMinc
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class FileInfoMinc extends FileInfoBase
This class holds all the file information for a MINC file. In addition, it has three classes to organize the data.MINC headers have three main parts: the dimensions, the global attributes, and the variables. There are typically three dimensions, representing the x, y, and z dimensions of the image. There is usually one global attribute, the history. There can be any number of variables.
Variables have within them any number of attributes. So for example, "rootvariable", the first variable in all the MINC files I have seen so far, has the following attributes: varid (= "MINC standard variable"), vartype (= "group________"), version (= "MINC version 1.0"), parent (blank), and children (image). Usually there is a variable for each dimension, a variable for the image, a variable for image min, and a variable for image max. There can also be variables containing patient information or anything else useful.
See the documentation for the classes MincDimElem, MincAttElem, and MincVarElem for further information. The classes are structured exactly like a MINC file.
- Version:
- 1.0 July 1, 2000
- See Also:
FileMinc
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gov.nih.mipav.model.file.FileInfoBase
FileInfoBase.AxisOrientation, FileInfoBase.ImageOrientation, FileInfoBase.Modality, FileInfoBase.Unit, FileInfoBase.UnitType
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
dicomToMincVarMap
Minc var equivalents to anonymizable Dicom tags.private FileMincDimElem[]
dimArray
DOCUMENT ME!private FileMincAttElem[]
gattArray
DOCUMENT ME!static int
NC_ATTRIBUTE
NetCDF defined data type - attribute.static int
NC_BYTE
NetCDF defined data type - byte.static int
NC_CHAR
NetCDF defined data type - character.static int
NC_DIMENSION
NetCDF defined data type - dimension.static int
NC_DOUBLE
NetCDF defined data type - double.static int
NC_FLOAT
NetCDF defined data type - float.static int
NC_INT
NetCDF defined data type - integer.static int
NC_SHORT
NetCDF defined data type - short.static int
NC_VARIABLE
NetCDF defined data type - variable.int
numrecs
DOCUMENT ME!private static long
serialVersionUID
Use serialVersionUID for interoperability.private FileMincVarElem[]
varArray
DOCUMENT ME!double
vmax
Valid image maximum value.double
vmin
Valid image minimum value.-
Fields inherited from class gov.nih.mipav.model.file.FileInfoBase
ANGSTROMS, ANGSTROMS_STRING, AXIAL, axisOrientation, axisOrientationStr, BIOMAGNETIC_IMAGING, cameraMake, cameraModel, CENTIMETERS, CENTIMETERS_STRING, COLOR_FLOW_DOPPLER, COMPRESSION_BZIP2, COMPRESSION_GZIP, COMPRESSION_NONE, COMPRESSION_ZIP, COMPUTED_RADIOGRAPHY, COMPUTED_TOMOGRAPHY, conversionSpaceTimeUnits, CORONAL, DEGREES, DEGREES_STRING, DIAPHANOGRAPHY, DIGITAL_RADIOGRAPHY, DUPLEX_DOPPLER, ENDOSCOPY, exposureTime, EXTERNAL_CAMERA_PHOTOGRAPHY, FA, fileName, fileSuffix, FNumber, focalLength, focalLength35, GENERAL_MICROSCOPY, HARDCOPY, HOURS, HOURS_STRING, HZ, HZ_STRING, ICG, imageOrientation, INCHES, INCHES_STRING, INTRAORAL_RADIOGRAPHY, ISOSpeedRating, KILOMETERS, KILOMETERS_STRING, LASER_SURFACE_SCAN, MAGNETIC_RESONANCE, MAGNETIC_RESONANCE_ANGIOGRAPHY, MAGNETIC_RESONANCE_SPECTROSCOPY, MAMMOGRAPHY, METERS, METERS_STRING, MICROMETERS, MICROMETERS_STRING, MICROSEC, MICROSEC_STRING, MILES, MILES_STRING, MILLIMETERS, MILLIMETERS_STRING, MILLISEC, MILLISEC_STRING, MILS, MILS_STRING, MINUTES, MINUTES_STRING, modality, NANOMETERS, NANOMETERS_STRING, NANOSEC, NANOSEC_STRING, NUCLEAR_MEDICINE, ORI_A2P_TYPE, ORI_I2S_TYPE, ORI_L2R_TYPE, ORI_P2A_TYPE, ORI_R2L_TYPE, ORI_S2I_TYPE, ORI_UNKNOWN_TYPE, origin, OTHER, PANORAMIC_XRAY, POSITRON_EMISSION_TOMOGRAPHY, PPM, PPM_STRING, RADIO_FLUOROSCOPY, RADIOGRAPHIC_IMAGING, RADIOTHERAPY_DOSE, RADIOTHERAPY_IMAGE, RADIOTHERAPY_PLAN, RADIOTHERAPY_RECORD, RADIOTHERAPY_STRUCTURE_SET, RADS, RADS_STRING, RED_FREE, SAGITTAL, SECONDS, SECONDS_STRING, SINGLE_PHOTON_EMISSION_COMPUTED_TOMOGRAPHY, SLIDE_MICROSCOPY, sUnits, tagDescription, tagName, THERMOGRAPHY, TRANSFORM_ANOTHER_DATASET, TRANSFORM_MNI_152, TRANSFORM_SCANNER_ANATOMICAL, TRANSFORM_TALAIRACH_TOURNOUX, TRANSFORM_UNKNOWN, tUnits, ULTRASOUND, unitsOfMeasure, UNKNOWN_MEASURE, UNKNOWN_MODALITY, UNKNOWN_ORIENT, UNKNOWN_STRING, XRAY_ANGIOGRAPHY
-
-
Constructor Summary
Constructors Constructor Description FileInfoMinc(java.lang.String name, java.lang.String directory, int format)
MINC file information constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttValue(FileMincAttElem elem, java.lang.Object value, int index)
Sets the value of the attribute element; used for setting attribute of variables.void
addDimElem(java.lang.String name, int length, int index)
Puts a new dimension element with the specified parameters into the dimension array at the gievn index.void
addGattElem(java.lang.String name, int type, int length, int index)
Puts a new global attribute array element with the specified parameters into the global attribute array at the given index.void
addVarElem(java.lang.String name, int nelems, int[] dimid, int index)
Puts a new variable element with the specified paramenters into the array at the given index.void
anonymize(boolean[] list)
Removes requested identifying info.static double
calculateIntercept(double min, double slope, double validMin)
Calculates rescale intercept given a min and a slope value.void
calculateRescaleIntercept(double[] rescaleIntercept, double[] rescaleSlope)
In MINC images, "real" values for pixels are calculated by taking the given image min and image max and rescaling the data accordingly.static double
calculateSlope(double max, double min, double validMax, double validMin)
Calculates rescale slope given a min and a max value.java.util.Hashtable<java.lang.String,java.lang.String>
convertTagsToTable()
Returns all of the dicom-converted tags in the minc header as a tag-value hashtable.void
createDimArray(int length)
Constructs the dimension array with the specified length.void
createGattArray(int length)
Constructs the global attribute array with the specified length.void
createVarArray(int length)
Constructs the variable array with the specified length.void
displayAboutInfo(JDialogBase dlog, TransMatrix matrix)
Displays important information about the image.static int[]
getAxisOrientation(TransMatrix mat)
Return the 3 axis orientation codes that correspond to the closest standard anatomical orientation of the (i,j,k) axes.double[]
getConvertStartLocationsToDICOM(int slice, int time)
Accessor that gets the "start" variable values, adjusted so that [0] holds the image x axis value, [1] the image y axis value, and [2] the image z axis value.java.lang.String
getDicomValue(java.lang.String dicomTag)
Get the value from the minc info based on a given dicom tag id.FileMincDimElem[]
getDimArray()
Gets the array with the dimension information.FileMincDimElem
getDimElem(int index)
Accessor that returns the dimension element at the indicated index in the dimension array.FileMincAttElem[]
getGattArray()
Gets the array with the attribute information.FileMincAttElem
getGattElem(int index)
Accessor that returns the global attribute element at the indicated index in the global attribute array.private double
getMincSliceThickness()
Return the slice thickness value stored in the minc header (var = 'acquisition', attrib = 'slice_thickness').float[]
getStartLocations()
Accessor that gets the "start" variable values, with the "xspace" in 0, "yspace" in 1, and "zspace" in 2.private static java.lang.String
getTagElem(java.lang.String fullTag)
Extract the element identifier (removing the group id).private static java.lang.String
getTagGroup(java.lang.String fullTag)
Extract the group to which a dicom or minc element belongs to.FileMincVarElem[]
getVarArray()
Gets the array with the variable information.FileMincVarElem
getVarElem(int index)
Accessor that returns the variable element at the indicated index in the variable array.void
setImportantImageInfo()
Sets necessary image information.void
setModality()
Sets the image modality based on the.static int
setOrientType(java.lang.String space, boolean positive)
Helper method to set the axis orientations.void
setResolutions(int orientation)
Sets the resolutions from the variable array based on the orientation of the image.private void
setStartLocation(double originCoord, int axis)
Sets the start location of the specified axis.void
setStartLocations(double[] origin)
Sets start locations of each axis.void
setUnits()
Sets the units of the dimensions, as in millimeters, inches, etc.-
Methods inherited from class gov.nih.mipav.model.file.FileInfoBase
copyCoreInfo, copyCoreInfo, displayAboutInfo, displayPrimaryInfo, finalize, getAboutInfo, getAllSameDimUnits, getAreaUnitsOfMeasureStr, getAxisDirection, getAxisOrientation, getAxisOrientation, getAxisOrientationFromStr, getAxisOrientationStr, getCameraMake, getCameraModel, getCompressionType, getDataType, getDataTypeFromStr, getEndianess, getEndianessFromStr, getExposureTime, getExtents, getFileDirectory, getFileFormat, getFileName, getFileSuffix, getFNumber, getFocalLength, getFocalLength35, getImageOrientation, getImageOrientationFromStr, getImageOrientationStr, getIs2_5D, getISOSpeedRating, getLPSOrigin, getLUT, getMax, getMaxB, getMaxG, getMaxR, getMin, getMinB, getMinG, getMinR, getModality, getModalityFromStr, getModalityStr, getModalityStr, getMultiFile, getNumOfBytesPerPixel, getOffset, getOrigin, getOrigin, getOriginalEndianess, getOriginAtSlice, getPhotometric, getPixelPadValue, getPrimaryInfo, getRescaleIntercept, getRescaleSlope, getResolution, getResolutions, getSize, getSliceThickness, getUnitsOfMeasure, getUnitsOfMeasure, getUnitsOfMeasureAbbrevStr, getUnitsOfMeasureAbbrevStr, getUnitsOfMeasureFromStr, getUnitsOfMeasureStr, getUnitsOfMeasureStr, getVolumeUnitsOfMeasureStr, isDicomOrdered, oppositeOrient, sameAxis, setAxisOrientation, setAxisOrientation, setCameraMake, setCameraModel, setCompressionType, setDataType, setEndianess, setExposureTime, setExtents, setExtents, setFileDirectory, setFileFormat, setFileName, setFileSuffix, setFNumber, setFocalLength, setFocalLength35, setImageOrientation, setISOSpeedRating, setLUT, setMax, setMaxB, setMaxG, setMaxR, setMin, setMinB, setMinG, setMinR, setModality, setMultiFile, setOffset, setOrigin, setOrigin, setOriginalEndianess, setPhotometric, setPixelPadValue, setRescaleIntercept, setRescaleSlope, setResolutions, setResolutions, setSliceThickness, setTagDescription, setTagName, setUnitsOfMeasure, setUnitsOfMeasure, setUnitsOfMeasure, setUnitsOfMeasure, toString
-
Methods inherited from class gov.nih.mipav.model.structures.ModelSerialCloneable
clone, nativeClone
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Use serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
NC_BYTE
public static final int NC_BYTE
NetCDF defined data type - byte.- See Also:
- Constant Field Values
-
NC_CHAR
public static final int NC_CHAR
NetCDF defined data type - character.- See Also:
- Constant Field Values
-
NC_SHORT
public static final int NC_SHORT
NetCDF defined data type - short.- See Also:
- Constant Field Values
-
NC_INT
public static final int NC_INT
NetCDF defined data type - integer.- See Also:
- Constant Field Values
-
NC_FLOAT
public static final int NC_FLOAT
NetCDF defined data type - float.- See Also:
- Constant Field Values
-
NC_DOUBLE
public static final int NC_DOUBLE
NetCDF defined data type - double.- See Also:
- Constant Field Values
-
NC_DIMENSION
public static final int NC_DIMENSION
NetCDF defined data type - dimension.- See Also:
- Constant Field Values
-
NC_VARIABLE
public static final int NC_VARIABLE
NetCDF defined data type - variable.- See Also:
- Constant Field Values
-
NC_ATTRIBUTE
public static final int NC_ATTRIBUTE
NetCDF defined data type - attribute.- See Also:
- Constant Field Values
-
dicomToMincVarMap
public static final java.lang.String[] dicomToMincVarMap
Minc var equivalents to anonymizable Dicom tags. Must be in the same order as FileInfoDicom.anonymizeTagIDs.- See Also:
FileInfoDicom.anonymizeTagIDs
-
numrecs
public int numrecs
DOCUMENT ME!
-
vmax
public double vmax
Valid image maximum value. Default = -1.
-
vmin
public double vmin
Valid image minimum value. Default = -1.
-
dimArray
private FileMincDimElem[] dimArray
DOCUMENT ME!
-
gattArray
private FileMincAttElem[] gattArray
DOCUMENT ME!
-
varArray
private FileMincVarElem[] varArray
DOCUMENT ME!
-
-
Method Detail
-
addAttValue
public void addAttValue(FileMincAttElem elem, java.lang.Object value, int index)
Sets the value of the attribute element; used for setting attribute of variables. A MincVarElem has an array of attributes and this method is called on those attributes.- Parameters:
elem
- the attribute element to add the value to.value
- the value to set the element to.index
- the index into the value array to set this value at.- See Also:
FileMincAttElem.setValue(java.lang.Object, int)
-
addDimElem
public void addDimElem(java.lang.String name, int length, int index)
Puts a new dimension element with the specified parameters into the dimension array at the gievn index. The name is usually xspace, yspace, or zspace; the length is the corresponding size of that dimension.- Parameters:
name
- the name of the dimension elementlength
- the length of the dimension elementindex
- the index to put this element into the array
-
addGattElem
public void addGattElem(java.lang.String name, int type, int length, int index)
Puts a new global attribute array element with the specified parameters into the global attribute array at the given index. Usually there is only one element in the global attribute array: the history.- Parameters:
name
- the name of the global attribute elementtype
- the data type, i.e. byte, char, int, etc (see statically defined types)length
- the length of the elementindex
- the index into the array to put this element at
-
addVarElem
public void addVarElem(java.lang.String name, int nelems, int[] dimid, int index)
Puts a new variable element with the specified paramenters into the array at the given index. There are other attributes to set for variables, in particular the attribute array, but that gets set in a different place.- Parameters:
name
- the name of this variable elementnelems
- the number of elements in the attribute arraydimid
- the dimension id array, usually empty but for "image" containing information about the dimensionsindex
- index into the variable array to put this variable- See Also:
FileMincVarElem
-
anonymize
public final void anonymize(boolean[] list)
Removes requested identifying info. Can remove info stored in the minc header in a dicom-like structure and in a more minc-like info structure.- Parameters:
list
- the list of tags to remove; it MUST correspond to anonymizeTagIDs list (or spurious errors result), and it must be of the same length, or this will throw an IllegalArgumentException.- Throws:
java.lang.IllegalArgumentException
- DOCUMENT ME!
-
calculateIntercept
public static final double calculateIntercept(double min, double slope, double validMin)
Calculates rescale intercept given a min and a slope value.- Parameters:
min
- Min value.slope
- Slope value.- Returns:
- Rescale intercept.
-
calculateRescaleIntercept
public void calculateRescaleIntercept(double[] rescaleIntercept, double[] rescaleSlope)
In MINC images, "real" values for pixels are calculated by taking the given image min and image max and rescaling the data accordingly. Image min and image max are given per slice.- Parameters:
rescaleIntercept
- Array of rescale intercepts to setrescaleSlope
- Array of rescale slopes to set
-
calculateSlope
public static final double calculateSlope(double max, double min, double validMax, double validMin)
Calculates rescale slope given a min and a max value.- Parameters:
max
- Max value.min
- Min value.- Returns:
- Rescale slope
-
convertTagsToTable
public java.util.Hashtable<java.lang.String,java.lang.String> convertTagsToTable()
Returns all of the dicom-converted tags in the minc header as a tag-value hashtable.- Returns:
- a tag-value hashtable
-
createDimArray
public final void createDimArray(int length)
Constructs the dimension array with the specified length.- Parameters:
length
- the length of the array
-
createGattArray
public final void createGattArray(int length)
Constructs the global attribute array with the specified length.- Parameters:
length
- the length of the array
-
createVarArray
public final void createVarArray(int length)
Constructs the variable array with the specified length.- Parameters:
length
- the length of the array
-
displayAboutInfo
public void displayAboutInfo(JDialogBase dlog, TransMatrix matrix)
Displays important information about the image.- Specified by:
displayAboutInfo
in classFileInfoBase
- Parameters:
dlog
- where to display the infomatrix
- the transformation matrix
-
getConvertStartLocationsToDICOM
public final double[] getConvertStartLocationsToDICOM(int slice, int time)
Accessor that gets the "start" variable values, adjusted so that [0] holds the image x axis value, [1] the image y axis value, and [2] the image z axis value.MINC positive axis is left to right; positive axis is posterior to anterior; postive axis is inferior to superior
DICOM positive axis is right to left; positive axis is anterior to posterior; postive axis is inferior to superior
If the space's alignment attribute has the value 'centre', then subtract half the space's step value (doesn't seem to apply to zspace for some reason..). Then transform the point by the inverse of the direction_cosines matrix (extracted from the spaces). The result then has some of the signs of its components flipped (which is determined by the image orientation) to get it from minc to dicom orientation.
- Parameters:
slice
- slice to begin the start variable on.timeSlice
- time to begin the start variable on- Returns:
- The slice position in dicom (and mipav) space.
-
getDicomValue
public java.lang.String getDicomValue(java.lang.String dicomTag)
Get the value from the minc info based on a given dicom tag id.- Parameters:
dicomTag
- dicom tag (group,elem)- Returns:
- the value stored in the info (or null if it doesn't exist)
-
getDimArray
public final FileMincDimElem[] getDimArray()
Gets the array with the dimension information.- Returns:
- the array
-
getDimElem
public final FileMincDimElem getDimElem(int index)
Accessor that returns the dimension element at the indicated index in the dimension array.- Parameters:
index
- index where the dimension element is located- Returns:
- dimArray[index]
-
getGattArray
public final FileMincAttElem[] getGattArray()
Gets the array with the attribute information.- Returns:
- the array
-
getGattElem
public final FileMincAttElem getGattElem(int index)
Accessor that returns the global attribute element at the indicated index in the global attribute array.- Parameters:
index
- index where the global attribute element is located- Returns:
- gattArray[index]
-
getStartLocations
public final float[] getStartLocations()
Accessor that gets the "start" variable values, with the "xspace" in 0, "yspace" in 1, and "zspace" in 2. This differs from the other methods because it doesn't place the values so that they correspond to image x, y, and z. Gets values as stored in MINC header, not modified to account for the different origin.- Returns:
- The "start" values for the image.
-
getVarArray
public final FileMincVarElem[] getVarArray()
Gets the array with the variable information.- Returns:
- the array
-
getVarElem
public final FileMincVarElem getVarElem(int index)
Accessor that returns the variable element at the indicated index in the variable array.- Parameters:
index
- index where the variable element is located- Returns:
- varArray[index]
-
setImportantImageInfo
public final void setImportantImageInfo()
Sets necessary image information.
-
setModality
public void setModality()
Sets the image modality based on the.
-
setResolutions
public void setResolutions(int orientation)
Sets the resolutions from the variable array based on the orientation of the image. The "zspace" in MINC refers to the inferior-superior axis, whereas in MIPAV the z resolution variable is the slices (space between slices) regardless of the orientation. Therefore for proper display we must convert between them.- Parameters:
orientation
- The orientation of the image (sagittal, coronal, or axial).
-
setStartLocations
public final void setStartLocations(double[] origin)
Sets start locations of each axis.- Parameters:
origin
- the image origin
-
setUnits
public final void setUnits()
Sets the units of the dimensions, as in millimeters, inches, etc. Called after the header has been read in so the values within the varArray have been set properly already.
-
getTagElem
private static java.lang.String getTagElem(java.lang.String fullTag)
Extract the element identifier (removing the group id).- Parameters:
fullTag
- the full element identitfier- Returns:
- the element id
-
getTagGroup
private static java.lang.String getTagGroup(java.lang.String fullTag)
Extract the group to which a dicom or minc element belongs to.- Parameters:
fullTag
- the full element identitfier- Returns:
- the element group
-
getAxisOrientation
public static int[] getAxisOrientation(TransMatrix mat)
Return the 3 axis orientation codes that correspond to the closest standard anatomical orientation of the (i,j,k) axes.- Parameters:
mat
- 4x4 matrix that transforms (i,j,k) indexes to x,y,z coordinates where +x = Right, +y = Anterior, +z = Superior Only the upper-left 3x3 corner of the matrix is used This routine finds the permutation of (x,y,z) which has the smallest angle to the (i,j,k) axes directions, which are columns of the input matrix Errors: The codes returned will be zero.- Returns:
- codes
-
getMincSliceThickness
private double getMincSliceThickness()
Return the slice thickness value stored in the minc header (var = 'acquisition', attrib = 'slice_thickness').- Returns:
- The slice thickness, if it is stored in the minc header (0 otherwise).
-
setOrientType
public static int setOrientType(java.lang.String space, boolean positive)
Helper method to set the axis orientations.- Parameters:
space
- The space - "xspace", "yspace", or "zspace".positive
- Flag indicating if the space is moving in a positive direction.- Returns:
- The proper axis orientation for that space.
-
setStartLocation
private void setStartLocation(double originCoord, int axis)
Sets the start location of the specified axis.- Parameters:
originCoord
- origin coord.axis
- Axis of orientation; x is 0, y is 1, z is 2.
-
-