navis
navis.BaseNeuron
#
Base class for all neurons.
Source code in navis/core/base.py
171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 765 766 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 |
|
bbox: np.ndarray
property
#
Bounding box of neuron.
connectors: pd.DataFrame
property
writable
#
Connector table. If none, will return None
.
core_md5: str
property
#
MD5 checksum of core data.
Generated from .CORE_DATA
properties.
RETURNS | DESCRIPTION |
---|---|
md5 | MD5 checksum of core data. TYPE: |
datatables: List[str]
property
#
Names of all DataFrames attached to this neuron.
extents: np.ndarray
property
#
Extents of neuron in x/y/z direction (includes connectors).
id: Any
property
writable
#
ID of the neuron.
Must be hashable. If not set, will assign a random unique identifier. Can be indexed by using the NeuronList.idx[]
locator.
is_locked
property
#
Test if neuron is locked.
is_stale: bool
property
#
Test if temporary attributes might be outdated.
label: str
property
writable
#
Label (e.g. for legends).
name: str
property
writable
#
Neuron name.
postsynapses
property
#
Table with postsynapses (filtered from connectors table).
Requires a "type" column in connector table. Will look for type labels that include "post" or that equal 1 or "1".
presynapses
property
#
Table with presynapses (filtered from connectors table).
Requires a "type" column in connector table. Will look for type labels that include "pre" or that equal 0 or "0".
soma
property
#
The soma of the neuron (if any).
type: str
property
#
Neuron type.
convert_units
#
Convert coordinates to different unit.
Only works if neuron's .units
is not dimensionless.
PARAMETER | DESCRIPTION |
---|---|
to |
TYPE: |
inplace |
TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.units
<Quantity(8, 'nanometer')>
>>> n.cable_length
266476.8
>>> n2 = n.convert_units('um')
>>> n2.units
<Quantity(1.0, 'micrometer')>
>>> n2.cable_length
2131.8
Source code in navis/core/base.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
|
copy
#
Return a copy of the neuron.
Source code in navis/core/base.py
641 642 643 644 645 646 647 648 649 650 651 652 653 |
|
map_units
#
Convert units to match neuron space.
Only works if neuron's .units
is isometric and not dimensionless.
PARAMETER | DESCRIPTION |
---|---|
units |
TYPE: |
on_error |
TYPE: |
See Also
navis.core.to_neuron_space
The base function for this method.
Examples:
>>> import navis
>>> # Example neurons are in 8x8x8nm voxel space
>>> n = navis.example_neurons(1)
>>> n.map_units('1 nanometer')
0.125
>>> # Numbers are passed-through
>>> n.map_units(1)
1
>>> # For neuronlists
>>> nl = navis.example_neurons(3)
>>> nl.map_units('1 nanometer')
[0.125, 0.125, 0.125]
Source code in navis/core/base.py
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 |
|
memory_usage
#
Return estimated memory usage of this neuron.
Works by going over attached data (numpy arrays and pandas DataFrames such as vertices, nodes, etc) and summing up their size in memory.
PARAMETER | DESCRIPTION |
---|---|
deep |
TYPE: |
estimate |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
int | Memory usage in bytes. |
Source code in navis/core/base.py
766 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 |
|
plot2d
#
Plot neuron using navis.plot2d
.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
DEFAULT: |
See Also
navis.plot2d
Function called to generate 2d plot.
Source code in navis/core/base.py
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
|
plot3d
#
Plot neuron using navis.plot3d
.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
DEFAULT: |
See Also
navis.plot3d
Function called to generate 3d plot.
Examples:
>>> import navis
>>> nl = navis.example_neurons()
>>> #Plot with connectors
>>> viewer = nl.plot3d(connectors=True)
Source code in navis/core/base.py
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 |
|
summary
#
Get a summary of this neuron.
Source code in navis/core/base.py
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
|
navis.Dotprops
#
Neuron represented as points + local vectors.
Dotprops consist of points with x/y/z coordinates, a tangent vector and an alpha value describing the immediate neighbourhood (see also references).
Typically constructed using navis.make_dotprops
.
References
Masse N.Y., Cachero S., Ostrovsky A., and Jefferis G.S.X.E. (2012). A mutual information approach to automate identification of neuronal clusters in Drosophila brain images. Frontiers in Neuroinformatics 6 (00021). doi: 10.3389/fninf.2012.00021
PARAMETER | DESCRIPTION |
---|---|
points |
TYPE: |
k |
TYPE: |
vect |
TYPE: |
alpha |
TYPE: |
units |
TYPE: |
**metadata |
DEFAULT: |
Source code in navis/core/dotprop.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 |
|
alpha
property
writable
#
Alpha value for tangent vectors (optional).
bbox: np.ndarray
property
#
Bounding box (includes connectors).
datatables: List[str]
property
#
Names of all DataFrames attached to this neuron.
kdtree
property
#
KDTree for points.
points
property
writable
#
Center of tangent vectors.
sampling_resolution
property
#
Mean distance between points.
soma: Optional[int]
property
writable
#
Index of soma point.
None
if no soma. You can assign either a function that accepts a Dotprops as input or a fix value. Default is None.
type: str
property
#
Neuron type.
vect
property
writable
#
Tangent vectors.
__init__
#
Initialize Dotprops Neuron.
Source code in navis/core/dotprop.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
|
copy
#
Return a copy of the dotprops.
RETURNS | DESCRIPTION |
---|---|
Dotprops | |
Source code in navis/core/dotprop.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
|
dist_dots
#
Query this Dotprops against another.
This function is mainly for navis.nblast
.
PARAMETER | DESCRIPTION |
---|---|
other | TYPE: |
alpha |
TYPE: |
distance_upper_bound |
TYPE: |
kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
dist | For each point in |
dotprods | Dotproduct of each pair of closest points between |
alpha_prod | Dotproduct of each pair of closest points between |
Source code in navis/core/dotprop.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
downsample
#
Downsample the neuron by given factor.
PARAMETER | DESCRIPTION |
---|---|
factor |
TYPE: |
inplace |
TYPE: |
**kwargs |
DEFAULT: |
See Also
navis.downsample_neuron
Base function. See for details and examples.
Source code in navis/core/dotprop.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
drop_fluff
#
Remove fluff from neuron.
By default, this function will remove all but the largest connected component from the neuron. You can change that behavior using the keep_size
and n_largest
parameters.
PARAMETER | DESCRIPTION |
---|---|
epsilon |
TYPE: |
keep_size |
TYPE: |
n_largest |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Dotprops | Only if |
See Also
navis.drop_fluff
Base function. See for details and examples.
Source code in navis/core/dotprop.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
|
recalculate_tangents
#
Recalculate tangent vectors and alpha with a new k
.
PARAMETER | DESCRIPTION |
---|---|
k |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Dotprops | Only if |
Source code in navis/core/dotprop.py
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
|
snap
#
Snap xyz location(s) to closest point or synapse.
PARAMETER | DESCRIPTION |
---|---|
locs |
TYPE: |
to |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
ix | Index/Indices of the closest point/connector. TYPE: |
dist | Distance(s) to the closest point/connector. TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> dp = navis.make_dotprops(n, k=5)
>>> ix, dist = dp.snap([0, 0, 0])
>>> ix
1123
Source code in navis/core/dotprop.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
|
to_skeleton
#
Turn Dotprop into a TreeNeuron.
This does not skeletonize the neuron but rather generates a line segment for each point based on the tangent vector. This is mainly used under the hood for plotting. Also note that only minimal meta data is carried over.
For proper skeletonization see navis.skeletonize
.
PARAMETER | DESCRIPTION |
---|---|
scale_vec |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Source code in navis/core/dotprop.py
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 |
|
navis.MeshNeuron
#
Neuron represented as mesh with vertices and faces.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
units |
TYPE: |
process |
TYPE: |
validate |
TYPE: |
**metadata |
DEFAULT: |
Source code in navis/core/mesh.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
|
bbox: np.ndarray
property
#
Bounding box (includes connectors).
faces
property
writable
#
Faces making up the neuron.
graph: nx.DiGraph
property
#
Networkx Graph representation of the vertex connectivity.
igraph: igraph.Graph
property
#
iGraph representation of the vertex connectivity.
sampling_resolution: float
property
#
Average distance between vertices.
skeleton: TreeNeuron
property
writable
#
Skeleton representation of this neuron.
soma
property
#
Not implemented for MeshNeurons - use .soma_pos
.
soma_pos
property
writable
#
X/Y/Z position of the soma.
Returns None
if no soma.
trimesh
property
#
Trimesh representation of the neuron.
type: str
property
#
Neuron type.
vertices
property
writable
#
Vertices making up the neuron.
volume: float
property
#
Volume of the neuron.
Calculated from the surface integral. Garbage if neuron is not watertight.
__init__
#
Initialize Mesh Neuron.
Source code in navis/core/mesh.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
copy
#
Return a copy of the neuron.
Source code in navis/core/mesh.py
400 401 402 403 404 405 406 407 408 409 |
|
skeletonize
#
Skeletonize mesh.
See navis.conversion.mesh2skeleton
for details.
PARAMETER | DESCRIPTION |
---|---|
method |
TYPE: |
heal |
TYPE: |
inv_dist |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
skeleton | TYPE: |
Source code in navis/core/mesh.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
|
snap
#
Snap xyz location(s) to closest vertex or synapse.
PARAMETER | DESCRIPTION |
---|---|
locs |
TYPE: |
to |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
ix | Index/indices of the closest vertex/connector. TYPE: |
dist | Distance(s) to the closest vertex/connector. TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='mesh')
>>> ix, dist = n.snap([0, 0, 0])
>>> ix
4134
Source code in navis/core/mesh.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
|
validate
#
Use trimesh to try and fix some common mesh issues.
See navis.fix_mesh
for details.
Source code in navis/core/mesh.py
485 486 487 488 489 490 491 |
|
navis.Neuron
#
Constructor for Neuron objects. Depending on the input, either a TreeNeuron
or a MeshNeuron
is returned.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
**metadata |
DEFAULT: |
See Also
navis.read_swc
Gives you more control over how data is extracted from SWC file. navis.example_neurons
Loads some example neurons provided.
Source code in navis/core/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
navis.NeuronConnector
#
Class which creates a connectivity graph from a set of neurons.
Connectivity is determined by shared IDs in the connectors
table.
Add neurons with the add_neuron
and add_neurons
methods. Alternatively, supply an iterable of neurons in the constructor. Neurons must have unique names.
See the to_(multi)digraph
method for output.
Source code in navis/connectivity/adjacency.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
add_neuron
#
Add a single neuron to the connector.
All neurons must have unique names.
PARAMETER | DESCRIPTION |
---|---|
nrn | TYPE: |
RETURNS | DESCRIPTION |
---|---|
Modified connector. | |
Source code in navis/connectivity/adjacency.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
add_neurons
#
Add several neurons to the connector.
All neurons must have unique names.
PARAMETER | DESCRIPTION |
---|---|
nrns | TYPE: |
RETURNS | DESCRIPTION |
---|---|
Modified connector. | |
Source code in navis/connectivity/adjacency.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
edges
#
Iterate through all synapse edges.
PARAMETER | DESCRIPTION |
---|---|
include_other | Include edges for which only one partner is known, by default True. If included, the name of the unknown partner will be TYPE: |
YIELDS | DESCRIPTION |
---|---|
tuple[int, str, str, int, int] | Connector ID, source name, target name, source treenode, target treenode. |
Source code in navis/connectivity/adjacency.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
to_adjacency
#
Create an adjacency matrix of neuron connectivity.
PARAMETER | DESCRIPTION |
---|---|
include_other | Whether to include a node called TYPE: |
RETURNS | DESCRIPTION |
---|---|
pandas.DataFrame | Row index is source neuron name, column index is target neuron name, cells are the number of synapses from source to target. |
Source code in navis/connectivity/adjacency.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
to_digraph
#
Create a graph of neuron connectivity.
PARAMETER | DESCRIPTION |
---|---|
include_other | Whether to include a node called TYPE: |
RETURNS | DESCRIPTION |
---|---|
nx.DiGraph | The graph has data |
Source code in navis/connectivity/adjacency.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
to_multidigraph
#
Create a graph of neuron connectivity where each synapse is an edge.
PARAMETER | DESCRIPTION |
---|---|
include_other | Whether to include a node called TYPE: |
RETURNS | DESCRIPTION |
---|---|
nx.MultiDiGraph | The nodes have data |
Source code in navis/connectivity/adjacency.py
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 |
|
navis.NeuronList
#
Collection of neurons.
Gives quick access to neurons' attributes and functions.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
make_copy |
TYPE: |
make_using |
TYPE: |
parallel |
TYPE: |
n_cores |
|
**kwargs |
DEFAULT: |
Source code in navis/core/neuronlist.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 765 766 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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
bbox
property
#
Bounding box across all neurons in the list.
empty
property
#
Return True if NeuronList is empty.
is_degenerated
property
#
Return True if contains neurons with non-unique IDs.
is_mixed
property
#
Return True if contains more than one type of neuron.
neurons
property
#
Neurons contained in this NeuronList.
shape
property
#
Shape of NeuronList (N, ).
types
property
#
Return neuron types present in this list.
add_metadata
#
Add neuron metadata from a DataFrame.
PARAMETER | DESCRIPTION |
---|---|
meta |
TYPE: |
id_col |
TYPE: |
neuron_id |
TYPE: |
columns |
TYPE: |
register |
TYPE: |
missing |
TYPE: |
See Also
navis.NeuronList.set_neuron_attributes Set individual attributes of neurons contained in the NeuronList.
Source code in navis/core/neuronlist.py
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 |
|
append
#
Add neuron(s) to this list.
Examples:
>>> import navis
>>> # This is mostly for doctests
>>> nl = navis.example_neurons()
>>> len(nl)
5
>>> # Add a single neuron to the list
>>> nl.append(nl[0])
>>> len(nl)
6
>>> # Add a list of neurons to the list
>>> nl.append(nl)
>>> len(nl)
12
Source code in navis/core/neuronlist.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
|
apply
#
Apply function across all neurons in this NeuronList.
PARAMETER | DESCRIPTION |
---|---|
func |
TYPE: |
parallel |
TYPE: |
n_cores |
|
omit_failures |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
Results | |
Examples:
>>> import navis
>>> nl = navis.example_neurons()
>>> # Apply resampling function
>>> nl_rs = nl.apply(navis.resample_skeleton, resample_to=1000, inplace=False)
Source code in navis/core/neuronlist.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
|
copy
#
Return copy of this NeuronList.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
DEFAULT: |
Source code in navis/core/neuronlist.py
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 |
|
get_neuron_attributes
#
Get attributes of neurons contained in the NeuronList.
PARAMETER | DESCRIPTION |
---|---|
name |
TYPE: |
default |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
np.ndarray | Array of values for the requested attribute. |
Source code in navis/core/neuronlist.py
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
|
head
#
Return summary for top N neurons.
Source code in navis/core/neuronlist.py
986 987 988 |
|
itertuples
#
Helper to mimic pandas.DataFrame.itertuples()
.
Source code in navis/core/neuronlist.py
790 791 792 |
|
mean
#
Return mean numeric and boolean values over all neurons.
Source code in navis/core/neuronlist.py
645 646 647 |
|
memory_usage
#
Return estimated size in memory of this NeuronList.
Works by going over each neuron and summing up their size in memory.
PARAMETER | DESCRIPTION |
---|---|
deep |
TYPE: |
estimate |
TYPE: |
sample |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
int | Memory usage in bytes. |
Source code in navis/core/neuronlist.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
|
plot2d
#
Plot neuron in 2D using navis.plot2d
.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
DEFAULT: |
See Also
navis.plot2d
Base function called to generate 2d plot.
Source code in navis/core/neuronlist.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
|
plot3d
#
Plot neuron in 3D using navis.plot3d
.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
DEFAULT: |
See Also
navis.plot3d
Base function called to generate 3d plot.
Source code in navis/core/neuronlist.py
701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
|
remove_duplicates
#
Remove duplicate neurons from list.
PARAMETER | DESCRIPTION |
---|---|
key |
TYPE: |
keep |
TYPE: |
inplace |
TYPE: |
Source code in navis/core/neuronlist.py
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 |
|
sample
#
Return random subset of neurons.
Source code in navis/core/neuronlist.py
691 692 693 694 695 696 697 698 699 |
|
set_neuron_attributes
#
Set attributes of neurons contained in the NeuronList.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
name |
TYPE: |
register |
TYPE: |
na |
TYPE: |
See Also
navis.NeuronList.add_metadata Set metadata from a dataframe.
Examples:
>>> import navis
>>> nl = navis.example_neurons(5)
>>> # Set a single value
>>> nl.set_neuron_attributes('some_value', name='my_attr')
>>> nl[0].my_attr
'some_value'
>>> # Set individual values as iterable
>>> nl.set_neuron_attributes([1, 2, 3, 4, 5], name='my_attr')
>>> nl[0].my_attr
1
>>> nl.my_attr
array([1, 2, 3, 4, 5])
>>> # Set individual values using a dictionary
>>> val_dict = dict(zip(nl.id, ['test', 2, 2.2, 4, 'test2']))
>>> nl.set_neuron_attributes(val_dict, name='my_attr')
>>> nl[0].my_attr
'test'
Source code in navis/core/neuronlist.py
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 |
|
sort_values
#
Sort neurons by given key.
Needs to be an attribute of all neurons: for example name
. Also works with custom attributes.
Source code in navis/core/neuronlist.py
955 956 957 958 959 960 961 962 963 |
|
sum
#
Return sum numeric and boolean values over all neurons.
Source code in navis/core/neuronlist.py
641 642 643 |
|
summary
#
Get summary over all neurons in this NeuronList.
PARAMETER | DESCRIPTION |
---|---|
N |
TYPE: |
add_props |
TYPE: |
progress |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pandas DataFrame | |
Source code in navis/core/neuronlist.py
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 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
|
tail
#
Return summary for bottom N neurons.
Source code in navis/core/neuronlist.py
990 991 992 |
|
unmix
#
Split into NeuronLists of the same neuron type.
RETURNS | DESCRIPTION |
---|---|
dict | Dictionary of |
Source code in navis/core/neuronlist.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
navis.TreeNeuron
#
Neuron represented as hierarchical tree (i.e. a skeleton).
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
units |
TYPE: |
**metadata |
DEFAULT: |
Source code in navis/core/skeleton.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 765 766 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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
|
adjacency_matrix
property
#
Adjacency matrix of the skeleton.
bbox: np.ndarray
property
#
Bounding box (includes connectors).
branch_points
property
#
Branch node table.
cable_length: Union[int, float]
property
#
Cable length.
connectors: pd.DataFrame
property
writable
#
Connector table. If none, will return None
.
cycles: Optional[List[int]]
property
#
Cycles in neuron (if any).
See also
networkx.find_cycles() Function used to find cycles.
edge_coords: np.ndarray
property
#
Coordinates of edges between nodes.
See Also
edges Same but with node IDs instead of x/y/z coordinates.
edges: np.ndarray
property
#
Edges between nodes.
See Also
edge_coords Same but with x/y/z coordinates instead of node IDs.
ends
property
#
End node table (same as leafs).
geodesic_matrix
property
#
Matrix with geodesic (along-the-arbor) distance between nodes.
graph: nx.DiGraph
property
#
Networkx Graph representation of this neuron.
igraph: igraph.Graph
property
#
iGraph representation of this neuron.
is_tree: bool
property
#
Whether neuron is a tree.
Also returns True if neuron consists of multiple separate trees!
See also
networkx.is_forest() Function used to test whether neuron is a tree. :attr:TreeNeuron.cycles
If your neuron is not a tree, this will help you identify cycles.
leafs: pd.DataFrame
property
#
Leaf node table.
n_branches: Optional[int]
property
#
Number of branch points.
n_leafs: Optional[int]
property
#
Number of leaf nodes.
n_skeletons: int
property
#
Number of seperate skeletons in this neuron.
n_trees: int
property
#
Count number of connected trees in this neuron.
nodes: pd.DataFrame
property
writable
#
Node table.
root: Sequence
property
writable
#
Root node(s).
sampling_resolution: float
property
#
Average cable length between child -> parent nodes.
segments: List[list]
property
#
Neuron broken down into linear segments (see also .small_segments
).
simple: TreeNeuron
property
#
Simplified representation consisting only of root, branch points and leafs.
small_segments: List[list]
property
#
Neuron broken down into small linear segments (see also .segments
).
soma: Optional[Union[str, int]]
property
writable
#
Search for soma and return node ID(s).
None
if no soma. You can assign either a function that accepts a TreeNeuron as input or a fix value. The default is navis.find_soma
.
soma_pos: Optional[Sequence]
property
writable
#
Search for soma and return its position.
Returns None
if no soma. You can also use this to assign a soma by position in which case it will snap to the closest node.
subtrees: List[List[int]]
property
#
List of subtrees. Sorted by size as sets of node IDs.
surface_area: float
property
#
Radius-based lateral surface area.
type: str
property
#
Neuron type.
vertices: np.ndarray
property
#
Vertices of the skeleton.
volume: float
property
#
Radius-based volume.
__init__
#
Initialize Skeleton Neuron.
Source code in navis/core/skeleton.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
cell_body_fiber
#
Prune neuron to its cell body fiber.
PARAMETER | DESCRIPTION |
---|---|
reroot_soma |
TYPE: |
inplace |
TYPE: |
See Also
navis.cell_body_fiber
This is the base function. See for details and examples.
Source code in navis/core/skeleton.py
1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
|
copy
#
Return a copy of the neuron.
PARAMETER | DESCRIPTION |
---|---|
deepcopy |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Source code in navis/core/skeleton.py
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 |
|
downsample
#
downsample
downsample
Downsample the neuron by given factor.
PARAMETER | DESCRIPTION |
---|---|
factor |
TYPE: |
inplace |
TYPE: |
**kwargs |
DEFAULT: |
See Also
navis.downsample_neuron
Base function. See for details and examples.
Source code in navis/core/skeleton.py
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
|
get_graph_nx
#
Calculate and return networkX representation of neuron.
Once calculated stored as .graph
. Call function again to update graph.
See Also
Source code in navis/core/skeleton.py
872 873 874 875 876 877 878 879 880 881 882 883 884 |
|
get_igraph
#
Calculate and return iGraph representation of neuron.
Once calculated stored as .igraph
. Call function again to update iGraph.
Important
Returns None
if igraph is not installed!
See Also
Source code in navis/core/skeleton.py
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 |
|
prune_at_depth
#
Prune all neurites past a given distance from a source.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
depth |
TYPE: |
source |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Pruned neuron(s). |
See Also
navis.prune_at_depth
This is the base function. See for details and examples.
Source code in navis/core/skeleton.py
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 |
|
prune_by_longest_neurite
#
Prune neuron down to the longest neurite.
PARAMETER | DESCRIPTION |
---|---|
n |
TYPE: |
reroot_soma |
TYPE: |
inplace |
TYPE: |
See Also
navis.longest_neurite
This is the base function. See for details and examples.
Source code in navis/core/skeleton.py
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 |
|
prune_by_strahler
#
Prune neuron based on Strahler order.
Will reroot neuron to soma if possible.
PARAMETER | DESCRIPTION |
---|---|
to_prune |
TYPE: |
inplace |
TYPE: |
See Also
navis.prune_by_strahler
This is the base function. See for details and examples.
Source code in navis/core/skeleton.py
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 |
|
prune_by_volume
#
Prune neuron by intersection with given volume(s).
PARAMETER | DESCRIPTION |
---|---|
v |
TYPE: |
mode |
TYPE: |
prevent_fragments |
TYPE: |
inplace |
TYPE: |
See Also
navis.in_volume
Base function. See for details and examples.
Source code in navis/core/skeleton.py
1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 |
|
prune_distal_to
#
Cut off nodes distal to given nodes.
PARAMETER | DESCRIPTION |
---|---|
node |
TYPE: |
inplace |
TYPE: |
See Also
navis.cut_skeleton
Base function. See for details and examples.
Source code in navis/core/skeleton.py
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
|
prune_proximal_to
#
Remove nodes proximal to given node. Reroots neuron to cut node.
PARAMETER | DESCRIPTION |
---|---|
node |
TYPE: |
inplace |
TYPE: |
See Also
navis.cut_skeleton
Base function. See for details and examples.
Source code in navis/core/skeleton.py
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
|
prune_twigs
#
Prune terminal twigs under a given size.
PARAMETER | DESCRIPTION |
---|---|
size |
TYPE: |
inplace |
TYPE: |
recursive |
TYPE: |
See Also
navis.prune_twigs
This is the base function. See for details and examples.
Source code in navis/core/skeleton.py
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 |
|
reload
#
Reload neuron. Must have filepath as .origin
as attribute.
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | If |
Source code in navis/core/skeleton.py
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 |
|
reroot
#
Reroot neuron to given node ID or node tag.
PARAMETER | DESCRIPTION |
---|---|
new_root |
TYPE: |
inplace |
TYPE: |
See Also
navis.reroot_skeleton
Base function. See for details and examples.
Source code in navis/core/skeleton.py
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 |
|
resample
#
resample
resample
Resample neuron to given resolution.
PARAMETER | DESCRIPTION |
---|---|
resample_to |
TYPE: |
inplace |
TYPE: |
See Also
navis.resample_skeleton
Base function. See for details and examples.
Source code in navis/core/skeleton.py
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
|
snap
#
Snap xyz location(s) to closest node or synapse.
PARAMETER | DESCRIPTION |
---|---|
locs |
TYPE: |
to |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
id | ID(s) of the closest node/connector. TYPE: |
dist | Distance(s) to the closest node/connector. TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> id, dist = n.snap([0, 0, 0])
>>> id
1124
Source code in navis/core/skeleton.py
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 |
|
to_swc
#
Generate SWC file from this neuron.
PARAMETER | DESCRIPTION |
---|---|
filename |
TYPE: |
kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
Nothing | |
See Also
navis.write_swc
See this function for further details.
Source code in navis/core/skeleton.py
1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 |
|
navis.Viewer
#
Vispy 3D viewer.
PARAMETER | DESCRIPTION |
---|---|
picking |
TYPE: |
**kwargs |
DEFAULT: |
ATTRIBUTE | DESCRIPTION |
---|---|
picking | Set to TYPE: |
selected | List of currently selected neurons. Can also be used to set the selection. |
show_legend | Set to TYPE: |
legend_font_size | Font size for legend. TYPE: |
Examples:
This viewer is what navis.plot3d
uses when backend='vispy'
. Instead of navis.plot3d
we can interact with the viewer directly:
>>> # Open a 3D viewer
>>> import navis
>>> v = navis.Viewer()
>>> # Close the 3D viewer
>>> v.close()
You can change the background color from the start or on-the-go:
>>> # Set background to green
>>> v = navis.Viewer(bgcolor='green')
>>> # Set background back to white
>>> v.set_bgcolor((1, 1, 1))
>>> # Alternative to v.close():
>>> navis.close3d()
Source code in navis/plotting/vispy/viewer.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 765 766 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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 |
|
bounds
property
#
Bounds of all currently visuals (visible and invisible).
canvas = scene.SceneCanvas(**defaults)
instance-attribute
#
from PyQt5.QtWidgets import QPushButton
Create canvas#
button = QPushButton('PyQt5 button', self.canvas.native) button.move(10, 10) self.canvas.show()
invisible
property
#
List IDs of currently visible neurons.
legend_font_size
property
writable
#
Change legend's font size.
neurons
property
#
Return visible and invisible neuron visuals currently on the canvas.
RETURNS | DESCRIPTION |
---|---|
OrderedDict |
|
objects
property
#
Ordered dictionary {uuid->[visuals]} of all objects in order of addition.
picking
property
writable
#
Set to True
to allow picking.
pinned
property
#
List IDs of currently pinned neurons.
selected
property
writable
#
Return IDs of or set selected neurons.
show_bounds
property
writable
#
Set to True
to show bounding box.
show_legend
property
writable
#
Set to True
to hide neuron legend.
size
property
writable
#
Size of canvas.
visible
property
#
List IDs of currently visible neurons.
visuals
property
#
List of all 3D visuals on this canvas.
add
#
Add objects to canvas.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
center |
TYPE: |
clear |
TYPE: |
combine |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
None | |
Source code in navis/plotting/vispy/viewer.py
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 765 766 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 |
|
center_camera
#
Center camera on visuals.
Source code in navis/plotting/vispy/viewer.py
718 719 720 721 722 723 724 725 726 727 728 729 730 |
|
clear
#
Clear canvas.
Source code in navis/plotting/vispy/viewer.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
|
clear_legend
#
Clear legend.
Source code in navis/plotting/vispy/viewer.py
534 535 536 537 538 |
|
close
#
Close viewer.
Source code in navis/plotting/vispy/viewer.py
817 818 819 820 821 822 823 824 825 826 827 |
|
colorize
#
Colorize neurons using a seaborn color palette.
Source code in navis/plotting/vispy/viewer.py
1047 1048 1049 1050 1051 1052 1053 |
|
hide_neurons
#
Hide given neuron(s).
Source code in navis/plotting/vispy/viewer.py
829 830 831 832 833 834 835 836 837 838 839 840 841 |
|
hide_selected
#
Hide currently selected neuron(s).
Source code in navis/plotting/vispy/viewer.py
843 844 845 |
|
pin_neurons
#
Pin given neuron(s).
Changes to the color or visibility of pinned neurons are silently ignored. You can use this to keep specific neurons visible while cycling through the rest - useful for comparisons.
Source code in navis/plotting/vispy/viewer.py
878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
pop
#
Remove the most recently added N visuals.
Source code in navis/plotting/vispy/viewer.py
575 576 577 578 |
|
remove
#
Remove given neurons/visuals from canvas.
Source code in navis/plotting/vispy/viewer.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
|
remove_bounds
#
Remove bounding box visual.
Source code in navis/plotting/vispy/viewer.py
601 602 603 604 605 606 |
|
screenshot
#
Save a screenshot of this viewer.
PARAMETER | DESCRIPTION |
---|---|
filename |
TYPE: |
pixel_scale |
TYPE: |
alpha |
TYPE: |
hide_overlay |
TYPE: |
Source code in navis/plotting/vispy/viewer.py
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
|
set_alpha
#
Set neuron color alphas.
PARAMETER | DESCRIPTION |
---|---|
a |
TYPE: |
Source code in navis/plotting/vispy/viewer.py
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
set_bgcolor
#
Set background color.
Source code in navis/plotting/vispy/viewer.py
1055 1056 1057 1058 1059 |
|
set_colors
#
Set neuron color.
PARAMETER | DESCRIPTION |
---|---|
c |
TYPE: |
Source code in navis/plotting/vispy/viewer.py
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
|
set_view
#
(Re-)set camera position.
PARAMETER | DESCRIPTION |
---|---|
view | TYPE: |
Source code in navis/plotting/vispy/viewer.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 |
|
show
#
Show viewer.
Source code in navis/plotting/vispy/viewer.py
803 804 805 806 807 808 809 810 811 812 813 814 815 |
|
toggle_bounds
#
Toggle bounding box.
Source code in navis/plotting/vispy/viewer.py
585 586 587 |
|
toggle_neurons
#
Toggle neuron(s) visibility.
Source code in navis/plotting/vispy/viewer.py
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 |
|
toggle_overlay
#
Toggle legend on and off.
Source code in navis/plotting/vispy/viewer.py
714 715 716 |
|
toggle_picking
#
Toggle picking and overlay text.
Source code in navis/plotting/vispy/viewer.py
352 353 354 355 356 357 358 359 |
|
toggle_select
#
Toggle selected of given neuron.
Source code in navis/plotting/vispy/viewer.py
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
|
unhide_neurons
#
Unhide given neuron(s).
Use n
to unhide specific neurons.
Source code in navis/plotting/vispy/viewer.py
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 |
|
unpin_neurons
#
Unpin given neuron(s).
Use n
to unhide specific neurons.
Source code in navis/plotting/vispy/viewer.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 |
|
update_bounds
#
Update bounding box visual.
Source code in navis/plotting/vispy/viewer.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
|
update_legend
#
Update legend.
Source code in navis/plotting/vispy/viewer.py
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 |
|
visuals_at
#
List visuals at given canvas position.
Source code in navis/plotting/vispy/viewer.py
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 |
|
navis.Volume
#
Mesh consisting of vertices and faces.
Subclass of trimesh.Trimesh
with a few additional methods.
PARAMETER | DESCRIPTION |
---|---|
vertices |
TYPE: |
faces |
TYPE: |
name |
TYPE: |
color |
TYPE: |
id |
TYPE: |
**kwargs |
DEFAULT: |
See Also
navis.example_volume
Loads example volume(s).
Source code in navis/core/volumes.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
|
bbox: np.ndarray
property
#
Bounding box of this volume.
center: np.ndarray
property
#
Center of mass.
color
property
writable
#
Color used for plotting.
id
property
writable
#
ID of this volume.
name
property
writable
#
Name of this volume.
verts: np.ndarray
property
writable
#
Legacy access to .vertices
.
combine
classmethod
#
Merge multiple volumes into a single object.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
name |
TYPE: |
color |
|
RETURNS | DESCRIPTION |
---|---|
[`navis.Volume`][] | |
Source code in navis/core/volumes.py
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 |
|
from_csv
classmethod
#
Load volume from csv files containing vertices and faces.
PARAMETER | DESCRIPTION |
---|---|
vertices |
TYPE: |
faces |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.Volume | |
Source code in navis/core/volumes.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
from_file
classmethod
#
Load volume from file.
PARAMETER | DESCRIPTION |
---|---|
filename |
TYPE: |
import_kwargs |
TYPE: |
**init_kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.Volume | |
Source code in navis/core/volumes.py
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 |
|
from_json
classmethod
#
Load volume from json file containing vertices and faces.
PARAMETER | DESCRIPTION |
---|---|
filename | TYPE: |
import_kwargs |
TYPE: |
**init_kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.Volume | |
Source code in navis/core/volumes.py
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 |
|
from_object
classmethod
#
Load volume from generic object that has .vertices
and .faces
attributes.
PARAMETER | DESCRIPTION |
---|---|
obj | TYPE: |
**init_kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.Volume | |
Source code in navis/core/volumes.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
plot3d
#
Plot volume using navis.plot3d
.
PARAMETER | DESCRIPTION |
---|---|
**kwargs |
DEFAULT: |
See Also
navis.plot3d
Function called to generate 3d plot.
Examples:
>>> import navis
>>> vol = navis.example_volume('LH')
>>> v = vol.plot3d(color = (255, 0, 0))
Source code in navis/core/volumes.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
resize
#
Resize volume.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
method |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
[`navis.Volume`][] | Resized copy of original volume. Only if |
None | If |
Source code in navis/core/volumes.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
|
show
#
See .plot3d
.
Source code in navis/core/volumes.py
550 551 552 553 |
|
to_2d
#
Compute the 2d alpha shape (concave hull) this volume.
Uses Scipy Delaunay and shapely.
PARAMETER | DESCRIPTION |
---|---|
alpha |
TYPE: |
view |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
list | Coordinates of 2d circumference e.g. |
Source code in navis/core/volumes.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|
to_csv
#
Save volume as two separated csv files containing vertices and faces.
PARAMETER | DESCRIPTION |
---|---|
filename |
TYPE: |
**kwargs |
DEFAULT: |
Source code in navis/core/volumes.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
to_json
#
Save volume as json file.
PARAMETER | DESCRIPTION |
---|---|
filename |
TYPE: |
Source code in navis/core/volumes.py
280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
validate
#
Use trimesh to try and fix issues (holes/normals).
Source code in navis/core/volumes.py
673 674 675 676 677 678 679 680 681 682 683 684 |
|
navis.VoxelNeuron
#
Neuron represented as voxels.
PARAMETER | DESCRIPTION |
---|---|
x |
|
offset |
TYPE: |
cache |
TYPE: |
units |
TYPE: |
**metadata |
DEFAULT: |
Source code in navis/core/voxel.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
|
bbox: np.ndarray
property
#
Bounding box (includes connectors) in units.
density: float
property
#
Fraction of filled voxels.
dtype: type
property
#
Data type of voxel values.
grid
property
writable
#
Voxel grid representation.
nnz: int
property
#
Number of non-zero voxels.
offset: np.ndarray
property
writable
#
Offset (in voxels).
shape
property
#
Shape of voxel grid.
type: str
property
#
Neuron type.
values
property
writable
#
Values for each voxel (can be None).
volume: float
property
#
Volume of neuron.
voxels
property
writable
#
Voxels making up the neuron.
__init__
#
Initialize Voxel Neuron.
Source code in navis/core/voxel.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
copy
#
Return a copy of the neuron.
Source code in navis/core/voxel.py
396 397 398 399 400 401 402 403 404 405 |
|
count_nonzero
#
Count non-zero voxels.
Source code in navis/core/voxel.py
387 388 389 390 391 392 393 394 |
|
max
#
Maximum value (excludes zeros).
Source code in navis/core/voxel.py
450 451 452 |
|
min
#
Minimum value (excludes zeros).
Source code in navis/core/voxel.py
446 447 448 |
|
strip
#
Strip empty voxels (leading/trailing planes of zeros).
Source code in navis/core/voxel.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
threshold
#
Drop below-threshold voxels.
Source code in navis/core/voxel.py
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
|
navis.arbor_segregation_index
#
Per arbor seggregation index (SI).
The segregation index (SI) as established by Schneider-Mizell et al. (eLife, 2016) is a measure for how polarized a neuron is. SI of 1 indicates total segregation of inputs and outputs into dendrites and axon, respectively. SI of 0 indicates homogeneous distribution. Here, we apply this to each arbour within a neuron by asking "If we were to cut a neuron at this node, what would the SI of the two resulting fragments be?"
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neuron | Adds "segregation_index" as column in the node table (for TreeNeurons) or as |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.reroot(n.soma, inplace=True)
>>> _ = navis.arbor_segregation_index(n)
>>> n.nodes.segregation_index.max().round(3)
0.277
See Also
navis.segregation_index
Calculate segregation score (polarity) between two fragments of a neuron. navis.synapse_flow_centrality
Calculate synapse flow centrality after Schneider-Mizell et al. navis.bending_flow
Variation on the Schneider-Mizell et al. synapse flow. navis.split_axon_dendrite
Split the neuron into axon, dendrite and primary neurite.
Source code in navis/morpho/mmetrics.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
|
navis.average_skeletons
#
Compute an average from a list of skeletons.
This is a very simple implementation which may give odd results if used on complex neurons. Works fine on e.g. backbones or tracts.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
limit |
TYPE: |
base_neuron |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Examples:
>>> # Get a bunch of neurons
>>> import navis
>>> da2 = navis.example_neurons()
>>> # Prune down to longest neurite
>>> for n in da2:
... if n.has_soma:
... n.reroot(n.soma, inplace=True)
>>> da2_pr = da2.prune_by_longest_neurite(inplace=False)
>>> # Make average
>>> da2_avg = navis.average_skeletons(da2_pr, limit=10e3)
>>> # Plot
>>> da2.plot3d()
>>> da2_avg.plot3d()
Source code in navis/morpho/manipulation.py
1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 |
|
navis.bending_flow
#
Calculate synapse "bending" flow.
This is a variation of the algorithm for calculating synapse flow from Schneider-Mizell et al. (eLife, 2016).
The way this implementation works is by iterating over each branch point and counting the number of pre->post synapse paths that "flow" from one child branch to the other(s).
Notes
This is algorithm appears to be more reliable than synapse flow centrality for identifying the main branch point for neurons that have incompletely annotated synapses.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neuron | Adds "bending_flow" as column in the node table (for TreeNeurons) or as |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.reroot(n.soma, inplace=True)
>>> _ = navis.bending_flow(n)
>>> n.nodes.bending_flow.max()
785645
See Also
navis.synapse_flow_centrality
Calculate synapse flow centrality after Schneider-Mizell et al. navis.segregation_index
Calculate segregation score (polarity). navis.arbor_segregation_index
Calculate the a by-arbor segregation index. navis.split_axon_dendrite
Split the neuron into axon, dendrite and primary neurite.
Source code in navis/morpho/mmetrics.py
666 667 668 669 670 671 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 765 766 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 |
|
navis.betweeness_centrality
#
Calculate vertex/node betweenness.
Betweenness is (roughly) defined by the number of shortest paths going through a vertex or an edge.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
from_ |
TYPE: |
directed |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neuron | Adds "betweenness" as column in the node table (for TreeNeurons) or as |
Examples:
>>> import navis
>>> n = navis.example_neurons(2, kind='skeleton')
>>> n.reroot(n.soma, inplace=True)
>>> _ = navis.betweeness_centrality(n)
>>> n[0].nodes.betweenness.max()
436866
>>> m = navis.example_neurons(1, kind='mesh')
>>> _ = navis.betweeness_centrality(m)
>>> m.betweenness.max()
59637
Source code in navis/morpho/mmetrics.py
1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 |
|
navis.break_fragments
#
Break neuron into its connected components.
Neurons can consists of several disconnected fragments. This function turns these fragments into separate neurons.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
labels_only |
TYPE: |
min_size |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
NeuronList | |
See Also
navis.heal_skeleton
Use to heal fragmentation instead of breaking it up.
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> # Artifically disconnect parts of the neuron
>>> n.nodes.loc[100, 'parent_id'] = -1
>>> # Break into fragments
>>> frags = navis.break_fragments(n)
>>> len(frags)
2
Source code in navis/morpho/manipulation.py
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 |
|
navis.cable_overlap
#
Calculate the amount of cable of neuron A within distance of neuron B.
PARAMETER | DESCRIPTION |
---|---|
a |
TYPE: |
dist |
TYPE: |
method |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pandas.DataFrame | Matrix in which neurons A are rows, neurons B are columns. Cable within distance is given in the neuron's native units:
|
See Also
navis.resample_skeleton
Use to resample neurons before calculating overlap.
Examples:
>>> import navis
>>> nl = navis.example_neurons(4)
>>> # Cable overlap is given in the neurons' units
>>> # Converting the example neurons from 8x8x8 voxel space into microns
>>> # make the results easier to interpret
>>> nl = nl.convert_units('um')
>>> # Resample to half a micron
>>> nl_res = nl.resample('.5 micron', inplace=False)
>>> # Get overlapping cable within 2 microns
>>> ol = navis.cable_overlap(nl_res[:2], nl_res[2:], dist='2 microns')
Source code in navis/connectivity/predict.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
navis.cell_body_fiber
#
Prune neuron to its cell body fiber.
Here, "cell body fiber" (CBF) refers to the tract connecting the soma to the backbone in unipolar neuron (common in e.g. insects). This function works best for typical neurons with clean skeletons.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
method |
TYPE: |
reroot_soma |
TYPE: |
heal |
TYPE: |
threshold |
TYPE: |
inverse |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Pruned neuron(s). Neurons without branches (i.e. w/ a single long segment) will be returned unaltered. |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> cbf = navis.cell_body_fiber(n, inplace=False)
>>> # Neuron now has only a single segment from the soma to the main fork
>>> len(cbf.segments)
1
See Also
navis.find_main_branchpoint
Find the main branch point.
navis.betweeness_centrality
Calculate the per-node betweeness centrality. This is used under the hood for method='betweeness'
.
Source code in navis/morpho/manipulation.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
navis.clear3d
#
Clear viewer 3D canvas.
Source code in navis/plotting/vispy/vputils.py
45 46 47 48 49 50 |
|
navis.close3d
#
Close existing 3D viewer (wipes memory).
Source code in navis/plotting/vispy/vputils.py
53 54 55 56 57 58 59 60 61 |
|
navis.combine_neurons
#
Combine multiple neurons into one.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Neuron | Combined neuron. |
See Also
navis.stitch_skeletons
Stitches multiple skeletons together to create one continuous neuron.
Examples:
Combine skeletons:
>>> import navis
>>> nl = navis.example_neurons(3)
>>> comb = navis.combine_neurons(nl)
Combine meshes:
>>> import navis
>>> nl = navis.example_neurons(3, kind='mesh')
>>> comb = navis.combine_neurons(nl)
Combine dotprops:
>>> import navis
>>> nl = navis.example_neurons(3)
>>> dp = navis.make_dotprops(nl)
>>> comb = navis.combine_neurons(dp)
Source code in navis/morpho/manipulation.py
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 |
|
navis.connectivity_similarity
#
Calculate connectivity similarity.
This functions offers a selection of metrics to compare connectivity:
- cosine: Cosine similarity (see here)
- rank_index: Normalized difference in rank of synaptic partners.
- matching_index: Number of shared partners divided by total number of partners.
-
matching_index_synapses: Number of shared synapses (i.e. number of connections from/onto the same partners) divided by total number of synapses.
Attention
This metric is tricky when there is a disparity of total number of connections between neuron A and B. For example, consider 100/200 and 1/50 shared/total synapse: 101/250 results in a fairly high matching index of 0.404.
-
matching_index_weighted_synapses: Similar to matching_index_synapses but slightly less prone to above mentioned error as it uses the percentage of shared synapses:
\[ S = \frac{\mathrm{NeuronA}_{\mathrm{sharedSynapses}}}{\mathrm{NeuronA}_{\mathrm{totalSynapses}}} \times \frac{\mathrm{NeuronB}_{\mathrm{sharedSynapses}}}{\mathrm{NeuronB}_{\mathrm{totalSynapses}}} \] -
vertex: Matching index that rewards shared and punishes non-shared partners. Based on Jarrell et al., 2012: $$ f(x,y) = min(x,y) - C1 \times max(x,y) \times \exp(-C2 * min(x,y)) $$ The final score is the sum of \(f(x,y)\) over all edges x, y between neurons A+B and their partners. C1 determines how negatively a case where one edge is much stronger than another is punished. C2 determines the point where the similarity switches from negative to positive. C1 and C2 default to 0.5 and 1, respectively, but can be changed by passing them in a dictionary as
**kwargs
. - vertex_normalized: This is vertex similarity normalized by the lowest (hypothetical total dissimilarity) and highest (all edge weights the same) achievable score.
PARAMETER | DESCRIPTION |
---|---|
adjacency |
TYPE: |
metric |
TYPE: |
threshold |
TYPE: |
n_cores |
|
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
DataFrame | Pandas DataFrame with similarity scores. Neurons without any connectivity will show up with |
Source code in navis/connectivity/similarity.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
navis.connectivity_sparseness
#
Calculate sparseness.
Sparseness comes in three flavors:
Lifetime kurtosis (LTK) quantifies the widths of tuning curves (according to Muench & Galizia, 2016):
where \(N\) is the number of observations, \(r_i\) the value of observation \(i\), and \(\overline{r}\) and \(\sigma_r\) the mean and the standard deviation of the observations' values, respectively. LTK is assuming a normal, or at least symmetric distribution.
Lifetime sparseness (LTS) quantifies selectivity (Bhandawat et al., 2007):
where \(N\) is the number of observations, and \(r_j\) is the value of an observation.
Activity ratio describes distributions with heavy tails (Rolls and Tovee, 1995).
Notes
NaN
values will be ignored. You can use that to e.g. ignore zero values in a large connectivity matrix by changing these values to NaN
before passing it to navis.sparseness
.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
which |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
sparseness |
|
Examples:
Calculate sparseness of olfactory inputs to group of neurons:
>>> import navis
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> # Get ORN response matrix from DoOR database
>>> url = 'https://raw.githubusercontent.com/ropensci/DoOR.data/master/data/door_response_matrix.csv'
>>> adj = pd.read_csv(url, delimiter=';')
>>> # Calculate lifetime sparseness
>>> S = navis.connectivity_sparseness(adj, which='LTS')
>>> # Plot distribution
>>> ax = S.plot.hist(bins=np.arange(0, 1, .1))
>>> _ = ax.set_xlabel('LTS')
>>> plt.show()
Source code in navis/connectivity/cnmetrics.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
navis.cut_skeleton
#
Split skeleton at given point and returns two new neurons.
Split is performed between cut node and its parent node. The cut node itself will still be present in both resulting neurons.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
where |
TYPE: |
ret |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
split | Fragments of the input neuron after cutting sorted such that distal parts come before proximal parts. For example, with a single cut you can expect to return a NeuronList containing two neurons: the first contains the part distal and the second the part proximal to the cut node. The distal->proximal order of fragments is tried to be maintained for multiple cuts but this is not guaranteed. TYPE: |
Examples:
Cut skeleton at a (somewhat random) branch point
>>> import navis
>>> n = navis.example_neurons(1)
>>> bp = n.nodes[n.nodes.type=='branch'].node_id.values
>>> dist, prox = navis.cut_skeleton(n, bp[0])
Make cuts at multiple branch points
>>> import navis
>>> n = navis.example_neurons(1)
>>> bp = n.nodes[n.nodes.type=='branch'].node_id.values
>>> splits = navis.cut_skeleton(n, bp[:10])
See Also
navis.TreeNeuron.prune_distal_to
navis.TreeNeuron.prune_proximal_to
TreeNeuron/List
shorthands to this function. navis.subset_neuron
Returns a neuron consisting of a subset of its nodes.
Source code in navis/graph/graph_utils.py
1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 |
|
navis.despike_skeleton
#
Remove spikes in skeleton (e.g. from jumps in image data).
For each node A, the Euclidean distance to its next successor (parent) B and that node's successor C (i.e A->B->C) is computed. If \(\frac{dist(A,B)}{dist(A,C)}>sigma\), node B is considered a spike and realigned between A and C.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
sigma |
TYPE: |
max_spike_length |
TYPE: |
inplace |
TYPE: |
reverse |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Despiked neuron(s). Only if |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> despiked = navis.despike_skeleton(n)
Source code in navis/morpho/manipulation.py
1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 |
|
navis.dist_between
#
Get the geodesic distance between nodes in nanometers.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
a |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
int | distance in nm |
See Also
navis.distal_to
Check if a node A is distal to node B. navis.geodesic_matrix
Get all-by-all geodesic distance matrix. navis.segment_length
Much faster if you have a linear segment and know all node IDs.
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> d = navis.dist_between(n,
... n.nodes.node_id.values[0],
... n.nodes.node_id.values[1])
Source code in navis/graph/graph_utils.py
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 |
|
navis.dist_to_root
#
Calculate distance to root for each node.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
weight |
TYPE: |
igraph_indices |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
dist | Dictionary with root distances. TYPE: |
Examples:
For doctest only
>>> import navis
>>> n = navis.example_neurons(1)
>>> seg = navis.graph.dist_to_root(n)
See Also
navis.geodesic_matrix
For distances between all points.
Source code in navis/graph/graph_utils.py
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 |
|
navis.distal_to
#
distal_to
distal_to
distal_to
Check if nodes A are distal to nodes B.
Important
Please note that if node A is not distal to node B, this does not automatically mean it is proximal instead: if nodes are on different branches, they are neither distal nor proximal to one another! To test for this case run a->b and b->a - if both return False
, nodes are on different branches.
Also: if a and b are the same node, this function will return True
!
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
a |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
bool | If |
pd.DataFrame | If |
Examples:
>>> import navis
>>> # Get a neuron
>>> x = navis.example_neurons(1)
>>> # Get a random node
>>> n = x.nodes.iloc[100].node_id
>>> # Check all nodes if they are distal or proximal to that node
>>> df = navis.distal_to(x, n)
>>> # Get the IDs of the nodes that are distal
>>> dist = df.loc[n, df.loc[n]].index.values
>>> len(dist)
101
For large neurons and/or large sets of a
/b
it can be much faster to use geodesic_matrix
instead:
>>> import navis
>>> import numpy as np
>>> x = navis.example_neurons(1)
>>> # Get an all-by-all distal_to
>>> df = navis.geodesic_matrix(x, weight=None, directed=True) < np.inf
>>> # Get distal_to for specific nodes
>>> df = navis.geodesic_matrix(x, weight=None, directed=True) < np.inf
>>> # Get distal_to for specific nodes
>>> a, b = x.nodes.node_id.values[:100], x.nodes.node_id.values[-100:]
>>> dist = navis.geodesic_matrix(x, weight=None, directed=True, from_=a)
>>> distal_to = dist[b] < np.inf
See Also
navis.geodesic_matrix
Depending on your neuron and how many nodes you're asking for, this function can be considerably faster! See examples.
Source code in navis/graph/graph_utils.py
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 |
|
navis.downsample_neuron
#
Downsample neuron(s) by a given factor.
For skeletons: preserves root, leafs, branchpoints by default. Preservation of nodes with synapses can be toggled - see preserve_nodes
parameter. Use downsampling_factor=float('inf')
to get a skeleton consisting only of root, branch and end points.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
downsampling_factor |
TYPE: |
preserve_nodes |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / Dotprops / VoxelNeurons / NeuronList | Same datatype as input. |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n_ds = navis.downsample_neuron(n,
... downsampling_factor=5,
... inplace=False)
>>> n.n_nodes > n_ds.n_nodes
True
See Also
navis.resample_skeleton
This function resamples a neuron to given resolution. This will change node IDs! navis.simplify_mesh
This is the function used for MeshNeurons
. Use directly for more control of the simplification.
Source code in navis/sampling/downsampling.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
navis.drop_fluff
#
Remove small disconnected pieces of "fluff".
By default, this function will remove all but the largest connected component from the neuron. You can change that behavior using the keep_size
and n_largest
parameters. Connectors (if present) will be remapped to the closest surviving vertex/node.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
keep_size |
TYPE: |
n_largest |
TYPE: |
epsilon |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Neuron / List | Neuron(s) without fluff. |
Examples:
>>> import navis
>>> m = navis.example_neurons(1, kind='mesh')
>>> m.n_vertices
6309
>>> # Remove all but the largest connected component
>>> top = navis.drop_fluff(m)
>>> top.n_vertices
5951
>>> # Keep the ten largest connected components
>>> two = navis.drop_fluff(m, n_largest=10)
>>> two.n_vertices
6069
>>> # Keep all fragments with at least 100 vertices
>>> clean = navis.drop_fluff(m, keep_size=100)
>>> clean.n_vertices
5951
>>> # Keep the two largest fragments with at least 50 vertices each
>>> # (for this neuron the result is just the largest fragment)
>>> clean2 = navis.drop_fluff(m, keep_size=50, n_largest=2)
>>> clean2.n_vertices
6037
Source code in navis/morpho/manipulation.py
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 |
|
navis.edges2neuron
#
Create TreeNeuron from edges and (optional) vertex coordinates.
PARAMETER | DESCRIPTION |
---|---|
edges |
TYPE: |
vertices |
TYPE: |
validate |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Examples:
>>> import navis
>>> import numpy as np
>>> verts = np.random.rand(5, 3)
>>> edges = np.array([(0, 1), (1, 2), (2, 3), (2, 4)])
>>> sk = navis.edges2neuron(edges, vertices=verts)
Source code in navis/graph/converters.py
750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 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 |
|
navis.example_neurons
#
Load example neuron(s).
These example neurons are skeletons and meshes of the same olfactory projection neurons from the DA1 glomerulus which have been automatically segmented in the Janelia hemibrain data set [1]. See also https://neuprint.janelia.org
.
Coordinates are in voxels which equal 8 x 8 x 8 nanometers.
PARAMETER | DESCRIPTION |
---|---|
n |
TYPE: |
kind |
TYPE: |
synapses |
TYPE: |
source |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | If |
MeshNeuron | If |
NeuronList | List of the above neuron types if |
References
[1] Louis K. Scheffer et al., bioRxiv. 2020. doi: https://doi.org/10.1101/2020.04.07.030213 A Connectome and Analysis of the Adult Drosophila Central Brain.
Examples:
Load a single neuron
>>> import navis
>>> n = navis.example_neurons(n=1)
Load all example neurons
>>> nl = navis.example_neurons()
Source code in navis/data/load_data.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
navis.example_volume
#
Load an example volume.
Volumes are in hemibrain space which means coordinates are in voxels at 8 x 8 x 8 nanometers/voxel.
PARAMETER | DESCRIPTION |
---|---|
name |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
navis.Volume | |
Examples:
Load LH volume
>>> import navis
>>> lh = navis.example_volume('LH')
Source code in navis/data/load_data.py
171 172 173 174 175 176 177 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 |
|
navis.find_main_branchpoint
#
Find main branch point of unipolar (e.g. insect) neurons.
Note that this might produce garbage if the neuron is fragmented.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
method |
TYPE: |
threshold |
TYPE: |
reroot_soma |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
branch_point | Node ID or list of node IDs of the main branch point(s). TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> navis.find_main_branchpoint(n, reroot_soma=True)
110
>>> # Cut neuron into axon, dendrites and primary neurite tract:
>>> # for this we need to cut twice - once at the main branch point
>>> # and once at one of its childs
>>> child = n.nodes[n.nodes.parent_id == 2066].node_id.values[0]
>>> split = navis.cut_skeleton(n, [2066, child])
>>> split
<class 'navis.core.neuronlist.NeuronList'> of 3 neurons
type n_nodes n_connectors n_branches n_leafs cable_length soma
0 TreeNeuron 2572 0 170 176 475078.177926 None
1 TreeNeuron 139 0 1 3 89983.511392 [3490]
2 TreeNeuron 3656 0 63 66 648285.745750 None
Source code in navis/graph/graph_utils.py
1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
|
navis.find_soma
#
Try finding a neuron's soma.
Will use the .soma_detection_radius
and .soma_detection_label
attribute of a neuron to search for the soma in the node table.
If attributes don't exists, will fallback to defaults: None
and 1
, respectively.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
RETURNS | DESCRIPTION |
---|---|
Node ID(s) of potential somata. | |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> navis.find_soma(n)
array([4177], dtype=int32)
Source code in navis/morpho/analyze.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
navis.fix_mesh
#
Try to fix some common problems with mesh.
- Remove infinite values
- Merge duplicate vertices
- Remove duplicate and degenerate faces
- Fix normals
- Remove unreference vertices
- Remove disconnected fragments (Optional)
- Fill holes (Optional)
PARAMETER | DESCRIPTION |
---|---|
mesh | TYPE: |
fill_holes |
TYPE: |
remove_fragments |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
fixed object : trimesh.Trimesh or navis.MeshNeuron | |
Source code in navis/meshes/mesh_utils.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
navis.flow_centrality
#
Calculate flow between leaf nodes.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neuron | Adds "flow_centrality" as column in the node table (for TreeNeurons) or as |
Examples:
>>> import navis
>>> n = navis.example_neurons(2)
>>> n.reroot(n.soma, inplace=True)
>>> _ = navis.flow_centrality(n)
>>> n[0].nodes.flow_centrality.max()
91234
See Also
navis.synapse_flow_centrality
Synapse-based flow centrality.
Source code in navis/morpho/mmetrics.py
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 |
|
navis.form_factor
#
Calculate form factor for given neuron.
The form factor F(q) is a Fourier transform of density-density correlation of particles used to classify objects in polymer physics. Based on Choi et al., 2022 (bioRxiv). Code adapted from github.com/kirichoi/FqClustering.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
start |
TYPE: |
parallel |
TYPE: |
n_cores |
|
progress |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Fq | For single neurons: |
References
Polymer physics-based classification of neurons Kiri Choi, Won Kyu Kim, Changbong Hyeon bioRxiv 2022.04.07.487455; doi: https://doi.org/10.1101/2022.04.07.487455
Examples:
>>> import navis
>>> nl = navis.example_neurons(3)
>>> nl = nl.convert_units('microns')
>>> # Resample to 1 node / micron
>>> rs = navis.resample_skeleton(nl, '1 micron')
>>> # Calculate form factor
>>> Fq = navis.form_factor(rs, start=-3, stop=3, num=301,
... parallel=True, n_cores=3)
>>> # Plot
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> x = np.logspace(-3, 3, 301)
>>> fig, ax = plt.subplots()
>>> for i in range(len(Fq)):
... _ = ax.plot(x, Fq[i])
>>> # Make log-log
>>> ax.set_xscale('log')
>>> ax.set_yscale('log')
>>> plt.show()
>>> # Cluster
>>> from scipy.spatial.distance import pdist
>>> from scipy.cluster.hierarchy import dendrogram, linkage
>>> dists = pdist(Fq)
>>> Z = linkage(dists, method='ward')
>>> dn = dendrogram(Z)
Source code in navis/morpho/fq.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
navis.geodesic_matrix
#
Generate geodesic ("along-the-arbor") distance matrix between nodes/vertices.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
from_ |
TYPE: |
directed |
TYPE: |
weight |
TYPE: |
limit |
|
RETURNS | DESCRIPTION |
---|---|
pd.DataFrame | Geodesic distance matrix. If the neuron is fragmented or |
See Also
navis.distal_to
Check if a node A is distal to node B. navis.dist_between
Get point-to-point geodesic distances. navis.dist_to_root
Distances from all skeleton node to their root(s). navis.graph.skeleton_adjacency_matrix
Generate adjacency matrix for a skeleton.
Examples:
Find average geodesic distance between all leaf nodes
>>> import navis
>>> n = navis.example_neurons(1)
>>> # Generate distance matrix
>>> m = navis.geodesic_matrix(n)
>>> # Subset matrix to leaf nodes
>>> leafs = n.nodes[n.nodes.type=='end'].node_id.values
>>> l_dist = m.loc[leafs, leafs]
>>> # Get mean
>>> round(l_dist.mean().mean())
12983
Source code in navis/graph/graph_utils.py
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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
|
navis.get_viewer
#
Grab active 3D viewer.
RETURNS | DESCRIPTION |
---|---|
[`navis.Viewer`][] | |
Examples:
>>> import navis
>>> from vispy import scene
>>> # Get and plot neuron in 3d
>>> n = navis.example_neurons(1)
>>> _ = n.plot3d(color='red', backend='vispy')
>>> # Grab active viewer and add custom text
>>> viewer = navis.get_viewer()
>>> text = scene.visuals.Text(text='TEST',
... pos=(0, 0, 0))
>>> viewer.add(text)
>>> # Close viewer
>>> viewer.close()
Source code in navis/plotting/vispy/vputils.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
navis.guess_radius
#
Guess radii for skeleton nodes.
Uses distance between connectors and nodes to guess radii. Interpolate for nodes without connectors. Fills in radius
column in node table.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
method |
TYPE: |
limit |
TYPE: |
smooth |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | |
Examples:
>>> import navis
>>> nl = navis.example_neurons(2)
>>> nl_radius = navis.guess_radius(nl)
Source code in navis/morpho/manipulation.py
1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 |
|
navis.heal_skeleton
#
Heal fragmented skeleton(s).
Tries to heal a fragmented skeleton (i.e. a neuron with multiple roots) using a minimum spanning tree.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
method |
TYPE: |
max_dist |
TYPE: |
min_size |
TYPE: |
drop_disc |
TYPE: |
mask |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | If |
CatmaidNeuron / List | If |
See Also
navis.stitch_skeletons
Use to stitch multiple skeletons together. navis.break_fragments
Use to produce individual neurons from disconnected fragments.
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> # Disconnect parts of the neuron
>>> n.nodes.loc[100, 'parent_id'] = -1
>>> len(n.root)
2
>>> # Heal neuron
>>> healed = navis.heal_skeleton(n)
>>> len(healed.root)
1
Source code in navis/morpho/manipulation.py
1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 |
|
navis.health_check
#
Run a health check on TreeNeurons and flag potential issues.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
verbose |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
list of issues or None | |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> navis.health_check(n)
Neuron 1734350788 seems perfectly fine.
Source code in navis/graph/clinic.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
navis.in_volume
#
in_volume
in_volume
in_volume
in_volume
in_volume
Test if points/neurons are within a given volume.
Notes
This function requires ncollpyde (recommended and installed with navis
) or pyoctree as backends for raycasting. If neither is installed, we can fall back to using scipy's ConvexHull instead. This is, however, slower and will give wrong positives for concave meshes!
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
volume |
TYPE: |
mode |
TYPE: |
backend |
TYPE: |
n_rays |
TYPE: |
prevent_fragments |
TYPE: |
validate |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Neuron | If input is a single neuron or NeuronList, will return subset of the neuron(s) (nodes and connectors) that are within given volume. |
list of bools | If input is |
dict | If multiple volumes are provided, results will be returned in dictionary with volumes as keys:: {'volume1': in_volume(x, volume1), 'volume2': in_volume(x, volume2), ... } |
Examples:
Prune neuron to volume
>>> import navis
>>> n = navis.example_neurons(1)
>>> lh = navis.example_volume('LH')
>>> n_lh = navis.in_volume(n, lh, inplace=False)
>>> n_lh
type navis.TreeNeuron
name 1734350788
id 1734350788
n_nodes 344
n_connectors None
n_branches 49
n_leafs 50
cable_length 32313.5
soma None
units 8 nanometer
dtype: object
Find out which points are inside a volume
>>> in_v = navis.in_volume(n.nodes[['x', 'y', 'z']].values, lh)
>>> in_v
array([False, False, False, ..., False, False, False])
>>> in_v.sum()
344
Source code in navis/intersection/intersect.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.insert_nodes
#
Insert new nodes between existing nodes.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
where |
TYPE: |
coords |
TYPE: |
validate |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Examples:
Insert new nodes between some random points
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.n_nodes
4465
>>> where = n.nodes[['parent_id', 'node_id']].values[100:200]
>>> _ = navis.insert_nodes(n, where=where, inplace=True)
>>> n.n_nodes
4565
Source code in navis/graph/graph_utils.py
2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 |
|
navis.inspect_h5
#
Extract basic info from Hdf5 file.
PARAMETER | DESCRIPTION |
---|---|
filepath |
TYPE: |
inspect_neurons |
TYPE: |
inspect_annotations |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
dict | Returns a dictionary with basic info about the file. An example:: { 'format_spec': 'hnf_v1', # format specifier 'neurons': { 'someID': {'skeleton': True, 'mesh': False, 'dotprops': True, 'annotations': ['connectors']}, 'someID2': {'skeleton': False, 'mesh': False, 'dotprops': True, 'annotations': ['connectors']} } } |
Source code in navis/io/hdf_io.py
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 |
|
navis.intersection_matrix
#
Compute intersection matrix between a set of neurons and volumes.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
volume | TYPE: |
attr |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
pandas DataFrame | |
Examples:
>>> import navis
>>> # Grab neurons
>>> nl = navis.example_neurons(3)
>>> # Grab a single volume
>>> lh = navis.example_volume("LH")
>>> # Re-use for testing
>>> vols = {'lh1': lh, 'lh2': lh}
>>> # Generate intersection matrix with cable length
>>> m = navis.intersection_matrix(nl, vols, attr='cable_length')
Source code in navis/intersection/intersect.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
navis.ivscc_features
#
Calculate IVSCC features for neuron(s).
Please see the IVSCC
tutorial for details.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
features |
TYPE: |
missing_compartments |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
ivscc | IVSCC features for the neuron(s). TYPE: |
Source code in navis/morpho/ivscc.py
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 |
|
navis.longest_neurite
#
Return a neuron consisting of only the longest neurite(s).
Based on geodesic distances.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
n |
TYPE: |
reroot_soma |
TYPE: |
from_root |
TYPE: |
inverse |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Pruned neuron. |
See Also
navis.split_into_fragments
Split neuron into fragments based on longest neurites.
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> # Keep only the longest neurite
>>> ln1 = navis.longest_neurite(n, n=1, reroot_soma=True)
>>> # Keep the two longest neurites
>>> ln2 = navis.longest_neurite(n, n=2, reroot_soma=True)
>>> # Keep everything but the longest neurite
>>> ln3 = navis.longest_neurite(n, n=slice(1, None), reroot_soma=True)
Source code in navis/graph/graph_utils.py
1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 |
|
navis.make_dotprops
#
Produce dotprops from neurons or point clouds.
This is following the implementation in R's nat
library.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
k |
TYPE: |
resample |
TYPE: |
threshold |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
navis.Dotprops | If input is multiple neurons, will return a |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> dp = navis.make_dotprops(n)
>>> dp
type navis.Dotprops
name DA1_lPN_R
id 1734350788
k 20
units 8 nanometer
n_points 4465
dtype: object
Source code in navis/core/core_utils.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.mesh
#
Generate mesh from object(s).
VoxelNeurons or (N, 3) arrays of voxel coordinates will be meshed using a marching cubes algorithm. TreeNeurons will be meshed by creating cylinders using the radii.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
mesh | Returns a trimesh or MeshNeuron depending on the input. Data tables (e.g. TYPE: |
Source code in navis/conversion/wrappers.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
navis.mirror
#
Mirror 3D coordinates about given axis.
This is a lower level version of navis.mirror_brain
that: 1. Flips object along midpoint of axis using a affine transformation. 2. (Optional) Applies a warp transform that corrects asymmetries.
PARAMETER | DESCRIPTION |
---|---|
points |
TYPE: |
mirror_axis_size |
TYPE: |
mirror_axis |
TYPE: |
warp |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
points_mirrored | Mirrored coordinates. |
See Also
navis.mirror_brain
Higher level function that uses meta data from registered template brains to transform data for you.
Source code in navis/transforms/xfm_funcs.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
|
navis.mirror_brain
#
Mirror 3D object (neuron, coordinates) about given axis.
The way this works is: 1. Look up the length of the template space along the given axis. For this, the template space has to be registered (see docs for details). 2. Flip object along midpoint of axis using a affine transformation. 3. (Optional) Apply a warp transform that corrects asymmetries.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
template |
TYPE: |
mirror_axis |
TYPE: |
warp |
TYPE: |
via |
TYPE: |
verbose |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
xf | Same object type as input (array, neurons, etc) but with transformed coordinates. |
Examples:
This example requires the flybrains library to be installed: pip3 install flybrains
Also, if you haven't already, you will need to have the optional Saalfeld lab (Janelia Research Campus) transforms installed (this is a one-off):
>>> import flybrains
>>> flybrains.download_jrc_transforms()
Once flybrains
is installed and you have downloaded the registrations, you can run this:
>>> import navis
>>> import flybrains
>>> # navis example neurons are in raw hemibrain (JRCFIB2018Fraw) space
>>> n = navis.example_neurons(1)
>>> # Mirror about x axis (this is a simple flip in this case)
>>> mirrored = navis.mirror_brain(n * 8 / 1000, tem plate='JRCFIB2018F', via='JRC2018F')
>>> # We also need to get back to raw coordinates
>>> mirrored = mirrored / 8 * 1000
See Also
navis.mirror
Lower level function for mirroring. You can use this if you want to mirror data without having a registered template for it.
Source code in navis/transforms/templates.py
1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 |
|
navis.nblast
#
NBLAST query against target neurons.
This implements the NBLAST algorithm from Costa et al. (2016) (see references) and mirror the implementation in R's nat.nblast
(https://github.com/natverse/nat.nblast).
PARAMETER | DESCRIPTION |
---|---|
query |
TYPE: |
target |
TYPE: |
scores |
TYPE: |
use_alpha |
TYPE: |
normalized |
TYPE: |
smat |
TYPE: |
limit_dist |
TYPE: |
approx_nn |
TYPE: |
n_cores |
|
precision |
TYPE: |
progress |
TYPE: |
smat_kwargs |
|
RETURNS | DESCRIPTION |
---|---|
scores | Matrix with NBLAST scores. Rows are query neurons, columns are targets. The order is the same as in TYPE: |
References
Costa M, Manton JD, Ostrovsky AD, Prohaska S, Jefferis GS. NBLAST: Rapid, Sensitive Comparison of Neuronal Structure and Construction of Neuron Family Databases. Neuron. 2016 Jul 20;91(2):293-311. doi: 10.1016/j.neuron.2016.06.012.
Examples:
>>> import navis
>>> nl = navis.example_neurons(n=5)
>>> nl.units
<Quantity([8 8 8 8 8], 'nanometer')>
>>> # Convert to microns
>>> nl_um = nl * (8 / 1000)
>>> # Convert to dotprops
>>> dps = navis.make_dotprops(nl_um)
>>> # Run the nblast
>>> scores = navis.nblast(dps[:3], dps[3:])
See Also
navis.nblast_allbyall
A more efficient way than nblast(query=x, target=x)
. navis.nblast_smart
A smart(er) NBLAST suited for very large NBLAST. navis.synblast
A synapse-based variant of NBLAST.
Source code in navis/nbl/nblast_funcs.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 765 766 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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
|
navis.nblast_align
#
Run NBLAST on pairwise-aligned neurons.
Requires the pycpd
library at least version 2.0.1 which at the time of writing is only available from Github (not PyPI):
https://github.com/siavashk/pycpd
PARAMETER | DESCRIPTION |
---|---|
query |
TYPE: |
target |
TYPE: |
align_method |
TYPE: |
two_way_align |
TYPE: |
sample_align |
TYPE: |
scores |
TYPE: |
use_alpha |
TYPE: |
normalized |
TYPE: |
smat |
TYPE: |
limit_dist |
TYPE: |
approx_nn |
TYPE: |
n_cores |
|
precision |
TYPE: |
progress |
TYPE: |
smat_kwargs |
TYPE: |
align_kwargs |
TYPE: |
dotprop_kwargs |
|
RETURNS | DESCRIPTION |
---|---|
scores | Matrix with NBLAST scores. Rows are query neurons, columns are targets. The order is the same as in TYPE: |
References
Costa M, Manton JD, Ostrovsky AD, Prohaska S, Jefferis GS. NBLAST: Rapid, Sensitive Comparison of Neuronal Structure and Construction of Neuron Family Databases. Neuron. 2016 Jul 20;91(2):293-311. doi: 10.1016/j.neuron.2016.06.012.
Examples:
>>> import navis
>>> nl = navis.example_neurons(n=5)
>>> nl.units
<Quantity([8 8 8 8 8], 'nanometer')>
>>> # Convert to microns
>>> nl_um = nl * (8 / 1000)
>>> # Run the align nblast
>>> scores = navis.nblast_align(nl_um[:3], nl_um[3:],
... dotprop_kwargs=dict(k=5),
... sample_align=.2)
See Also
navis.nblast
The vanilla version of NBLAST. navis.nblast_allbyall
A more efficient way than nblast(query=x, target=x)
. navis.nblast_smart
A smart(er) NBLAST suited for very large NBLAST. navis.synblast
A synapse-based variant of NBLAST.
Source code in navis/nbl/ablast_funcs.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
navis.nblast_allbyall
#
All-by-all NBLAST of inputs neurons.
A more efficient way than running nblast(query=x, target=x)
.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
n_cores |
|
use_alpha |
TYPE: |
normalized |
TYPE: |
smat |
TYPE: |
limit_dist |
TYPE: |
approx_nn |
TYPE: |
precision |
TYPE: |
progress |
TYPE: |
smat_kwargs |
|
RETURNS | DESCRIPTION |
---|---|
scores | Matrix with NBLAST scores. Rows are query neurons, columns are targets. The order is the same as in TYPE: |
References
Costa M, Manton JD, Ostrovsky AD, Prohaska S, Jefferis GS. NBLAST: Rapid, Sensitive Comparison of Neuronal Structure and Construction of Neuron Family Databases. Neuron. 2016 Jul 20;91(2):293-311. doi: 10.1016/j.neuron.2016.06.012.
Examples:
>>> import navis
>>> nl = navis.example_neurons(n=5)
>>> nl.units
<Quantity([8 8 8 8 8], 'nanometer')>
>>> # Convert to microns
>>> nl_um = nl * (8 / 1000)
>>> # Make dotprops
>>> dps = navis.make_dotprops(nl_um)
>>> # Run the nblast
>>> scores = navis.nblast_allbyall(dps)
See Also
navis.nblast
For generic query -> target nblasts.
Source code in navis/nbl/nblast_funcs.py
910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
|
navis.nblast_smart
#
Smart(er) NBLAST query against target neurons.
In contrast to navis.nblast
, this function will first run a "pre-NBLAST" in which only 10% of the query dotprops' points are used. Using those initial scores we select, for each query, the highest scoring targets and run the full NBLAST only on those query-target pairs (see t
and criterion
for fine-tuning).
PARAMETER | DESCRIPTION |
---|---|
query |
TYPE: |
target |
TYPE: |
t |
TYPE: |
criterion |
TYPE: |
return_mask |
TYPE: |
scores |
TYPE: |
use_alpha |
TYPE: |
normalized |
TYPE: |
smat |
TYPE: |
smat_kwargs |
|
limit_dist |
TYPE: |
approx_nn |
TYPE: |
precision |
TYPE: |
n_cores |
|
progress |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
scores | Matrix with NBLAST scores. Rows are query neurons, columns are targets. The order is the same as in TYPE: |
mask | Only if |
References
Costa M, Manton JD, Ostrovsky AD, Prohaska S, Jefferis GS. NBLAST: Rapid, Sensitive Comparison of Neuronal Structure and Construction of Neuron Family Databases. Neuron. 2016 Jul 20;91(2):293-311. doi: 10.1016/j.neuron.2016.06.012.
Examples:
>>> import navis
>>> nl = navis.example_neurons(n=5)
>>> nl.units
<Quantity([8 8 8 8 8], 'nanometer')>
>>> # Convert to microns
>>> nl_um = nl * (8 / 1000)
>>> # Convert to dotprops
>>> dps = navis.make_dotprops(nl_um)
>>> # Run a NBLAST where only the top target from the pre-NBLAST is run
>>> # through a full NBLAST
>>> scores = navis.nblast_smart(dps[:3], dps[3:], t=1, criterion='N')
See Also
navis.nblast
The conventional full NBLAST. navis.nblast_allbyall
A more efficient way than nblast(query=x, target=x)
. navis.synblast
A synapse-based variant of NBLAST.
Source code in navis/nbl/nblast_funcs.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
|
navis.network2igraph
#
Generate iGraph graph from edge list or adjacency.
Requires iGraph to be installed.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
threshold |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
igraph.Graph(directed=True) | iGraph representation of the network. |
Source code in navis/graph/converters.py
173 174 175 176 177 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 |
|
navis.network2nx
#
Generate NetworkX graph from edge list or adjacency.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
threshold |
TYPE: |
group_by |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
networkx.DiGraph | NetworkX representation of the network. |
Source code in navis/graph/converters.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
navis.neuron2KDTree
#
Turn neuron into scipy KDTree.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
tree_type |
TYPE: |
data |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
`scipy.spatial.cKDTree` or `scipy.spatial.KDTree` | |
Source code in navis/graph/converters.py
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 |
|
navis.neuron2igraph
#
Turn Tree-, Mesh- or VoxelNeuron(s) into an iGraph graph.
Requires iGraph to be installed.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
simplify |
TYPE: |
connectivity |
TYPE: |
raise_not_installed |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
igraph.Graph | Representation of the neuron. Returns list of graphs if x is multiple neurons. Directed for TreeNeurons, undirected for MeshNeurons. |
None | If igraph not installed. |
Source code in navis/graph/converters.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
|
navis.neuron2nx
#
Turn Tree-, Mesh- or VoxelNeuron into an NetworkX graph.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
simplify |
TYPE: |
epsilon |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
graph | NetworkX representation of the neuron. Returns list of graphs if x is multiple neurons. Graph is directed for TreeNeurons and undirected for Mesh- and VoxelNeurons. Graph is weighted for Tree- and MeshNeurons. TYPE: |
Source code in navis/graph/converters.py
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 |
|
navis.neuron2tangents
#
Turn skeleton(s) into points + tangent vectors.
This will drop zero-length vectors (i.e when node and parent occupy the exact same position).
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
RETURNS | DESCRIPTION |
---|---|
points | Midpoints for each child->parent node pair. TYPE: |
vect | Normalized child-> parent vectors. TYPE: |
length | Distance between parent and child TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> t = navis.neuron2tangents(n)
Source code in navis/graph/converters.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
navis.nx2neuron
#
Create TreeNeuron from NetworkX Graph.
This function will try to generate a neuron-like tree structure from the Graph. Therefore the graph must not contain loops!
All node attributes (e.g. x
, y
, z
, radius
) will be added to the neuron's .nodes
table.
PARAMETER | DESCRIPTION |
---|---|
G |
TYPE: |
root |
TYPE: |
break_cycles |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Examples:
>>> import navis
>>> import networkx as nx
>>> G = nx.balanced_tree(2, 3)
>>> tn = navis.nx2neuron(G)
>>> tn
type navis.TreeNeuron
name None
n_nodes 15
n_connectors None
n_branches 6
n_leafs 8
cable_length 0.0
soma None
units 1 dimensionless
dtype: object
Source code in navis/graph/converters.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 |
|
navis.patch_cloudvolume
#
Monkey patch cloud-volume to return navis neurons.
This function must be run before initializing the CloudVolume
! Adds new methods/parameters to CloudVolume.mesh.get
and CloudVolume.skeleton.get
. See examples for details.
Examples:
>>> import navis
>>> import cloudvolume as cv
>>> # Monkey patch cloudvolume
>>> navis.patch_cloudvolume()
>>> # Connect to the Google segmentation of FAFB
>>> vol = cv.CloudVolume('precomputed://gs://fafb-ffn1-20200412/segmentation',
... use_https=True,
... progress=False)
>>> ids = [2137190164, 2268989790]
>>> # Fetch as navis neuron using newly added method or ...
>>> nl = vol.mesh.get_navis(ids, lod=3)
>>> # ... alternatively use `as_navis` keyword argument in original method
>>> nl = vol.mesh.get(ids, lod=3, as_navis=True)
>>> type(nl)
<class 'navis.core.neuronlist.NeuronList'>
>>> # The same works for skeletons
>>> skels = vol.skeleton.get_navis(ids)
Source code in navis/utils/cv.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
navis.persistence_distances
#
Calculate morphological similarity using persistence diagrams.
This works by: 1. Generate persistence points for each neuron. 2. Create a weighted Gaussian from persistence points and sample 100 evenly spaced points to create a feature vector. 3. Calculate Euclidean distance.
PARAMETER | DESCRIPTION |
---|---|
q |
TYPE: |
normalize |
TYPE: |
bw |
TYPE: |
augment |
TYPE: |
**persistence_kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
distances | TYPE: |
See Also
navis.persistence_points
The function to calculate the persistence points. navis.persistence_vectors
Use this to get and inspect the actual vectors used here.
Source code in navis/morpho/persistence.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.persistence_points
#
Calculate points for a persistence diagram.
Based on Li et al., PLoS One (2017). Briefly, this cuts the neuron into linear segments, the start (birth) and end (death) of which are assigned a value (see descriptor
parameter). In combination, these points represent a fingerprint for the topology of the neuron.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
descriptor |
TYPE: |
remove_cbf |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pandas.DataFrame | |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.reroot(n.soma, inplace=True)
>>> p = navis.persistence_points(n)
References
Li Y, Wang D, Ascoli GA, Mitra P, Wang Y (2017) Metrics for comparing neuronal tree shapes based on persistent homology. PLOS ONE 12(8): e0182184. https://doi.org/10.1371/journal.pone.0182184
Source code in navis/morpho/persistence.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
navis.persistence_vectors
#
Produce vectors from persistence points.
Works by creating a Gaussian and sampling samples
evenly spaced points across it.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
threshold |
TYPE: |
samples |
TYPE: |
bw |
TYPE: |
center |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
vectors | |
samples | Sampled distances. If |
References
Li Y, Wang D, Ascoli GA, Mitra P, Wang Y (2017) Metrics for comparing neuronal tree shapes based on persistent homology. PLOS ONE 12(8): e0182184. https://doi.org/10.1371/journal.pone.0182184
See Also
navis.persistence_points
The function to calculate the persistence points. navis.persistence_distances
Get distances based on (augmented) persistence vectors.
Source code in navis/morpho/persistence.py
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 |
|
navis.plot1d
#
Plot neuron topology in 1D according to Cuntz et al. (2010).
This function breaks a neurons into segments between branch points. See Cuntz et al., PLoS Computational Biology (2010) for detailed explanation. For very complex neurons, this neuron "barcode" can get fairly complicated - make sure to zoom in.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
ax | TYPE: |
color |
TYPE: |
palette |
TYPE: |
color_by |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
matplotlib.ax | |
Examples:
>>> import navis
>>> import matplotlib.pyplot as plt
>>> n = navis.example_neurons(2)
>>> ax = navis.plot1d(n)
>>> plt.show()
Close figures (only relevant for doctests)
>>> plt.close('all')
See the flat plotting tutorial
for more examples.
Source code in navis/plotting/d.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.plot2d
#
Generate 2D plots of neurons and neuropils.
The main advantage of this is that you can save plot as vector graphics.
Note
This function uses matplotlib
which "fakes" 3D as it has only very limited control over layering objects in 3D. Therefore neurites are not necessarily plotted in the right Z order. This becomes especially troublesome when plotting a complex scene with lots of neurons criss-crossing. See the method
parameter for details.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
Object parameters
soma : bool | dict, default=True
Plot soma if one exists. Size of the soma is determined
by the neuron's `.soma_radius` property which defaults
to the "radius" column for `TreeNeurons`. You can also
pass `soma` as a dictionary to customize the appearance
of the soma - for example `soma={"color": "red", "lw": 2, "ec": 1}`.
radius : bool | "auto", default=False
If "auto" will plot neurites of `TreeNeurons` with radius
if they have radii. If True, will try plotting neurites of
`TreeNeurons` with radius regardless. The radius can be
scaled by `linewidth`. Note that this will increase rendering
time.
linewidth : int | float, default=.5
Width of neurites. Also accepts alias `lw`.
linestyle : str, default='-'
Line style of neurites. Also accepts alias `ls`.
color : None | str | tuple | list | dict, default=None
Use single str (e.g. `'red'`) or `(r, g, b)` tuple
to give all neurons the same color. Use `list` of
colors to assign colors: `['red', (1, 0, 1), ...].
Use `dict` to map colors to neuron IDs:
`{id: (r, g, b), ...}`.
palette : str | array | list of arrays, default=None
Name of a matplotlib or seaborn palette. If `color` is
not specified will pick colors from this palette.
color_by : str | array | list of arrays, default = None
Color neurons by a property. Can be:
- a list/array of labels, one per each neuron
- a neuron property (str)
- a column name in the node table of `TreeNeurons`
- a list/array of values for each node
Numerical values will be normalized. You can control
the normalization by passing a `vmin` and/or `vmax` parameter.
shade_by : str | array | list of arrays, default=None
Similar to `color_by` but will affect only the alpha
channel of the color. If `shade_by='strahler'` will
compute Strahler order if not already part of the node
table (TreeNeurons only). Numerical values will be
normalized. You can control the normalization by passing
a `smin` and/or `smax` parameter.
alpha : float [0-1], default=1
Alpha value for neurons. Overriden if alpha is provided
as fourth value in `color` (rgb*a*). You can override
alpha value for connectors by using `cn_alpha`.
mesh_shade : bool, default=False
Only relevant for meshes (e.g. `MeshNeurons`) and
`TreeNeurons` with radius, and when method is 3d or
3d complex. Whether to shade the object which will give it
a 3D look.
depth_coloring : bool, default=False
If True, will use neuron color to encode depth (Z).
Overrides `color` argument. Does not work with
`method = '3d_complex'`.
depth_scale : bool, default=True
If True and `depth_coloring=True` will plot a scale.
connectors : bool | "presynapses" | "postsynapses" | str | list, default=True
Plot connectors. This can either be `True` (plot all
connectors), `"presynapses"` (only presynaptic connectors)
or `"postsynapses"` (only postsynaptic connectors). If
a string or a list is provided, it will be used to filter the
`type` column in the connectors table.
connectors_only : boolean, default=False
Plot only connectors, not the neuron.
cn_size : int | float, default = 1
Size of connectors.
cn_layout : dict, default={}
Defines default settings (color, style) for connectors.
See `navis.config.default_connector_colors` for the
default layout.
cn_colors : str | tuple | dict | "neuron"
Overrides the default connector (e.g. synpase) colors:
- single color as str (e.g. `'red'`) or rgb tuple
(e.g. `(1, 0, 0)`)
- dict mapping the connectors tables `type` column to
a color (e.g. `{"pre": (1, 0, 0)}`)
- with "neuron", connectors will receive the same color
as their neuron
cn_mesh_colors : bool, default=False
If True, will use the neuron's color for its connectors.
scatter_kws : dict, default={}
Parameters to be used when plotting points. Accepted
keywords are: `size` and `color`.
volume_outlines : bool | "both", default=False
If True will plot volume outline with no fill. Only
works with `method="2d"`. Requires the `shapely` package.
dps_scale_vec : float
Scale vector for dotprops.
Figure parameters
method : '2d' | '3d' (default) | '3d_complex'
Method used to generate plot. Comes in three flavours:
1. `2d` uses normal matplotlib. Neurons are plotted on
top of one another in the order their are passed to
the function. Use the `view` parameter (below) to
set the view (default = xy).
2. `3d` uses matplotlib's 3D axis. Here, matplotlib
decide the depth order (zorder) of plotting. Can
change perspective either interacively or by code
(see examples).
3. `3d_complex` same as 3d but each neuron segment is
added individually. This allows for more complex
zorders to be rendered correctly. Slows down
rendering!
view : tuple, default = ("x", "y")
Sets view for `method='2d'`. Can be any combination of
"x", "y", "z" and their negations. For example, to plot
from the top, use `view=('x', '-y')`. For 3D `methods`,
this will set the initial view which can be changed by
adjusting `ax.azim`, `ax.elev` and `ax.roll` (see examples).
non_view_axes3d : "show" | "hide" (default) | "fade"
Only relevant for methods '3d' and '3d_complex': what to
do with the axis that are not in the view. If 'hide', will
hide them. If 'show', will show them. If 'fade', will
make them semi-transparent. This is relevant if you
intend if you intend to customize the view after plotting.
autoscale : bool, default=True
If True, will scale the axes to fit the data.
scalebar : int | float | str | pint.Quantity | dict, default=False
Adds a scale bar. Provide integer, float or str to set
size of scalebar. Int|float are assumed to be in same
units as data. You can specify units in as string:
e.g. "1 um". For methods '3d' and '3d_complex', this
will create an axis object.
You can customize the scalebar by passing a dictionary.
For example:
`{size: "1 micron", color: 'k', lw: 3, alpha: 0.9}`
ax : matplotlib.Axes, default=None
Pass an axis object if you want to plot on an existing
canvas. Must match `method` - i.e. 2D or 3D axis.
figsize : tuple, default=None
Size of figure. Ignored if `ax` is provided.
rasterize : bool, default=False
Neurons produce rather complex vector graphics which can
lead to large files when saving to SVG, PDF or PS. Use
this parameter to rasterize neurons and meshes/volumes
(but not axes or labels) to reduce file size.
orthogonal : bool, default=True
Whether to use orthogonal or perspective view for
methods '3d' and '3d_complex'.
group_neurons : bool, default=False
If True, neurons will be grouped. Works with SVG export
but not PDF. Does NOT work with `method='3d_complex'`.
RETURNS | DESCRIPTION |
---|---|
fig | TYPE: |
ax | TYPE: |
Examples:
>>> import navis
>>> import matplotlib.pyplot as plt
Plot list of neurons as simple 2d:
>>> nl = navis.example_neurons()
>>> fig, ax = navis.plot2d(nl, method='2d', view=('x', '-z'))
>>> plt.show()
Add a volume:
>>> vol = navis.example_volume('LH')
>>> fig, ax = navis.plot2d([nl, vol], method='2d', view=('x', '-z'))
>>> plt.show()
Change neuron colors:
>>> fig, ax = navis.plot2d(
... nl,
... method='2d',
... view=('x', '-z'),
... color=['r', 'g', 'b', 'm', 'c', 'y']
... )
>>> plt.show()
Plot in "fake" 3D:
>>> fig, ax = navis.plot2d(nl, method='3d', view=('x', '-z'))
>>> plt.show()
>>> # In an interactive window you can dragging the plot to rotate
Plot in "fake" 3D and change perspective:
>>> fig, ax = navis.plot2d(nl, method='3d', view=('x', '-z'))
>>> # Change view
>>> ax.elev = -20
>>> ax.azim = 45
>>> ax.roll = 180
>>> plt.show()
Plot using depth-coloring:
>>> fig, ax = navis.plot2d(nl, method='3d', depth_coloring=True, view=('x', '-z'))
>>> plt.show()
See the plotting intro for more examples.
See Also
navis.plot3d
Use this if you want interactive, perspectively correct renders and if you don't need vector graphics as outputs. navis.plot1d
A nifty way to visualise neurons in a single dimension. navis.plot_flat
Plot neurons as flat structures (e.g. dendrograms).
Source code in navis/plotting/dd.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 |
|
navis.plot3d
#
Generate interactive 3D plot.
Uses either octarine, vispy, k3d or plotly as backend. By default, the choice is automatic depending on what backends are installed and the context:
- Terminal: octarine > vispy > plotly
- Jupyter: plotly > octarine > k3d
See the backend
parameter on how to change this behavior.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
Object parameters
color : None | str | tuple | list | dict, default=None
Use single str (e.g. `'red'`) or `(r, g, b)` tuple
to give all neurons the same color. Use `list` of
colors to assign colors: `['red', (1, 0, 1), ...].
Use `dict` to map colors to neurons:
`{neuron.id: (r, g, b), ...}`.
palette : str | array | list of arrays, default=None
Name of a matplotlib or seaborn palette. If `color` is
not specified will pick colors from this palette.
alpha : float [0-1], optional
Alpha value for neurons. Overriden if alpha is provided
as color specified in `color` has an alpha channel.
connectors : bool | "presynapses" | "postsynapses" | str | list, default=True
Plot connectors. This can either be `True` (plot all
connectors), `"presynapses"` (only presynaptic connectors)
or `"postsynapses"` (only postsynaptic connectors). If
a string or a list is provided, it will be used to filter the
`type` column in the connectors table.
Use these parameters to adjust the way connectors are plotted:
- `cn_colors` (str | tuple | dict | "neuron" ) overrides
the default connector (e.g. synpase) colors:
- single color as str (e.g. `'red'`) or rgb tuple
(e.g. `(1, 0, 0)`)
- dict mapping the connectors tables `type` column to
a color (e.g. `{"pre": (1, 0, 0)}`)
- with "neuron", connectors will receive the same color
as their neuron
- `cn_layout` (dict): Layout of the connectors. See
`navis.config.default_connector_colors` for options.
- `cn_size` (float): Size of the connectors.
- `cn_alpha` (float): Transparency of the connectors.
- `cn_mesh_colors` (bool): Whether to color the connectors
by the neuron's color.
connectors_only : bool, default=False
Plot only connectors (e.g. synapses) if available and
ignore the neurons.
color_by : str | array | list of arrays, default = None
Color neurons by a property. Can be:
- a list/array of labels, one per each neuron
- a neuron property (str)
- a column name in the node table of `TreeNeurons`
- a list/array of values for each node
Numerical values will be normalized. You can control
the normalization by passing a `vmin` and/or `vmax`
parameter. Must specify a colormap via `palette`.
shade_by : str | array | list of arrays, default=None
Similar to `color_by` but will affect only the alpha
channel of the color. If `shade_by='strahler'` will
compute Strahler order if not already part of the node
table (TreeNeurons only). Numerical values will be
normalized. You can control the normalization by passing
a `smin` and/or `smax` parameter. Does not work with
`k3d` backend.
radius : bool | "auto", default=False
If "auto" will plot neurites of `TreeNeurons` with radius
if they have radii. If True, will try plotting neurites of
`TreeNeurons` with radius regardless. The radius can be
scaled by `linewidth`. Note that this will increase rendering
time.
soma : bool, default=True
TreeNeurons only: Whether to plot soma if it exists. Size
of the soma is determined by the neuron's `.soma_radius`
property which defaults to the "radius" column for
`TreeNeurons`.
linewidth : float, default=3 for plotly and 1 for all others
TreeNeurons only.
linestyle : str, default='-'
TreeNeurons only. Follows the same rules as in matplotlib.
scatter_kws : dict, optional
Use to modify scatter plots. Accepted parameters are:
- `size` to adjust size of dots
- `color` to adjust color
Figure parameters
backend : 'auto' (default) | 'octarine' | 'vispy' | 'plotly' | 'k3d'
Which backend to use for plotting. Note that there will
be minor differences in what feature/parameters are
supported depending on the backend:
- `auto` selects backend based on availability and
context (see above). You can override this by setting an
environment variable e.g. `NAVIS_PLOT3D_BACKEND="vispy"`
or `NAVIS_PLOT3D_JUPYTER_BACKEND="k3d"`.
- `octarine` uses WGPU to generate high performances
interactive 3D plots. Works both terminal and Jupyter.
- `vispy` similar to octarine but uses OpenGL: slower
but runs on older systems. Works only from terminals.
- `plotly` generates 3D plots using WebGL. Works
"inline" in Jupyter notebooks but can also produce a
HTML file that can be opened in any browers.
- `k3d` generates 3D plots using k3d. Works only in
Jupyter notebooks!
Below parameters are for plotly backend only:
fig : plotly.graph_objs.Figure
Pass to add graph objects to existing plotly figure. Will
not change layout.
title : str, default=None
For plotly only! Change plot title.
width/height : int, optional
Use to adjust figure size.
fig_autosize : bool, default=False
For plotly only! Autoscale figure size.
Attention: autoscale overrides width and height
hover_name : bool, default=False
If True, hovering over neurons will show their label.
hover_id : bool, default=False
If True, hovering over skeleton nodes will show their ID.
legend : bool, default=True
Whether or not to show the legend.
legend_orientation : "v" (default) | "h"
Orientation of the legend. Can be 'h' (horizontal) or 'v'
(vertical).
legend_group : dict, default=None
A dictionary mapping neuron IDs to labels (strings).
Use this to group neurons under a common label in the
legend.
inline : bool, default=True
If True and you are in an Jupyter environment, will
render plotly/k3d plots inline. If False, will generate
and return either a plotly Figure or a k3d Plot object
without immediately showing it.
Below parameters are for the Octarine/vispy backends only:
clear : bool, default = False
If True, will clear the viewer before adding the new
objects.
center : bool, default = True
If True, will center camera on the newly added objects.
combine : bool, default = False
If True, will combine objects of the same type into a
single visual. This can greatly improve performance but
also means objects can't be selected individually
anymore. This is Vispy only.
size : (width, height) tuple, optional
Use to adjust figure/window size.
show : bool, default=True
Whether to immediately show the viewer.
RETURNS | DESCRIPTION |
---|---|
If `backend='octarine'` | From terminal: opens a 3D window and returns :class: |
If `backend='vispy'` | Opens a 3D window and returns |
If `backend='plotly'` | Returns either |
If `backend='k3d'` | Returns either |
Examples:
>>> import navis
In a Jupyter notebook using plotly as backend:
>>> nl = navis.example_neurons()
>>> # Backend is automatically chosen but we can set it explicitly
>>> # Plot inline
>>> nl.plot3d(backend='plotly')
>>> # Plot as separate html in a new window
>>> fig = nl.plot3d(backend='plotly', inline=False)
>>> import plotly.offline
>>> _ = plotly.offline.plot(fig)
In a Jupyter notebook using k3d as backend:
>>> nl = navis.example_neurons()
>>> # Plot inline
>>> nl.plot3d(backend='k3d')
In a terminal using octarine as backend:
>>> # Plot list of neurons
>>> nl = navis.example_neurons()
>>> v = navis.plot3d(nl, backend='octarine')
>>> # Clear canvas
>>> navis.clear3d()
Some more advanced examples:
>>> # plot3d() can deal with combinations of objects
>>> nl = navis.example_neurons()
>>> vol = navis.example_volume('LH')
>>> vol.color = (255, 0, 0, .5)
>>> # This plots a neuronlists, a single neuron and a volume
>>> v = navis.plot3d([nl[0:2], nl[3], vol])
>>> # Clear viewer (works only with octarine and vispy)
>>> v = navis.plot3d(nl, clear=True)
See the plotting intro for even more examples.
Source code in navis/plotting/ddd.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.plot_flat
#
Plot neuron as flat diagrams.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
layout |
TYPE: |
connectors |
TYPE: |
highlight_connectors |
TYPE: |
ax |
TYPE: |
shade_by_length |
TYPE: |
normalize_distance |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
ax | TYPE: |
pos | (X, Y) positions for each node: TYPE: |
Examples:
Plot neuron in "subway" layout:
>>> import navis
>>> n = navis.example_neurons(1).convert_units('nm')
>>> ax, pos = navis.plot_flat(n, layout='subway',
... figsize=(12, 2),
... connectors=True)
>>> _ = ax.set_xlabel('distance [nm]')
>>> plt.show()
Plot neuron in "dot" layout (requires pygraphviz and graphviz):
>>> # First downsample to speed up processing
>>> ds = navis.downsample_neuron(n, 10, preserve_nodes='connectors')
>>> ax, pos = navis.plot_flat(ds, layout='dot', connectors=True)
>>> plt.show()
To close all figures (only for doctests)
>>> plt.close('all')
See the plotting intro and the neuron topology tutorial for more examples.
Source code in navis/plotting/flat.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
navis.pop3d
#
Remove the last item added to the 3D canvas.
Source code in navis/plotting/vispy/vputils.py
64 65 66 67 |
|
navis.prune_at_depth
#
Prune all neurites past a given distance from a source.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
depth |
TYPE: |
source |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Pruned neuron(s). |
Examples:
>>> import navis
>>> n = navis.example_neurons(2)
>>> # Reroot to soma
>>> n.reroot(n.soma, inplace=True)
>>> # Prune all twigs farther from the root than 100 microns
>>> # (example neuron are in 8x8x8nm units)
>>> n_pr = navis.prune_at_depth(n,
... depth=100e3 / 8,
... inplace=False)
>>> all(n.n_nodes > n_pr.n_nodes)
True
Source code in navis/morpho/manipulation.py
2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 |
|
navis.prune_by_strahler
#
Prune neuron based on Strahler order.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
to_prune |
TYPE: |
reroot_soma |
TYPE: |
inplace |
TYPE: |
force_strahler_update |
TYPE: |
relocate_connectors |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Pruned neuron(s). |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n_pr = navis.prune_by_strahler(n, to_prune=1, inplace=False)
>>> n.n_nodes > n_pr.n_nodes
True
Source code in navis/morpho/manipulation.py
174 175 176 177 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 |
|
navis.prune_twigs
#
Prune terminal twigs under a given size.
By default this function will simply drop all terminal twigs shorter than size
. This is very fast but rather stupid: for example, if a twig is just 1 nanometer longer than size
it will not be touched at all. If you require precision, set exact=True
which will prune exactly size
off the terminals but is about an order of magnitude slower.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
size |
TYPE: |
exact |
TYPE: |
mask |
TYPE: |
inplace |
TYPE: |
recursive |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Pruned neuron(s). |
Examples:
Simple pruning
>>> import navis
>>> n = navis.example_neurons(2)
>>> # Prune twigs smaller than 5 microns
>>> # (example neuron are in 8x8x8nm units)
>>> n_pr = navis.prune_twigs(n,
... size=5000 / 8,
... recursive=float('inf'),
... inplace=False)
>>> all(n.n_nodes > n_pr.n_nodes)
True
Exact pruning
>>> n = navis.example_neurons(1)
>>> # Prune twigs by exactly 5 microns
>>> # (example neuron are in 8x8x8nm units)
>>> n_pr = navis.prune_twigs(n,
... size=5000 / 8,
... exact=True,
... inplace=False)
>>> n.n_nodes > n_pr.n_nodes
True
Prune using units
>>> import navis
>>> n = navis.example_neurons(1)
>>> # Example neurons are in 8x8x8nm units...
>>> n.units
<Quantity(8, 'nanometer')>
>>> # ... therefore we can use units for `size`
>>> n_pr = navis.prune_twigs(n,
... size='5 microns',
... inplace=False)
>>> n.n_nodes > n_pr.n_nodes
True
Source code in navis/morpho/manipulation.py
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 |
|
navis.read_h5
#
Read Neuron/List from Hdf5 file.
This import is following the schema specified here
PARAMETER | DESCRIPTION |
---|---|
filepath |
TYPE: |
read |
TYPE: |
subset |
TYPE: |
prefer_raw |
TYPE: |
parallel |
TYPE: |
on_error |
TYPE: |
ret_errors |
TYPE: |
Only |
|
annotations |
TYPE: |
strict |
TYPE: |
reader |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neurons | TYPE: |
errors | If TYPE: |
Examples:
See navis.write_h5
for examples.
See Also
navis.write_h5
Write neurons to HDF5 file. navis.io.inspect_h5
Extract meta data (format, number of neurons, available annotations and representations) from HDF5 file. This is useful if you don't know what's actually contained within the HDF5 file.
Source code in navis/io/hdf_io.py
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 765 766 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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
|
navis.read_json
#
Load neuron from JSON (file or string).
PARAMETER | DESCRIPTION |
---|---|
s |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
[`navis.NeuronList`][] | |
See Also
[navis.neuron2json
][] Turn neuron into json.
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> js = navis.write_json(n, filepath=None)
>>> n2 = navis.read_json(js)
Source code in navis/io/json_io.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
navis.read_mesh
#
Load mesh file into Neuron/List.
This is a thin wrapper around trimesh.load_mesh
which supports most commonly used formats (obj, ply, stl, etc.).
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
include_subdirs |
TYPE: |
parallel |
TYPE: |
output |
TYPE: |
errors |
TYPE: |
limit |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
MeshNeuron | If |
Volume | If |
Trimesh | If |
NeuronList | If |
list | If |
See Also
navis.read_precomputed
Read meshes and skeletons from Neuroglancer's precomputed format.
Examples:
Read a single file into navis.MeshNeuron
:
>>> m = navis.read_mesh('mesh.obj')
Read all e.g. .obj files in a directory:
>>> nl = navis.read_mesh('/some/directory/*.obj')
Sample first 50 files in folder:
>>> nl = navis.read_mesh('/some/directory/*.obj', limit=50)
Read single file into navis.Volume
:
>>> nl = navis.read_mesh('mesh.obj', output='volume')
Source code in navis/io/mesh_io.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.read_nml
#
Read xml-based NML files into Neuron/Lists.
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
include_subdirs |
TYPE: |
parallel |
TYPE: |
precision |
TYPE: |
limit |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.NeuronList | |
See Also
navis.read_nmx
Read NMX files (collections of NML files).
Source code in navis/io/nmx_io.py
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 |
|
navis.read_nmx
#
Read NMX files into Neuron/Lists.
NMX is an xml-based format used by pyKNOSSOS. See e.g. here for a data dump of neurons from Wanner et al. (2016).
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
include_subdirs |
TYPE: |
parallel |
TYPE: |
precision |
TYPE: |
limit |
TYPE: |
errors |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.NeuronList | |
See Also
navis.read_nml
Read NML file(s).
Source code in navis/io/nmx_io.py
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 |
|
navis.read_nrrd
#
Create Neuron/List from NRRD file.
See here for specs of NRRD file format including description of the headers.
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
output |
TYPE: |
threshold |
TYPE: |
thin |
TYPE: |
include_subdirs |
TYPE: |
parallel |
TYPE: |
fmt |
TYPE: |
limit |
TYPE: |
errors |
TYPE: |
**dotprops_kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.VoxelNeuron | If |
navis.Dotprops | If Dotprops will contain NRRD header as |
navis.NeuronList | If import of multiple NRRD will return NeuronList of Dotprops/VoxelNeurons. |
(image, header)(np.ndarray, OrderedDict) | If |
Source code in navis/io/nrrd_io.py
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 |
|
navis.read_parquet
#
Read parquet file into Neuron/List.
See here for format specifications.
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
read_meta |
TYPE: |
limit |
TYPE: |
subset |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
navis.TreeNeuron / Dotprops | If parquet file contains a single neuron. |
navis.NeuronList | If parquet file contains multiple neurons. |
See Also
navis.write_parquet
Export neurons as parquet files. navis.scan_parquet
Scan parquet file for its contents.
Examples:
See navis.write_parquet
for examples.
Source code in navis/io/pq_io.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.read_precomputed
#
Read skeletons and meshes from neuroglancer's precomputed format.
Follows the formats specified here.
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
datatype |
TYPE: |
include_subdirs |
TYPE: |
fmt |
TYPE: |
info |
TYPE: |
limit |
TYPE: |
parallel |
TYPE: |
errors |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.MeshNeuron | |
navis.NeuronList | |
See Also
navis.write_precomputed
Export neurons/volumes to precomputed format. navis.read_mesh
Read common mesh formats (obj, stl, etc).
Source code in navis/io/precomputed_io.py
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 |
|
navis.read_rda
#
Read objects from nat R data (.rda) file.
Currently supports parsing neurons, dotprops and mesh3d. Note that this is rather slow and I do not recommend doing this for large collections of neurons. For large scale conversion I recommend using the R interface (navis.interfaces.r
, see online tutorials) via rpy2
.
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
combined |
TYPE: |
neurons_only |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.NeuronList | If |
dict | If |
Source code in navis/io/rda_io.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
navis.read_swc
#
Create Neuron/List from SWC file.
This import is following format specified here.
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
connector_labels |
TYPE: |
include_subdirs |
TYPE: |
delimiter |
TYPE: |
parallel |
TYPE: |
precision |
TYPE: |
fmt |
TYPE: |
read_meta |
TYPE: |
limit |
TYPE: |
errors |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.TreeNeuron | Contains SWC file header as |
navis.NeuronList | If import of multiple SWCs will return NeuronList of TreeNeurons. |
See Also
navis.write_swc
Export neurons as SWC files.
Examples:
Read a single file:
>>> s = navis.read_swc('skeleton.swc')
Read all .swc files in a directory:
>>> s = navis.read_swc('/some/directory/')
Read all .swc files in a zip archive:
>>> s = navis.read_swc('skeletons.zip')
Sample the first 100 SWC files in a zip archive:
>>> s = navis.read_swc('skeletons.zip', limit=100)
Read first all SWC files an ftp folder:
>>> s = navis.read_swc('ftp://server:port/path/to/swc/')
Source code in navis/io/swc_io.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
|
navis.read_tiff
#
Create Neuron/List from TIFF file.
Requires tifffile
library which is not automatically installed!
PARAMETER | DESCRIPTION |
---|---|
f |
TYPE: |
output |
TYPE: |
channel |
TYPE: |
threshold |
TYPE: |
thin |
TYPE: |
include_subdirs |
TYPE: |
parallel |
TYPE: |
fmt |
TYPE: |
limit |
TYPE: |
errors |
TYPE: |
**dotprops_kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
navis.VoxelNeuron | If |
navis.Dotprops | If |
navis.NeuronList | If import of multiple TIFF will return NeuronList of Dotprops/VoxelNeurons. |
(image, header)(np.ndarray, OrderedDict) | If |
Source code in navis/io/tiff_io.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.remove_nodes
#
Drop nodes from neuron without disconnecting it.
Dropping node 2 from 1->2->3 will lead to connectivity 1->3.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
which |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Examples:
Drop points from a neuron
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.n_nodes
4465
>>> # Drop a hundred nodes
>>> n2 = navis.remove_nodes(n, n.nodes.node_id.values[100:200])
>>> n2.n_nodes
4365
Source code in navis/graph/graph_utils.py
2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 |
|
navis.reroot_skeleton
#
Reroot neuron to new root.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
new_root |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | Rerooted neuron. |
See Also
navis.TreeNeuron.reroot
Quick access to reroot directly from TreeNeuron/List objects.
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> # Reroot neuron to its soma
>>> n2 = navis.reroot_skeleton(n, n.soma)
Source code in navis/graph/graph_utils.py
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
|
navis.resample_along_axis
#
Resample neuron such that nodes lie exactly on given 1d grid.
This function does not simply snap nodes to the closest grid line but instead adds new nodes where edges between existing nodes intersect with the planes defined by the grid.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
interval |
TYPE: |
axis |
TYPE: |
old_nodes |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | The resampled neuron(s). |
See Also
navis.resample_skeleton
Resample neuron such that edges between nodes have a given length. navis.downsample_neuron
This function reduces the number of nodes instead of resample to certain resolution. Useful if you are just after some simplification e.g. for speeding up your calculations or you want to preserve node IDs.
Examples:
Resample neuron such that we have one node in every 40nm slice along z axis
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.n_nodes
4465
>>> res = navis.resample_along_axis(n, interval='40 nm',
... axis=2, old_nodes='remove')
>>> res.n_nodes < n.n_nodes
True
Source code in navis/sampling/resampling.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
|
navis.resample_skeleton
#
Resample skeleton(s) to given resolution.
Preserves root, leafs and branchpoints. Soma, connectors and node tags (if present) are mapped onto the closest node in the resampled neuron.
Important
A few things to keep in mind: - This generates an entirely new set of node IDs! They will be unique within a neuron, but you may encounter duplicates across neurons. - Any non-standard node table columns (e.g. "labels") will be lost. - Soma(s) will be pinned to the closest node in the resampled neuron.
Also: be aware that high-resolution neurons will use A LOT of memory.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
resample_to |
TYPE: |
method |
TYPE: |
map_columns |
TYPE: |
inplace |
TYPE: |
skip_errors |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Downsampled neuron(s). |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> # Check sampling resolution (nodes/cable)
>>> round(n.sampling_resolution)
60
>>> # Resample to 1 micron (example neurons are in 8x8x8nm)
>>> n_rs = navis.resample_skeleton(n,
... resample_to=1000 / 8,
... inplace=False)
>>> round(n_rs.sampling_resolution)
134
See Also
navis.downsample_neuron
This function reduces the number of nodes instead of resample to certain resolution. Useful if you are just after some simplification - e.g. for speeding up your calculations or you want to preserve node IDs. navis.resample_along_axis
Resample neuron along a single axis such that nodes align with given 1-dimensional grid.
Source code in navis/sampling/resampling.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.rewire_skeleton
#
Rewire neuron from graph.
This function takes a graph representation of a neuron and rewires its node table accordingly. This is useful if we made changes to the graph (i.e. adding or removing edges) and want those to propagate to the node table.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
g |
TYPE: |
root |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> n.n_trees
1
>>> # Drop one edge from graph
>>> g = n.graph.copy()
>>> g.remove_edge(310, 309)
>>> # Rewire neuron
>>> n2 = navis.rewire_skeleton(n, g, inplace=False)
>>> n2.n_trees
2
Source code in navis/graph/graph_utils.py
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 |
|
navis.scan_parquet
#
Scan parquet file.
PARAMETER | DESCRIPTION |
---|---|
file |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pd.DataFrame | Summary of file's content. |
See Also
navis.write_parquet
Export neurons as parquet files. navis.read_parquet
Read parquet file into neurons.
Examples:
See navis.write_parquet
for examples.
Source code in navis/io/pq_io.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
navis.segment_analysis
#
Calculate morphometric properties a neuron's segments.
This currently includes Strahler index, length, distance to root and tortuosity. If neuron has a radius will also calculate radius-based metrics such as volume.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pandas.DataFrame | Each row represents one linear segment between leafs/branch nodes (corresponds to |
See Also
navis.strahler_index
This function calculates the Strahler index for every nodes/vertex in the neuron. navis.tortuosity
This function calculates a tortuosity for the entire neuron.
Examples:
Run analysis on a single neuron:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> n.reroot(n.soma, inplace=True)
>>> sa = navis.segment_analysis(n)
>>> sa.head()
length tortuosity root_dist strahler_index ... volume
0 1073.535053 1.151022 229.448586 1 ... 4.159788e+07
1 112.682839 1.092659 10279.037511 1 ... 1.153095e+05
2 214.124934 1.013030 9557.521377 1 ... 8.618440e+05
3 159.585328 1.074575 9747.866968 1 ... 9.088157e+05
4 229.448586 1.000000 0.000000 6 ... 3.206231e+07
>>> # Get per Strahler index means
>>> sa.groupby('strahler_index').mean()
length tortuosity root_dist ... volume
strahler_index
1 200.957415 1.111979 13889.593659 ... 8.363172e+05
2 171.283617 1.047736 14167.056400 ... 1.061405e+06
3 134.788019 1.023672 13409.920288 ... 9.212662e+05
4 711.063734 1.016606 15768.886051 ... 7.304981e+06
5 146.350195 1.000996 8443.345668 ... 2.262917e+06
6 685.852990 1.056258 1881.594266 ... 1.067976e+07
Compare across neurons:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> sa = navis.segment_analysis(nl)
>>> # Note the `neuron` column when running the analysis on NeuronLists
>>> sa.head()
neuron length tortuosity root_dist ... volume
0 1734350788 112.682839 1.092659 11123.123978 ... 1.153095e+05
1 1734350788 214.124934 1.013030 10401.607843 ... 8.618440e+05
2 1734350788 159.585328 1.074575 10591.953435 ... 9.088157e+05
3 1734350788 1073.535053 1.151022 0.000000 ... 4.159788e+07
4 1734350788 260.538727 1.000000 1073.535053 ... 3.593405e+07
>>> # Get Strahler index counts for each neuron
>>> si_counts = sa.groupby(['neuron', 'strahler_index']).size().unstack()
>>> si_counts
strahler_index 1 2 3 4 5 6 7
neuron
722817260 656.0 336.0 167.0 74.0 32.0 24.0 NaN
754534424 726.0 345.0 176.0 111.0 37.0 9.0 18.0
754538881 642.0 344.0 149.0 88.0 21.0 24.0 NaN
1734350788 618.0 338.0 138.0 74.0 38.0 11.0 NaN
1734350908 761.0 363.0 203.0 116.0 20.0 33.0 NaN
Source code in navis/morpho/mmetrics.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
|
navis.segment_length
#
Get length of a linear segment.
This function is superfast but has no checks - you must provide a valid segment.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
segment |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
length | TYPE: |
See Also
navis.dist_between
If you only know start and end points of the segment.
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> l = navis.segment_length(n, n.segments[0])
>>> round(l)
56356
Source code in navis/graph/graph_utils.py
940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 |
|
navis.segregation_index
#
Calculate segregation index (SI).
The segregation index as established by Schneider-Mizell et al. (eLife, 2016) is a measure for how polarized a neuron is. SI of 1 indicates total segregation of inputs and outputs into dendrites and axon, respectively. SI of 0 indicates homogeneous distribution.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
Notes
From Schneider-Mizell et al. (2016): "Note that even a modest amount of mixture (e.g. axo-axonic inputs) corresponds to values near H = 0.5–0.6 (Figure 7—figure supplement 1). We consider an unsegregated neuron (H ¡ 0.05) to be purely dendritic due to their anatomical similarity with the dendritic domains of those segregated neurons that have dendritic outputs."
RETURNS | DESCRIPTION |
---|---|
H | Segregation Index (SI). TYPE: |
Source code in navis/morpho/mmetrics.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
|
navis.set_default_connector_colors
#
Set/update default connector colors.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
Source code in navis/utils/misc.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
navis.set_loggers
#
Set levels for all associated module loggers.
Examples:
>>> from navis.utils import set_loggers
>>> from navis import config
>>> # Get current level
>>> lvl = config.logger.level
>>> # Set new level
>>> set_loggers('INFO')
>>> # Revert to old level
>>> set_loggers(lvl)
Source code in navis/utils/misc.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
navis.set_pbars
#
Set global progress bar behaviors.
PARAMETER | DESCRIPTION |
---|---|
hide |
TYPE: |
leave |
TYPE: |
jupyter |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Nothing | |
Examples:
>>> from navis.utils import set_pbars
>>> # Hide progress bars after finishing
>>> set_pbars(leave=False)
>>> # Never show progress bars
>>> set_pbars(hide=True)
>>> # Never use Jupyter widget progress bars
>>> set_pbars(jupyter=False)
Source code in navis/utils/misc.py
173 174 175 176 177 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 |
|
navis.sholl_analysis
#
Run Sholl analysis for given neuron(s).
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
radii |
TYPE: |
center |
TYPE: |
geodesic |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
results | Results contain, for each spherical bin, the number of intersections, cable length and number of branch points. TYPE: |
References
See the Wikipedia article for a brief explanation.
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> # Sholl analysis
>>> sha = navis.sholl_analysis(n, radii=100, center='root')
>>> # Plot distributions
>>> ax = sha.plot()
>>> # Sholl analysis but using geodesic distance
>>> sha = navis.sholl_analysis(n, radii=100, center='root', geodesic=True)
Source code in navis/morpho/mmetrics.py
1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 |
|
navis.simplify_mesh
#
Simplify meshes (TriMesh, MeshNeuron, Volume).
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
F |
TYPE: |
backend |
TYPE: |
inplace |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
simplified | Simplified object. |
See Also
navis.downsample_neuron
Downsample all kinds of neurons. navis.meshes.simplify_mesh_fqmr
pyfqmr implementation for mesh simplification. navis.meshes.simplify_mesh_open3d
Open3D implementation for mesh simplification. navis.meshes.simplify_mesh_pyml
PyMeshLab implementation for mesh simplification. navis.meshes.simplify_mesh_blender
Blender 3D implementation for mesh simplification.
Source code in navis/meshes/operations.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
navis.skeletonize
#
Turn neuron into skeleton.
Currently, we can only skeletonize meshes, dotprops and point clouds but are looking into ways to also do it for VoxelNeurons
.
For meshes, this function is a thin-wrapper for skeletor
. It uses sensible defaults for neurons but if you want to fine-tune your skeletons you should look into using skeletor
directly.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
skeleton | For meshes, this has a TYPE: |
See Also
navis.drop_fluff
Use this if your mesh has lots of tiny free floating bits to reduce noise and speed up skeletonization.
Examples:
Skeletonize a mesh#
>>> import navis
>>> # Get a mesh neuron
>>> n = navis.example_neurons(1, kind='mesh')
>>> # Convert to skeleton
>>> sk = navis.skeletonize(n)
>>> # Mesh vertex indices to node IDs map
>>> sk.vertex_map
array([938, 990, 990, ..., 39, 234, 234])
Skeletonize dotprops (i.e. point-clouds)#
>>> import navis
>>> # Get a skeleton and turn into dotprops
>>> dp = navis.make_dotprops(navis.example_neurons(1))
>>> # Turn back into a skeleton
>>> sk = navis.skeletonize(dp)
Source code in navis/conversion/wrappers.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
navis.smooth_mesh
#
Smooth meshes (TriMesh, MeshNeuron, Volume).
Uses Laplacian smoothing. Not necessarily because that is always the best approach but because there are three backends (see below) that offer similar interfaces.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
iterations |
TYPE: |
L |
TYPE: |
backend |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
smoothed | Smoothed object. |
Source code in navis/meshes/operations.py
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 |
|
navis.smooth_skeleton
#
Smooth skeleton(s) using rolling windows.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
window |
TYPE: |
to_smooth |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | Smoothed neuron(s). |
Examples:
Smooth x/y/z locations (default):
>>> import navis
>>> nl = navis.example_neurons(2)
>>> smoothed = navis.smooth_skeleton(nl, window=5)
Smooth only radii:
>>> rad_smoothed = navis.smooth_skeleton(nl, to_smooth='radius')
See Also
navis.smooth_mesh
For smoothing MeshNeurons and other mesh-likes. navis.smooth_voxels
For smoothing VoxelNeurons.
Source code in navis/morpho/manipulation.py
1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 |
|
navis.smooth_voxels
#
Smooth voxel(s) using a Gaussian filter.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
sigma |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
VoxelNeuron / List | Smoothed neuron(s). |
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='mesh')
>>> vx = navis.voxelize(n, pitch='1 micron')
>>> smoothed = navis.smooth_voxels(vx, sigma=2)
See Also
navis.smooth_mesh
For smoothing MeshNeurons and other mesh-likes. navis.smooth_skeleton
For smoothing TreeNeurons.
Source code in navis/morpho/images.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
navis.split_axon_dendrite
#
Split a neuron into axon and dendrite.
The result is highly dependent on the method and on your neuron's morphology and works best for "typical" neurons.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
metric |
TYPE: |
flow_thresh |
TYPE: |
split |
TYPE: |
cellbodyfiber |
TYPE: |
reroot_soma |
TYPE: |
label_only |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
NeuronList | Axon, dendrite, linker and CBF (the latter two aren't guaranteed). Fragments will have a new property |
Examples:
>>> import navis
>>> x = navis.example_neurons(1)
>>> split = navis.split_axon_dendrite(x, metric='synapse_flow_centrality',
... reroot_soma=True)
>>> split
<class 'navis.NeuronList'> of 3 neurons
neuron_name id n_nodes n_connectors compartment
0 neuron 123457 16 148 0 axon
1 neuron 123457 16 9682 1766 linker
2 neuron 123457 16 2892 113 dendrite
>>> # For convenience, split_axon_dendrite assigns colors to the resulting
>>> # fragments: axon = red, dendrites = blue, CBF = green
>>> _ = split.plot3d(color=split.color)
Alternatively just label the compartments
>>> x = navis.split_axon_dendrite(x, label_only=True)
>>> x.nodes[~x.nodes.compartment.isnull()].head()
node_id label x y z radius parent_id type compartment
110 111 0 17024.0 33790.0 26602.0 72.462097 110 slab linker
111 112 0 17104.0 33670.0 26682.0 72.462097 111 slab linker
112 113 0 17184.0 33450.0 26782.0 70.000000 112 slab linker
113 114 0 17244.0 33270.0 26822.0 70.000000 113 slab linker
114 115 0 17324.0 33150.0 26882.0 74.852798 114 slab linker
See Also
navis.heal_skeleton
Axon/dendrite split works only on neurons consisting of a single tree. Use this function to heal fragmented neurons before trying the axon/dendrite split.
Source code in navis/morpho/manipulation.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 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 765 766 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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
|
navis.split_into_fragments
#
Split neuron into fragments.
Cuts are based on longest neurites: the first cut is made where the second largest neurite merges onto the largest neurite, the second cut is made where the third largest neurite merges into either of the first fragments and so on.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
n |
TYPE: |
min_size |
TYPE: |
reroot_soma |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
NeuronList | |
Examples:
>>> import navis
>>> x = navis.example_neurons(1)
>>> # Cut into two fragments
>>> cut1 = navis.split_into_fragments(x, n=2)
>>> # Cut into fragments of >10 um size
>>> cut2 = navis.split_into_fragments(x, n=float('inf'), min_size=10e3)
Source code in navis/graph/graph_utils.py
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 |
|
navis.stitch_skeletons
#
Stitch multiple skeletons together.
Uses minimum spanning tree to determine a way to connect all fragments while minimizing length (Euclidean distance) of the new edges. Nodes that have been stitched will get a "stitched" tag.
Important
If duplicate node IDs are found across the fragments to stitch they will be remapped to new unique values!
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
method |
TYPE: |
master |
TYPE: |
max_dist |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | Stitched neuron. |
See Also
navis.combine_neurons
Combines multiple neurons of the same type into one without stitching. Works on TreeNeurons, MeshNeurons and Dotprops.
Examples:
Stitching neuronlist by simply combining data tables:
>>> import navis
>>> nl = navis.example_neurons(2)
>>> stitched = navis.stitch_skeletons(nl, method='NONE')
Stitching fragmented neurons:
>>> a = navis.example_neurons(1)
>>> fragments = navis.cut_skeleton(a, 100)
>>> stitched = navis.stitch_skeletons(fragments, method='LEAFS')
Source code in navis/morpho/manipulation.py
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 |
|
navis.strahler_index
#
Calculate Strahler Index (SI).
Starts with SI of 1 at each leaf and walks to root. At forks with different incoming SIs, the highest index is continued. At forks with the same incoming SI, highest index + 1 is continued.
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
method |
TYPE: |
to_ignore |
TYPE: |
min_twig_size |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neuron | Adds "strahler_index" as column in the node table (for TreeNeurons) or as |
See Also
navis.segment_analysis
This function provides by-segment morphometrics, including Strahler indices.
Examples:
>>> import navis
>>> n = navis.example_neurons(2, kind='skeleton')
>>> n.reroot(n.soma, inplace=True)
>>> _ = navis.strahler_index(n)
>>> n[0].nodes.strahler_index.max()
6
>>> m = navis.example_neurons(1, kind='mesh')
>>> _ = navis.strahler_index(m)
>>> m.strahler_index.max()
5
Source code in navis/morpho/mmetrics.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.subset_neuron
#
Subset a neuron to a given set of nodes/vertices.
Note that for MeshNeurons
it is not guaranteed that all vertices in subset
survive because we will also drop degenerate vertices that do not participate in any faces.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
subset |
TYPE: |
keep_disc_cn |
TYPE: |
prevent_fragments |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron | MeshNeuron | Dotprops | NeuronList | |
Examples:
Subset skeleton to all branches with less than 10 nodes
>>> import navis
>>> # Get neuron
>>> n = navis.example_neurons(1)
>>> # Get all linear segments
>>> segs = n.segments
>>> # Get short segments
>>> short_segs = [s for s in segs if len(s) <= 10]
>>> # Flatten segments into list of nodes
>>> nodes_to_keep = [n for s in short_segs for n in s]
>>> # Subset neuron
>>> n_short = navis.subset_neuron(n, subset=nodes_to_keep)
Subset multiple neurons using a callable
>>> import navis
>>> nl = navis.example_neurons(2)
>>> # Subset neurons to all leaf nodes
>>> nl_end = navis.subset_neuron(
... nl,
... subset=lambda x: x.leafs.node_id
... )
See Also
navis.cut_skeleton
Cut neuron at specific points. navis.in_volume
To intersect a neuron with a volume (mesh).
Source code in navis/morpho/subset.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
navis.symmetrize_brain
#
Symmetrize 3D object (neuron, coordinates).
The way this works is by: 1. Finding the closest mirror transform (unless provided) 2. Mirror data on the left-hand-side to the right-hand-side using the proper (warp) mirror transform to offset deformations 3. Simply flip that data back to the left-hand-side
This works reasonably well but may produce odd results around the midline. For high quality symmetrization you are better off generating dedicated transform (see navis-flybrains
for an example).
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
template |
TYPE: |
via |
TYPE: |
verbose |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
xs | Same object type as input (array, neurons, etc) but hopefully symmetrical. |
Examples:
This example requires the flybrains library to be installed: pip3 install flybrains
>>> import navis
>>> import flybrains
>>> # Get the FAFB14 neuropil mesh
>>> m = flybrains.FAFB14.mesh
>>> # Symmetrize the mesh
>>> s = navis.symmetrize_brain(m, template='FAFB14')
>>> # Plot side-by-side for comparison
>>> m.plot3d()
>>> s.plot3d(color=(1, 0, 0))
Source code in navis/transforms/templates.py
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 |
|
navis.synapse_flow_centrality
#
Calculate synapse flow centrality (SFC).
From Schneider-Mizell et al. (2016): "We use flow centrality for four purposes. First, to split an arbor into axon and dendrite at the maximum centrifugal SFC, which is a preliminary step for computing the segregation index, for expressing all kinds of connectivity edges (e.g. axo-axonic, dendro-dendritic) in the wiring diagram, or for rendering the arbor in 3d with differently colored regions. Second, to quantitatively estimate the cable distance between the axon terminals and dendritic arbor by measuring the amount of cable with the maximum centrifugal SFC value. Third, to measure the cable length of the main dendritic shafts using centripetal SFC, which applies only to insect neurons with at least one output synapse in their dendritic arbor. And fourth, to weigh the color of each skeleton node in a 3d view, providing a characteristic signature of the arbor that enables subjective evaluation of its identity."
Uses navis-fastcore if available.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
mode |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
neuron | Adds "synapse_flow_centrality" as column in the node table (for TreeNeurons) or as |
Examples:
>>> import navis
>>> n = navis.example_neurons(2)
>>> n.reroot(n.soma, inplace=True)
>>> _ = navis.synapse_flow_centrality(n)
>>> n[0].nodes.synapse_flow_centrality.max()
786969
See Also
navis.bending_flow
Variation of synapse flow centrality: calculates bending flow. navis.arbor_segregation_index
By-arbor segregation index. navis.segregation_index
Calculates segregation score (polarity) of a neuron. navis.split_axon_dendrite
Tries splitting a neuron into axon and dendrite. navis.flow_centrality
Leaf-based version of flow centrality.
Source code in navis/morpho/mmetrics.py
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
|
navis.synapse_similarity
#
Cluster neurons based on their synapse placement.
Distances score is calculated by calculating for each synapse of neuron A: (1) the (Euclidean) distance to the closest synapse in neuron B and (2) comparing the synapse density around synapse A and B. This is type-sensitive: presynapses will only be matched with presynapses, post with post, etc. The formula is described in Schlegel et al., eLife (2017):
The synapse similarity score for neurons i and j being the average of \(f(i_{s},j_{k})\) over all synapses s of i. Synapse k is the closest synapse of the same sign (pre/post) in neuron j to synapse s. \(d^{2}_{sk}\) is the Euclidean distance between these distances. Variable \(\sigma\) (sigma
) determines what distance between s and k is considered "close". \(n(i_{s})\) and \(n(j_{k})\) are defined as the number of synapses of neuron i/j that are within given radius \(\omega\) (omega
) of synapse s and j, respectively (same sign only). This esnures that in cases of a strong disparity between \(n(i_{s})\) and \(n(j_{k})\), the synapse similarity will be close to zero even if the distance between s and k is very small.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
sigma |
TYPE: |
omega |
TYPE: |
mu_score |
TYPE: |
restrict_cn |
TYPE: |
n_cores |
|
RETURNS | DESCRIPTION |
---|---|
pandas.DataFrame | |
See Also
navis.synblast
NBLAST variant using synapses.
Examples:
>>> import navis
>>> nl = navis.example_neurons(5)
>>> scores = navis.synapse_similarity(nl, omega=5000/8, sigma=2000/8)
Source code in navis/connectivity/similarity.py
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 414 415 |
|
navis.synblast
#
Synapsed-based variant of NBLAST.
The gist is this: for each synapse in the query neuron, we find the closest synapse in the target neuron (can be restricted by synapse types). Those distances are then scored similar to nearest-neighbor pairs in NBLAST but without the vector component.
PARAMETER | DESCRIPTION |
---|---|
query |
TYPE: |
by_type |
TYPE: |
cn_types |
TYPE: |
scores |
TYPE: |
n_cores |
|
normalized |
TYPE: |
smat |
TYPE: |
progress |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
scores | Matrix with SynBLAST scores. Rows are query neurons, columns are targets. TYPE: |
Examples:
>>> import navis
>>> nl = navis.example_neurons(n=5)
>>> nl.units
<Quantity([8 8 8 8 8], 'nanometer')>
>>> # Convert to microns
>>> nl_um = nl * (8 / 1000)
>>> # Run type-agnostic SyNBLAST
>>> scores = navis.synblast(nl_um[:3], nl_um[3:], progress=False)
>>> # Run type-sensitive (i.e. pre vs pre and post vs post) SyNBLAST
>>> scores = navis.synblast(nl_um[:3], nl_um[3:], by_type=True, progress=False)
See Also
navis.nblast
The original morphology-based NBLAST.
Source code in navis/nbl/synblast_funcs.py
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 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
|
navis.thin_voxels
#
Skeletonize image data to single voxel width.
This is a simple thin wrapper around scikit-learn's skeletonize
.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
thin | Thinned VoxelNeuron or numpy array. |
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='mesh')
>>> vx = navis.voxelize(n, pitch='1 micron')
>>> thinned = navis.thin_voxels(vx)
Source code in navis/morpho/images.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
navis.tortuosity
#
Calculate tortuosity of a neuron.
See Stepanyants et al., Neuron (2004) for detailed explanation. Briefly, tortuosity index T
is defined as the ratio of the branch segment length L
(seg_length
) to the Euclidean distance R
between its ends.
The way this is implemented in navis
: For each linear stretch (i.e. segments between branch points, leafs or roots) we calculate its geodesic length L
and the Euclidean distance R
between its ends. The final tortuosity is the mean of L / R
across all segments.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
seg_length |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
tortuosity | If x is NeuronList, will return DataFrame. If x is single TreeNeuron, will return either a single float (if no or a single seg_length is queried) or a DataFrame (if multiple seg_lengths are queried). |
See Also
navis.segment_analysis
This function provides by-segment morphometrics, including tortuosity.
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> # Calculate tortuosity as-is
>>> T = navis.tortuosity(n)
>>> round(T, 3)
1.074
>>> # Calculate tortuosity with 1 micron segment lengths
>>> T = navis.tortuosity(n, seg_length='1 micron')
>>> round(T, 3)
1.054
Source code in navis/morpho/mmetrics.py
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 |
|
navis.vary_colors
#
Add small variance to color.
Source code in navis/plotting/colors.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 |
|
navis.voxelize
#
Turn neuron into voxels.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
pitch |
TYPE: |
bounds |
TYPE: |
counts |
TYPE: |
vectors |
TYPE: |
alphas |
TYPE: |
smooth |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
VoxelNeuron | Has the voxel grid as |
Examples:
>>> import navis
>>> # Get a skeleton
>>> n = navis.example_neurons(1)
>>> # Convert to voxel neuron
>>> vx = navis.voxelize(n, pitch='5 microns')
Source code in navis/conversion/wrappers.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
navis.write_h5
#
Write Neuron/List to Hdf5 file.
PARAMETER | DESCRIPTION |
---|---|
n |
TYPE: |
filepath |
TYPE: |
serialized |
TYPE: |
raw |
TYPE: |
append |
TYPE: |
overwrite_neurons |
TYPE: |
Only |
|
annotations |
TYPE: |
format |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Nothing | |
Examples:
>>> import navis
>>> # First get mesh, skeleton and dotprop representations for some neurons
>>> sk = navis.example_neurons(5, kind='skeleton')
>>> me = navis.example_neurons(5, kind='mesh')
>>> dp = navis.make_dotprops(sk, k=5)
>>> # Write them to a file
>>> navis.write_h5(sk + me + dp, '~/test.h5', overwrite_neurons=True)
>>> # Read back from file
>>> nl = navis.read_h5('~/test.h5')
See Also
navis.read_h5
Read neurons from h5 file.
Source code in navis/io/hdf_io.py
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 |
|
navis.write_json
#
Save neuron(s) to json-formatted file.
Nodes and connectors are serialised using pandas' to_json()
. Most other items in the neuron's dict are serialised using json.dumps()
. Properties not serialised: .graph
, .igraph
.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
filepath |
TYPE: |
**kwargs |
DEFAULT: |
RETURNS | DESCRIPTION |
---|---|
str | Only if |
See Also
navis.read_json
Read json back into navis neurons.
Source code in navis/io/json_io.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
navis.write_mesh
#
Export meshes (MeshNeurons, Volumes, Trimeshes) to disk.
Under the hood this is using trimesh to export meshes.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
filepath |
TYPE: |
filetype |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | If filepath is not |
bytes | If filepath is |
See Also
navis.read_mesh
Import neurons. navis.write_precomputed
Write meshes to Neuroglancer's precomputed format.
Examples:
Write MeshNeurons
to folder:
>>> import navis
>>> nl = navis.example_neurons(3, kind='mesh')
>>> navis.write_mesh(nl, tmp_dir, filetype='obj')
Specify the filenames:
>>> import navis
>>> nl = navis.example_neurons(3, kind='mesh')
>>> navis.write_mesh(nl, tmp_dir / '{neuron.name}.obj')
Write directly to zip archive:
>>> import navis
>>> nl = navis.example_neurons(3, kind='mesh')
>>> navis.write_mesh(nl, tmp_dir / 'meshes.zip', filetype='obj')
Source code in navis/io/mesh_io.py
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 |
|
navis.write_nrrd
#
Write VoxelNeurons or Dotprops to NRRD file(s).
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
filepath |
TYPE: |
compression_level |
TYPE: |
attrs |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
Nothing | |
Examples:
Save a single neuron to a specific file:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> vx = navis.voxelize(n, pitch='2 microns')
>>> navis.write_nrrd(vx, tmp_dir / 'my_neuron.nrrd')
Save multiple neurons to a folder (must exist). Filenames will be autogenerated as "{neuron.id}.nrrd":
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> dp = navis.make_dotprops(nl, k=5)
>>> navis.write_nrrd(dp, tmp_dir)
Save multiple neurons to a folder but modify the pattern for the autogenerated filenames:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> vx = navis.voxelize(nl, pitch='2 microns')
>>> navis.write_nrrd(vx, tmp_dir / 'voxels-{neuron.name}.nrrd')
Save multiple neurons to a zip file:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> vx = navis.voxelize(nl, pitch='2 microns')
>>> navis.write_nrrd(vx, tmp_dir / 'neuronlist.zip')
Save multiple neurons to a zip file but modify the filenames:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> vx = navis.voxelize(nl, pitch='2 microns')
>>> navis.write_nrrd(vx, tmp_dir / 'voxels-{neuron.name}.nrrd@neuronlist.zip')
See Also
navis.read_nrrd
Import VoxelNeuron from NRRD files.
Source code in navis/io/nrrd_io.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.write_parquet
#
Write TreeNeuron(s) or Dotprops to parquet file.
See here for format specifications.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
filepath |
TYPE: |
write_meta |
TYPE: |
See Also
navis.read_parquet
Import skeleton from parquet file. navis.scan_parquet
Scan parquet file for its contents.
Examples:
Save a bunch of skeletons:
>>> import navis
>>> nl = navis.example_neurons(3, kind='skeleton')
>>> navis.write_parquet(nl, tmp_dir / 'skeletons.parquet')
Inspect that file's content
>>> import navis
>>> contents = navis.scan_parquet(tmp_dir / 'skeletons.parquet')
>>> contents
id units name soma
0 722817260 8 nanometer DA1_lPN_R NaN
1 1734350908 8 nanometer DA1_lPN_R [6]
2 1734350788 8 nanometer DA1_lPN_R [4177]
Read the skeletons back in
>>> import navis
>>> nl = navis.read_parquet(tmp_dir / 'skeletons.parquet')
>>> len(nl)
3
Source code in navis/io/pq_io.py
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 |
|
navis.write_precomputed
#
Export skeletons or meshes to neuroglancer's (legacy) precomputed format.
Note that you should not mix meshes and skeletons in the same folder!
Follows the formats specified here.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
filepath |
TYPE: |
write_info |
TYPE: |
write_manifest |
TYPE: |
radius |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | If filepath is not |
bytes | If filepath is |
See Also
navis.read_precomputed
Import neurons from neuroglancer's precomputed format. navis.write_mesh
Write meshes to generic mesh formats (obj, stl, etc).
Examples:
Write skeletons:
>>> import navis
>>> n = navis.example_neurons(3, kind='skeleton')
>>> navis.write_precomputed(n, tmp_dir)
Write meshes:
>>> import navis
>>> n = navis.example_neurons(3, kind='mesh')
>>> navis.write_precomputed(n, tmp_dir)
Write directly to zip archive:
>>> import navis
>>> n = navis.example_neurons(3, kind='skeleton')
>>> navis.write_precomputed(n, tmp_dir / 'precomputed.zip')
Source code in navis/io/precomputed_io.py
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
|
navis.write_swc
#
Write TreeNeuron(s) to SWC.
Follows the format specified here.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
filepath |
TYPE: |
header |
TYPE: |
write_meta |
TYPE: |
labels |
TYPE: |
export_connectors |
TYPE: |
return_node_map |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
node_map | Only if TYPE: |
See Also
navis.read_swc
Import skeleton from SWC files.
Examples:
Save a single neuron to a specific file:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> navis.write_swc(n, tmp_dir / 'my_neuron.swc')
Save two neurons to specific files:
>>> import navis
>>> nl = navis.example_neurons(2, kind='skeleton')
>>> navis.write_swc(nl, [tmp_dir / 'my_neuron1.swc', tmp_dir / 'my_neuron2.swc'])
Save multiple neurons to a folder (must exist). Filenames will be autogenerated as "{neuron.id}.swc":
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> navis.write_swc(nl, tmp_dir)
Save multiple neurons to a folder but modify the pattern for the autogenerated filenames:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> navis.write_swc(nl, tmp_dir / 'skel-{neuron.name}.swc')
Save multiple neurons to a zip file:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> navis.write_swc(nl, tmp_dir / 'neuronlist.zip')
Save multiple neurons to a zip file but modify the filenames:
>>> import navis
>>> nl = navis.example_neurons(5, kind='skeleton')
>>> navis.write_swc(nl, tmp_dir / 'skel-{neuron.name}.swc@neuronlist.zip')
Source code in navis/io/swc_io.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
|
navis.xform
#
Apply transform(s) to data.
Notes
For Neurons only: whether there is a change in units during transformation (e.g. nm -> um) is inferred by comparing distances between x/y/z coordinates before and after transform. This guesstimate is then used to convert .units
and node/soma radii. This works reasonably well with base 10 increments (e.g. nm -> um) but is off with odd changes in units.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
transform |
TYPE: |
affine_fallback |
TYPE: |
caching |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
same type as `x` | Copy of input with transformed coordinates. |
Examples:
>>> import navis
>>> # Example neurons are in 8nm voxel space
>>> nl = navis.example_neurons()
>>> # Make a simple Affine transform to go from voxel to nanometers
>>> import numpy as np
>>> M = np.diag([8, 8, 8, 8])
>>> tr = navis.transforms.AffineTransform(M)
>>> # Apply the transform
>>> xf = navis.xform(nl, tr)
See Also
navis.xform_brain
Higher level function that finds and applies a sequence of transforms to go from one template brain to another.
Source code in navis/transforms/xfm_funcs.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 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 |
|
navis.xform_brain
#
Transform 3D data between template brains.
This requires the appropriate transforms to be registered with navis
. See the docs/tutorials for details.
Notes
For Neurons only: transforms can introduce a change in the units (e.g. if the transform goes from micron to nanometer space). Some template brains have their units hard-coded in their meta data (as _navis_units
). If that's not the case we fall-back to trying to infer any change in units by comparing distances between x/y/z coordinate before and after the transform. That approach works reasonably well with base 10 increments (e.g. nm -> um) but may be off with odd changes in units (e.g. physical -> voxel space). Regardless of whether hard-coded or inferred, any change in units is used to update the .units
property and node/soma radii for TreeNeurons.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
source |
TYPE: |
target |
TYPE: |
via |
TYPE: |
avoid |
TYPE: |
affine_fallback |
TYPE: |
caching |
TYPE: |
verbose |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
same type as `x` | Copy of input with transformed coordinates. |
Examples:
This example requires the flybrains library to be installed: pip3 install flybrains
Also, if you haven't already, you will need to have the optional Saalfeld lab (Janelia Research Campus) transforms installed (this is a one-off):
>>> import flybrains
>>> flybrains.download_jrc_transforms()
Once flybrains
is installed and you have downloaded the registrations, you can run this:
>>> import navis
>>> import flybrains
>>> # navis example neurons are in raw (8nm voxel) hemibrain (JRCFIB2018Fraw) space
>>> n = navis.example_neurons(1)
>>> # Transform to FAFB14 space
>>> xf = navis.xform_brain(n, source='JRCFIB2018Fraw', target='FAFB14')
See Also
navis.xform
Lower level entry point that takes data and applies a given transform or sequence thereof. navis.mirror_brain
Uses non-rigid transforms to mirror neurons from the left to the right side of given template brain and vice versa.
Source code in navis/transforms/templates.py
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 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
|