deepcinac.utils.cells_map_utils
¶
Module Contents¶
Classes¶
Functions¶
|
|
|
Extract coords from file_name, should be z .zip or .roi file |
|
calculate angle in 2-D between points and x axis |
|
calculate area of any triangle given co-ordinates of the corners |
|
-
deepcinac.utils.cells_map_utils.
create_cells_coord_from_suite_2p
(is_cell_file_name, stat_file_name, movie_dimensions)¶ - Parameters
is_cell_file_name – path and file_name of the file iscell.npy produce by suite2p segmentation process
be None (Could) –
None (if) –
all cells in stat are cells to keep (means) –
stat_file_name – path and file_name of the file stat.npy produce by suite2p segmentation process
movie_dimensions – tuple of 2 int, dimensions of the movie n col x n line
Returns: a CellsCoord instance
-
deepcinac.utils.cells_map_utils.
get_coords_extracted_from_fiji
(file_name)¶ Extract coords from file_name, should be z .zip or .roi file :param file_name: .zip or .roi file
Returns: Array of len the number of contours made of array of 2 lines (x & y) and n columns, n being the number of coordinate to set the contour of each cell.
-
class
deepcinac.utils.cells_map_utils.
CellsCoord
(coords=None, pixel_masks=None, nb_lines=None, nb_col=None, from_matlab=False, invert_xy_coord=False)¶ -
build_raw_traces_from_movie
(self, movie, without_overlap=False, buffer_overlap=1)¶ Return a 2d array representing the fluoresence signal raw trace for each cell :param movie: 3d array n_frames x len_y x len_x :param without_overlap: (bool) if True, means the trace will be build only from the pixels from this cell :param buffer_overlap: indicate from how much pixels increasing the size of overlaping cell
Returns: A 2d array (n_cells * n_frames) of float
-
build_cell_polygon_from_contour
(self, cell)¶ Build the (shapely) polygon representing a given cell using its contour’s coordinates. :param cell:
Returns:
-
get_cell_mask
(self, cell, dimensions, without_overlap=False, buffer_overlap=1)¶ Return the mask of the pixels of the cell :param cell: :param dimensions: height x width :param without_overlap: if True, means with return only the pixel belonging to this cell
buffer_overlap: indicate from how much pixels increasing the size of overlaping cell
- Returns
binary 2d array (movie dimension), with 1 for the pixels belonging to the cell
-
match_cells_indices
(self, coord_obj, path_results, plot_title_opt='')¶ - Parameters
coord_obj – another instanc of coord_obj
- Returns
a 1d array, each index corresponds to the index of a cell of coord_obj, and map it to an index to self
or -1 if no cell match
-
plot_cells_map
(self, path_results, data_id, use_pixel_masks=False, title_option='', connections_dict=None, background_color=0, 0, 0, 1, default_cells_color=1, 1, 1, 1.0, default_edge_color='white', dont_fill_cells_not_in_groups=False, link_connect_color='white', link_line_width=1, cell_numbers_color='dimgray', show_polygons=False, cells_to_link=None, edge_line_width=2, cells_alpha=1.0, fill_polygons=True, cells_groups=None, cells_groups_colors=None, cells_groups_alpha=None, cells_to_hide=None, img_on_background=None, real_size_image_on_bg=True, cells_groups_edge_colors=None, with_edge=False, with_cell_numbers=False, text_size=6, save_formats='png', save_plot=True, return_fig=False, ax_to_use=None, verbose=False, use_welsh_powell_coloring=False, dpi=300)¶ - Parameters
path_results –
data_id –
use_pixel_masks –
title_option –
connections_dict – key is an int representing a cell number, and value is a dict representing the cells it
to. The key is a cell is connected too (connects) –
the value represent the strength of the connection (and) –
how many times it connects to it) ((like) –
background_color –
default_cells_color –
default_edge_color –
dont_fill_cells_not_in_groups –
link_connect_color –
link_line_width –
cell_numbers_color –
show_polygons –
cells_to_link –
edge_line_width –
cells_alpha –
fill_polygons –
cells_groups –
cells_groups_colors –
cells_groups_alpha –
cells_to_hide –
img_on_background –
real_size_image_on_bg – if True, the size of the figure will respect the original size of the background
image –
cells_groups_edge_colors –
with_edge –
with_cell_numbers –
text_size –
save_formats –
save_plot –
return_fig –
ax_to_use –
verbose – if True, some informations will be printed along the way
use_welsh_powell_coloring – if True, use welsh powell algorithm to color all cells that intersect with
- different color. In that case, cancel cell_groups arguments.
dpi:
Returns:
-
add_cells_using_pixel_masks_on_ax
(self, ax, cells_groups, cells_not_in_groups, cells_to_hide, default_cells_color, cells_groups_colors, with_cell_numbers, cell_numbers_color, text_size, background_color, cells_imshow_alpha, bg_imshow_alpha)¶ Using pixel mask if it exists :param ax: :param cells_groups: :param cells_not_in_groups: :param cells_to_hide: :param default_cells_color: :param cells_groups_colors: :param with_cell_numbers: :param cell_numbers_color: :param text_size: :param background_color:
Returns:
-
add_cells_using_polygons_on_ax
(self, ax, cells_groups, cells_not_in_groups, cells_to_hide, with_edge, edge_line_width, default_cells_color, default_edge_color, cells_groups_edge_colors, cells_groups_colors, cells_groups_alpha, cells_alpha, with_cell_numbers, cell_numbers_color, text_size, dont_fill_cells_not_in_groups)¶ Add cells to a matplolib ax using the polygons representation. Arguments give parameters to apply :param ax: :param cells_groups: :param cells_not_in_groups: :param cells_to_hide: :param with_edge: :param edge_line_width: :param default_cells_color: :param default_edge_color: :param cells_groups_edge_colors: :param cells_groups_colors: :param cells_groups_alpha: :param cells_alpha: :param with_cell_numbers: :param cell_numbers_color: :param text_size: :param dont_fill_cells_not_in_groups:
Returns:
-
plot_text_cell
(self, cell, ax, cell_numbers_color, text_size)¶ Plot the cell number on the cell :param cell: integer :param ax: matplolib axis :param cell_numbers_color: color of the text :param text_size: text size (float)
Returns:
-
get_cell_new_coord_in_source
(self, cell, minx, miny)¶
-
scale_polygon_to_source
(self, poly_gon, minx, miny)¶
-
get_source_profile
(self, cell, tiff_movie, traces, peak_nums, spike_nums, pixels_around=0, bounds=None, buffer=None, with_full_frame=False)¶ Return the source profile of a cell :param cell: :param pixels_around: :param bounds: how much padding around the cell pretty much, coordinate of the frame covering the source profile 4 int list :param buffer: :param with_full_frame: Average the full frame :return:
-
get_transient_profile
(self, cell, transient, tiff_movie, traces, pixels_around=0, bounds=None)¶
-
corr_between_source_and_transient
(self, cell, transient, source_profile_dict, tiff_movie, traces, source_profile_corr_dict=None, pixels_around=1)¶ Measure the correlation (pearson) between a source and transient profile for a giveb cell :param cell: :param transient: :param source_profile_dict should contains cell as key, and results of get_source_profile avec values :param pixels_around: :param source_profile_corr_dict: if not None, used to save the correlation of the source profile, f for memory and computing proficiency :return:
-
-
deepcinac.utils.cells_map_utils.
_angle_to_point
(point, centre)¶ calculate angle in 2-D between points and x axis
-
deepcinac.utils.cells_map_utils.
area_of_triangle
(p1, p2, p3)¶ calculate area of any triangle given co-ordinates of the corners
-
deepcinac.utils.cells_map_utils.
convex_hull
(points, smidgen=0.0075)¶ from: https://stackoverflow.com/questions/17553035/draw-a-smooth-polygon-around-data-points-in-a-scatter-plot-in-matplotlib Calculate subset of points that make a convex hull around points Recursively eliminates points that lie inside two neighbouring points until only convex hull is remaining.
- Parameters
points : ndarray (2 x m) array of points for which to find hull use pylab to show progress? smidgen : float offset for graphic number labels - useful values depend on your data range
- Returns
hull_points : ndarray (2 x n) convex hull surrounding points