Package gov.nih.mipav.model.algorithms
Class AlgorithmBase
java.lang.Object
java.lang.Thread
gov.nih.mipav.model.algorithms.AlgorithmBase
- All Implemented Interfaces:
ActionListener,WindowListener,Runnable,EventListener
- Direct Known Subclasses:
AgglomerativeInformationBottleneck,Algorithm4DImageCalculator,AlgorithmActiveContoursWithoutEdges,AlgorithmAdaptiveKuwaharaFilter,AlgorithmAddMargins,AlgorithmAGCIE,AlgorithmAGVF,AlgorithmAHE,AlgorithmAHElocal,AlgorithmAINDANE,AlgorithmAnisotropicDiffusion,AlgorithmAntigradient2,AlgorithmAnyTwoImagesSNR,AlgorithmArcLength,AlgorithmASM,AlgorithmAutoCorrelation,AlgorithmAutoCovariance,AlgorithmAutoSeedWatershed,AlgorithmBarrelDistortion,AlgorithmBilateralFilter,AlgorithmBoundaryAttenuation,AlgorithmBoxCount,AlgorithmBrainExtractor,AlgorithmBrainSurfaceExtractor,AlgorithmBRISK,AlgorithmBSmooth,AlgorithmBSnake,AlgorithmBSpline,AlgorithmBSplineControlPointImageFilter,AlgorithmCannyEdgeDetection,AlgorithmCenterOfMass,AlgorithmCenterOfMassRGB,AlgorithmChangeType,AlgorithmCircleGeneration,AlgorithmCircleToRectangle,AlgorithmCircularSectorToRectangle,AlgorithmCoherenceEnhancingDiffusion,AlgorithmColocalizationEM,AlgorithmColocalizationRegression,AlgorithmColorEdge,AlgorithmColorSaturation,AlgorithmComplexConcat,AlgorithmComplexToReal,AlgorithmConcat,AlgorithmConcatMult,AlgorithmConstELSUNCOpt3D,AlgorithmConstPowellOptBase,AlgorithmConstrainedELSUNCOAR3D,AlgorithmConstrainedOAR3D,AlgorithmContrastEnhancementUsingExposureFusion,AlgorithmConvergenceField,AlgorithmConvert3Dto4D,AlgorithmConvert4Dto3D,AlgorithmConvolver,AlgorithmCorrectSpacing,AlgorithmCrop,AlgorithmCropTilted,AlgorithmCubicLagrangian,AlgorithmCumulativeHistogram,AlgorithmCyclicPermutation,AlgorithmDConvolver,AlgorithmDemonsLite,AlgorithmDEMRI3,AlgorithmDicomOrder,AlgorithmDICOMtoAVI,AlgorithmDistanceFilter,AlgorithmDTI2EGFA,AlgorithmDTIColorDisplay,AlgorithmDTIColorDisplay,AlgorithmDTICreateListFile,AlgorithmDTITract,AlgorithmDualContourSearch,AlgorithmDWI2DTI,AlgorithmEdgeDetection3D,AlgorithmEdgeLaplacian,AlgorithmEdgeLaplacianSep,AlgorithmEdgeNMSuppression,AlgorithmEdgePreservingSmoothing,AlgorithmEfficientWatershed,AlgorithmEllipseGeneration,AlgorithmEllipseToCircle,AlgorithmEllipseToRectangle,AlgorithmEllipticFilter,AlgorithmEllipticFourierDescriptors,AlgorithmELSUNCOpt2D,AlgorithmELSUNCOpt3D,AlgorithmEmbeddedConfidenceEdgeDetection,AlgorithmEntropicEdgeDetection,AlgorithmEntropyMinimization,AlgorithmEvaluateMaskSegmentation,AlgorithmEvaluateSegmentation,AlgorithmExtractSlices,AlgorithmExtractSlicesVolumes,AlgorithmExtractSurface,AlgorithmExtractSurfaceCubes,AlgorithmFaceAnonymizer,AlgorithmFaceAnonymizerBET,AlgorithmFacetModel,AlgorithmFastMarching,AlgorithmFastMarching,AlgorithmFFT,AlgorithmFFT2,AlgorithmFIREEdgeExtraction,AlgorithmFlip,AlgorithmFloodFill,AlgorithmFRAP,AlgorithmFrequencyFilter,AlgorithmFrequencyFilterColor,AlgorithmFRETAcceptorPhotobleach,AlgorithmFRETBleedThrough,AlgorithmFRETEfficiency,AlgorithmFuzzMinDeAndChatterji,AlgorithmFuzzyCMeans,AlgorithmFuzzyConnectednessSegmentation,AlgorithmFuzzyMinimization,AlgorithmGaussianBlur,AlgorithmGaussianBlurSep,AlgorithmGaussianMixtureModelEM,AlgorithmGenerateIsolines,AlgorithmGradientInverseWeightedSmoothing,AlgorithmGradientMagnitude,AlgorithmGradientMagnitudeSep,AlgorithmGraphBasedSegmentation,AlgorithmGrayScaleMorphology25D,AlgorithmGrayScaleMorphology2D,AlgorithmGrayScaleMorphology3D,AlgorithmGuidedFilter,AlgorithmGVF,AlgorithmHaralickTexture,AlgorithmHarrisCornerDetector,AlgorithmHarrisLaplace,AlgorithmHeightFunction,AlgorithmHepticLagrangian,AlgorithmHessian,AlgorithmHilbertTransform,AlgorithmHillClimbingWatershed,AlgorithmHistogram,AlgorithmHistogram2Dim,AlgorithmHistogramMatch,AlgorithmHistogramSliceMatch,AlgorithmHMRF_EM,AlgorithmHoughCardioid,AlgorithmHoughCircle,AlgorithmHoughEllipse,AlgorithmHoughHyperbola,AlgorithmHoughLine,AlgorithmHoughParabola,AlgorithmHurstIndex,AlgorithmIAGCWD,AlgorithmIHN3Correction,AlgorithmImageCalculator,AlgorithmImageHessian,AlgorithmImageMath,AlgorithmIndependentComponents,AlgorithmInsertSlice,AlgorithmInsertVolume,AlgorithmIsophoteCurvature,AlgorithmIteratedBlindDeconvolution,AlgorithmKernelRegression,AlgorithmKMeans,AlgorithmLaplacian,AlgorithmLapMedianess,AlgorithmLawsTexture,AlgorithmLearnFromFailure64,AlgorithmLearnFromFailure64Knees,AlgorithmLevelSet,AlgorithmLevelSetDiffusion,AlgorithmLLE,AlgorithmLocalNormalization,AlgorithmLocalVariance,AlgorithmLogSlopeMapping,AlgorithmLowerCompletion,AlgorithmLuminanceAdaptation,AlgorithmMarkovSegment,AlgorithmMarkovSmooth,AlgorithmMask,AlgorithmMatchForReference,AlgorithmMatchImages,AlgorithmMaximumIntensityProjection,AlgorithmMaximumLikelihoodIteratedBlindDeconvolution,AlgorithmMean,AlgorithmMeanShiftClustering,AlgorithmMeanShiftSegmentation,AlgorithmMedian,AlgorithmMidsagittal,AlgorithmMinimumPerimeterPolygon,AlgorithmMixGaussEM,AlgorithmMode,AlgorithmMorphologicalFilter,AlgorithmMorphology25D,AlgorithmMorphology2D,AlgorithmMorphology3D,AlgorithmMosaicToSlices,AlgorithmMRIShadingCorrection,AlgorithmMSER,AlgorithmMSpectralFuzzyCMeans,AlgorithmMultiExponentialFitting,AlgorithmN4MRIBiasFieldCorrectionFilter,AlgorithmNearlyCircleToCircle,AlgorithmNetworkSnake,AlgorithmNLNoiseReduction,AlgorithmNMSuppression,AlgorithmNoise,AlgorithmNonlocalMeansFilter,AlgorithmNonMaxSuppts,AlgorithmNonparametricSegmentation,AlgorithmObjectExtractor,AlgorithmPbBoundaryDetection,AlgorithmPhaseCongruency,AlgorithmPointArea,AlgorithmPointSetToImageFilter,AlgorithmPowellOptBase,AlgorithmPowerWatershed,AlgorithmPrincipalComponents,AlgorithmProstateBoundaryExt,AlgorithmProstateBoundaryFeature2D,AlgorithmProstateFeatures,AlgorithmProstateFeatures2D,AlgorithmProstateFeaturesSaveAutoTrain,AlgorithmQuantify,AlgorithmQuantifyMask,AlgorithmQuinticLagrangian,AlgorithmRandSliceOrder,AlgorithmRegBSpline,AlgorithmRegChamfer,AlgorithmRegELSUNCOAR25D,AlgorithmRegELSUNCOAR2D,AlgorithmRegELSUNCOAR35D,AlgorithmRegELSUNCOAR3D,AlgorithmRegionGrow,AlgorithmRegionMergingViaBoundaryMelting,AlgorithmRegionsFromPartialBorders,AlgorithmRegLeastSquares,AlgorithmRegOAR25D2,AlgorithmRegOAR2D,AlgorithmRegOAR35D,AlgorithmRegOAR3D,AlgorithmRegPatientPos,AlgorithmRegularizedIsotropicDiffusion,AlgorithmRegValidation,AlgorithmRegVOILandmark,AlgorithmRemoveSlices,AlgorithmRemoveTSlices,AlgorithmReplaceBlankSlicesWithAverages,AlgorithmReplaceRemovedSlices,AlgorithmReplaceSlice,AlgorithmReplaceValue,AlgorithmReslice,AlgorithmRGBConcat,AlgorithmRGBtoGray,AlgorithmRGBtoGrays,AlgorithmRGBtoHSB,AlgorithmRiceWaveletTools,AlgorithmRotate,AlgorithmRuleBasedContrastEnhancement,AlgorithmScaleSaliency,AlgorithmSCDSegmentation,AlgorithmSeparableConvolver,AlgorithmSequentialScanningWatershed,AlgorithmSFTA,AlgorithmShortestPathWatershed,AlgorithmSimulatedExposureFusion,AlgorithmSingleMRIImageSNR,AlgorithmSkullRemoval,AlgorithmSliceAveraging,AlgorithmSM2,AlgorithmSnake,AlgorithmSobel,AlgorithmSpectralClustering,AlgorithmSphereGeneration,AlgorithmSplitAndMergeWatershed,AlgorithmStandardDeviationThreshold,AlgorithmSubsample,AlgorithmSubset,AlgorithmSubtractVOI,AlgorithmSwap34,AlgorithmSwapDims,AlgorithmSwapSlicesVolume,AlgorithmSWI,AlgorithmSymmetricNearestNeighbor,AlgorithmTalairachTransform,AlgorithmTamuraTexture,AlgorithmTextureAnalysis,AlgorithmTextureSegmentation,AlgorithmThinning2D,AlgorithmThresholdDual,AlgorithmThresholdDualRGB,AlgorithmTiltCorrection,AlgorithmTimeFitting,AlgorithmTProcess,AlgorithmTPSpline,AlgorithmTranscode,AlgorithmTransform,AlgorithmTransformBSpline,AlgorithmTransformVOI,AlgorithmTrilateralFilter,AlgorithmTwoMRIImagesSNR,AlgorithmUnionFindComponentLabelling,AlgorithmUnionFindWatershed,AlgorithmUnsharpMask,AlgorithmVesselEnhancement,AlgorithmVOIExtraction,AlgorithmVOIExtractionPaint,AlgorithmVOIHausdorffDistance,AlgorithmVOILogicalOperations,AlgorithmVOIProps,AlgorithmVOIShapeInterpolation,AlgorithmVOISimplexOpt,AlgorithmWatershed,AlgorithmWaveletFuse,AlgorithmWaveletThreshold,AlgorithmWSinc,Backpropagation,BiorthogonalWavelets,BlindDeblur,BM3D,ChirpZTransform,Confmap,ContourPlot,CopyMoveAttackDetection,CopyMoveAttackDetection2,Covdet,DBSCANClusteringSegment,Dijkstra,DiscreteCosineTransform,DiscreteSineTransform,DoublyConnectedSC,DTIGradTableCorrectionAfterTrans,FFTUtility,FFTUtilityEP,fMRIBlindDeconvolution,GaussianMixtureModelsIncompleteSamples,HaarTransform,HartleyTransform,HartleyTransform2,HistogramOfOrientedGradients,HornSchunk,ImageQuality,ImRegPOC,InverseLaplaceTest,JDialogLoadImage.AlgorithmLoadB,LargestCircle,libdt,LIBSVM,LightboxGenerator,LocalIntensityOrderPattern,LSCM,LSQR,MotionDetection,MultiGuidedFilter,MultiResolutionBilateralFilter,NLMeans_filt2D,NoiseLevel,OpenCLAlgorithmBase,OpticalFlowToolbox,PhasePreservingDenoising,PseudoPolarFourierTransform,PyramidToolbox,PyWavelets,Quaternions,RectangularConformalMap,SchwarzChristoffelMapping,SchwarzChristoffelMapping2,SIFT,SIFT3D,SIFTImageSimilarity,SlantTransform,SpatialBroxOpticalFlow,SphericalConformalMap,StochasticForests,SVM,SymmsIntegralMapping,TemporalBroxOpticalFlow,TVL1FLOW,Voro,WalshHadamardTransform,WalshHadamardTransform2,WalshHadamardTransform3
Base abstract class for algorithms.
- Version:
- 0.1 Feburary 11, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanThis flag will be set to true when the algorithm has completed.protected booleanDestination flag indicating if a destination (result) image is generated.protected ModelImageDestination image.private doubleElapsed time (in milliseconds) -- time it took for algorithm to run.protected booleanIf true process each image of a 3D volume independently.private EventListenerListA list of the ChangeListeners which are interested in the ChangeEvent.protected BitSetMask indicating which voxels to process.protected intUsed to store the maximum value of the progress bar.protected intUsed to store the minimum value of the progress bar.protected booleanIndicates if multi-threading will be used to optimize the algorithm.protected intThe number of threads will be used to execute the algorithm if multi-threading is enabledprivate Vector<AlgorithmInterface> Vector list of AlgorithmInterface objects.protected floatStore the progress being made.protected intprotected floatprotected booleanShould be set to true if NOT in a single thread - will NOT force a graphics update of the progress bar.protected booleanIf true convolution kernels are separable.protected ModelImageSource image.private longStart time (in milliseconds) to be used to compute elapsed time.protected booleanFlag indicating whether or not the thread is stopped.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor which sets thread stopped to false, source and destination images to null, and destination flag to false.AlgorithmBase(ModelImage destImage, ModelImage srcImage) Constructor which sets thread stopped to false and sets source and destination images. -
Method Summary
Modifier and TypeMethodDescriptionvoidRoutine to catch action eventsvoidAdd a listener to this class so that when when the algorithm has completed processing it can use notifyListener to notify all listeners that the algorithm has completed.voidAdds the ProgressChangeListener to this FileBase object.static intcalculateImageSize(int[] dims) Calculate the size of the image.voidcalculatePrincipleAxis(ModelImage image, boolean doColor) Working ...doubleComputes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).static doublecomputeElapsedTime(long start) Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).protected float[]convertIntoFloat(String[] str) Takes an array of strings and converts each entry into a float value.protected voiddelinkProgressToAlgorithm(AlgorithmBase baseAlgo) Disconnect this algorithm with the progress bar which holds a reference to this algorithm.protected voiddelinkProgressToAlgorithmMulti(AlgorithmBase baseAlgo) voiddisplayError(String error) Displays an error in a frame.voiderrorCleanUp(String strErr, boolean gcFlag) Display string pass into the method.voidfinalize()Calls garbage collector to release system resources.protected voidfireProgressStateChanged(float fVal, String title, String message) Updates listeners of progress status.protected voidfireProgressStateChanged(int value) Notifies all listeners that have registered interest for notification on this event type.protected voidfireProgressStateChanged(int value, String title, String message) Notifies all listeners that have registered interest for notification on this event type.protected voidfireProgressStateChanged(String message) Notifies listeners that have registered interest for notification on this event type.protected voidfireProgressStateChanged(String imageName, String message) Updates listeners of progress status.int[]generateProgressValues(int currentProgress, int desiredMaxProgress) Helper function to determine which values to pass on to linked algorithms (that will fire progress changes to the same progress bar).Accessor to return the destination imagedoubleReturns the elapsed time in seconds.getMask()Gets the Bitset mask object.intReturns the max progress value.intReturns the min progress value.intfloatIf there is a progress bar that is listening to the algorithm's progress change events, this will retrieve that progress bar.Returns the progress change event listener list.intfloatint[]Gets the current stored min and max progress values.Gets the current source image for the algorithmbooleanReturns flag that indicates that the algorithm has been sucessfully completed.booleanReturns flag that indicates if the image should be processed slice by slice.booleanbooleanShould be set to true if NOT in a single thread (i.e., the main gui and this algo are in different threads) - will NOT force a graphics update of the progress bar.booleanReturns flag that indicates that the algorithm thread has been stopped.protected voidlinkProgressToAlgorithm(AlgorithmBase baseAlgo) Helper function to link the currently listening progress bar with an algorithm created within an algorithm.protected voidlinkProgressToAlgorithm(AlgorithmBase baseAlgo, String title, int min, int max) New helper function for use with the ViewJProgressBarMulti.voidmakeProgress(float step) voidnotifyListeners(AlgorithmBase algorithm) Used to notify all listeners that the algorithm has completed.voidRemove a listener from the class.voidRemoves the ChangeListener from the FileBase object.voidrun()Performs start-up and tear-down operations that should be done by all algorithms (timing, history log).abstract voidActually runs the algorithm.voidsetCompleted(boolean flag) Sets completed to flag indicating if algorithm has sucessfully completed.voidsetImage25D(boolean flag) Sets a flag to indicate the image has dimensions of (i.e. spacial, spacial, time) and image processing routines should apply 2.5D algorithm.voidSets the mask (BitSet object).voidsetMaxProgressValue(int maxProgressValue) Sets the max progress value.voidsetMinProgressValue(int minProgressValue) Sets the min progress value.voidsetMultiThreadingEnabled(boolean multiThreadingEnabled) voidsetNumberOfThreads(int nthreads) voidsetProgress(int progress) voidsetProgressModulus(int progressModulus) voidsetProgressStep(float progressStep) voidsetProgressValues(int[] minmax) Sets the min and max progress values from an array of two ints.voidsetProgressValues(int min, int max) Sets both the min and max progress values.voidsetRunningInSeparateThread(boolean separateThread) Sets the running in separate thread flag which controls how the progress bar is updated.voidsetSrcImage(ModelImage srcImage) Sets the source image of the algorithmvoidSets the start time to the current time.voidsetThreadStopped(boolean flag) Sets the thread stopped to flag indicating if algorithm has stopped.final booleanstartMethod(int priority) Checks to see if a thread is already running on this object.voidwindowActivated(WindowEvent event) Do nothing.voidwindowClosed(WindowEvent event) Do nothing.voidwindowClosing(WindowEvent event) Sets completed to false, disposes the progress bar and notifies all listeners that the algorithm is stopped.voidwindowDeactivated(WindowEvent event) Do nothing.voidwindowDeiconified(WindowEvent event) Do nothing.voidwindowIconified(WindowEvent event) Do nothing.voidwindowOpened(WindowEvent event) Do nothing.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, 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
-
destFlag
protected boolean destFlagDestination flag indicating if a destination (result) image is generated. -
destImage
Destination image. -
image25D
protected boolean image25DIf true process each image of a 3D volume independently. -
separable
protected boolean separableIf true convolution kernels are separable. -
mask
Mask indicating which voxels to process. If true process voxel else skip. -
runningInSeparateThread
protected boolean runningInSeparateThreadShould be set to true if NOT in a single thread - will NOT force a graphics update of the progress bar. Should be set to false if in a single thread - will force a graphics update of the progress bar. This defaults to false, since we can automatically set it to true when startMethod() is called. When starting the algorithm with run(), this boolean should remain false.- See Also:
-
srcImage
Source image. -
threadStopped
protected volatile boolean threadStoppedFlag indicating whether or not the thread is stopped. -
completed
private boolean completedThis flag will be set to true when the algorithm has completed. -
elapsedTime
private double elapsedTimeElapsed time (in milliseconds) -- time it took for algorithm to run. -
listenerList
A list of the ChangeListeners which are interested in the ChangeEvent. -
maxProgressValue
protected int maxProgressValueUsed to store the maximum value of the progress bar. -
minProgressValue
protected int minProgressValueUsed to store the minimum value of the progress bar. -
objectList
Vector list of AlgorithmInterface objects. When the algorithm has been stopped or completed, all listeners in this list are notified. -
startTime
private long startTimeStart time (in milliseconds) to be used to compute elapsed time. -
progress
protected float progressStore the progress being made. -
progressStep
protected float progressStep -
progressModulus
protected int progressModulus -
multiThreadingEnabled
protected boolean multiThreadingEnabledIndicates if multi-threading will be used to optimize the algorithm. -
nthreads
protected int nthreadsThe number of threads will be used to execute the algorithm if multi-threading is enabled
-
-
Constructor Details
-
AlgorithmBase
public AlgorithmBase()Default constructor which sets thread stopped to false, source and destination images to null, and destination flag to false. -
AlgorithmBase
Constructor which sets thread stopped to false and sets source and destination images.- Parameters:
destImage- Destination image, can be null.srcImage- Source image, should not be null.
-
-
Method Details
-
runAlgorithm
public abstract void runAlgorithm()Actually runs the algorithm. Implemented by inheriting algorithms. -
actionPerformed
Routine to catch action events- Specified by:
actionPerformedin interfaceActionListener- Parameters:
e- ActionEvent
-
addListener
Add a listener to this class so that when when the algorithm has completed processing it can use notifyListener to notify all listeners that the algorithm has completed.- Parameters:
obj- AlgorithmInterface "object' to be added to the list
-
addProgressChangeListener
Adds the ProgressChangeListener to this FileBase object.- Parameters:
l- the ProgressChangeListener object
-
calculatePrincipleAxis
Working ... This function is never used. It doesn't modify any parameters or data members and returns void.- Parameters:
image- DOCUMENT ME!doColor- DOCUMENT ME!
-
computeElapsedTime
public double computeElapsedTime()Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).- Returns:
- the elapsed time in seconds -- this is a double value
-
computeElapsedTime
public static double computeElapsedTime(long start) Computes the elapased time as the difference between the start time and the current time (both of which are in milliseconds).- Returns:
- the elapsed time in seconds -- this is a double value
-
displayError
Displays an error in a frame.- Parameters:
error- string that is displayed
-
errorCleanUp
Display string pass into the method. If the string is null no message is displayed. The completed flag is set tofalseand the progress bar is disposed;- Parameters:
strErr- the string that is to be displayed. If the string is null no message is displayed.gcFlag- iftruecall the garbage collector.
-
finalize
public void finalize()Calls garbage collector to release system resources. -
generateProgressValues
public int[] generateProgressValues(int currentProgress, int desiredMaxProgress) Helper function to determine which values to pass on to linked algorithms (that will fire progress changes to the same progress bar). You pass in the current progress and then the max desired progress.... you do NOT adjust the progress yourself, you assume a 0-100 range always, so if the current progress of a certain algorithm was 50%, and you want the helper algorithm to run on an adjusted scale of 50% to 70%, then you pass 50 and 70 as current invalid input: '&' desiredMax respectively. if the algorithm passing this in was on a scale of 0->50, then the displayed progress will range from 25% to 35% (50% of 50->70)- Parameters:
currentProgress- current progress of algorithm on a 0->100 scaledesiredMaxProgress- max progress desired for linked algorithm- Returns:
- array of 2 ints [current, max]
-
getDestImage
Accessor to return the destination image- Returns:
- ModelImage destination image
-
getElapsedTime
public double getElapsedTime()Returns the elapsed time in seconds. This does not compute a new elapsed time.- Returns:
- the elapsed time, in seconds computed earlier
- See Also:
-
getMask
Gets the Bitset mask object.- Returns:
- The mask indicating which voxels of the image to process
-
getMaxProgressValue
public int getMaxProgressValue()Returns the max progress value.- Returns:
- max progress value
-
getMinProgressValue
public int getMinProgressValue()Returns the min progress value.- Returns:
- min progress value
-
getProgressChangeListener
If there is a progress bar that is listening to the algorithm's progress change events, this will retrieve that progress bar. This function is really only here to support AlgorithmExtractSurface, AlgorithmExtractSurfaceCubes, and AlgorithmHeightFunction which use ModelQuadMesh and ModelTriangle Mesh (which do not follow the standard algorithmbase setup). This function should not be used elsewhere and will probably be removed (and modelquad/trianglemesh will be changed).- Returns:
- a progressbar if there is one listening, null otherwise.
-
getProgressChangeListeners
Returns the progress change event listener list.- Returns:
- the progress change event listener list.
-
getProgressValues
public int[] getProgressValues()Gets the current stored min and max progress values.- Returns:
- int [] { currentMin, currentMax}
-
getSrcImage
Gets the current source image for the algorithm- Returns:
- the source image
-
isCompleted
public boolean isCompleted()Returns flag that indicates that the algorithm has been sucessfully completed.- Returns:
trueif algorithm completed successfully,falseif it was stopped or had an error.
-
isImage25D
public boolean isImage25D()Returns flag that indicates if the image should be processed slice by slice.- Returns:
trueif image should be processed slice by slice.
-
isRunningInSeparateThread
public boolean isRunningInSeparateThread()Should be set to true if NOT in a single thread (i.e., the main gui and this algo are in different threads) - will NOT force a graphics update of the progress bar. Should be set to false if in a single thread - will force a graphics update of the progress bar.- Returns:
- boolean true if this algorithm is in a different thread from the main mipav gui thread.
-
isThreadStopped
public boolean isThreadStopped()Returns flag that indicates that the algorithm thread has been stopped.- Returns:
trueif thread has stopped.
-
notifyListeners
Used to notify all listeners that the algorithm has completed.- Parameters:
algorithm- algorithm class that has completed the function
-
removeListener
Remove a listener from the class.- Parameters:
obj- the algorithm listener to be removed from the list for this algo
-
removeProgressChangeListener
Removes the ChangeListener from the FileBase object.- Parameters:
l- the ProgressChangeListener object
-
run
public void run()Performs start-up and tear-down operations that should be done by all algorithms (timing, history log). Since this class extends the Thread class it can be run in its own thread by invoking object.start(); It can also be invoked without a new thread by calling the the run() method directly (ie. object.run()). -
setCompleted
public void setCompleted(boolean flag) Sets completed to flag indicating if algorithm has sucessfully completed.- Parameters:
flag- Flag to set totrueif the algorithm has completed.
-
setImage25D
public void setImage25D(boolean flag) Sets a flag to indicate the image has dimensions of (i.e. spacial, spacial, time) and image processing routines should apply 2.5D algorithm.- Parameters:
flag- flag to set to
-
setMask
Sets the mask (BitSet object).- Parameters:
imageMask- BitSet object indicating which voxels to process
-
setMaxProgressValue
public void setMaxProgressValue(int maxProgressValue) Sets the max progress value.- Parameters:
maxProgressValue- the maximum progress value
-
setMinProgressValue
public void setMinProgressValue(int minProgressValue) Sets the min progress value.- Parameters:
minProgressValue- the minimum progress value
-
setProgressValues
public void setProgressValues(int[] minmax) Sets the min and max progress values from an array of two ints.- Parameters:
minmax- array of two ints [min, max]
-
setProgressValues
public void setProgressValues(int min, int max) Sets both the min and max progress values.- Parameters:
min- the min progress valuemax- the max progress value
-
setRunningInSeparateThread
public void setRunningInSeparateThread(boolean separateThread) Sets the running in separate thread flag which controls how the progress bar is updated. If true the progress bar is not forced to update.- Parameters:
separateThread- Should be set to true if NOT in a single thread (i.e., the main gui and this algo are in different threads) - will NOT force a graphics update of the progress bar. Should be set to false if in a single thread - will force a graphics update of the progress bar.
-
setSrcImage
Sets the source image of the algorithm- Parameters:
srcImage- the source image
-
setStartTime
public void setStartTime()Sets the start time to the current time. This should be called at the beginning of the run() method. -
setThreadStopped
public void setThreadStopped(boolean flag) Sets the thread stopped to flag indicating if algorithm has stopped.- Parameters:
flag- flag to set to
-
startMethod
public final boolean startMethod(int priority) Checks to see if a thread is already running on this object. If so, it returns false, else it starts the thread and returns true.- Parameters:
priority- thread priority- Returns:
- false if a thread is already running this algorithm, true otherwise
-
windowActivated
Do nothing.- Specified by:
windowActivatedin interfaceWindowListener- Parameters:
event- the window activated event
-
windowClosed
Do nothing.- Specified by:
windowClosedin interfaceWindowListener- Parameters:
event- the window closed event
-
windowClosing
Sets completed to false, disposes the progress bar and notifies all listeners that the algorithm is stopped.- Specified by:
windowClosingin interfaceWindowListener- Parameters:
event- event that triggered function
-
windowDeactivated
Do nothing.- Specified by:
windowDeactivatedin interfaceWindowListener- Parameters:
event- the window deactivated event
-
windowDeiconified
Do nothing.- Specified by:
windowDeiconifiedin interfaceWindowListener- Parameters:
event- the window deiconified event
-
windowIconified
Do nothing.- Specified by:
windowIconifiedin interfaceWindowListener- Parameters:
event- the window iconified event
-
windowOpened
Do nothing.- Specified by:
windowOpenedin interfaceWindowListener- Parameters:
event- the window opened event
-
convertIntoFloat
Takes an array of strings and converts each entry into a float value. Useful for updating DICOM file information.- Parameters:
str- Some number of strings in an array- Returns:
- An array of floats; the same number of entries in str are returned in the array.
-
fireProgressStateChanged
Notifies listeners that have registered interest for notification on this event type.- Parameters:
message- the new message to display on the progress bar
-
fireProgressStateChanged
protected void fireProgressStateChanged(int value) Notifies all listeners that have registered interest for notification on this event type.- Parameters:
value- the value of the progress bar.
-
fireProgressStateChanged
Updates listeners of progress status. Without actually changing the numerical value- Parameters:
imageName- the name of the imagemessage- the new message to display
-
fireProgressStateChanged
Notifies all listeners that have registered interest for notification on this event type.- Parameters:
value- the value of the progress bar.title- the title of the progress dialog.message- the message for that specific progress value.
-
fireProgressStateChanged
Updates listeners of progress status.- Parameters:
fVal- the percent progress of the algorithm so fartitle- the title to send to the listenersmessage- the message to send to the listeners
-
linkProgressToAlgorithm
Helper function to link the currently listening progress bar with an algorithm created within an algorithm. This function should only be called when the other algorithm is expected to update the progress bar seamlessly. It should be called in conjuction with AlgorithmBase's setProgressValues() so that the sub-algorithm will have know the min and max progress values.Generally this will be called with the following lines: linkProgressToAlgorithm(theSubAlgorithm); theSubAlgorithm.setProgressValues(generateProgressValues(currentProgressOfAlgorithm, desiredMaxProgressOfSubAlgorithm));
- Parameters:
baseAlgo- the subalgorithm created within current algorithm
-
linkProgressToAlgorithm
New helper function for use with the ViewJProgressBarMulti. This allows for keeping track of multi-threaded algorithms and allow the user to better keep track of multiple processes being run. Any linked algorithms should update together in the manner specificed by min/max.- Parameters:
baseAlgo- the subalgorithm created within current algorithmtitle- the title shown in the progress bar panelmin- the lower bound of the updating portion of the parent algorithmmax- the upper bound of the updating portion of the parent algorithm
-
delinkProgressToAlgorithm
Disconnect this algorithm with the progress bar which holds a reference to this algorithm. In order to release the memory of this algorithm, this function should be called after the algorithm was finished.- Parameters:
baseAlgo-
-
delinkProgressToAlgorithmMulti
-
getProgress
public float getProgress() -
setProgress
public void setProgress(int progress) -
makeProgress
public void makeProgress(float step) -
getProgressStep
public float getProgressStep() -
setProgressStep
public void setProgressStep(float progressStep) -
isMultiThreadingEnabled
public boolean isMultiThreadingEnabled() -
setMultiThreadingEnabled
public void setMultiThreadingEnabled(boolean multiThreadingEnabled) -
getNumberOfThreads
public int getNumberOfThreads() -
setNumberOfThreads
public void setNumberOfThreads(int nthreads) -
getProgressModulus
public int getProgressModulus() -
setProgressModulus
public void setProgressModulus(int progressModulus) -
calculateImageSize
public static int calculateImageSize(int[] dims) Calculate the size of the image.- Parameters:
dims-- Returns:
-