fluopi package¶
fluopi.analysis module¶
-
fluopi.analysis.
area
(r, cv, T, filename='null')[source]¶ Compute and plot the colonies area over time as a perfect circle (using the input radius value) around the colony position value
Parameters: - r (dictionary) – colony radius at each time step of the selected colony (obtained with frame_colony_radius() function)
- cv – colonies ID vector to plot
Returns: A – colony area at each time step of the selected colony. Call it as: A[colonyID][time step]
Return type: dictionary
-
fluopi.analysis.
bg_subst
(data, bg)[source]¶ Substract the mean background value for each channel and frame obtained with BG_Val function.
Parameters: - data (dictionary) – R G B images data
- bg (array) – ackground mean value of each channel for every time frame (can be obtained with BG_Val function)
Returns: Data – R G B images data with the background substracted
Return type: dictionary
-
fluopi.analysis.
bg_value
(x1, x2, y1, y2, data, im_count)[source]¶ compute the background mean value for each channel and frame based on a rectagle defined by the user. Plot the rectangle over the image and makes plots of each channel mean background value over time
Parameters: - x1,x2,x1,x2 (int values) – rectangle area limits: (x1,y1) = left-up corner. (x2,y2) = rigth-bottom corner
- data (dictionary) – R G B images data to get the background, and his names on data[‘Im’]
- im_count (int) – total number of files on the folder (can be obtained with count_files function)
Returns: bg – Background mean value of each channel for every time frame
Return type: dictionary
-
fluopi.analysis.
channels_sum
(rois_data, cv)[source]¶ Compute the sum over the RGB channels for each image
Parameters: - rois_data (dictionary) – RGB time-lapse image data of each ROIS, from obtain_rois()
- cv (vector) – contain the ID of the of colonies analysed
Returns: sum_chan_rois – Sum of channels for each time step and ROI
Return type: dictionary
-
fluopi.analysis.
colony_blobs_id
(data, thresh, im_name, filename='null')[source]¶ Use skimage to identify the position of each colony and define the circular region used by each of them
Parameters: - data (array of single channel image data) –
- thresh – Pixel values > thresh are included in the analysis, range (0,1)
- im_name – Name of an image on which to overlay colony positions and sizes
- filename (string) – filename with whom save the output image+blobs+ID
Returns: A – Contains the (x,y) position and size of each blob for each of N colonies detected
Return type: array (Nx3)
-
fluopi.analysis.
colony_classifier
(fit, classes, chanx_dat, chany_dat)[source]¶ Classify chanx_dat and chany_dat (which correspond to the data serie being classified) on the classes names given as inputs. The classification is on the small chany_dat distance value with the value computed with the chanx_dat and each fitted function (that are on “fit”). In other words, accord the minimal y-coordinate distance between each dot and fitted lines.
Parameters: - fit (array like) – each position on the array cointains the parameters of the linear fit of each categorie. fit = [z1, z2, z3] where z is the return of linear_fit.
- classes (string array) – contain the names of the defined categories (its length have to be same long as fit)
- chanx_dat (vector) – data of the channel on x axis for the data to be classified
- chany_dat (vector) – data of the channel on y axis for the data to be classified
Returns: - clas (list) – contain the category of each classified colony in order. e.g. clas = [‘cat3’, ‘cat1, ‘cat1’, ‘cat1’, ‘cat2’, etc …]
- clas_dict (dictionary) – contain the channel value of the colonies of each category in the corresponding dictinary class. clas_dict = [‘class’][chan_xdat, chany_dat, boolean]. The boolean vector have the length of the total colony analyzed, and indicate (with True) which colonies correspond to that category.
-
fluopi.analysis.
count_files
(path, file_type)[source]¶ To count the number of files of a defined extension (filetype on a certain folder (path)
Parameters: - path (string) – folder name where the images are stored
- file_type (string) – extension of the files to count (e.g. tif, png, jpg)
Returns: ImageCount – number of defined filetype files on the path folder
Return type: int
-
fluopi.analysis.
croi_mean_int_frames
(data, blobs, radii, cv)[source]¶ compute the mean intensity values for each time and channels for each CROI (circular ROI), redefining the ROIS based on radii values It takes the fit radius value at each time (radii), with it defines a circular ROI, sum all the pixel values inside them and divide this value for the number of pixel considered. –> obtain the intensity mean value inside the colony limits on each time.
Parameters: - data (dictionary) – RGB dictionary with the images data
- blobs (array like) – contains the information of identified blobs
- radii (dictionary) – contains the radius for each colony on each time step
- cv (vector) – contain the ID of the colonies to analyse
Returns: all_chan_crois_mean_val – contain the mean pixel value of each channel for each time step of each colony. call it as: all_chan_crois_mean_val[‘channel_name’][blob_number][timepoint]
Return type: dictionary
-
fluopi.analysis.
data_sum_time
(data)[source]¶ Sum the data for each pixel over time
Parameters: Data (dictionary) – R G B images data Returns: SData – Sum data over time and over channels for each pixel of the Data Return type: array like
-
fluopi.analysis.
f_linear
(x, a, b)[source]¶ compute the linear function value with given parameters
Parameters: - x (int or vector) – independent variable values
- a (double) – slope parameter
- b (double) – y-intercept parameter
Returns: Return type: evaluated linear fucntion with the given parameters for the given x
-
fluopi.analysis.
f_mu
(t, b, d)[source]¶ compute the grwoth rate (mu) function value
Parameters: - t (int or vector) – independent variable values (suposed to be time vector)
- b (double) – functon parameter
- c (double) – function parameter
Returns: Return type: evaluated “mu” fucntion with the given parameters
-
fluopi.analysis.
f_sigma
(t, a, b, c)[source]¶ Compute the sigmoide function value using the given input values
Parameters: - t (vector) – independent variable ( “x axis”, suposed to be time)
- a (double) – maximum value parameter
- b (double) – function parameter
- c (double) – delay parameter
Returns: Return type: function evaluation
-
fluopi.analysis.
frame_colony_radius
(rois, cv, thr, min_sig=0.5, max_sig=10, num_sig=200)[source]¶ Get the colony radius at each time step
Parameters: - rois (dictionary) – ROI image data from obtain_rois()
- cv (vector) – contain the ID of the of colonies analysed
- thr (double) – Threshold for skfeat.blob_log
- min_sig (double) – minimum value of sigma used on skfeat.blob_log
- max_sig (double) – maximum value of sigma used on skfeat.blob_log
- num_sig (int) – number of sigma values used between min_sig and max_sig on skfeat.blob_log
Returns: R – The time series of colony size, indexed by colony id number
Return type: dictionary
-
fluopi.analysis.
function_fit
(xdata, ydata, init, end, cv, func=<function f_sigma>, param_bounds=([1, -inf, 0.1], [inf, -1, 1]))[source]¶ Fit a given function to given data
Parameters: - xdata (vector) – independent variable ( “x axis”, suposed to be time vector)
- ydict (array like) – array of dependent variable vectors
- init (double) – point on the time vector to init the fitting
- end (double) – point on the time vector to end the fitting
- cv (vector) – contain the ID of the colonies to analyse
- func (function) – function to be fitted
- param_bounds (array of vectors) – lower and upper bounds of each parameters para_bounds=([lower bounds],[upper bounds])
Returns: Y_fit – contain the fitting result for each colony in the dictionary. It is:
Y_fit[col ID][evalF z]:
- evalF: vector
result vector of the fitted function: evalF=func(xdata, optimal_parameters)
- z: vector
fitted parameters
Return type: dictionay
-
fluopi.analysis.
get_im_data
(x_frames, image_count, f_name)[source]¶ Load image data from a sequence of files
Parameters: - x_frames (int) – step frames (e.g 10 to use only ten to ten images)
- image_count (int) – total number of files on the folder (can be obtained with count_files function)
- f_name (string) – file name pattern including full path where images are stored, e.g. “/folder/image-%04d”
Returns: ImsR,ImsG,ImsB – data per channel of each image (ImsR -> matrix size = (W,H,image_count/x_frames))
Return type: array_like
-
fluopi.analysis.
linear_fit
(data1, data2, filename='null')[source]¶ Fit linear function (f_linear) to given data, display the fited function and make a plot of the result. You are able to save the resulting plot by given as input the “filename” to save it.
Parameters: - data1 (vector) – independent variable ( “x axis”) to be used as input of f_linear
- data2 (vector) – “y-data values” used as reference to peform the fitting
- filename (string) – name of the image file if it is desired to save it.
Returns: z – fitted parameters
Return type: vector
-
fluopi.analysis.
obtain_rois
(data, blobs)[source]¶ Based on the information of each identified colony, create arrays to contain the regions of interest (ROI) around each one.
Parameters: - data (dictionary) – R G B image data per frame
- blobs (array like) – Array of colony positions and sizes given by skimage in colonyBlob()
Returns: - all_rois – The ROI array image data for square region around colony position of side 2*(colony size) to call it: all_rois[‘channel_name’][blob_number][y,x,timepoint]
- all_rois_circle – The ROI array image data only within circle (radius = width/2), with the data outside the circle equal to zero. The size of the array is equal to square ROIS (all_rois) size. to call it: all_rois_circle[‘channel_name’][blob_number][y,x,timepoint]
- nc – Number of colonies analysed (length of returned arrays)
-
fluopi.analysis.
smooth_data
(data, sigma)[source]¶ Apply gaussian filter to smooth each frame data
Parameters: - data (dictionary) – 4 dimensional (R,G,B, and Time) matrix with the data
- sigma (double) – Filter parameter (standard deviation)
Returns: - NSIms (dictionary) – Sum over time of Smoothed data per channel (call it nsims[channel][r,c])
- NSImsAll (array_like) – Matrix with sum of nsims over the channels (call it nsimsAll[r,c])
- SImsT (dictionary) – Smoothed data per channel per frame (call it as simsT[channel][r,c,f])
-
fluopi.analysis.
time_vector
(data, x_frames, dt)[source]¶ Get the vector of times for the image sequence loaded
Parameters: - data (dictionary) – dictionary with the R G B data of all images
- xframes (int) – step frames used on the analysis (e.g 10 means you are using one every ten to ten images)
- dt (double) – time step of the frames in hour units. It can be obtained from the file used to perform the timelapse.
Returns: T – Time vector for the used data (hour units)
Return type: array_like
fluopi.plotting module¶
-
fluopi.plotting.
check_radius
(rois, idx, t, r_fit='null', r_dots='null', filename='null')[source]¶ Plot the colony radius estimate overlayed on an kymograph image slice
Parameters: - r_fit (vector) – colony fited radius at each time step of the selected colony (obtained from a model)
- r_dots – colony radius at each time step of the selected colony (obtained with frame_colony_radius() function)
- rois (dictionary) – ROI image of each colony (obtained with obtain_rois() function)
- idx (int) – id of the colony to check
- t (vector) – the vector of real time values
- filename (string) – filename to save the plot generated
-
fluopi.plotting.
logplot_radius
(r, cv, t, filename='null')[source]¶ Plot the log of the square of the radius for each colony
Parameters: - r (dictionary) – colony radius at each time step of each colony at each time step (obtained with frame_colony_size() function)
- cv (vector) – colonies ID vector to plot
- T (vector) – the vector of real time values
- filename (string) – filename to save the plot generated
-
fluopi.plotting.
plot_im_frame
(f_path, frame)[source]¶ To perform separated plots of each channel of image frame
Parameters: - f_path (string_like) – path directory where the images are stored
- frame (int) – frame number to plot
-
fluopi.plotting.
plot_radius
(r, cv, t, filename='null')[source]¶ Plot the radius for each colony at each time step
Parameters: - r (dictionary) – colony radius at each time step of each colony (obtained with frame_colony_size() function)
- cv (vector) – colonies ID vector to plot
- t (vector) – the vector of real time values
- filename (string) – filename to save the plot generated
-
fluopi.plotting.
plt_im_frame_channels
(f_path, frame)[source]¶ To perform separated plots of each channel of an image frame
Parameters: - f_path (string_like) – folder name where the images are stored
- frame (int) – Frame number to plot
-
fluopi.plotting.
plt_lin_fit
(x_min, x_max, l_fit, color)[source]¶ Make a plot of an already linear fit, being posible to define the function evaluation limits (x independient variable limits) and the color of the dots and fitted line.
Parameters: - x_min (int) – RGB time-lapse image data of each ROI, obtained with obtain_rois()
- x_max (int) – channel name (e.g. ‘G’) to be on the x axis
- l_fit (vector) – linear fitted parameters. Obtained with linear_fit function
- color (char) – char of the color to be used on the dots and line (e.g. ‘r’)
-
fluopi.plotting.
rois_last_frame_2chan_plt
(rois_data, channel_x, channel_y, serie_name)[source]¶ Sum all the pixel values for channel_x and channel_y (e.g.channel G and channel R) separately for the last frame of each ROI and make a plot where channel_x sum value is on the X axis and channel_y sum value is on the Y axis. Each dot correspond to one ROI values and represent the ratio of the two channels for that colony.
Parameters: - rois_data (dictionary) – RGB time-lapse image data of each ROI, obtained with obtain_rois()
- channel_x (string) – channel name (e.g. ‘G’) to be on the x axis
- channel_y (string) – channel name (e.g. ‘R’) to be on the y axis
- serie_name (string) – name of the the data serie in analysis (used as title of the plot)
-
fluopi.plotting.
rois_plt_fluo_dynam
(rois, time_v, cv, filename='null')[source]¶ Plot the total fluorescence of each colony over time
Parameters: - rois (dictionary) – the ROI image array data (is better to use circular ROIS, obtained with obtain_rois() function)
- time_v (vector) – the vector of real time values
- cv (vector) – contain the ID of the of colonies analysed
- filename (string) – filename with whom save the output image with fluorescence dynamics
-
fluopi.plotting.
row_transect
(data, row, x_frames, data_frame=-1)[source]¶ Plot the value of a transect (row of pixels) in a frame and plot it
Parameters: - data (dictionary) – dictionary with the R G B data of all images, and his names on Data[‘Im’]
- row (int) – row where you want to see the transect
- x_frames (int) – step frames used on the analysis (e.g 10 means you are using one every ten to ten images)
- data_frame (int) – frame number of the image of interest, default = last one
-
fluopi.plotting.
tl_roi
(rois, idx, times, fname, radius='null', chan_sum=False, gridsize=[0, 0])[source]¶ Save images of selected time steps on “times” vector, for a selected ROI (idx). This images can be used to make timelapse videos of isolated colonies.
If you specify a gridsize of a proper size, then it display the ROI frames on the notebook
Parameters: - rois (dictionary) – RGB time-lapse image data of each rois, from obtain_rois()
- idx (intr) – contain the ID of the of the selected colony
- times (vector) – conitains the selected frames times
- fname (string) – the complete filename to save the images of ROIs e.g. fname=(‘rois/Col’+str(idx)+’_ROI_step%d.png’)
- chan_sum (boolean) – True to perfom the sum of the three channels of the ROI. False to show the image original colors.
- gridsize (vector) – size of the subplot grid. if gridsize=[0,0] the figure will not be shown on the notebook.
Returns: Return type: Save the images of the selected frames of a ROI.