From 505ce6cfed7858567bda6718fd287d1af2d3e4eb Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 27 Jan 2020 12:13:26 +0000 Subject: [PATCH 01/21] points to brainrender --- neuro/points/__init__.py | 0 neuro/points/points_to_brainrender.py | 107 + setup.py | 8 +- tests/data/points/brainrender.h5 | Bin 0 -> 38720 bytes tests/data/points/cellfinder_out.xml | 3947 +++++++++++++++++++ tests/tests/test_integration/test_points.py | 39 + tests/tests/test_nothing.py | 2 - 7 files changed, 4100 insertions(+), 3 deletions(-) create mode 100644 neuro/points/__init__.py create mode 100644 neuro/points/points_to_brainrender.py create mode 100644 tests/data/points/brainrender.h5 create mode 100644 tests/data/points/cellfinder_out.xml create mode 100644 tests/tests/test_integration/test_points.py delete mode 100644 tests/tests/test_nothing.py diff --git a/neuro/points/__init__.py b/neuro/points/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/neuro/points/points_to_brainrender.py b/neuro/points/points_to_brainrender.py new file mode 100644 index 0000000..f7e4f92 --- /dev/null +++ b/neuro/points/points_to_brainrender.py @@ -0,0 +1,107 @@ +""" +Converts point positions from cellfinder coordinates to brainrender +""" + +import argparse +import imlib.IO.cells as cells_io +from imlib.misc import check_positive_float, check_positive_int + + +def run( + cells_file, + output_filename, + pixel_size_x=10, + pixel_size_y=10, + pixel_size_z=10, + max_z=13200, + key="df", +): + print(f"Converting file: {cells_file}") + cells = cells_io.get_cells(cells_file) + cells = cells_io.cells_to_dataframe(cells) + + cells["x"] = cells["x"] * pixel_size_x + cells["y"] = cells["y"] * pixel_size_y + cells["z"] = cells["z"] * pixel_size_z + + cells.columns = ["z", "y", "x", "type"] + + cells["x"] = max_z - cells["x"] + + print(f"Saving to: {output_filename}") + cells.to_hdf(output_filename, key=key, mode="w") + + print("Finished") + + +def get_parser(): + parser = argparse.ArgumentParser( + formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument( + dest="cells_file", + type=str, + help="Cellfinder cells file to be converted", + ) + parser.add_argument( + dest="output_filename", + type=str, + help="Output filename. Should end with '.h5'", + ) + + parser.add_argument( + "-x", + "--x-pixel-size", + dest="x_pixel_size", + type=check_positive_float, + default=10, + help="Pixel_size that the cells are defined in.", + ) + parser.add_argument( + "-y", + "--y-pixel-size", + dest="y_pixel_size", + type=check_positive_float, + default=10, + help="Pixel_size that the cells are defined in.", + ) + parser.add_argument( + "-z", + "--z-pixel-size", + dest="z_pixel_size", + type=check_positive_float, + default=10, + help="Pixel_size that the cells are defined in.", + ) + parser.add_argument( + "--max-z", + dest="max_z", + type=check_positive_int, + default=13200, + help="Maximum z extent of the atlas", + ) + parser.add_argument( + "--hdf-key", + dest="hdf_key", + type=str, + default="df", + help="hdf identifier ", + ) + return parser + + +def main(): + args = get_parser().parse_args() + run( + args.cells_file, + args.output_filename, + pixel_size_x=args.x_pixel_size, + pixel_size_y=args.y_pixel_size, + pixel_size_z=args.z_pixel_size, + max_z=args.max_z, + key=args.hdf_key, + ) + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 92778ad..5c705ad 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_namespace_packages -requirements = ["brainrender", "napari"] +requirements = ["brainrender", "napari", "imlib", "pandas"] setup( @@ -37,5 +37,11 @@ "Intended Audience :: Developers", "Intended Audience :: Science/Research", ], + entry_points={ + "console_scripts": [ + "points_to_brainrender = " + "neuro.points.points_to_brainrender:main", + ] + }, zip_safe=False, ) diff --git a/tests/data/points/brainrender.h5 b/tests/data/points/brainrender.h5 new file mode 100644 index 0000000000000000000000000000000000000000..df90eeccc2b55d657f2706f1c76b6471754567e9 GIT binary patch literal 38720 zcmeI5eb`i0xrc`j@f8sf6%|d9$PAUx(8!Dc1VEL$jpdL&&=%m2F@?HdHUygPRw=X&Ae;Y+G{=Q`C8B3 zGhH>{l>U3Q?%29gdo?svT2|WC|LK38=hgeh;xE3peJuZI2Is&<&5M6DtF)@r+79IJ z?HIpPi{cOK`TOvp{rXj^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ellfinder_out.xml new file mode 100644 index 0000000..33280b7 --- /dev/null +++ b/tests/data/points/cellfinder_out.xml @@ -0,0 +1,3947 @@ + + + + placeholder.tif + + + 1 + + 2 + + 679 + 80 + 660 + + + 679 + 102 + 656 + + + 629 + 108 + 659 + + + 681 + 316 + 629 + + + 678 + 92 + 658 + + + 626 + 95 + 662 + + + 779 + 152 + 639 + + + 615 + 151 + 655 + + + 609 + 156 + 654 + + + 601 + 168 + 653 + + + 701 + 290 + 632 + + + 727 + 321 + 628 + + + 715 + 327 + 628 + + + 655 + 79 + 664 + + + 666 + 87 + 662 + + + 675 + 136 + 654 + + + 600 + 177 + 653 + + + 880 + 322 + 614 + + + 617 + 151 + 656 + + + 599 + 161 + 655 + + + 544 + 224 + 647 + + + 683 + 300 + 633 + + + 682 + 302 + 633 + + + 709 + 302 + 632 + + + 689 + 315 + 632 + + + 678 + 340 + 631 + + + 664 + 118 + 658 + + + 592 + 163 + 656 + + + 874 + 299 + 616 + + + 720 + 297 + 632 + + + 636 + 108 + 663 + + + 681 + 115 + 658 + + + 707 + 300 + 633 + + + 712 + 304 + 632 + + + 696 + 311 + 633 + + + 615 + 116 + 663 + + + 694 + 292 + 635 + + + 710 + 297 + 633 + + + 709 + 300 + 633 + + + 696 + 304 + 633 + + + 700 + 314 + 632 + + + 844 + 264 + 200 + + + 740 + 292 + 632 + + + 686 + 304 + 635 + + + 750 + 332 + 628 + + + 591 + 75 + 672 + + + 494 + 82 + 675 + + + 614 + 104 + 666 + + + 609 + 109 + 666 + + + 597 + 221 + 648 + + + 943 + 238 + 611 + + + 287 + 278 + 649 + + + 685 + 318 + 635 + + + 69 + 388 + 662 + + + 572 + 576 + 618 + + + 618 + 135 + 662 + + + 723 + 307 + 633 + + + 682 + 314 + 635 + + + 730 + 313 + 632 + + + 684 + 323 + 634 + + + 699 + 299 + 636 + + + 718 + 307 + 634 + + + 649 + 337 + 635 + + + 650 + 66 + 671 + + + 649 + 74 + 670 + + + 607 + 160 + 659 + + + 690 + 300 + 637 + + + 715 + 311 + 634 + + + 505 + 93 + 675 + + + 692 + 307 + 637 + + + 628 + 80 + 672 + + + 612 + 95 + 671 + + + 650 + 105 + 666 + + + 539 + 136 + 668 + + + 596 + 162 + 661 + + + 686 + 301 + 638 + + + 704 + 301 + 637 + + + 730 + 340 + 632 + + + 614 + 57 + 677 + + + 599 + 177 + 658 + + + 744 + 299 + 634 + + + 673 + 59 + 672 + + + 632 + 82 + 672 + + + 650 + 85 + 670 + + + 665 + 88 + 668 + + + 610 + 103 + 670 + + + 585 + 152 + 663 + + + 616 + 159 + 660 + + + 691 + 297 + 639 + + + 701 + 301 + 638 + + + 735 + 306 + 635 + + + 509 + 59 + 682 + + + 575 + 581 + 620 + + + 687 + 67 + 671 + + + 658 + 90 + 669 + + + 652 + 109 + 667 + + + 636 + 118 + 667 + + + 614 + 130 + 666 + + + 697 + 298 + 640 + + + 723 + 328 + 635 + + + 605 + 174 + 660 + + + 694 + 292 + 640 + + + 709 + 297 + 639 + + + 682 + 302 + 640 + + + 596 + 102 + 673 + + + 654 + 117 + 666 + + + 651 + 120 + 666 + + + 539 + 167 + 664 + + + 704 + 297 + 639 + + + 686 + 307 + 639 + + + 726 + 317 + 636 + + + 671 + 325 + 639 + + + 687 + 332 + 637 + + + 699 + 338 + 636 + + + 632 + 141 + 664 + + + 616 + 102 + 672 + + + 670 + 108 + 667 + + + 611 + 151 + 665 + + + 599 + 224 + 653 + + + 668 + 326 + 641 + + + 728 + 327 + 637 + + + 659 + 347 + 640 + + + 552 + 373 + 643 + + + 729 + 523 + 620 + + + 656 + 95 + 672 + + + 710 + 296 + 641 + + + 735 + 339 + 635 + + + 662 + 81 + 674 + + + 656 + 90 + 672 + + + 670 + 122 + 666 + + + 611 + 165 + 663 + + + 524 + 165 + 668 + + + 699 + 293 + 642 + + + 663 + 313 + 642 + + + 701 + 314 + 640 + + + 637 + 88 + 674 + + + 610 + 114 + 672 + + + 868 + 285 + 624 + + + 703 + 291 + 643 + + + 707 + 293 + 642 + + + 724 + 296 + 641 + + + 678 + 533 + 622 + + + 691 + 309 + 643 + + + 689 + 313 + 643 + + + 708 + 313 + 641 + + + 625 + 100 + 675 + + + 694 + 294 + 644 + + + 701 + 296 + 643 + + + 670 + 336 + 642 + + + 663 + 338 + 642 + + + 658 + 350 + 641 + + + 498 + 94 + 682 + + + 715 + 296 + 643 + + + 672 + 301 + 644 + + + 721 + 318 + 640 + + + 721 + 335 + 639 + + + 629 + 50 + 683 + + + 621 + 154 + 667 + + + 608 + 159 + 666 + + + 666 + 306 + 645 + + + 710 + 305 + 643 + + + 715 + 335 + 640 + + + 665 + 344 + 642 + + + 613 + 92 + 679 + + + 663 + 91 + 675 + + + 692 + 100 + 671 + + + 587 + 177 + 665 + + + 863 + 283 + 628 + + + 866 + 296 + 627 + + + 711 + 293 + 645 + + + 669 + 330 + 644 + + + 627 + 91 + 679 + + + 497 + 94 + 684 + + + 693 + 296 + 646 + + + 669 + 310 + 646 + + + 665 + 330 + 644 + + + 683 + 337 + 643 + + + 645 + 120 + 672 + + + 616 + 164 + 667 + + + 600 + 180 + 665 + + + 681 + 309 + 645 + + + 684 + 312 + 645 + + + 672 + 318 + 645 + + + 652 + 81 + 679 + + + 100 + 267 + 678 + + + 703 + 292 + 647 + + + 682 + 303 + 647 + + + 720 + 309 + 644 + + + 676 + 350 + 643 + + + 621 + 95 + 679 + + + 651 + 135 + 671 + + + 706 + 290 + 648 + + + 745 + 301 + 643 + + + 682 + 312 + 647 + + + 656 + 80 + 680 + + + 661 + 82 + 680 + + + 503 + 125 + 681 + + + 608 + 144 + 673 + + + 465 + 407 + 651 + + + 527 + 91 + 687 + + + 693 + 302 + 647 + + + 730 + 330 + 642 + + + 613 + 174 + 667 + + + 860 + 279 + 631 + + + 697 + 300 + 649 + + + 526 + 155 + 677 + + + 722 + 315 + 646 + + + 617 + 106 + 681 + + + 691 + 297 + 650 + + + 663 + 320 + 649 + + + 690 + 345 + 646 + + + 652 + 92 + 681 + + + 609 + 107 + 681 + + + 616 + 162 + 671 + + + 607 + 178 + 669 + + + 688 + 302 + 650 + + + 685 + 303 + 650 + + + 709 + 303 + 649 + + + 678 + 310 + 650 + + + 669 + 354 + 647 + + + 643 + 94 + 682 + + + 608 + 160 + 673 + + + 704 + 302 + 650 + + + 555 + 359 + 653 + + + 638 + 82 + 686 + + + 675 + 312 + 651 + + + 693 + 312 + 650 + + + 650 + 75 + 686 + + + 628 + 83 + 686 + + + 619 + 103 + 683 + + + 680 + 300 + 652 + + + 679 + 304 + 652 + + + 608 + 114 + 682 + + + 534 + 179 + 674 + + + 854 + 279 + 635 + + + 705 + 298 + 652 + + + 696 + 313 + 651 + + + 710 + 314 + 650 + + + 743 + 332 + 645 + + + 665 + 336 + 650 + + + 646 + 114 + 680 + + + 686 + 305 + 653 + + + 692 + 315 + 652 + + + 662 + 324 + 652 + + + 506 + 83 + 695 + + + 616 + 120 + 682 + + + 592 + 192 + 670 + + + 704 + 303 + 652 + + + 722 + 317 + 649 + + + 725 + 323 + 649 + + + 681 + 349 + 650 + + + 653 + 99 + 683 + + + 701 + 291 + 654 + + + 677 + 308 + 653 + + + 678 + 310 + 653 + + + 610 + 115 + 684 + + + 586 + 624 + 185 + + + 716 + 309 + 652 + + + 786 + 393 + 641 + + + 649 + 107 + 683 + + + 710 + 313 + 653 + + + 664 + 85 + 687 + + + 656 + 86 + 688 + + + 682 + 308 + 655 + + + 675 + 336 + 653 + + + 640 + 97 + 687 + + + 618 + 162 + 677 + + + 724 + 305 + 652 + + + 704 + 321 + 652 + + + 616 + 94 + 689 + + + 694 + 307 + 655 + + + 665 + 341 + 654 + + + 683 + 306 + 657 + + + 685 + 345 + 654 + + + 496 + 215 + 675 + + + 687 + 310 + 656 + + + 696 + 312 + 656 + + + 728 + 322 + 652 + + + 722 + 330 + 652 + + + 721 + 346 + 651 + + + 700 + 348 + 653 + + + 647 + 60 + 695 + + + 642 + 88 + 690 + + + 628 + 110 + 687 + + + 845 + 257 + 643 + + + 697 + 300 + 657 + + + 698 + 304 + 656 + + + 642 + 57 + 696 + + + 632 + 98 + 689 + + + 684 + 339 + 655 + + + 663 + 341 + 656 + + + 670 + 362 + 654 + + + 637 + 127 + 685 + + + 692 + 298 + 659 + + + 714 + 313 + 656 + + + 686 + 107 + 685 + + + 513 + 509 + 197 + + + 678 + 304 + 659 + + + 700 + 313 + 657 + + + 719 + 317 + 655 + + + 720 + 320 + 655 + + + 716 + 351 + 653 + + + 696 + 302 + 658 + + + 709 + 307 + 657 + + + 687 + 299 + 660 + + + 704 + 300 + 659 + + + 669 + 108 + 688 + + + 638 + 229 + 670 + + + 710 + 310 + 658 + + + 731 + 339 + 654 + + + 694 + 344 + 657 + + + 674 + 358 + 657 + + + 642 + 100 + 692 + + + 609 + 114 + 692 + + + 609 + 140 + 687 + + + 723 + 299 + 658 + + + 698 + 301 + 660 + + + 712 + 317 + 658 + + + 664 + 333 + 659 + + + 639 + 95 + 693 + + + 705 + 317 + 658 + + + 695 + 376 + 655 + + + 361 + 568 + 657 + + + 844 + 286 + 645 + + + 681 + 299 + 662 + + + 682 + 307 + 662 + + + 689 + 307 + 661 + + + 717 + 315 + 658 + + + 655 + 91 + 694 + + + 621 + 121 + 691 + + + 621 + 139 + 687 + + + 685 + 302 + 663 + + + 709 + 305 + 661 + + + 700 + 307 + 661 + + + 694 + 310 + 662 + + + 723 + 384 + 654 + + + 679 + 306 + 663 + + + 666 + 324 + 662 + + + 703 + 329 + 659 + + + 756 + 341 + 653 + + + 737 + 123 + 681 + + + 842 + 288 + 646 + + + 671 + 309 + 663 + + + 705 + 307 + 661 + + + 716 + 318 + 659 + + + 623 + 61 + 703 + + + 625 + 97 + 696 + + + 618 + 106 + 695 + + + 614 + 174 + 682 + + + 667 + 318 + 663 + + + 678 + 333 + 661 + + + 514 + 73 + 708 + + + 632 + 95 + 697 + + + 653 + 109 + 693 + + + 525 + 117 + 700 + + + 512 + 167 + 690 + + + 840 + 263 + 651 + + + 693 + 312 + 663 + + + 691 + 315 + 663 + + + 711 + 316 + 661 + + + 716 + 321 + 661 + + + 729 + 329 + 659 + + + 690 + 338 + 661 + + + 607 + 104 + 698 + + + 612 + 127 + 693 + + + 681 + 310 + 664 + + + 699 + 337 + 661 + + + 664 + 344 + 662 + + + 670 + 98 + 695 + + + 612 + 108 + 697 + + + 618 + 158 + 687 + + + 607 + 184 + 682 + + + 671 + 367 + 661 + + + 588 + 86 + 703 + + + 697 + 306 + 664 + + + 590 + 87 + 704 + + + 639 + 88 + 700 + + + 708 + 315 + 664 + + + 686 + 316 + 665 + + + 671 + 362 + 663 + + + 630 + 93 + 701 + + + 704 + 304 + 665 + + + 708 + 321 + 663 + + + 714 + 321 + 663 + + + 693 + 329 + 664 + + + 638 + 94 + 700 + + + 696 + 301 + 666 + + + 708 + 306 + 665 + + + 689 + 306 + 666 + + + 683 + 316 + 665 + + + 699 + 319 + 664 + + + 643 + 96 + 699 + + + 612 + 116 + 697 + + + 666 + 115 + 694 + + + 838 + 270 + 653 + + + 689 + 309 + 667 + + + 665 + 313 + 667 + + + 657 + 93 + 700 + + + 610 + 149 + 692 + + + 612 + 162 + 689 + + + 616 + 173 + 687 + + + 716 + 322 + 664 + + + 612 + 153 + 692 + + + 588 + 167 + 690 + + + 594 + 184 + 686 + + + 837 + 267 + 654 + + + 693 + 305 + 668 + + + 688 + 312 + 667 + + + 717 + 319 + 664 + + + 685 + 341 + 665 + + + 618 + 104 + 701 + + + 708 + 303 + 667 + + + 705 + 307 + 666 + + + 702 + 320 + 666 + + + 687 + 320 + 667 + + + 673 + 323 + 667 + + + 715 + 327 + 664 + + + 690 + 101 + 696 + + + 620 + 183 + 686 + + + 836 + 293 + 652 + + + 698 + 306 + 668 + + + 683 + 312 + 668 + + + 703 + 313 + 667 + + + 726 + 342 + 663 + + + 719 + 343 + 664 + + + 725 + 362 + 662 + + + 687 + 319 + 669 + + + 724 + 327 + 665 + + + 609 + 116 + 702 + + + 834 + 275 + 655 + + + 716 + 321 + 666 + + + 609 + 122 + 701 + + + 619 + 160 + 692 + + + 676 + 306 + 670 + + + 718 + 311 + 667 + + + 683 + 316 + 669 + + + 714 + 320 + 666 + + + 689 + 339 + 667 + + + 707 + 338 + 666 + + + 635 + 64 + 710 + + + 644 + 106 + 701 + + + 622 + 179 + 688 + + + 713 + 301 + 669 + + + 667 + 309 + 671 + + + 705 + 315 + 668 + + + 716 + 325 + 667 + + + 695 + 330 + 668 + + + 722 + 340 + 665 + + + 666 + 351 + 669 + + + 608 + 113 + 703 + + + 533 + 127 + 705 + + + 512 + 138 + 704 + + + 606 + 191 + 687 + + + 690 + 313 + 671 + + + 668 + 358 + 669 + + + 628 + 95 + 707 + + + 606 + 128 + 701 + + + 614 + 169 + 692 + + + 718 + 308 + 669 + + + 743 + 309 + 666 + + + 705 + 313 + 670 + + + 668 + 367 + 669 + + + 650 + 88 + 706 + + + 621 + 110 + 704 + + + 693 + 303 + 672 + + + 704 + 319 + 670 + + + 599 + 105 + 708 + + + 616 + 161 + 695 + + + 603 + 196 + 688 + + + 714 + 312 + 671 + + + 515 + 109 + 713 + + + 605 + 124 + 704 + + + 608 + 141 + 701 + + + 704 + 315 + 671 + + + 659 + 337 + 672 + + + 660 + 148 + 696 + + + 650 + 151 + 696 + + + 509 + 151 + 704 + + + 704 + 301 + 673 + + + 693 + 308 + 673 + + + 697 + 313 + 672 + + + 681 + 315 + 673 + + + 698 + 319 + 671 + + + 710 + 367 + 668 + + + 670 + 115 + 701 + + + 624 + 130 + 702 + + + 606 + 194 + 690 + + + 690 + 315 + 673 + + + 712 + 320 + 671 + + + 651 + 323 + 675 + + + 708 + 365 + 669 + + + 632 + 104 + 708 + + + 644 + 112 + 705 + + + 459 + 148 + 706 + + + 608 + 177 + 694 + + + 604 + 191 + 691 + + + 544 + 200 + 692 + + + 717 + 316 + 672 + + + 709 + 320 + 672 + + + 651 + 332 + 675 + + + 692 + 332 + 673 + + + 591 + 469 + 665 + + + 673 + 93 + 708 + + + 693 + 308 + 675 + + + 709 + 320 + 672 + + + 651 + 322 + 676 + + + 673 + 93 + 708 + + + 644 + 112 + 706 + + + 624 + 130 + 704 + + + 459 + 149 + 707 + + + 544 + 200 + 693 + + + 705 + 313 + 674 + + + 651 + 332 + 676 + + + 691 + 332 + 674 + + + 708 + 365 + 671 + + + 590 + 469 + 666 + + + 801 + 491 + 654 + + + 590 + 90 + 715 + + + 632 + 105 + 709 + + + 614 + 162 + 699 + + + 604 + 191 + 693 + + + 690 + 315 + 676 + + + 673 + 320 + 677 + + + 683 + 323 + 676 + + + 694 + 331 + 675 + + + 660 + 357 + 675 + + + 667 + 374 + 674 + + + 637 + 96 + 712 + + + 634 + 156 + 700 + + + 621 + 186 + 695 + + + 713 + 347 + 672 + + + 669 + 348 + 675 + + + 633 + 142 + 703 + + + 614 + 160 + 700 + + + 614 + 169 + 698 + + + 707 + 341 + 673 + + + 711 + 356 + 672 + + + 663 + 366 + 675 + + + 681 + 321 + 677 + + + 636 + 87 + 715 + + + 518 + 124 + 715 + + + 645 + 145 + 702 + + + 619 + 177 + 698 + + + 714 + 327 + 675 + + + 660 + 352 + 677 + + + 626 + 177 + 698 + + + 705 + 318 + 676 + + + 716 + 346 + 674 + + + 638 + 574 + 658 + + + 621 + 104 + 714 + + + 640 + 135 + 706 + + + 532 + 194 + 699 + + + 668 + 316 + 680 + + + 618 + 112 + 713 + + + 630 + 171 + 700 + + + 608 + 180 + 699 + + + 692 + 362 + 677 + + + 523 + 71 + 728 + + + 716 + 311 + 677 + + + 683 + 332 + 679 + + + 429 + 424 + 685 + + + 604 + 74 + 722 + + + 619 + 108 + 715 + + + 588 + 189 + 699 + + + 612 + 113 + 714 + + + 652 + 131 + 708 + + + 613 + 163 + 703 + + + 740 + 361 + 674 + + + 657 + 93 + 716 + + + 685 + 320 + 681 + + + 697 + 328 + 680 + + + 681 + 342 + 680 + + + 572 + 512 + 668 + + + 629 + 71 + 723 + + + 610 + 96 + 720 + + + 505 + 104 + 724 + + + 624 + 173 + 703 + + + 679 + 314 + 682 + + + 689 + 328 + 680 + + + 714 + 331 + 678 + + + 669 + 342 + 681 + + + 711 + 346 + 678 + + + 727 + 358 + 676 + + + 666 + 363 + 680 + + + 546 + 392 + 683 + + + 607 + 137 + 711 + + + 817 + 246 + 674 + + + 696 + 327 + 680 + + + 648 + 156 + 705 + + + 616 + 176 + 703 + + + 686 + 322 + 682 + + + 651 + 67 + 724 + + + 635 + 118 + 715 + + + 590 + 127 + 716 + + + 611 + 187 + 702 + + + 822 + 266 + 672 + + + 938 + 279 + 653 + + + 661 + 316 + 685 + + + 661 + 367 + 682 + + + 627 + 170 + 705 + + + 629 + 174 + 705 + + + 589 + 201 + 700 + + + 795 + 433 + 667 + + + 589 + 94 + 724 + + + 631 + 162 + 707 + + + 645 + 164 + 706 + + + 602 + 206 + 699 + + + 669 + 340 + 683 + + + 694 + 341 + 681 + + + 589 + 128 + 717 + + + 652 + 147 + 708 + + + 608 + 199 + 700 + + + 629 + 115 + 718 + + + 634 + 139 + 712 + + + 627 + 176 + 705 + + + 677 + 335 + 685 + + + 711 + 335 + 682 + + + 669 + 113 + 716 + + + 618 + 183 + 705 + + + 592 + 209 + 700 + + + 622 + 143 + 713 + + + 713 + 339 + 683 + + + 699 + 321 + 685 + + + 648 + 342 + 688 + + + 682 + 354 + 685 + + + 696 + 364 + 684 + + + 658 + 92 + 723 + + + 617 + 108 + 723 + + + 635 + 164 + 710 + + + 611 + 191 + 705 + + + 709 + 315 + 685 + + + 682 + 337 + 686 + + + 646 + 72 + 728 + + + 599 + 104 + 725 + + + 638 + 133 + 716 + + + 645 + 150 + 712 + + + 681 + 319 + 687 + + + 696 + 329 + 685 + + + 706 + 633 + 665 + + + 617 + 115 + 722 + + + 586 + 130 + 721 + + + 634 + 160 + 711 + + + 595 + 211 + 702 + + + 691 + 334 + 686 + + + 609 + 142 + 717 + + + 612 + 170 + 711 + + + 713 + 331 + 685 + + + 695 + 338 + 687 + + + 684 + 338 + 688 + + + 670 + 366 + 687 + + + 623 + 430 + 683 + + + 654 + 499 + 675 + + + 670 + 150 + 712 + + + 712 + 360 + 685 + + + 671 + 450 + 681 + + + 614 + 147 + 717 + + + 657 + 322 + 691 + + + 700 + 337 + 686 + + + 726 + 367 + 684 + + + 609 + 126 + 722 + + + 612 + 146 + 717 + + + 645 + 696 + 182 + + + 651 + 320 + 692 + + + 703 + 324 + 688 + + + 644 + 335 + 691 + + + 722 + 367 + 686 + + + 640 + 103 + 727 + + + 611 + 127 + 724 + + + 618 + 198 + 708 + + + 712 + 326 + 687 + + + 691 + 339 + 689 + + + 719 + 364 + 686 + + + 733 + 378 + 684 + + + 713 + 623 + 668 + + + 611 + 119 + 725 + + + 657 + 320 + 693 + + + 647 + 333 + 692 + + + 716 + 345 + 687 + + + 650 + 348 + 691 + + + 716 + 351 + 687 + + + 653 + 403 + 687 + + + 628 + 85 + 731 + + + 521 + 169 + 720 + + + 611 + 199 + 708 + + + 605 + 206 + 706 + + + 675 + 356 + 690 + + + 594 + 534 + 676 + + + 617 + 108 + 728 + + + 590 + 194 + 710 + + + 833 + 302 + 674 + + + 649 + 336 + 694 + + + 652 + 345 + 693 + + + 613 + 113 + 728 + + + 630 + 118 + 726 + + + 613 + 194 + 711 + + + 608 + 209 + 708 + + + 606 + 210 + 708 + + + 657 + 318 + 695 + + + 678 + 350 + 691 + + + 660 + 511 + 677 + + + 593 + 119 + 729 + + + 606 + 123 + 727 + + + 602 + 123 + 727 + + + 659 + 324 + 694 + + + 657 + 413 + 689 + + + 623 + 116 + 727 + + + 612 + 136 + 724 + + + 634 + 156 + 718 + + + 644 + 162 + 716 + + + 627 + 170 + 715 + + + 629 + 89 + 733 + + + 503 + 118 + 735 + + + 518 + 138 + 730 + + + 607 + 183 + 714 + + + 602 + 208 + 709 + + + 596 + 213 + 708 + + + 655 + 329 + 696 + + + 687 + 334 + 693 + + + 637 + 96 + 732 + + + 625 + 103 + 732 + + + 603 + 205 + 711 + + + 446 + 442 + 209 + + + 623 + 470 + 685 + + + 650 + 109 + 729 + + + 509 + 119 + 736 + + + 806 + 255 + 687 + + + 655 + 320 + 697 + + + 665 + 361 + 693 + + + 620 + 158 + 720 + + + 610 + 168 + 718 + + + 620 + 170 + 718 + + + 612 + 187 + 714 + + + 688 + 343 + 693 + + + 650 + 357 + 695 + + + 652 + 359 + 695 + + + 644 + 429 + 690 + + + 592 + 90 + 737 + + + 596 + 99 + 736 + + + 807 + 267 + 686 + + + 629 + 446 + 690 + + + 587 + 92 + 738 + + + 623 + 185 + 716 + + + 703 + 338 + 693 + + + 661 + 343 + 696 + + + 645 + 344 + 697 + + + 718 + 102 + 649 + + + 603 + 121 + 655 + + + 708 + 283 + 627 + + + 717 + 297 + 625 + + + 726 + 315 + 623 + + + 695 + 318 + 625 + + + 730 + 339 + 621 + + + 510 + 53 + 669 + + + 636 + 90 + 658 + + + 583 + 160 + 650 + + + 884 + 281 + 609 + + + 711 + 301 + 626 + + + 704 + 321 + 625 + + + 652 + 75 + 660 + + + 631 + 77 + 661 + + + 753 + 320 + 622 + + + 671 + 76 + 659 + + + 649 + 81 + 660 + + + 613 + 117 + 657 + + + 615 + 160 + 651 + + + 718 + 305 + 626 + + + 713 + 306 + 626 + + + 736 + 335 + 622 + + + 503 + 75 + 668 + + + 600 + 99 + 661 + + + 675 + 113 + 653 + + + 657 + 116 + 654 + + + 597 + 156 + 652 + + + 683 + 301 + 628 + + + 708 + 306 + 627 + + + 528 + 162 + 655 + + + 695 + 298 + 629 + + + 636 + 75 + 663 + + + 653 + 80 + 661 + + + 547 + 226 + 644 + + + 683 + 305 + 630 + + + 696 + 305 + 629 + + + 727 + 318 + 626 + + + 666 + 78 + 661 + + + 673 + 119 + 655 + + + 610 + 160 + 653 + + + 594 + 222 + 644 + + + + diff --git a/tests/tests/test_integration/test_points.py b/tests/tests/test_integration/test_points.py new file mode 100644 index 0000000..a34cce1 --- /dev/null +++ b/tests/tests/test_integration/test_points.py @@ -0,0 +1,39 @@ +import os +import sys +from pathlib import Path +import pandas as pd + +from neuro.points.points_to_brainrender import ( + main as points_to_brainrender_run, +) + +points_dir = Path("tests", "data", "points") +cellfinder_out = points_dir / "cellfinder_out.xml" +brainrender_file = points_dir / "brainrender.h5" + + +def test_points_to_brainrender(tmpdir): + tmpdir = Path(tmpdir) + brainrender_file_test = tmpdir / "brainrender_test.h5" + + args = [ + "points_to_brainrender", + str(cellfinder_out), + str(brainrender_file_test), + "-x", + "10", + "-y", + "10", + "-z", + "10", + "--max-z", + "13200", + "--hdf-key", + "df", + ] + sys.argv = args + points_to_brainrender_run() + + pd.read_hdf(brainrender_file_test, key="df") == pd.read_hdf( + brainrender_file, key="df" + ) diff --git a/tests/tests/test_nothing.py b/tests/tests/test_nothing.py deleted file mode 100644 index 69a2822..0000000 --- a/tests/tests/test_nothing.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_nothing(): - assert True From 952e9ab72e9a6f548f89075898a4782b89e46cca Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 27 Jan 2020 12:54:00 +0000 Subject: [PATCH 02/21] update testing --- .travis.yml | 3 --- setup.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30f9295..ddb92df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,6 @@ matrix: - os: linux python: 3.7 dist: bionic - - os: linux - python: 3.8 - dist: bionic before_install: - wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - bash miniconda.sh -b -p $HOME/miniconda diff --git a/setup.py b/setup.py index 5c705ad..41887f8 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ "coverage<=4.5.4", ] }, - python_requires=">=3.6", + python_requires=[">=3.6", "<3.8",], packages=find_namespace_packages(exclude=("docs", "tests*")), include_package_data=True, url="https://github.com/SainsburyWellcomeCentre/neuro", From 2580b2ae8f9d0aa3a4893370a29831481669dd46 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 27 Jan 2020 12:56:44 +0000 Subject: [PATCH 03/21] refactor --- tests/tests/test_integration/test_points.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tests/test_integration/test_points.py b/tests/tests/test_integration/test_points.py index a34cce1..3c2b9f2 100644 --- a/tests/tests/test_integration/test_points.py +++ b/tests/tests/test_integration/test_points.py @@ -1,4 +1,3 @@ -import os import sys from pathlib import Path import pandas as pd From 9cc2449e97a79f8c4d38fa24426d088956ae765c Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 27 Jan 2020 12:58:03 +0000 Subject: [PATCH 04/21] refactor --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 41887f8..478265e 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ "coverage<=4.5.4", ] }, - python_requires=[">=3.6", "<3.8",], + python_requires=">=3.6, <3.8", packages=find_namespace_packages(exclude=("docs", "tests*")), include_package_data=True, url="https://github.com/SainsburyWellcomeCentre/neuro", From 951fb218a1e41ac03d9a2747c406a70133b156bb Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 27 Jan 2020 13:01:34 +0000 Subject: [PATCH 05/21] badges --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index f229c45..8cde1cc 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,12 @@ +[![Python Version](https://img.shields.io/pypi/pyversions/neuro.svg)](https://python.org) +[![PyPI](https://img.shields.io/pypi/v/neuro.svg)](https://pypi.org/project/neuro) +[![Wheel](https://img.shields.io/pypi/wheel/neuro.svg)](https://pypi.org/project/neuro) +[![Development Status](https://img.shields.io/pypi/status/neuro.svg)](https://github.com/SainsburyWellcomeCentre/neuro) +[![Travis](https://img.shields.io/travis/com/SainsburyWellcomeCentre/neuro?label=Travis%20CI)]( + https://travis-ci.com/SainsburyWellcomeCentre/neuro) +[![Coverage Status](https://coveralls.io/repos/github/SainsburyWellcomeCentre/neuro/badge.svg?branch=master)](https://coveralls.io/github/SainsburyWellcomeCentre/neuro?branch=master) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) + + # neuro Visualisation and analysis of brain imaging data From ec82f0b560bb9068ca036b64c080fd7c0e67bf7b Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Mon, 27 Jan 2020 13:11:08 +0000 Subject: [PATCH 06/21] notes --- neuro/points/points_to_brainrender.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neuro/points/points_to_brainrender.py b/neuro/points/points_to_brainrender.py index f7e4f92..042d7d1 100644 --- a/neuro/points/points_to_brainrender.py +++ b/neuro/points/points_to_brainrender.py @@ -1,5 +1,8 @@ """ Converts point positions from cellfinder coordinates to brainrender + +N.B. This is currently specific to coronal images, with the origin at the most +caudal, ventral left point. The default is also for 10um voxel spacing. """ import argparse From 8c3a978a4af53dc27e7338b68d5331067bc0a82b Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 11:15:36 +0000 Subject: [PATCH 07/21] formatting with black --- neuro/injection_finder/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/neuro/injection_finder/utils.py b/neuro/injection_finder/utils.py index 9eee265..30abd73 100644 --- a/neuro/injection_finder/utils.py +++ b/neuro/injection_finder/utils.py @@ -58,6 +58,7 @@ def get_center_of_mass(actor): """ return actor.centerOfMass() + def get_largest_component(obj_filepath): """ Given a .obj file with multiple disconnected meshes in it, it From 1fd3e41e771da6802c4cacb64482a16472807064 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 11:16:23 +0000 Subject: [PATCH 08/21] add .DS_store to gitignore --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 4 ++++ neuro/injection_finder/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 4 insertions(+) delete mode 100644 .DS_Store delete mode 100644 neuro/injection_finder/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index d013abaa0566d38ed37a74e0474a5cb9c8e00779..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}xR_5N`R=f-!P1kz+63IItXqi^&G@;LT)>9@M~Y*vKZhC9p^oG5Z?&Mm~YB z<4ju!1Wh~{BQweLn@(ri^xI9RWsLFWxa%-hVvGq;#7qI2F9gR?*Cb;-h+NO1g2`wQ z^i{AHOOC(E0DikXi&@CVY{-_s-+M6VN28=#{ot8wF2A)cL{SuXi??1+O}xZU#-pY` zyvE+SpY#H2UntdI*nV&sg_Cw^|3t-!AI0HNCr8~7LT;|2xT_{jHIBO@J&$JwgeZtY zyHuV|8&16S)9Wg7)x7x z@P=_;#dqMHXUroBi2-7O7}yX7?C~ddHe|oFO=5r;_&Ec3K1fhR*J5f=A05!(^%2K& zh$vv=TLMv9bSzncEi%*QTt$g zgVYiO#K0;8S<@|H{XhNw{lA(-Jz{_u_*V?@T+3@UVN15Qu5Au$tpx3WqF`KVaFGIr hF2xXwrML{L1^f~XK-Xew5Ii7s5zsVHLk#>X1D~wfQC9!} diff --git a/.gitignore b/.gitignore index e16642c..482c16f 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,7 @@ venv.bak/ .idea/ .vs/ *.~lock.* + + +# macOS +*.DS_Store diff --git a/neuro/injection_finder/.DS_Store b/neuro/injection_finder/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Tue, 4 Feb 2020 11:36:44 +0000 Subject: [PATCH 09/21] typo --- neuro/injection_finder/extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index c24aae7..148f012 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -168,7 +168,7 @@ def main(): # Get output directory if args.output_directory is None: - outdir = os.get_cwd() + outdir = os.getcwd() elif not os.path.isdir(args.output_directory): raise ValueError("Output directory invalid") else: From f2a8970ae7d6b921dbb682ec3f2c411cc597ac2c Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 11:36:58 +0000 Subject: [PATCH 10/21] update imports --- neuro/injection_finder/registration.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/neuro/injection_finder/registration.py b/neuro/injection_finder/registration.py index a979a55..c28d26d 100644 --- a/neuro/injection_finder/registration.py +++ b/neuro/injection_finder/registration.py @@ -1,16 +1,19 @@ import os from brainio import brainio -from amap.tools import source_files -from amap.config.config import get_binary -from amap.tools.exceptions import RegistrationError - -from cellfinder.tools.system import ( +from imlib.general.system import ( safe_execute_command, SafeExecuteCommandError, ) +from imlib.general.exceptions import RegistrationError + + +from amap.tools import source_files +from amap.config.config import get_binary + + PROGRAM_NAME = "reg_resample" DEFAULT_CONTROL_POINT_FILE = "inverse_control_point_file.nii" default_atlas_name = "brain_filtered.nii" From 3c8f7cce9c970149a25a6b7e9104ff0aab795903 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 11:48:43 +0000 Subject: [PATCH 11/21] update imports --- neuro/injection_finder/extraction.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index 148f012..5d9c9bc 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -7,9 +7,13 @@ from brainio import brainio -from registration import get_registered_image -from utils import reorient_image, marching_cubes_to_obj, get_largest_component -from parsers import extraction_parser +from neuro.injection_finder.registration import get_registered_image +from neuro.injection_finder.utils import ( + reorient_image, + marching_cubes_to_obj, + get_largest_component, +) +from neuro.injection_finder.parsers import extraction_parser # For logging import logging From 0356c993f5121c9196a7e88d7229dd9ff41a50f9 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 11:54:15 +0000 Subject: [PATCH 12/21] deal with no obj path given --- neuro/injection_finder/extraction.py | 6 ++++++ neuro/injection_finder/parsers.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index 5d9c9bc..d934da3 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -1,5 +1,6 @@ import os import numpy as np +from pathlib import Path from skimage.filters import gaussian as gaussian_filter from skimage.filters import threshold_otsu @@ -178,6 +179,11 @@ def main(): else: outdir = args.output_directory + if args.obj_path is None: + args.obj_path = Path(args.img_filepath).with_suffix(".obj") + else: + args.obj_path = Path(args.obj_path) + # Start log log_name = "injection_finder_{}".format( os.path.split(args.registration_folder)[-1] diff --git a/neuro/injection_finder/parsers.py b/neuro/injection_finder/parsers.py index 3b9af16..774f740 100644 --- a/neuro/injection_finder/parsers.py +++ b/neuro/injection_finder/parsers.py @@ -38,8 +38,8 @@ def extraction_parser(): "--obj-path", dest="obj_path", type=str, - default=False, - help="Path to output .obj file. Optional.", + default=None, + help="Path to output .obj file. Will default to the image directory.", ) parser.add_argument( From 24a84647fdde6986e22b7636cbf303880957d441 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 13:08:34 +0000 Subject: [PATCH 13/21] error typo --- neuro/injection_finder/extraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index d934da3..2bcdeb9 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -131,7 +131,7 @@ def extract(self, image, voxel_size=10): ) ) else: - raise valueError( + raise ValueError( "Unrecognised thresholding type: " + self.threshold_type ) From 6b53e436c0b753d8339998c611f16c86c22bfdc1 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 13:57:59 +0000 Subject: [PATCH 14/21] move utils too imlib --- docs/_static/basic.css | 4 --- docs/_static/documentation_options.js | 1 - docs/_static/searchtools.js | 6 ++-- neuro/injection_finder/extraction.py | 2 +- neuro/injection_finder/utils.py | 48 ++++++++++++++------------- 5 files changed, 29 insertions(+), 32 deletions(-) diff --git a/docs/_static/basic.css b/docs/_static/basic.css index b04360d..ea6972d 100644 --- a/docs/_static/basic.css +++ b/docs/_static/basic.css @@ -672,10 +672,6 @@ div.code-block-caption + div > div.highlight > pre { margin-top: 0; } -div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */ - user-select: none; -} - div.code-block-caption span.caption-number { padding: 0.1em 0.3em; font-style: italic; diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 4790c4d..6d86510 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -3,7 +3,6 @@ var DOCUMENTATION_OPTIONS = { VERSION: '', LANGUAGE: 'None', COLLAPSE_INDEX: false, - BUILDER: 'html', FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt', diff --git a/docs/_static/searchtools.js b/docs/_static/searchtools.js index ad84587..6031f99 100644 --- a/docs/_static/searchtools.js +++ b/docs/_static/searchtools.js @@ -245,7 +245,7 @@ var Search = { if (results.length) { var item = results.pop(); var listItem = $('
  • '); - if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { + if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') { // dirhtml builder var dirname = item[0] + '/'; if (dirname.match(/\/index\/$/)) { @@ -424,7 +424,7 @@ var Search = { for (j = 0; j < _files.length; j++) { file = _files[j]; if (!(file in scoreMap)) - scoreMap[file] = {}; + scoreMap[file] = {} scoreMap[file][word] = o.score; } }); @@ -432,7 +432,7 @@ var Search = { // create the mapping for (j = 0; j < files.length; j++) { file = files[j]; - if (file in fileMap && fileMap[file].indexOf(word) === -1) + if (file in fileMap) fileMap[file].push(word); else fileMap[file] = [word]; diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index 2bcdeb9..fc391f8 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -7,11 +7,11 @@ from skimage import measure from brainio import brainio +from imlib.IO.surfaces import marching_cubes_to_obj from neuro.injection_finder.registration import get_registered_image from neuro.injection_finder.utils import ( reorient_image, - marching_cubes_to_obj, get_largest_component, ) from neuro.injection_finder.parsers import extraction_parser diff --git a/neuro/injection_finder/utils.py b/neuro/injection_finder/utils.py index 30abd73..a91d4c1 100644 --- a/neuro/injection_finder/utils.py +++ b/neuro/injection_finder/utils.py @@ -1,5 +1,6 @@ import numpy as np from vtkplotter.analysis import extractLargestRegion +from vtkplotter import load, save # ----------------------- IMAGE MANIPULATION FUNCTIONS ----------------------- # def reorient_image(image, invert_axes=None, orientation="saggital"): @@ -27,28 +28,29 @@ def reorient_image(image, invert_axes=None, orientation="saggital"): return image -# ------------------------- MARCHING CUBES FUNCTIONS ------------------------- # -def marching_cubes_to_obj(marching_cubes_out, output_file): - """ - Saves the output of skimage.measure.marching_cubes as an .obj file - - :param marching_cubes_out: tuple - :param output_file: str - - """ - - verts, faces, normals, _ = marching_cubes_out - with open(output_file, "w") as f: - for item in verts: - f.write(f"v {item[0]} {item[1]} {item[2]}\n") - for item in normals: - f.write(f"vn {item[0]} {item[1]} {item[2]}\n") - for item in faces: - f.write( - f"f {item[0]}//{item[0]} {item[1]}//{item[1]} " - f"{item[2]}//{item[2]}\n" - ) - f.close() +# +# # ------------------------- MARCHING CUBES FUNCTIONS ------------------------- # +# def marching_cubes_to_obj(marching_cubes_out, output_file): +# """ +# Saves the output of skimage.measure.marching_cubes as an .obj file +# +# :param marching_cubes_out: tuple +# :param output_file: str +# +# """ +# +# verts, faces, normals, _ = marching_cubes_out +# with open(output_file, "w") as f: +# for item in verts: +# f.write(f"v {item[0]} {item[1]} {item[2]}\n") +# for item in normals: +# f.write(f"vn {item[0]} {item[1]} {item[2]}\n") +# for item in faces: +# f.write( +# f"f {item[0]}//{item[0]} {item[1]}//{item[1]} " +# f"{item[2]}//{item[2]}\n" +# ) +# f.close() # ----------------------------- VTKPLOTTER UTILS ----------------------------- # @@ -64,6 +66,6 @@ def get_largest_component(obj_filepath): Given a .obj file with multiple disconnected meshes in it, it selects the largest of these and discards the rest. """ - actor = load(obj_filepath) + actor = load(str(obj_filepath)) actor = extractLargestRegion(actor).flipNormals() save(actor, obj_filepath) From 85293a8f3a87f73d70b4e254e7a34cc53585dbbe Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 18:00:48 +0000 Subject: [PATCH 15/21] remove amap imports --- docs/_static/basic.css | 4 ++ docs/_static/documentation_options.js | 1 + docs/_static/searchtools.js | 6 +-- docs/searchindex.js | 2 +- neuro/injection_finder/extraction.py | 8 ++- neuro/injection_finder/registration.py | 7 +-- neuro/injection_finder/utils.py | 71 -------------------------- 7 files changed, 14 insertions(+), 85 deletions(-) delete mode 100644 neuro/injection_finder/utils.py diff --git a/docs/_static/basic.css b/docs/_static/basic.css index ea6972d..b04360d 100644 --- a/docs/_static/basic.css +++ b/docs/_static/basic.css @@ -672,6 +672,10 @@ div.code-block-caption + div > div.highlight > pre { margin-top: 0; } +div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */ + user-select: none; +} + div.code-block-caption span.caption-number { padding: 0.1em 0.3em; font-style: italic; diff --git a/docs/_static/documentation_options.js b/docs/_static/documentation_options.js index 6d86510..4790c4d 100644 --- a/docs/_static/documentation_options.js +++ b/docs/_static/documentation_options.js @@ -3,6 +3,7 @@ var DOCUMENTATION_OPTIONS = { VERSION: '', LANGUAGE: 'None', COLLAPSE_INDEX: false, + BUILDER: 'html', FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt', diff --git a/docs/_static/searchtools.js b/docs/_static/searchtools.js index 6031f99..ad84587 100644 --- a/docs/_static/searchtools.js +++ b/docs/_static/searchtools.js @@ -245,7 +245,7 @@ var Search = { if (results.length) { var item = results.pop(); var listItem = $('
  • '); - if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') { + if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { // dirhtml builder var dirname = item[0] + '/'; if (dirname.match(/\/index\/$/)) { @@ -424,7 +424,7 @@ var Search = { for (j = 0; j < _files.length; j++) { file = _files[j]; if (!(file in scoreMap)) - scoreMap[file] = {} + scoreMap[file] = {}; scoreMap[file][word] = o.score; } }); @@ -432,7 +432,7 @@ var Search = { // create the mapping for (j = 0; j < files.length; j++) { file = files[j]; - if (file in fileMap) + if (file in fileMap && fileMap[file].indexOf(word) === -1) fileMap[file].push(word); else fileMap[file] = [word]; diff --git a/docs/searchindex.js b/docs/searchindex.js index a52c11b..8a80b12 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["index","main/dev/CONTRIBUTING","main/user_guide/tools/cells_to_brainrender"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","main/dev/CONTRIBUTING.md","main/user_guide/tools/cells_to_brainrender.md"],objects:{},objnames:{},objtypes:{},terms:{"20gb":[],"2gb":[],"case":1,"default":2,"function":1,"import":2,"new":1,"true":[1,2],"try":1,The:[],These:1,abl:[],activ:[],add:1,add_cells_from_fil:2,adding:1,advanc:[],all:[1,2],allen:[],allthough:[],also:[],altern:[],amap:[0,1],analysi:0,ani:1,anoth:1,appropri:[],approv:1,atla:2,atlas:[],automat:1,avail:[],avoid:[],bash:[],befor:1,being:[],below:[],black:1,brain:0,brainrend:0,branch:1,build:1,call:2,can:2,carri:[],cell:0,cellfind:[0,1],cellfinder_download:[],cells_in_standard_spac:2,centr:0,chang:[1,2],check:1,choos:[],clean:1,cli:1,clone:1,cluster:[],code:1,collect:0,com:1,command:1,commit:1,companion:1,compat:[],comput:[],conf:[],connect:[],consist:1,contribut:0,convert:0,correct:[],creat:[],cudatoolkit:[],current:[],data:[0,2],date:1,defin:2,design:1,dev:1,develop:1,dimens:2,disk:[],document:[],done:[],driver:[],easier:1,edit:1,either:1,elsewher:[],end:2,ensur:1,error:1,etc:[],everyth:[],exist:[],exit:1,exported_cel:2,extent:2,extract:1,fetch:1,file:[],filenam:2,first:2,fork:1,format:0,found:[],from:0,futur:[],git:1,github:1,has:2,have:[],hdf:2,henc:1,here:[],highli:[],histori:1,hook:1,how:[],http:1,identifi:2,imag:0,imlib:1,infer:[],initi:1,instal:1,instruct:[],internet:[],invers:1,isol:[],issu:1,jupyt:2,keep:1,kei:2,latest:[],learn:[],like:[],line:1,link:[],linux:1,machin:[],mai:1,main:1,maintain:1,make:1,master:1,max:2,maximum:2,merg:1,miniconda3:[],miniconda:[],minim:[],modifi:[],mous:[],must:2,name:[],necessari:1,need:[],neuro:1,onc:[],onli:[],origin:[],other:[],out:[],output:2,packag:1,particularli:0,path:[],pip:[0,1],pixel:2,pleas:1,points_to_brainrend:2,pre:1,prevent:1,previous:[],process:0,push:1,py37:1,pytest:1,python:[],recommend:[],refer:[],registr:[],relev:1,rememb:[],remot:1,render:2,repositori:1,run:[1,2],sainsburi:0,sainsburywellcomecentr:1,save:[],scene:2,second:2,see:2,set:1,should:[1,2],size:2,softwar:1,sourc:[],space:2,specifi:2,squash:1,still:[],style:1,submit:1,suppli:[],system:[],tag:1,target:1,tell:[],test:[],thi:1,third:2,time:[],tmp:[],tool:1,twice:[],ubuntu:[],unit_test:1,updat:[],upon:1,upstream:1,use:1,used:[],uses:1,using:[],version:1,via:1,want:[],wellcom:0,when:[],where:[],which:[],whole:0,wide:[],work:1,workflow:1,would:[],x86_64:[],xml:2,you:[],your:1,your_usernam:1},titles:["neuro","Contributing","Converting cells from cellfinder to brainrender format"],titleterms:{For:[],The:2,about:[],addit:[],also:2,argument:2,atla:[],brainrend:2,cell:2,cellfind:2,classif:[],conda:[],contribut:1,convert:2,cuda:[],cudnn:[],depend:1,develop:0,download:[],environ:[],file:2,follow:2,format:[1,2],from:2,gpu:[],guid:[],instal:0,introduct:0,mai:2,model:[],need:2,neuro:0,option:2,posit:2,pull:1,releas:1,request:1,requir:[],set:[],setup:1,support:[],test:1,thi:2,tool:0,train:[],travi:1,used:2,user:[],visualis:2}}) \ No newline at end of file +Search.setIndex({docnames:["index","main/dev/CONTRIBUTING","main/user_guide/tools/cells_to_brainrender"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["index.rst","main/dev/CONTRIBUTING.md","main/user_guide/tools/cells_to_brainrender.md"],objects:{},objnames:{},objtypes:{},terms:{"case":1,"default":2,"function":1,"import":2,"new":1,"true":[1,2],"try":1,These:1,add:1,add_cells_from_fil:2,adding:1,all:[1,2],amap:[0,1],analysi:0,ani:1,anoth:1,approv:1,atla:2,automat:1,befor:1,black:1,brain:0,brainrend:0,branch:1,build:1,call:2,can:2,cell:0,cellfind:[0,1],cells_in_standard_spac:2,centr:0,chang:[1,2],check:1,clean:1,cli:1,clone:1,code:1,collect:0,com:1,command:1,commit:1,companion:1,consist:1,contribut:0,convert:0,data:[0,2],date:1,defin:2,design:1,dev:1,develop:1,dimens:2,easier:1,edit:1,either:1,end:2,ensur:1,error:1,exit:1,exported_cel:2,extent:2,extract:1,fetch:1,filenam:2,first:2,fork:1,format:0,from:0,git:1,github:1,has:2,hdf:2,henc:1,histori:1,hook:1,http:1,identifi:2,imag:0,imlib:1,initi:1,instal:1,invers:1,issu:1,jupyt:2,keep:1,kei:2,line:1,linux:1,mai:1,main:1,maintain:1,make:1,master:1,max:2,maximum:2,merg:1,must:2,necessari:1,neuro:1,output:2,packag:1,particularli:0,pip:[0,1],pixel:2,pleas:1,points_to_brainrend:2,pre:1,prevent:1,process:0,push:1,py37:1,pytest:1,relev:1,remot:1,render:2,repositori:1,run:[1,2],sainsburi:0,sainsburywellcomecentr:1,scene:2,second:2,see:2,set:1,should:[1,2],size:2,softwar:1,space:2,specifi:2,squash:1,style:1,submit:1,tag:1,target:1,thi:1,third:2,tool:1,unit_test:1,upon:1,upstream:1,use:1,uses:1,version:1,via:1,wellcom:0,whole:0,work:1,workflow:1,xml:2,your:1,your_usernam:1},titles:["neuro","Contributing","Converting cells from cellfinder to brainrender format"],titleterms:{The:2,also:2,argument:2,brainrend:2,cell:2,cellfind:2,contribut:1,convert:2,depend:1,develop:0,file:2,follow:2,format:[1,2],from:2,instal:0,introduct:0,mai:2,need:2,neuro:0,option:2,posit:2,pull:1,releas:1,request:1,setup:1,test:1,thi:2,tool:0,travi:1,used:2,visualis:2}}) \ No newline at end of file diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index fc391f8..07d2340 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -8,12 +8,9 @@ from brainio import brainio from imlib.IO.surfaces import marching_cubes_to_obj +from imlib.image.orient import reorient_image from neuro.injection_finder.registration import get_registered_image -from neuro.injection_finder.utils import ( - reorient_image, - get_largest_component, -) from neuro.injection_finder.parsers import extraction_parser # For logging @@ -165,7 +162,8 @@ def extract(self, image, voxel_size=10): marching_cubes_to_obj((verts, faces, normals, values), self.obj_path) # Keep only the largest connected component - get_largest_component(self.obj_path) + # DO THIS AT THE IMAGE STAGE + # get_largest_component(self.obj_path) def main(): diff --git a/neuro/injection_finder/registration.py b/neuro/injection_finder/registration.py index c28d26d..7e24841 100644 --- a/neuro/injection_finder/registration.py +++ b/neuro/injection_finder/registration.py @@ -8,10 +8,7 @@ ) from imlib.general.exceptions import RegistrationError - - -from amap.tools import source_files -from amap.config.config import get_binary +from imlib.source.niftyreg_binaries import get_binary, get_niftyreg_binaries PROGRAM_NAME = "reg_resample" @@ -38,7 +35,7 @@ def prepare_segmentation_cmd( def get_registered_image(nii_path, registration_dir, logging, overwrite=False): # get binaries - nifty_reg_binaries_folder = source_files.get_niftyreg_binaries() + nifty_reg_binaries_folder = get_niftyreg_binaries() program_path = get_binary(nifty_reg_binaries_folder, PROGRAM_NAME) # get file paths diff --git a/neuro/injection_finder/utils.py b/neuro/injection_finder/utils.py deleted file mode 100644 index a91d4c1..0000000 --- a/neuro/injection_finder/utils.py +++ /dev/null @@ -1,71 +0,0 @@ -import numpy as np -from vtkplotter.analysis import extractLargestRegion -from vtkplotter import load, save - -# ----------------------- IMAGE MANIPULATION FUNCTIONS ----------------------- # -def reorient_image(image, invert_axes=None, orientation="saggital"): - """ - Reorients the image to the coordinate space of the atlas - - :param image_path: str - :param threshold: float - :param invert_axes: tuple (Default value = None) - :param image: - :param orientation: (Default value = "saggital") - - """ - if invert_axes is not None: - for axis in list(invert_axes): - image = np.flip(image, axis=axis) - - if orientation is not "saggital": - if orientation is "coronal": - transposition = (2, 1, 0) - elif orientation is "horizontal": - transposition = (1, 2, 0) - - image = np.transpose(image, transposition) - return image - - -# -# # ------------------------- MARCHING CUBES FUNCTIONS ------------------------- # -# def marching_cubes_to_obj(marching_cubes_out, output_file): -# """ -# Saves the output of skimage.measure.marching_cubes as an .obj file -# -# :param marching_cubes_out: tuple -# :param output_file: str -# -# """ -# -# verts, faces, normals, _ = marching_cubes_out -# with open(output_file, "w") as f: -# for item in verts: -# f.write(f"v {item[0]} {item[1]} {item[2]}\n") -# for item in normals: -# f.write(f"vn {item[0]} {item[1]} {item[2]}\n") -# for item in faces: -# f.write( -# f"f {item[0]}//{item[0]} {item[1]}//{item[1]} " -# f"{item[2]}//{item[2]}\n" -# ) -# f.close() - - -# ----------------------------- VTKPLOTTER UTILS ----------------------------- # -def get_center_of_mass(actor): - """ - Get the center of mass of a vtk actor - """ - return actor.centerOfMass() - - -def get_largest_component(obj_filepath): - """ - Given a .obj file with multiple disconnected meshes in it, it - selects the largest of these and discards the rest. - """ - actor = load(str(obj_filepath)) - actor = extractLargestRegion(actor).flipNormals() - save(actor, obj_filepath) From a68c4f72802d3925478c31fc3ec76d97b9cf967f Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 18:35:44 +0000 Subject: [PATCH 16/21] optional logging to file --- neuro/injection_finder/extraction.py | 12 ++++++++---- neuro/injection_finder/parsers.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index 07d2340..c655962 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -13,10 +13,11 @@ from neuro.injection_finder.registration import get_registered_image from neuro.injection_finder.parsers import extraction_parser +import neuro as package_for_log + # For logging import logging from fancylog import fancylog -import fancylog as package class Extractor: @@ -183,10 +184,13 @@ def main(): args.obj_path = Path(args.obj_path) # Start log - log_name = "injection_finder_{}".format( - os.path.split(args.registration_folder)[-1] + fancylog.start_logging( + outdir, + package_for_log, + filename="injection_finder", + verbose=args.debug, + log_to_file=args.save_log, ) - fancylog.start_logging(outdir, package, filename=log_name, verbose=True) # Start extraction Extractor( diff --git a/neuro/injection_finder/parsers.py b/neuro/injection_finder/parsers.py index 774f740..568c7d5 100644 --- a/neuro/injection_finder/parsers.py +++ b/neuro/injection_finder/parsers.py @@ -77,4 +77,17 @@ def extraction_parser(): default="False", help="If false skip running again the registration", ) + parser.add_argument( + "--debug", + dest="debug", + action="store_true", + help="Debug mode. Will increase verbosity of logging and save all " + "intermediate files for diagnosis of software issues.", + ) + parser.add_argument( + "--save-log", + dest="save_log", + action="store_true", + help="Save logging to file (in addition to logging to terminal).", + ) return parser From 564430b24d05ea077001dfd30b620ebbc78ab00e Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Tue, 4 Feb 2020 18:52:17 +0000 Subject: [PATCH 17/21] tidy --- neuro/injection_finder/extraction.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index c655962..01fad62 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -14,8 +14,6 @@ from neuro.injection_finder.parsers import extraction_parser import neuro as package_for_log - -# For logging import logging from fancylog import fancylog From b15a65e40174b975d5fa042dd3f82b4b1d036d20 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 5 Feb 2020 15:58:54 +0000 Subject: [PATCH 18/21] registration moved to imlib --- neuro/injection_finder/extraction.py | 42 ++++++++++++---------- neuro/injection_finder/parsers.py | 6 ++-- neuro/injection_finder/registration.py | 48 ++++---------------------- 3 files changed, 34 insertions(+), 62 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index 01fad62..ba3ceb4 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -31,21 +31,26 @@ def __init__( obj_path=None, overwrite_registration=False, ): - """ - Extractor processes a downsampled.nii image to extract the location of the injection site. - This is done by registering the image to the allen CCF, blurring, thresholding and finally a - marching cube algorithm to extract the surface of the injection site. - - :param img_filepath: str, path to .nii file - :param registration_folder: str, path to the registration folder [from cellfinder or amap] - :param logging: instance of fancylog logger - :param overwrite: bool, if False it will avoid overwriting files - :gaussian_kernel: float, size of kernel used for smoothing - :param percentile_threshold: float, in range [0, 1] percentile to use for thresholding - :param threshold_type: str, either ['otsu', 'percentile'], type of threshold used - :param obj_path: path to .obj file destination. - :param overwrite_registration: if false doesn't overwrite the registration step + Extractor processes a downsampled.nii image to extract the location of + the injection site. + This is done by registering the image to the allen CCF, blurring, + thresholding and finally a marching cube algorithm to extract the + surface of the injection site. + + :param img_filepath: str, path to .nii file + :param registration_folder: str, path to the registration folder + [from cellfinder or amap] + :param logging: instance of fancylog logger + :param overwrite: bool, if False it will avoid overwriting files + :gaussian_kernel: float, size of kernel used for smoothing + :param percentile_threshold: float, in range [0, 1] percentile to use + for thresholding + :param threshold_type: str, either ['otsu', 'percentile'], + type of threshold used + :param obj_path: path to .obj file destination. + :param overwrite_registration: if false doesn't overwrite the + registration step """ # Get arguments @@ -73,14 +78,14 @@ def setup(self): self.img_filepath.split(".")[0] + "_thresholded.nii" ) - # Get path to obj file and check if it existsts + # Get path to obj file and check if it exists if self.obj_path is None: self.obj_path = self.img_filepath.split(".")[0] + ".obj" if os.path.isfile(self.obj_path) and not self.overwrite: self.logging.warning( - "A file exists already at {}. \ - Analysis will not run as overwrite is set disabled".format( + "A file exists already at {}." + "Analysis will not run as overwrite is set disabled".format( self.obj_path ) ) @@ -122,7 +127,8 @@ def extract(self, image, voxel_size=10): ): thresh = np.percentile(filtered.ravel(), self.percentile_threshold) self.logging.info( - "Thresholding with {} threshold type. {}th percentile [{}]".format( + "Thresholding with {} threshold type. " + "{}th percentile [{}]".format( self.threshold_type, self.percentile_threshold, thresh ) ) diff --git a/neuro/injection_finder/parsers.py b/neuro/injection_finder/parsers.py index 568c7d5..5532e1e 100644 --- a/neuro/injection_finder/parsers.py +++ b/neuro/injection_finder/parsers.py @@ -57,7 +57,8 @@ def extraction_parser(): dest="percentile_threshold", type=float, default=99.995, - help="Float in range [0, 100]. The percentile number of pixel intensity values for tresholding", + help="Float in range [0, 100]. The percentile number of pixel " + "intensity values for tresholding", ) parser.add_argument( @@ -66,7 +67,8 @@ def extraction_parser(): dest="threshold_type", type=str, default="otsu", - help="'otsu' or 'percentile'. Determines how the threshold value is computed", + help="'otsu' or 'percentile'. Determines how the threshold " + "value is computed", ) parser.add_argument( diff --git a/neuro/injection_finder/registration.py b/neuro/injection_finder/registration.py index 7e24841..51a06af 100644 --- a/neuro/injection_finder/registration.py +++ b/neuro/injection_finder/registration.py @@ -1,43 +1,14 @@ import os from brainio import brainio +from imlib.register.niftyreg.transform import run_transform -from imlib.general.system import ( - safe_execute_command, - SafeExecuteCommandError, -) -from imlib.general.exceptions import RegistrationError -from imlib.source.niftyreg_binaries import get_binary, get_niftyreg_binaries - - -PROGRAM_NAME = "reg_resample" DEFAULT_CONTROL_POINT_FILE = "inverse_control_point_file.nii" default_atlas_name = "brain_filtered.nii" -def prepare_segmentation_cmd( - program_path, - floating_image_path, - output_file_name, - destination_image_filename, - control_point_file, -): - cmd = "{} -cpp {} -flo {} -ref {} -res {}".format( - program_path, - control_point_file, - floating_image_path, - destination_image_filename, - output_file_name, - ) - return cmd - - def get_registered_image(nii_path, registration_dir, logging, overwrite=False): - # get binaries - nifty_reg_binaries_folder = get_niftyreg_binaries() - program_path = get_binary(nifty_reg_binaries_folder, PROGRAM_NAME) - # get file paths basedir = os.path.split(nii_path)[0] output_filename = os.path.join( @@ -45,11 +16,9 @@ def get_registered_image(nii_path, registration_dir, logging, overwrite=False): "{}_transformed.nii".format(os.path.split(nii_path)[1].split(".")[0]), ) if os.path.isfile(output_filename) and not overwrite: - run = False + logging.info("Skipping registration as output file already exists") else: - run = True - if run: destination_image = os.path.join(registration_dir, default_atlas_name) control_point_file = os.path.join( registration_dir, DEFAULT_CONTROL_POINT_FILE @@ -58,19 +27,14 @@ def get_registered_image(nii_path, registration_dir, logging, overwrite=False): log_file_path = os.path.join(basedir, "registration_log.txt") error_file_path = os.path.join(basedir, "registration_err.txt") - reg_cmd = prepare_segmentation_cmd( - program_path, + logging.info("Running registration") + run_transform( nii_path, output_filename, destination_image, control_point_file, + log_file_path, + error_file_path, ) - logging.info("Running registration") - try: - safe_execute_command(reg_cmd, log_file_path, error_file_path) - except SafeExecuteCommandError as err: - raise RegistrationError("Registration failed; {}".format(err)) - else: - logging.info("Skipping registration as output file already exists") return brainio.load_any(output_filename) From 7658f7388af1c31fcddc25ce94c45294a1f8daa4 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 5 Feb 2020 16:42:01 +0000 Subject: [PATCH 19/21] keep largest object --- neuro/injection_finder/extraction.py | 40 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index ba3ceb4..63e070e 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -138,6 +138,7 @@ def extract(self, image, voxel_size=10): ) binary = filtered > thresh + binary = keep_n_largest_objects(binary) oriented_binary = reorient_image( binary, invert_axes=[2,], orientation="coronal" ) @@ -166,9 +167,42 @@ def extract(self, image, voxel_size=10): faces = faces + 1 marching_cubes_to_obj((verts, faces, normals, values), self.obj_path) - # Keep only the largest connected component - # DO THIS AT THE IMAGE STAGE - # get_largest_component(self.obj_path) + +def keep_n_largest_objects(numpy_array, n=1, connectivity=None): + """ + Given an input binary numpy array, return a "clean" array with only the + n largest connected components remaining + + Inspired by stackoverflow.com/questions/47540926 + + TODO: optimise + + :param numpy_array: Binary numpy array + :param n: How many objects to keep + :param connectivity: Labelling connectivity (see skimage.measure.label) + :return: "Clean" numpy array with n largest objects + """ + + labels = measure.label(numpy_array, connectivity=connectivity) + assert labels.max() != 0 # assume at least 1 CC + n_largest_objects = get_largest_non_zero_object(labels) + if n > 1: + i = 1 + while i < n: + labels[n_largest_objects] = 0 + n_largest_objects += get_largest_non_zero_object(labels) + i += 1 + return n_largest_objects + + +def get_largest_non_zero_object(label_image): + """ + In a labelled (each object assigned an int) numpy array. Return the + largest object with a value >= 1. + :param label_image: Output of skimage.measure.label + :return: Boolean numpy array or largest object + """ + return label_image == np.argmax(np.bincount(label_image.flat)[1:]) + 1 def main(): From 6c607480263e7149ac2f20a4d11aec3f03149fc6 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 5 Feb 2020 16:45:50 +0000 Subject: [PATCH 20/21] reduce RAM usage --- neuro/injection_finder/extraction.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index 63e070e..c7e0670 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -109,12 +109,12 @@ def extract(self, image, voxel_size=10): # Gaussian filter kernel_shape = [self.gaussian_kernel, self.gaussian_kernel, 6] - filtered = gaussian_filter(image, kernel_shape) + image = gaussian_filter(image, kernel_shape) self.logging.info("Filtering completed") # Thresholding if self.threshold_type.lower() == "otsu": - thresh = threshold_otsu(filtered) + thresh = threshold_otsu(image) self.logging.info( "Thresholding with {} threshold type".format( self.threshold_type @@ -125,7 +125,7 @@ def extract(self, image, voxel_size=10): self.threshold_type.lower() == "percentile" or self.threshold_type.lower() == "perc" ): - thresh = np.percentile(filtered.ravel(), self.percentile_threshold) + thresh = np.percentile(image.ravel(), self.percentile_threshold) self.logging.info( "Thresholding with {} threshold type. " "{}th percentile [{}]".format( @@ -137,11 +137,8 @@ def extract(self, image, voxel_size=10): "Unrecognised thresholding type: " + self.threshold_type ) - binary = filtered > thresh + binary = image > thresh binary = keep_n_largest_objects(binary) - oriented_binary = reorient_image( - binary, invert_axes=[2,], orientation="coronal" - ) # Save thresholded image if not os.path.isfile(self.thresholded_savepath) or self.overwrite: @@ -152,10 +149,14 @@ def extract(self, image, voxel_size=10): ) brainio.to_nii(binary.astype(np.int16), self.thresholded_savepath) + binary = reorient_image( + binary, invert_axes=[2,], orientation="coronal" + ) + # apply marching cubes self.logging.info("Extracting surface from thresholded image") verts, faces, normals, values = measure.marching_cubes_lewiner( - oriented_binary, 0, step_size=1 + binary, 0, step_size=1 ) # Scale to atlas spacing From dff47ecb6d330edc205a0d8f0d6f9baa2f5b2e21 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Wed, 5 Feb 2020 18:28:30 +0000 Subject: [PATCH 21/21] remove unnecessary logging args --- neuro/injection_finder/extraction.py | 4 ---- neuro/injection_finder/registration.py | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/neuro/injection_finder/extraction.py b/neuro/injection_finder/extraction.py index c7e0670..0c8095b 100644 --- a/neuro/injection_finder/extraction.py +++ b/neuro/injection_finder/extraction.py @@ -23,7 +23,6 @@ def __init__( self, img_filepath, registration_folder, - logging, overwrite=False, gaussian_kernel=2, percentile_threshold=99.95, @@ -41,7 +40,6 @@ def __init__( :param img_filepath: str, path to .nii file :param registration_folder: str, path to the registration folder [from cellfinder or amap] - :param logging: instance of fancylog logger :param overwrite: bool, if False it will avoid overwriting files :gaussian_kernel: float, size of kernel used for smoothing :param percentile_threshold: float, in range [0, 1] percentile to use @@ -94,7 +92,6 @@ def setup(self): image = get_registered_image( self.img_filepath, self.registration_folder, - self.logging, overwrite=self.overwrite_registration, ) return image @@ -235,7 +232,6 @@ def main(): Extractor( args.img_filepath, args.registration_folder, - logging, overwrite=args.overwrite, gaussian_kernel=args.gaussian_kernel, percentile_threshold=args.percentile_threshold, diff --git a/neuro/injection_finder/registration.py b/neuro/injection_finder/registration.py index 51a06af..3abe057 100644 --- a/neuro/injection_finder/registration.py +++ b/neuro/injection_finder/registration.py @@ -1,4 +1,5 @@ import os +import logging from brainio import brainio from imlib.register.niftyreg.transform import run_transform @@ -8,7 +9,7 @@ default_atlas_name = "brain_filtered.nii" -def get_registered_image(nii_path, registration_dir, logging, overwrite=False): +def get_registered_image(nii_path, registration_dir, overwrite=False): # get file paths basedir = os.path.split(nii_path)[0] output_filename = os.path.join(