|
86 | 86 | "metadata": {}, |
87 | 87 | "outputs": [], |
88 | 88 | "source": [ |
89 | | - "def viewer_show_las_layer(viewer):\n", |
| 89 | + "def show_last_layer(viewer):\n", |
90 | 90 | " \"\"\"\n", |
91 | 91 | "\n", |
92 | 92 | " Helper function to hide all layers but last one.\n", |
|
107 | 107 | "metadata": {}, |
108 | 108 | "outputs": [], |
109 | 109 | "source": [ |
110 | | - "viewer = napari.Viewer(show=False)\n", |
111 | | - "# viewer = napari.Viewer(show=True)\n", |
| 110 | + "# viewer = napari.Viewer(show=False)\n", |
| 111 | + "viewer = napari.Viewer(show=True)\n", |
112 | 112 | "o = napari_omaas.OMAAS(viewer)\n", |
113 | 113 | "viewer.window.add_dock_widget(o, area='right')" |
114 | 114 | ] |
|
259 | 259 | "metadata": {}, |
260 | 260 | "outputs": [], |
261 | 261 | "source": [ |
262 | | - "%%capture\n", |
| 262 | + "# %%capture\n", |
263 | 263 | "# the %%capture command above will hide the ouptut of this cell bc can be very long (only used for the documentation)\n", |
264 | 264 | "\n", |
265 | 265 | "try:\n", |
266 | 266 | " # viewer.open(path=my_file, plugin= \"napari-omaas\")\n", |
267 | | - " viewer.open_sample('napari-omaas', 'heart_sample_2')\n", |
| 267 | + " viewer.open_sample('napari-omaas', 'heart_sample_single_illumination')\n", |
268 | 268 | "except Exception as e:\n", |
269 | 269 | " raise CustomException(e, sys)" |
270 | 270 | ] |
|
332 | 332 | "viewer.add_shapes(my_shape)\n", |
333 | 333 | "\n", |
334 | 334 | "o.rotate_l_crop.setChecked(True)\n", |
335 | | - "o.crop_from_shape_btn.click() # done\n" |
| 335 | + "o.crop_from_shape_btn.click() # done\n", |
| 336 | + "\n", |
| 337 | + "\n", |
| 338 | + "show_last_layer(viewer=viewer)\n", |
| 339 | + "\n", |
| 340 | + "\n", |
| 341 | + "# this is just to manipulate the viewer by changing the position of the image, zooming it and changing to the first frame\n", |
| 342 | + "viewer.camera.center = 0.0, 150, 127\n", |
| 343 | + "viewer.camera.zoom = 2.3\n", |
| 344 | + "viewer.dims.current_step = (0, 156, 749)\n" |
| 345 | + ] |
| 346 | + }, |
| 347 | + { |
| 348 | + "cell_type": "markdown", |
| 349 | + "metadata": {}, |
| 350 | + "source": [ |
| 351 | + "Alternatively, you can use the function to rotate automatically rotate the views in correct position amd work with the four views as shown bellow." |
| 352 | + ] |
| 353 | + }, |
| 354 | + { |
| 355 | + "cell_type": "code", |
| 356 | + "execution_count": null, |
| 357 | + "metadata": {}, |
| 358 | + "outputs": [], |
| 359 | + "source": [ |
| 360 | + "# # change to tab called \"Shapes\"\n", |
| 361 | + "# o.tabs.setCurrentIndex(1)\n", |
| 362 | + "# o.crop_all_views_and_rotate_btn.click()\n", |
| 363 | + "\n", |
| 364 | + "# show_last_layer(viewer=viewer)\n" |
336 | 365 | ] |
337 | 366 | }, |
338 | 367 | { |
|
351 | 380 | }, |
352 | 381 | { |
353 | 382 | "cell_type": "code", |
354 | | - "execution_count": 14, |
| 383 | + "execution_count": 15, |
355 | 384 | "metadata": {}, |
356 | 385 | "outputs": [], |
357 | 386 | "source": [ |
|
432 | 461 | }, |
433 | 462 | { |
434 | 463 | "cell_type": "code", |
435 | | - "execution_count": 18, |
| 464 | + "execution_count": 19, |
436 | 465 | "metadata": {}, |
437 | 466 | "outputs": [], |
438 | 467 | "source": [ |
439 | | - "viewer_show_las_layer(viewer)\n", |
440 | | - "\n", |
441 | | - "viewer.camera.center = 0.0, 150, 127\n", |
442 | | - "viewer.camera.zoom = 2.3" |
| 468 | + "show_last_layer(viewer)" |
443 | 469 | ] |
444 | 470 | }, |
445 | 471 | { |
|
471 | 497 | }, |
472 | 498 | { |
473 | 499 | "cell_type": "code", |
474 | | - "execution_count": null, |
| 500 | + "execution_count": 21, |
475 | 501 | "metadata": {}, |
476 | 502 | "outputs": [], |
477 | 503 | "source": [ |
|
557 | 583 | }, |
558 | 584 | { |
559 | 585 | "cell_type": "code", |
560 | | - "execution_count": 25, |
| 586 | + "execution_count": 28, |
561 | 587 | "metadata": {}, |
562 | 588 | "outputs": [], |
563 | 589 | "source": [ |
|
582 | 608 | }, |
583 | 609 | { |
584 | 610 | "cell_type": "code", |
585 | | - "execution_count": 27, |
| 611 | + "execution_count": 30, |
586 | 612 | "metadata": {}, |
587 | 613 | "outputs": [], |
588 | 614 | "source": [ |
589 | | - "viewer_show_las_layer(viewer)" |
| 615 | + "show_last_layer(viewer)" |
590 | 616 | ] |
591 | 617 | }, |
592 | 618 | { |
593 | 619 | "cell_type": "code", |
594 | | - "execution_count": 28, |
| 620 | + "execution_count": 31, |
595 | 621 | "metadata": {}, |
596 | 622 | "outputs": [], |
597 | 623 | "source": [ |
|
616 | 642 | }, |
617 | 643 | { |
618 | 644 | "cell_type": "code", |
619 | | - "execution_count": 30, |
| 645 | + "execution_count": 33, |
620 | 646 | "metadata": {}, |
621 | 647 | "outputs": [], |
622 | 648 | "source": [ |
623 | | - "viewer_show_las_layer(viewer)" |
| 649 | + "show_last_layer(viewer)" |
624 | 650 | ] |
625 | 651 | }, |
626 | 652 | { |
|
733 | 759 | }, |
734 | 760 | { |
735 | 761 | "cell_type": "code", |
736 | | - "execution_count": null, |
| 762 | + "execution_count": 39, |
737 | 763 | "metadata": {}, |
738 | 764 | "outputs": [], |
739 | 765 | "source": [ |
|
761 | 787 | }, |
762 | 788 | { |
763 | 789 | "cell_type": "code", |
764 | | - "execution_count": 38, |
| 790 | + "execution_count": 40, |
765 | 791 | "metadata": {}, |
766 | 792 | "outputs": [], |
767 | 793 | "source": [ |
|
794 | 820 | }, |
795 | 821 | { |
796 | 822 | "cell_type": "code", |
797 | | - "execution_count": null, |
| 823 | + "execution_count": 42, |
798 | 824 | "metadata": {}, |
799 | 825 | "outputs": [], |
800 | 826 | "source": [ |
801 | 827 | "\n", |
802 | 828 | "%%capture\n", |
803 | 829 | "# the %%capture command above will hide the ouptut of this cell bc can be very long (only used for the documentation)\n", |
804 | 830 | "\n", |
805 | | - "# o.plot_last_generated_img()\n", |
806 | | - "# o.preview_AP_splitted_btn.click()\n", |
807 | 831 | "target_image = viewer.layers[-1]\n", |
808 | | - "# image_stack = target_image.data\n", |
809 | | - "# for value in [75, 90]:\n", |
| 832 | + "\n", |
| 833 | + "# if you wish to compute multiples APD maps with different % values, replace \n", |
| 834 | + "# the value inside the square brakets with your desired values\n", |
| 835 | + "# like for example: [25, 75, 90]\n", |
| 836 | + "\n", |
810 | 837 | "for value in [90]:\n", |
811 | 838 | " viewer.layers.selection.active = target_image\n", |
812 | 839 | " o.slider_APD_map_percentage.setValue(value)\n", |
|
823 | 850 | }, |
824 | 851 | { |
825 | 852 | "cell_type": "code", |
826 | | - "execution_count": 68, |
| 853 | + "execution_count": 43, |
827 | 854 | "metadata": {}, |
828 | 855 | "outputs": [], |
829 | 856 | "source": [ |
830 | | - "viewer_show_las_layer(viewer)" |
| 857 | + "show_last_layer(viewer)" |
831 | 858 | ] |
832 | 859 | }, |
833 | 860 | { |
|
850 | 877 | }, |
851 | 878 | { |
852 | 879 | "cell_type": "code", |
853 | | - "execution_count": 70, |
| 880 | + "execution_count": 45, |
854 | 881 | "metadata": {}, |
855 | 882 | "outputs": [], |
856 | 883 | "source": [ |
|
872 | 899 | }, |
873 | 900 | { |
874 | 901 | "cell_type": "code", |
875 | | - "execution_count": 72, |
| 902 | + "execution_count": 47, |
876 | 903 | "metadata": {}, |
877 | 904 | "outputs": [], |
878 | 905 | "source": [ |
|
888 | 915 | "nbscreenshot(viewer)" |
889 | 916 | ] |
890 | 917 | }, |
| 918 | + { |
| 919 | + "cell_type": "markdown", |
| 920 | + "metadata": {}, |
| 921 | + "source": [ |
| 922 | + "### Post-process the resulting map" |
| 923 | + ] |
| 924 | + }, |
| 925 | + { |
| 926 | + "cell_type": "markdown", |
| 927 | + "metadata": {}, |
| 928 | + "source": [ |
| 929 | + "You can retouch and smooth the resulting APD map using the same `Post-processing` map tab for visualization.\n", |
| 930 | + "\n", |
| 931 | + "The bellow commands would be the equivalent to manually click on preview and adjust process the image via eroding or filtering using a gaussian filer.\n", |
| 932 | + "Let's see how:" |
| 933 | + ] |
| 934 | + }, |
| 935 | + { |
| 936 | + "cell_type": "code", |
| 937 | + "execution_count": 4, |
| 938 | + "metadata": {}, |
| 939 | + "outputs": [], |
| 940 | + "source": [ |
| 941 | + "o.tabs.setCurrentIndex(3)\n", |
| 942 | + "o.mapping_tabs.setCurrentIndex(1)" |
| 943 | + ] |
| 944 | + }, |
| 945 | + { |
| 946 | + "cell_type": "code", |
| 947 | + "execution_count": 17, |
| 948 | + "metadata": {}, |
| 949 | + "outputs": [], |
| 950 | + "source": [ |
| 951 | + "o.preview_postProcessingMAP_btn.click()" |
| 952 | + ] |
| 953 | + }, |
| 954 | + { |
| 955 | + "cell_type": "code", |
| 956 | + "execution_count": 13, |
| 957 | + "metadata": {}, |
| 958 | + "outputs": [], |
| 959 | + "source": [ |
| 960 | + "# set the sigam value for the gaussian filter\n", |
| 961 | + "o.InterctiveWindod_edit_map.gaussian_sigma.setValue(1.5)\n", |
| 962 | + "\n", |
| 963 | + "# set the radius of the filter\n", |
| 964 | + "o.InterctiveWindod_edit_map.gaussian_radius.setValue(4)\n", |
| 965 | + "\n", |
| 966 | + "# set the numebr of pixels to erode (reduce the edge) of the image\n", |
| 967 | + "o.InterctiveWindod_edit_map.n_pixels_erode_slider.setValue(4)\n" |
| 968 | + ] |
| 969 | + }, |
| 970 | + { |
| 971 | + "cell_type": "markdown", |
| 972 | + "metadata": {}, |
| 973 | + "source": [ |
| 974 | + "If you are happy wiht the results, you can accept the changes and close the postproceeesing window" |
| 975 | + ] |
| 976 | + }, |
| 977 | + { |
| 978 | + "cell_type": "code", |
| 979 | + "execution_count": null, |
| 980 | + "metadata": {}, |
| 981 | + "outputs": [], |
| 982 | + "source": [ |
| 983 | + "# Accept changes\n", |
| 984 | + "o.InterctiveWindod_edit_map.accept_post_processing_changes_btn.click()" |
| 985 | + ] |
| 986 | + }, |
| 987 | + { |
| 988 | + "cell_type": "code", |
| 989 | + "execution_count": 18, |
| 990 | + "metadata": {}, |
| 991 | + "outputs": [], |
| 992 | + "source": [ |
| 993 | + "# Close the tool\n", |
| 994 | + "o.InterctiveWindod_edit_map.close_postprocessing_map_window_btn.click()" |
| 995 | + ] |
| 996 | + }, |
| 997 | + { |
| 998 | + "cell_type": "markdown", |
| 999 | + "metadata": {}, |
| 1000 | + "source": [ |
| 1001 | + "Let's now plot the two MAPs images side by side to check the differences visually." |
| 1002 | + ] |
| 1003 | + }, |
| 1004 | + { |
| 1005 | + "cell_type": "code", |
| 1006 | + "execution_count": null, |
| 1007 | + "metadata": {}, |
| 1008 | + "outputs": [], |
| 1009 | + "source": [ |
| 1010 | + "# select the first item in the list of images maps (only one present at the moment)\n", |
| 1011 | + "\n", |
| 1012 | + "o.map_imgs_selector.item(0).setSelected(True)\n", |
| 1013 | + "o.map_imgs_selector.item(1).setSelected(True)\n", |
| 1014 | + "o.plot_curr_map_btn.click()" |
| 1015 | + ] |
| 1016 | + }, |
| 1017 | + { |
| 1018 | + "cell_type": "code", |
| 1019 | + "execution_count": null, |
| 1020 | + "metadata": {}, |
| 1021 | + "outputs": [], |
| 1022 | + "source": [ |
| 1023 | + "nbscreenshot(viewer=viewer)" |
| 1024 | + ] |
| 1025 | + }, |
891 | 1026 | { |
892 | 1027 | "cell_type": "markdown", |
893 | 1028 | "metadata": {}, |
|
911 | 1046 | "# Here we export last 3 images\n", |
912 | 1047 | "o.save_img_dir_box_text.setText(str(results_folder_path))\n", |
913 | 1048 | "# for value in [-1]:\n", |
914 | | - "for value in range(-1, -3, -1):\n", |
| 1049 | + "for value in range(-1, -4, -1):\n", |
915 | 1050 | " viewer.layers.selection.active = viewer.layers[value]\n", |
916 | 1051 | " o.export_image_btn.click()" |
917 | 1052 | ] |
| 1053 | + }, |
| 1054 | + { |
| 1055 | + "cell_type": "code", |
| 1056 | + "execution_count": null, |
| 1057 | + "metadata": {}, |
| 1058 | + "outputs": [], |
| 1059 | + "source": [] |
918 | 1060 | } |
919 | 1061 | ], |
920 | 1062 | "metadata": { |
921 | 1063 | "kernelspec": { |
922 | | - "display_name": "roi_plugin_test", |
| 1064 | + "display_name": "Python 3", |
923 | 1065 | "language": "python", |
924 | 1066 | "name": "python3" |
925 | 1067 | }, |
|
0 commit comments