neurocollage.collage

2D collage with matplotlib.

Functions

get_annotation_info(annotation, ...[, n_pixels])

Get information to plot annotation on a plane.

get_greedy_perm(X, sample)

Compute a furthest point sampling permutation of a set of points.

get_plane_rotation_matrix(plane, ...[, target])

Get basis vectors best aligned to target direction.

get_y_info(annotation, atlas, plane_origin, ...)

Get direction of y axis on a grid on the atlas planes.

plot_2d_collage(cells_df, planes, ...[, ...])

Plot collage of an mtype and a list of planes.

plot_3d_collage(cells_df, planes, ...[, ...])

Plot 3d collage with trimesh.

plot_cells(ax, cells_df, planes[, ...])

Plot cells for collage.

neurocollage.collage.get_annotation_info(annotation, plane_origin, rotation_matrix, n_pixels=1024)

Get information to plot annotation on a plane.

Parameters:
  • annotation (VoxelData) – atlas annotations

  • plane_origin (np.ndarray) – origin of plane (Plane.point)

  • rotation_matrix (3*3 np.ndarray) – rotation matrix to transform from real coordinates to plane coordinates

  • n_pixels (int) – number of pixel on each axis of the plane for plotting layers

neurocollage.collage.get_greedy_perm(X, sample)

Compute a furthest point sampling permutation of a set of points.

Adapted from ripser.py

neurocollage.collage.get_plane_rotation_matrix(plane, current_rotation, target=None)

Get basis vectors best aligned to target direction.

We define a direct orthonormal basis of the plane (e_1, e_2) such that || e_2 - target || is minimal. The positive axes along the vectors e_1 and e_2 correspond respectively to the horizontal and vertical dimensions of the image.

Parameters:
  • plane (atlas_analysis.plane.maths.Plane) – plane object

  • current_rotation (ndarray) – rotation matrix at the location

  • target (list) – target vector to align each plane

Returns:

rotation matrix to map VoxelData coordinates to plane coordinates

Return type:

np.ndarray

neurocollage.collage.get_y_info(annotation, atlas, plane_origin, rotation_matrix, n_pixels=64)

Get direction of y axis on a grid on the atlas planes.

neurocollage.collage.plot_2d_collage(cells_df, planes, layer_annotation, atlas_path, mtype=None, pdf_filename='collage.pdf', sample=10, nb_jobs=-1, joblib_verbose=10, dpi=200, n_pixels=100, with_y_field=True, n_pixels_y=20, plot_neuron_kwargs=None, with_cells=True, cells_linear_density=None, cells_wire_plot=False, figsize=(20, 20), random=False, video=False)

Plot collage of an mtype and a list of planes.

Parameters:
  • cells_df (cells) – should contain location of soma and mtypes

  • planes (list) – list of plane objects from atlas_analysis

  • layer_annotation (VoxelData) – layer annotation on atlas

  • atlas_path (str) – the path to the atlas

  • mtype (str) – mtype of cells to plot

  • pdf_filename (str) – pdf filename

  • sample (int) – maximum number of cells to plot

  • nb_jobs (int) – number of joblib workers

  • joblib_verbose (int) – verbose level of joblib

  • dpi (int) – dpi for pdf rendering (rasterized)

  • n_pixels (int) – number of pixels for plotting layers

  • with_y_field (bool) – plot y field

  • n_pixels_y (int) – number of pixels for plotting y field

  • plot_neuron_kwargs (dict) – dict given to neurom.viewer.plot_neuron as kwargs

  • with_cells (bool) – plot cells or not

  • cells_linear_density (float) – apply resampling to plot less points

  • cells_wire_plot (bool) – if true, do not use neurom.view, but plt.plot

  • figsize (tuple(int, int)) – the size of the figure

  • random (bool) – randomly select cells if True, or select furthest away cells

  • video (bool) – instead of saving a pdf, we generate a video across planes frames are saved in folder named from pdf_filename, and video as [pdf_filename.stem].mp4

neurocollage.collage.plot_3d_collage(cells_df, planes, layer_annotation, atlas_path, mtype, region, hemisphere, centerline, sample=10, filename=None, show=False)

Plot 3d collage with trimesh.

neurocollage.collage.plot_cells(ax, cells_df, planes, rotation_matrix=None, mtype=None, sample=10, plot_neuron_kwargs=None, linear_density=None, wire_plot=False, random=False)

Plot cells for collage.