image_analysis.pipeline package

Submodules

image_analysis.pipeline.feature module

class image_analysis.pipeline.feature.Feature(key_name, batch_op=False, frame_op=False, save=False)[source]

Bases: object

DESCRIPTION:
Base class for features we want to extract or transformations we want to apply to data. If batch_op and frame_op is left false then it is a learning model (or anything else you want really)
ARGS:
batch_op:boolean to say the feature runs on batches of frames
frame_op:boolean to say the feature runs on each frame
save:boolean check to save feature in output dict
extract(**args)[source]
DESCRIPTION:
extract features from the data
predict(Y)[source]
DESCRIPTION:
predict new points
train(**args)[source]
DESCRIPTION:
train models on images

image_analysis.pipeline.fft module

class image_analysis.pipeline.fft.FFT(inputshape, usegpu=False, nthreads=1)[source]

Bases: image_analysis.pipeline.feature.Feature

DESCRIPTION:
Fast fourier transform feature
ARGS:
inputshape:we need to know in advance the shape of input for performance reason
usegpu:#TODO use gpu for implementation or not
nthreads:number of threads to run fft in multhreaded mode
fft2d(input)[source]
DESCRIPTION:
2d fast fourier transform
ARGS:
input:input frame to transform
fftshift(input)[source]
DESCRIPTION:
2d fast fourier shift
ARGS:
input:input frame to shift
ifft2d(input)[source]
DESCRIPTION:
2d inverse fast fourier transform
ARGS:
input:input frame to transform

image_analysis.pipeline.orientation_filter module

class image_analysis.pipeline.orientation_filter.OrientationFilter(mask='bowtie', center_orientation=90, orientation_width=20, high_cutoff=None, low_cutoff=0.1, target_size=None, falloff='')[source]

Bases: image_analysis.pipeline.feature.Feature

DESCRIPTION:
Creates a filter that can be multiplied by the amplitude spectrum of an image to increase/decrease specific orientations/spatial frequencies.
ARGS:
inputshape:shape of then input for pyfftw builder
center_orientation:
 int for the center orientation (0-180)
orientation_width:
 int for the orientation width of the filter
high_cutoff:int high spatial frequency cutoff
low_cutoff:int low spatial frequency cutoff
target_size:int total size.
falloff:string ‘triangle’ or ‘rectangle’ shape of the filter falloff from the center.
nthreads:number of multithreads
bowtie(center_orientation, orientation_width, high_cutoff, low_cutoff, target_size, falloff='')[source]
DESCRIPTION:
Creates a filter that can be multiplied by the amplitude spectrum of an image to increase/decrease specific orientations/spatial frequencies.
ARGS:
center_orientation:
 int for the center orientation (0-180).
orientation_width:
 int for the orientation width of the filter.
high_cutoff:int high spatial frequency cutoff.
low_cutoff:int low spatial frequency cutoff.
target_size:int total size.
falloff:string ‘triangle’ or ‘rectangle’ shape of the filter falloff from the center.

RETURNS:

the bowtie shaped filter.
extract(frame)[source]
DESCRIPTION:
Transforms a matrix using FFT, multiplies the result by a mask, and then transforms the matrix back using Inverse FFT.
ARGS:
input_frame:(m x n) numpy array
mask:int determining the type of filter to implement, where 1 = iso (noize amp) and 2 = horizontal decrement (bowtie)
RETURNS:
return the transformed and processed frame
noise_amp(size)[source]
DESCRIPTION:
Creates a size x size matrix of randomly generated noise with amplitude values with 1/f slope
ARGS:
size:size of matrix
RETURNS:
:returns the amplitudes with noise added

image_analysis.pipeline.pipeline module

class image_analysis.pipeline.pipeline.Pipeline(data=None, ops=None, seq=None, save_all=None, models=None)[source]

Bases: object

DESCRIPTION:
This class is the bridge between running features on images. Automates the process of extracting each feature, saving it, outputing it and putting it in dictionary form
ARGS:
data:image data
ops:features to run on images. These ops don’t have dependencies
seq:features to run in sequential way (output is input to another)
save_all:boolean check to save all features ran
models:dictionary of statistical models to run on the data
as_ndarray(frame_key=None, batch_key=None, seq_key=None)[source]
DESCRIPTION:
get a feature as a numpy array
ARGS:
frame_key:key of frame feature to get
batch_key:key of batch feature to get
seq_key:key of seq operations to get
display()[source]
DESCRIPTION:
print pipeline stuff like models we have and operations
extract(keep_input_data=True)[source]
DESCRIPTION:
extract all features
ARGS:
keep_input_data:
 boolean check whether we want to keep original data
predict(X, model='')[source]
DESCRIPTION:
predicts value for data X according to model. It returns a dictionary with the model name and predicted values as key and value
ARGS:
X:the data X to predict labels for
model:optional parameter to predict using a specific model only or all if none is specified
set_batch_ops(batch_ops=None)[source]
DESCRIPTION:
update batch operations list
ARGS:
batch_ops:features to put in batch_ops
set_empty_frame(batch_ops, frame_ops, seq_ops)[source]
DESCRIPTION:
creates an empty frame with the operation keys only
ARGS:
batch_ops:features to extract from batches
frame_ops:features to extract from frames
seq_ops:features to extract sequentially
set_frame_ops(frame_ops=None)[source]
DESCRIPTION:
update frame operations list
ARGS:
frame_ops:features to put in frame_ops
set_ops(ops=None, seq=None)[source]
DESCRIPTION:
puts ops and seq into separate list for better managing
ARGS:
ops:features to run on images. These ops don’t have dependencies
seq:features to run in sequential way (output is input to another)
set_seq(seq=None)[source]
DESCRIPTION:
update sequential operations list
ARGS:
seq:features to put in seq_ops
train(X, y, model='')[source]
DESCRIPTION:
train the models using X as train data and y as labels for X
ARGS:
X:data to train on
y:labels for X
model:optional parameter to predict using a specific model only or all if none is specified

image_analysis.pipeline.svm module

class image_analysis.pipeline.svm.SVM(gamma=0.001)[source]

Bases: image_analysis.pipeline.feature.Feature

DESCRIPTITON:
scikit-learn Support vector machine wrapper
ARGS:
gamma:kernel coefficient
predict(X)[source]
DESCRIPTION:
predrict values for new data
ARGS:
X:data to predict labels for
train(X, y)[source]
DESCRIPTION:
train the svm
ARGS:
X:the data
y:the labels for the data

Module contents