Eidolon
|
Functions | |
def | hounsfieldToUnit (h) |
def | checkNan (obj) |
def | rescaleArray (arr, minv=0.0, maxv=1.0, dtype=np.float32) |
def | rescaleArrayIntMax (arr, dtype=np.uint16) |
def | processImageNp (imgobj, writeBack=False, dtype=np.float32) |
def | transposeRowsColsNP (img) |
def | reverseAxes (img) |
def | sampleImageRay (img, start, samplevec, numsamples) |
def | loadImageFile (filename, imgobj, pos=vec3(), rot=rotator(), spacing=(1.0, 1.0)) |
def | loadImageStack (files, imgLoadFunc, positions, rot=rotator(), spacing=(1.0, 1.0), task=None) |
def | generateImageStack (width, height, slices, timesteps=1, pos=vec3(), rot=rotator(), spacing=vec3(1), name='img') |
def | generateTestImageStack (width, height, slices, timesteps=1, pos=vec3(), rot=rotator(), spacing=vec3(1)) |
def | generateSphereImageStack (width, height, slices, center=vec3(0.5), scale=vec3(0.45), innerval=0.75, shellval=1.0) |
def | calculateImageStackHistogramRange (process, imgs, minv, maxv) |
def | calculateImageStackHistogram (imgs, minv=None, maxv=None, task=None) |
def | getHistogramExtremas (hist, thresholdFilter=True, thresholdfunc=None, sigma=3, order=5) |
def | isCTImageSeries (imgs=None, minv=None, maxv=None, hist=None) |
def | applySlopeIntercept (imgobj, slope=None, inter=None) |
def | getLargestMaskObject (mask) |
def | calculateMotionField (obj) |
def | calculateMotionFFT (imgmat) |
def | generateMotionMask (motion, percentile=90, filterSize=10) |
def | generateMaskConvexHull (mask) |
def | cropCenter (img, cropDims) |
def | cropVolumeMask (imgobj, mask, threshold, task=None) |
def | cropObjectEmptySpace (obj, name, xymargins=0, zFilter=False) |
def | cropRefImage (obj, ref, name, marginx=0, marginy=0) |
def | cropMotionImage (obj, name, percentile=90, filterSize=10) |
def | maskMotionImage (obj, firstStepOnly=True, percentile=90, filterSize=10) |
def | centerImagesLocalSpace (obj) |
def | normalizeImageData (obj) |
def | binaryMaskImageRange (process, imgs, threshold) |
def | binaryMaskImage (obj, threshold, task=None) |
def | thresholdImageRange (process, imgs, minv, maxv) |
def | thresholdImage (obj, minv, maxv, task=None) |
def | sampleImageVolume (obj, pt, timestep, transinv=None) |
def | calculateReprIsoplaneMesh (rep, planetrans, stackpos, slicewidth) |
def | resampleImage (srcobj, destobj) |
def | deformImage2D (img, defx, defy) |
def | shiftImageXY (img, shifts) |
def | mergeColinearImagesRange (process, imglist, mergefunc) |
def | mergeColinearImages (imgobjs, objout, mergefunc=None, task=None) |
def | mergeImages (imgobjs, imgout, mergefunc=None, task=None) |
def | dilateImageVolume (obj, size=(5, 5, 5)) |
def | extendImageRange (process, imglist, mx, my, fillVal) |
def | extendImage (obj, name, mx, my, mz, fillVal=0, numProcs=0, task=None) |
def | createTemporalImage (obj, numImgsPerStep=None, stepMul=1) |
Variables | |
Hounsfield | |
tuple | defaultImageQuad |
def eidolon.ImageAlgorithms.applySlopeIntercept | ( | imgobj, | |
slope = None , |
|||
inter = None |
|||
) |
Apply the slope and intercept values to the image object `imgobj', each pixel i is replaced with i*slope+inter.
def eidolon.ImageAlgorithms.binaryMaskImage | ( | obj, | |
threshold, | |||
task = None |
|||
) |
Fill `obj' with a binary mask, each value of each image replaced with 1.0 if >=`threshold', 0.0 otherwise.
def eidolon.ImageAlgorithms.binaryMaskImageRange | ( | process, | |
imgs, | |||
threshold | |||
) |
def eidolon.ImageAlgorithms.calculateImageStackHistogram | ( | imgs, | |
minv = None , |
|||
maxv = None , |
|||
task = None |
|||
) |
def eidolon.ImageAlgorithms.calculateImageStackHistogramRange | ( | process, | |
imgs, | |||
minv, | |||
maxv | |||
) |
def eidolon.ImageAlgorithms.calculateMotionFFT | ( | imgmat | ) |
Given a 4D image array `imgmat', calculate the motion representation using fourier transforms to determine where motion is present. The result is a 3D image with dimensions of `obj' with areas of motion having higher intensity. see: Lin et. al, "Automated Detection of Left Ventricle in 4D MR Images: Experience from a Large Study"
def eidolon.ImageAlgorithms.calculateMotionField | ( | obj | ) |
Returns a motion field array from time-dependent image `obj'.
def eidolon.ImageAlgorithms.calculateReprIsoplaneMesh | ( | rep, | |
planetrans, | |||
stackpos, | |||
slicewidth | |||
) |
Calculates the mesh for image representation object `rep' at plane `planetrans' and at the stack position `stackpos' (which is meaningful only for ImageSeriesRepr types). This will determine where `rep' is intersected by `planetrans' and returns the triple (nodes,indices,xis) representing a mesh for that intersecting geometry. 2D images viewed at oblique angles produces slices which are `slicewidth' wide. Returns a (nodes,indices,xis) triple where the nodes are in world space coordinates.
def eidolon.ImageAlgorithms.centerImagesLocalSpace | ( | obj | ) |
Moves `obj' so that its boundbox center is at the origin.
def eidolon.ImageAlgorithms.checkNan | ( | obj | ) |
Assert that all values in the image object `obj' are not NaN.
def eidolon.ImageAlgorithms.createTemporalImage | ( | obj, | |
numImgsPerStep = None , |
|||
stepMul = 1 |
|||
) |
Apply a temporal scheme to the image object `obj', assuming that the members of obj.images are in spatial then temporal order but have incorrect timestep information. If `numImgsPerStep' is provided then this is used as the number of images each timestep is defined by. If not provided this can be determine for 2D planes or 3D volumes by checking how many images after the first are present before another in the same location is encountered. Each calculated timestep is multiplied by `stepMul' when set for each new image. Return value is a new time-dependent scene object with the same image data but with timesteps set to calculated values.
def eidolon.ImageAlgorithms.cropCenter | ( | img, | |
cropDims | |||
) |
Crop the center of the given array `img' to produce an array with dimensions `cropDims'. For each axis i in `img', the result will have the dimension size given in cropDims[i]. If cropDims[i] is None or cropDims[i] is beyond the length of `cropDims', the original dimension size is retained. Eg. cropCenter(np.zeros((10,20,20)),None,15,30) will return an array of dimensions (10,15,20).
def eidolon.ImageAlgorithms.cropMotionImage | ( | obj, | |
name, | |||
percentile = 90 , |
|||
filterSize = 10 |
|||
) |
Returns a copy of `obj' cropped in XY using motion info from calculateMotionField(obj).
def eidolon.ImageAlgorithms.cropObjectEmptySpace | ( | obj, | |
name, | |||
xymargins = 0 , |
|||
zFilter = False |
|||
) |
Crop the images of ImageSceneObject `obj' to exclude empty space, defined by being any pixel below the minimal value plus a small threshold. A new object is produced with name `name' having its own copy of the image data, even if the entirety of the original images is included (ie. not clipped). If `xymargins' is specified then the clipping square is expanded by that much. if `zFilter' is true then images whose maximal value is below the clipping threshold are excluded in their entirety.
def eidolon.ImageAlgorithms.cropRefImage | ( | obj, | |
ref, | |||
name, | |||
marginx = 0 , |
|||
marginy = 0 |
|||
) |
Crop the image `obj' to the spatial boundbox of `ref' with added (X,Y) margins `marginx' and `marginy'. Returns the cropped image with name `name'.
def eidolon.ImageAlgorithms.cropVolumeMask | ( | imgobj, | |
mask, | |||
threshold, | |||
task = None |
|||
) |
Crop the image `imgobj' to the boundbox of voxels in `mask' greater than or equal to `threshold'. This assumes the image objects are colinear (ie. same shape). Returns the cropped copy of `imgobj'.
def eidolon.ImageAlgorithms.deformImage2D | ( | img, | |
defx, | |||
defy | |||
) |
Deform 2D image `img' by the given X and Y deformation fields.
def eidolon.ImageAlgorithms.dilateImageVolume | ( | obj, | |
size = (5,5,5) |
|||
) |
Dilate the image `obj' by `size' using grey dilation. This overwrites the data in `obj'.
def eidolon.ImageAlgorithms.extendImage | ( | obj, | |
name, | |||
mx, | |||
my, | |||
mz, | |||
fillVal = 0 , |
|||
numProcs = 0 , |
|||
task = None |
|||
) |
Extends the image `obj' by the given margins (mx,my,mz) in each dimension. The extended regions are filled with the value `fillVall'. The `numProcs' value is used in determining how many processes to use (0 for all). The returned object has name `name' and represents the same spatial data as the original plus the added margins.
def eidolon.ImageAlgorithms.extendImageRange | ( | process, | |
imglist, | |||
mx, | |||
my, | |||
fillVal | |||
) |
def eidolon.ImageAlgorithms.generateImageStack | ( | width, | |
height, | |||
slices, | |||
timesteps = 1 , |
|||
pos = vec3() , |
|||
rot = rotator() , |
|||
spacing = vec3(1) , |
|||
name = 'img' |
|||
) |
Create a blank image stack with each timestep ordered bottom-up with integer timesteps.
def eidolon.ImageAlgorithms.generateMaskConvexHull | ( | mask | ) |
Returns a convex hull mask image covering the non-zero values in 2D/3D image `mask'.
def eidolon.ImageAlgorithms.generateMotionMask | ( | motion, | |
percentile = 90 , |
|||
filterSize = 10 |
|||
) |
Given a 3D image `motion' containing the FFT motion representation, generate a mask image of the same dimensions containing the area of motion greater than the given percentile which is then filtered with maximum filter of size `filterSize'. A larger `percentile' keeps less motion while a larger `filterSize' increases the bounds around the selected motion area of interest.
def eidolon.ImageAlgorithms.generateSphereImageStack | ( | width, | |
height, | |||
slices, | |||
center = vec3(0.5) , |
|||
scale = vec3(0.45) , |
|||
innerval = 0.75 , |
|||
shellval = 1.0 |
|||
) |
Create a sphere image on an otherwise blank image stack made with generateImageStack().
def eidolon.ImageAlgorithms.generateTestImageStack | ( | width, | |
height, | |||
slices, | |||
timesteps = 1 , |
|||
pos = vec3() , |
|||
rot = rotator() , |
|||
spacing = vec3(1) |
|||
) |
Create a test pattern on an otherwise blank image stack made with generateImageStack().
def eidolon.ImageAlgorithms.getHistogramExtremas | ( | hist, | |
thresholdFilter = True , |
|||
thresholdfunc = None , |
|||
sigma = 3 , |
|||
order = 5 |
|||
) |
Given a histogram matrix `hist', identify the maximal and minimal points in the histogram's curve. The histogram is first smoothed using a gaussian filter with the given `sigma' argument, and then argrelextrema() is applied to this with the given `order' argument
def eidolon.ImageAlgorithms.getLargestMaskObject | ( | mask | ) |
Given a numpy array `mask' containing a binary mask, returns an equivalent array with only the largest mask object.
def eidolon.ImageAlgorithms.hounsfieldToUnit | ( | h | ) |
Converts a Hounsfield unit value `h' to a unit value, 0 if `h' is the minimal Hounsfield value to 1 if maximal.
def eidolon.ImageAlgorithms.isCTImageSeries | ( | imgs = None , |
|
minv = None , |
|||
maxv = None , |
|||
hist = None |
|||
) |
Returns True if the list of ShareImage objects `imgs' represents a volume of CT data. This is done by counting the number of maximi in the image histogram, if there's more than 3 this is a CT series. If `hist' is not None, this RealMatrix is used as the histogram, otherwise one is calculated from `imgs'.
def eidolon.ImageAlgorithms.loadImageFile | ( | filename, | |
imgobj, | |||
pos = vec3() , |
|||
rot = rotator() , |
|||
spacing = (1.0,1.0) |
|||
) |
Returns a SharedImage object containing the image data from `imgobj' which must have a fillRealMatrix(mat) method.
def eidolon.ImageAlgorithms.loadImageStack | ( | files, | |
imgLoadFunc, | |||
positions, | |||
rot = rotator() , |
|||
spacing = (1.0,1.0) , |
|||
task = None |
|||
) |
def eidolon.ImageAlgorithms.maskMotionImage | ( | obj, | |
firstStepOnly = True , |
|||
percentile = 90 , |
|||
filterSize = 10 |
|||
) |
def eidolon.ImageAlgorithms.mergeColinearImages | ( | imgobjs, | |
objout, | |||
mergefunc = None , |
|||
task = None |
|||
) |
Merge the images in `imgobjs' into `objout' using the function `mergefunc' which accepts a list of values `val' and expects a single float value in return. By default the built-in function max is used in `mergefunc' is None. The objects in `imgobjs' must be colinear with `objout', that is the topology of the image planes in these objects must be the same as those in `objout', so there must be as many images in each of these objects and each image plane is located in the same time and space as the counterpart in `objout'. The order of planes as stored in the `images' field of the objects must also be the same.
def eidolon.ImageAlgorithms.mergeColinearImagesRange | ( | process, | |
imglist, | |||
mergefunc | |||
) |
def eidolon.ImageAlgorithms.mergeImages | ( | imgobjs, | |
imgout, | |||
mergefunc = None , |
|||
task = None |
|||
) |
Merge the images of `imgobjs' into `imgout'. Each image in `imgobjs' is resampled into a clone of `imgout' which are then merged into `imgout' using `mergefunc', except if `imgout' is in `imgobjs', in which case it will be used directly in calculations. The object `mergefunc' is either a callable in the gloval namespace accepting a list of floats and returning a single float (by default the built-in max) or a string expression converting a list of floats `vals' into a single float value. For example, "avg(vals)" produces an averaged image.
def eidolon.ImageAlgorithms.normalizeImageData | ( | obj | ) |
Rescales the image data of `obj' to be in the unit range.
def eidolon.ImageAlgorithms.processImageNp | ( | imgobj, | |
writeBack = False , |
|||
dtype = np.float32 |
|||
) |
Given an ImageSceneObject instance `imgobj', this manager yields the 4D numpy array of type `dtype' containing the image data in XYZT (column/row/depth/time) dimensional ordering. This allows the array to be modified which is then written back into the object once the context exits if `writeBack' is True. The array is fresh thus can be retained outside the context.
def eidolon.ImageAlgorithms.resampleImage | ( | srcobj, | |
destobj | |||
) |
Resample the data from `srcobj' into `destobj', overwriting the latter's contents.
def eidolon.ImageAlgorithms.rescaleArray | ( | arr, | |
minv = 0.0 , |
|||
maxv = 1.0 , |
|||
dtype = np.float32 |
|||
) |
Rescale the values of numpy array `arr' to be from `minv' to `maxv'.
def eidolon.ImageAlgorithms.rescaleArrayIntMax | ( | arr, | |
dtype = np.uint16 |
|||
) |
Rescale the array `arr' to be between the minimum and maximum values of the type `dtype'.
def eidolon.ImageAlgorithms.reverseAxes | ( | img | ) |
Reverse the axes of numpy array `img'.
def eidolon.ImageAlgorithms.sampleImageRay | ( | img, | |
start, | |||
samplevec, | |||
numsamples | |||
) |
Sample `numsamples' values from `img' starting from `start' in direction of `samplevec' (both in matrix coords).
def eidolon.ImageAlgorithms.sampleImageVolume | ( | obj, | |
pt, | |||
timestep, | |||
transinv = None |
|||
) |
Sample the image volume `obj' at the given point in world space and time, returning 0 if the point is outside the volume. The value `transinv' should be the inverse transform of the object's volume, if this is None then the transform is queried from `obj', therefore this is an optional optimization value only.
def eidolon.ImageAlgorithms.shiftImageXY | ( | img, | |
shifts | |||
) |
Shift the images of `img' in the XY dimension at each timestep by the given per-Z offsets in `shifts'.
def eidolon.ImageAlgorithms.thresholdImage | ( | obj, | |
minv, | |||
maxv, | |||
task = None |
|||
) |
Fill `obj' with a 0 for all values outside the range [minv,maxv], any value within is untouched.
def eidolon.ImageAlgorithms.thresholdImageRange | ( | process, | |
imgs, | |||
minv, | |||
maxv | |||
) |
def eidolon.ImageAlgorithms.transposeRowsColsNP | ( | img | ) |
Return `img' with indices 0 and 1 transposed, sued for converting between row- or column-majored image volumes.
tuple defaultImageQuad |