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,ActionListener,WindowListener,Runnable,EventListener
Algorithm calculates a Diffusion Tensor Image from a series of Diffusion Weighted Images.
See: Introduction to Diffusion Tensor Imaging, by Susumu Mori
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AlgorithmBrainSurfaceExtractorhandle to BSE Algorithm *private String[][]List of file names for the Diffusion Weighted Images, from the .path file.private int[]keeps track of unique entries in the BMatrixprivate booleanWhether to just display the B0 weighted image and return, or to do a full calculation:private booleanWhen true, use the ModelImage DTI parameters.private floatThe mean noise value:private final intNumber of different entries in the BMatrix:private final intX Dimension of the input images:private final intY Dimension of the input images:private final intNumber of slices in the input images:private final intNumber of images in the weighted series:private ViewJFrameImageViewJFrameImage for displaying the B0 weighted image:private ModelImageB0 weighted image:private WildMagic.LibFoundation.Mathematics.GMatrixdGeneral matrix storing BMatrix values.private ModelImageOutput DTI Image:private ModelImageDWI Image 4D series of weighted diffusion imagesprivate ModelImageMask Image for masking brain regions during tensor calculation:private StringFormat 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, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAlgorithmDWI2DTI(ModelImage kMaskImage, boolean bDisplayB0, int iSlices, int iDimX, int iDimY, int iBOrig, int iWeights, float fMeanNoise, String[][] aakDWIList, int[] aiMatrixEntries, WildMagic.LibFoundation.Mathematics.GMatrixd kBMatrix, String kRawFormat) Create a new AlgorithmDWI2DTIAlgorithmDWI2DTI(ModelImage kDWIImage, ModelImage maskImage) -
Method Summary
Modifier and TypeMethodDescriptionvoidalgorithmPerformed(AlgorithmBase algorithm) Called after an algorithm this listener is registered to exits (maybe successfully, maybe not).voidcalculateDTI(int start, int end, float[] dtiData, float[][][] weightData, Jama.Matrix B, Jama.Matrix H) voidcalculateDTIVoxel(float[] dtiData, float[][] dwiData, float[][][] weightData, int x, int y, int z, Jama.Matrix B) voidcalculateDTIVoxel2(float[] dtiData, float[][] dwiData, float[][][] weightData, int x, int y, int z, Jama.Matrix H, int volumeSize) Jama.MatrixcalculateMatrix(Jama.Matrix m) private voidfloat[]Second step in processing the diffusion weighted images.private voidCreate the mask image.private float[][][]Creates the weighted data for the tensor calculation from the diffusion weighted images.voidvoidgetDTI()Return the DTI Image.getDWI()private float[]readDicomWeight(int iSlice, int iWeight) Get the slice data for the image with the given slice and weight.private floatreadFloat(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 intreadInteger(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.voidCalculate 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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
m_kMaskImage
Mask Image for masking brain regions during tensor calculation: -
m_kDWIImage
DWI Image 4D series of weighted diffusion images -
m_kB0Image
B0 weighted image: -
m_kB0Frame
ViewJFrameImage for displaying the B0 weighted image: -
m_bDisplayB0
private boolean m_bDisplayB0Whether to just display the B0 weighted image and return, or to do a full calculation: -
m_iSlices
private final int m_iSlicesNumber of slices in the input images: -
m_iDimX
private final int m_iDimXX Dimension of the input images: -
m_iDimY
private final int m_iDimYY Dimension of the input images: -
m_iBOrig
private final int m_iBOrigNumber of different entries in the BMatrix: -
m_iWeights
private final int m_iWeightsNumber of images in the weighted series: -
m_fMeanNoise
private float m_fMeanNoiseThe mean noise value: -
m_kBMatrix
private WildMagic.LibFoundation.Mathematics.GMatrixd m_kBMatrixGeneral matrix storing BMatrix values. -
m_aakDWIList
List of file names for the Diffusion Weighted Images, from the .path file. -
m_aiMatrixEntries
private int[] m_aiMatrixEntrieskeeps track of unique entries in the BMatrix -
m_kRawImageFormat
Format of the raw data: (float, int, dicom, etc.) -
m_kDTI
Output DTI Image: -
m_bUseDTIParameters
private boolean m_bUseDTIParametersWhen true, use the ModelImage DTI parameters. -
alg
handle to BSE Algorithm * -
m_3dbufferMap_float
-
m_4dbufferMap_float
-
m_3dbufferMap_int
-
m_4dbufferMap_int
-
-
Constructor Details
-
AlgorithmDWI2DTI
public AlgorithmDWI2DTI(ModelImage kMaskImage, boolean bDisplayB0, int iSlices, int iDimX, int iDimY, int iBOrig, int iWeights, float fMeanNoise, String[][] aakDWIList, int[] aiMatrixEntries, WildMagic.LibFoundation.Mathematics.GMatrixd kBMatrix, 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.kBMatrix- BMatrix values.kRawFormat- format string for the raw data.repidx-
-
AlgorithmDWI2DTI
-
-
Method Details
-
algorithmPerformed
Description copied from interface:AlgorithmInterfaceCalled 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:
algorithmPerformedin 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
Return the DTI Image.- Returns:
- the DTI Image.
-
getDWI
-
runAlgorithm
public void runAlgorithm()Calculate the DTI image. If the mask image is null, calculate the mask image first.- Specified by:
runAlgorithmin 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.
-