Class AlgorithmDWI2DTI
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.DiffusionTensorImaging.AlgorithmDWI2DTI
-
- All Implemented Interfaces:
AlgorithmInterface
,java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
public class AlgorithmDWI2DTI extends AlgorithmBase implements AlgorithmInterface
Algorithm calculates a Diffusion Tensor Image from a series of Diffusion Weighted Images. See: Introduction to Diffusion Tensor Imaging, by Susumu Mori
-
-
Field Summary
Fields Modifier and Type Field Description private AlgorithmBrainSurfaceExtractor
alg
handle to BSE Algorithm *private java.util.HashMap<java.lang.String,float[]>
m_3dbufferMap_float
private java.util.HashMap<java.lang.String,int[]>
m_3dbufferMap_int
private java.util.HashMap<java.lang.String,float[]>
m_4dbufferMap_float
private java.util.HashMap<java.lang.String,int[]>
m_4dbufferMap_int
private java.lang.String[][]
m_aakDWIList
List of file names for the Diffusion Weighted Images, from the .path file.private int[]
m_aiMatrixEntries
keeps track of unique entries in the BMatrixprivate boolean
m_bDisplayB0
Whether to just display the B0 weighted image and return, or to do a full calculation:private boolean
m_bUseDTIParameters
When true, use the ModelImage DTI parameters.private float
m_fMeanNoise
The mean noise value:private int
m_iBOrig
Number of different entries in the BMatrix:private int
m_iDimX
X Dimension of the input images:private int
m_iDimY
Y Dimension of the input images:private int
m_iSlices
Number of slices in the input images:private int
m_iWeights
Number of images in the weighted series:private ViewJFrameImage
m_kB0Frame
ViewJFrameImage for displaying the B0 weighted image:private ModelImage
m_kB0Image
B0 weighted image:private WildMagic.LibFoundation.Mathematics.GMatrixd
m_kBMatrix
General matrix storing BMatrix values.private ModelImage
m_kDTI
Output DTI Image:private ModelImage
m_kDWIImage
DWI Image 4D series of weighted diffusion imagesprivate ModelImage
m_kMaskImage
Mask Image for masking brain regions during tensor calculation:private java.lang.String
m_kRawImageFormat
Format of the raw data: (float, int, dicom, etc.)-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description AlgorithmDWI2DTI(ModelImage kMaskImage, boolean bDisplayB0, int iSlices, int iDimX, int iDimY, int iBOrig, int iWeights, float fMeanNoise, java.lang.String[][] aakDWIList, int[] aiMatrixEntries, WildMagic.LibFoundation.Mathematics.GMatrixd kBMatrix, java.lang.String kRawFormat)
Create a new AlgorithmDWI2DTIAlgorithmDWI2DTI(ModelImage kDWIImage, ModelImage maskImage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
algorithmPerformed(AlgorithmBase algorithm)
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).void
calculateDTI(int start, int end, float[] dtiData, float[][][] weightData, Jama.Matrix B, Jama.Matrix H)
void
calculateDTIVoxel(float[] dtiData, float[][] dwiData, float[][][] weightData, int x, int y, int z, Jama.Matrix B)
void
calculateDTIVoxel2(float[] dtiData, float[][] dwiData, float[][][] weightData, int x, int y, int z, Jama.Matrix H, int volumeSize)
Jama.Matrix
calculateMatrix(Jama.Matrix m)
private void
createDWI()
float[]
createDWIImage()
Second step in processing the diffusion weighted images.private void
createMaskImage()
Create the mask image.private float[][][]
createTensorWeights()
Creates the weighted data for the tensor calculation from the diffusion weighted images.void
deleteImages()
void
disposeLocal()
ModelImage
getDTI()
Return the DTI Image.ModelImage
getDWI()
private float[]
readDicomWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight.private float
readFloat(byte[] abData, int iIndex)
Translates the byte[] into float values at the given indes iIndex.private float[]
readFloatWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight.private int
readInteger(byte[] abData, int iIndex)
Translates the byte[] into integer values at the given indes iIndex.private float[]
readIntegerWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight.private float[]
readSliceWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight.void
runAlgorithm()
Calculate the DTI image.float[]
solve(Jama.Matrix y, Jama.Matrix m)
-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, finalize, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
m_kMaskImage
private ModelImage m_kMaskImage
Mask Image for masking brain regions during tensor calculation:
-
m_kDWIImage
private ModelImage m_kDWIImage
DWI Image 4D series of weighted diffusion images
-
m_kB0Image
private ModelImage m_kB0Image
B0 weighted image:
-
m_kB0Frame
private ViewJFrameImage m_kB0Frame
ViewJFrameImage for displaying the B0 weighted image:
-
m_bDisplayB0
private boolean m_bDisplayB0
Whether to just display the B0 weighted image and return, or to do a full calculation:
-
m_iSlices
private final int m_iSlices
Number of slices in the input images:
-
m_iDimX
private final int m_iDimX
X Dimension of the input images:
-
m_iDimY
private final int m_iDimY
Y Dimension of the input images:
-
m_iBOrig
private final int m_iBOrig
Number of different entries in the BMatrix:
-
m_iWeights
private final int m_iWeights
Number of images in the weighted series:
-
m_fMeanNoise
private float m_fMeanNoise
The mean noise value:
-
m_kBMatrix
private WildMagic.LibFoundation.Mathematics.GMatrixd m_kBMatrix
General matrix storing BMatrix values.
-
m_aakDWIList
private java.lang.String[][] m_aakDWIList
List of file names for the Diffusion Weighted Images, from the .path file.
-
m_aiMatrixEntries
private int[] m_aiMatrixEntries
keeps track of unique entries in the BMatrix
-
m_kRawImageFormat
private java.lang.String m_kRawImageFormat
Format of the raw data: (float, int, dicom, etc.)
-
m_kDTI
private ModelImage m_kDTI
Output DTI Image:
-
m_bUseDTIParameters
private boolean m_bUseDTIParameters
When true, use the ModelImage DTI parameters.
-
alg
private AlgorithmBrainSurfaceExtractor alg
handle to BSE Algorithm *
-
m_3dbufferMap_float
private final java.util.HashMap<java.lang.String,float[]> m_3dbufferMap_float
-
m_4dbufferMap_float
private final java.util.HashMap<java.lang.String,float[]> m_4dbufferMap_float
-
m_3dbufferMap_int
private final java.util.HashMap<java.lang.String,int[]> m_3dbufferMap_int
-
m_4dbufferMap_int
private final java.util.HashMap<java.lang.String,int[]> m_4dbufferMap_int
-
-
Constructor Detail
-
AlgorithmDWI2DTI
public AlgorithmDWI2DTI(ModelImage kMaskImage, boolean bDisplayB0, int iSlices, int iDimX, int iDimY, int iBOrig, int iWeights, float fMeanNoise, java.lang.String[][] aakDWIList, int[] aiMatrixEntries, WildMagic.LibFoundation.Mathematics.GMatrixd kBMatrix, java.lang.String kRawFormat)
Create a new AlgorithmDWI2DTI- Parameters:
kMaskImage
- mask image masking non-brain regions, if null it is calculated.bDisplayB0
- when true open and display the B0 weighted image and return.iSlices
- number of slices in the raw data.iDimX
- x-dimensions of the raw data.iDimY
- y-dimensions of the raw data.iBOrig
- number of different entries in the BMatrix.iWeights
- number of weighted series.fMeanNoise
- mean noise value.aakDWIList
- list of file names in the weighted series.repidx
-kBMatrix
- BMatrix values.kRawFormat
- format string for the raw data.
-
AlgorithmDWI2DTI
public AlgorithmDWI2DTI(ModelImage kDWIImage, ModelImage maskImage)
-
-
Method Detail
-
algorithmPerformed
public void algorithmPerformed(AlgorithmBase algorithm)
Description copied from interface:AlgorithmInterface
Called after an algorithm this listener is registered to exits (maybe successfully, maybe not). If the algorithm is run in a separate thread, this call will be made within that thread. If not, this call will be made from that same, shared thread.- Specified by:
algorithmPerformed
in interfaceAlgorithmInterface
- Parameters:
algorithm
- the algorithm which has just completed
-
calculateDTI
public void calculateDTI(int start, int end, float[] dtiData, float[][][] weightData, Jama.Matrix B, Jama.Matrix H)
-
calculateDTIVoxel
public void calculateDTIVoxel(float[] dtiData, float[][] dwiData, float[][][] weightData, int x, int y, int z, Jama.Matrix B)
-
calculateDTIVoxel2
public void calculateDTIVoxel2(float[] dtiData, float[][] dwiData, float[][][] weightData, int x, int y, int z, Jama.Matrix H, int volumeSize)
-
calculateMatrix
public Jama.Matrix calculateMatrix(Jama.Matrix m)
-
createDWIImage
public float[] createDWIImage()
Second step in processing the diffusion weighted images. This function is called once the brain extractor is complete. The brain image is transformed into a mask image, which is passed to this function. The mask image limits where the tensor calculations are performed. The tensor is calculated, then the eigen vectors and functional anisotropy images. The DialogDTIColorDisplay is then launched.- Parameters:
kMaskImage
- mask image representing the brain.
-
deleteImages
public void deleteImages()
-
disposeLocal
public void disposeLocal()
-
getDTI
public ModelImage getDTI()
Return the DTI Image.- Returns:
- the DTI Image.
-
getDWI
public ModelImage getDWI()
-
runAlgorithm
public void runAlgorithm()
Calculate the DTI image. If the mask image is null, calculate the mask image first.- Specified by:
runAlgorithm
in classAlgorithmBase
-
solve
public float[] solve(Jama.Matrix y, Jama.Matrix m)
-
createDWI
private void createDWI()
-
createMaskImage
private void createMaskImage()
Create the mask image. Create an image with the B0 weighted data, if one has not already been created. Next use the JDialogBrainSurfaceExtractor to extract only the brain regions.
-
createTensorWeights
private float[][][] createTensorWeights()
Creates the weighted data for the tensor calculation from the diffusion weighted images.- Returns:
- float[][][] containing the weights used in the tensor calculation.
-
readDicomWeight
private float[] readDicomWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight.- Parameters:
iSlice
- slice to read.iWeight
- weight to read.- Returns:
- float[] containing the data.
-
readFloat
private float readFloat(byte[] abData, int iIndex)
Translates the byte[] into float values at the given indes iIndex.- Parameters:
abData
- byte[] containing float values.iIndex
- index into the array to get the float from.- Returns:
- float value representing 4 bytes starting at abData[iIndex*4].
-
readFloatWeight
private float[] readFloatWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight. For 3d and 4d non-multifile images, the whole buffer is read in and stored...then slice data is extracted from that buffer- Parameters:
iSlice
- slice to read.iWeight
- weight to read.- Returns:
- float[] containing the data.
-
readInteger
private int readInteger(byte[] abData, int iIndex)
Translates the byte[] into integer values at the given indes iIndex.- Parameters:
abData
- byte[] containing integer values.iIndex
- index into the array to get the float from.- Returns:
- integer value representing 4 bytes starting at abData[iIndex*4].
-
readIntegerWeight
private float[] readIntegerWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight. For 3d and 4d non-multifile images, the whole buffer is read in and stored...then slice data is extracted from that buffer- Parameters:
iSlice
- slice to read.iWeight
- weight to read.- Returns:
- float[] containing the data.
-
readSliceWeight
private float[] readSliceWeight(int iSlice, int iWeight)
Get the slice data for the image with the given slice and weight.- Parameters:
iSlice
- slice to read.iWeight
- weight to read.- Returns:
- float[] containing the data.
-
-