cuisto.display
display module, part of cuisto.
Contains display functions, essentially wrapping matplotlib and seaborn functions.
add_data_coverage(df, ax, colors=None, **kwargs)
#
Add lines below the plot to represent data coverage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
DataFrame with |
required |
ax
|
Axes
|
Handle to axes where to add the patch. |
required |
colors
|
list or str or None
|
Colors for the patches, as a RGB list or hex list. Should be the same size as
the number of patches to plot, eg. the number of columns in |
None
|
**kwargs
|
passed to patches.Rectangle()
|
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Axes
|
Handle to updated axes. |
Source code in cuisto/display.py
add_injection_patch(X, ax, **kwargs)
#
Add a patch representing the injection sites.
The patch will span from the minimal coordinate to the maximal. If plotted in stereotaxic coordinates, coordinates should be converted beforehand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
list
|
Coordinates in mm for each animals. Can be empty to not plot anything. |
required |
ax
|
Axes
|
Handle to axes where to add the patch. |
required |
**kwargs
|
passed to Axes.axvspan
|
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Axes
|
Handle to updated Axes. |
Source code in cuisto/display.py
draw_structure_outline(view='sagittal', structures=['root'], outline_file='', ax=None, microns=False, **kwargs)
#
Plot brain regions outlines in given projection.
This requires a file containing the structures outlines.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
view
|
str
|
Projection, "sagittal", "coronal" or "top". Default is "sagittal". |
'sagittal'
|
structures
|
list[str]
|
List of structures acronyms whose outlines will be drawn. Default is ["root"]. |
['root']
|
outline_file
|
str
|
Full path the outlines HDF5 file. |
''
|
ax
|
Axes or None
|
Axes where to plot the outlines. If None, get current axes (the default). |
None
|
microns
|
bool
|
If False (default), converts the coordinates in mm. |
False
|
**kwargs
|
passed to pyplot.plot()
|
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Axes
|
|
Source code in cuisto/display.py
nice_bar_plot(df, x='', y=[''], hue='', ylabel=[''], orient='h', nx=None, ordering=None, names_list=None, hue_mirror=False, log_scale=False, bar_kws={}, pts_kws={})
#
Nice bar plot of per-region objects distribution.
This is used for objects distribution across brain regions. Shows the y
metric
(count, aeral density, cumulated length...) in each x
categories (brain regions).
orient
controls wether the bars are shown horizontally (default) or vertically.
Input df
must have an additional "hemisphere" column. All y
are plotted in the
same figure as different subplots. nx
controls the number of displayed regions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
|
required |
x
|
str
|
Key in |
''
|
y
|
str
|
Key in |
''
|
hue
|
str
|
Key in |
''
|
ylabel
|
list of str
|
Y axis labels. |
['']
|
orient
|
h or v
|
"h" for horizontal bars (default) or "v" for vertical bars. |
'h'
|
nx
|
None or int
|
Number of |
None
|
ordering
|
None or list[str] or max
|
Sorted list of acronyms. Data will be sorted follwowing this order, if "max", sorted by descending values, if None, not sorted (default). |
None
|
names_list
|
list or None
|
List of names to display. If None (default), takes the most prominent overall ones. |
None
|
hue_mirror
|
bool
|
If there are 2 groups, plot in mirror. Default is False. |
False
|
log_scale
|
bool
|
Set the metrics in log scale. Default is False. |
False
|
bar_kws
|
dict
|
Passed to seaborn.barplot(). |
{}
|
pts_kws
|
dict
|
Passed to seaborn.stripplot(). |
{}
|
Returns:
Name | Type | Description |
---|---|---|
figs |
list
|
List of figures. |
Source code in cuisto/display.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
nice_distribution_plot(df, x='', y='', hue=None, xlabel='', ylabel='', injections_sites={}, channel_colors={}, channel_names={}, ax=None, **kwargs)
#
Nice plot of 1D distribution of objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
|
required |
x
|
str
|
Keys in |
''
|
y
|
str
|
Keys in |
''
|
hue
|
str or None
|
Key in |
None
|
xlabel
|
str
|
X and Y axes labels. |
''
|
ylabel
|
str
|
X and Y axes labels. |
''
|
injections_sites
|
dict
|
List of injection sites 1D coordinates in a dict with the channel name as key. If empty, injection site is not plotted (default). |
{}
|
channel_colors
|
dict
|
Required if injections_sites is not empty, dict mapping channel names to a color. |
{}
|
channel_names
|
dict
|
Required if injections_sites is not empty, dict mapping channel names to a display name. |
{}
|
ax
|
Axes or None
|
Axes in which to plot the figure, if None, a new figure is created (default). |
None
|
**kwargs
|
passed to seaborn.lineplot()
|
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
matplotlib axes
|
Handle to axes. |
Source code in cuisto/display.py
nice_heatmap(df, animals, x='', y='', xlabel='', ylabel='', invertx=False, inverty=False, **kwargs)
#
Nice plots of 2D distribution of boutons as a heatmap per animal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
|
required |
animals
|
list-like of str
|
List of animals. |
required |
x
|
str
|
Keys in |
''
|
y
|
str
|
Keys in |
''
|
xlabel
|
str
|
Labels of x and y axes. |
''
|
ylabel
|
str
|
Labels of x and y axes. |
''
|
invertx
|
bool
|
Wether to inverse the x or y axes. Default is False. |
False
|
inverty
|
bool
|
Wether to inverse the x or y axes. Default is False. |
False
|
**kwargs
|
passed to seaborn.histplot()
|
|
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Axes or list of Axes
|
Handle to axes. |
Source code in cuisto/display.py
nice_joint_plot(df, x='', y='', xlabel='', ylabel='', invertx=False, inverty=False, outline_kws={}, ax=None, **kwargs)
#
Joint distribution.
Used to display a 2D heatmap of objects. This is more qualitative than quantitative, for display purposes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
|
required |
x
|
str
|
Keys in |
''
|
y
|
str
|
Keys in |
''
|
xlabel
|
str
|
Label of x and y axes. |
''
|
ylabel
|
str
|
Label of x and y axes. |
''
|
invertx
|
bool
|
Whether to inverse the x or y axes. Default is False for both. |
False
|
inverty
|
bool
|
Whether to inverse the x or y axes. Default is False for both. |
False
|
outline_kws
|
dict
|
Passed to draw_structure_outline(). |
{}
|
ax
|
Axes or None
|
Axes to plot in. If None, draws in current axes (default). |
None
|
**kwargs
|
Passed to seaborn.histplot. |
{}
|
Returns:
Name | Type | Description |
---|---|---|
ax |
Axes
|
|
Source code in cuisto/display.py
plot_1D_distributions(dfs_distributions, cfg, df_coordinates=None)
#
Wraps nice_distribution_plot().
Source code in cuisto/display.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
|
plot_2D_distributions(df, cfg)
#
Wraps nice_joint_plot().
Source code in cuisto/display.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
|
plot_regions(df, cfg, **kwargs)
#
Wraps nice_bar_plot().