Skip to content

Commit e189ca7

Browse files
authored
Merge pull request #119 from rjlopez2:documentation
Documentation
2 parents 562ccc4 + 881f780 commit e189ca7

File tree

6 files changed

+218
-44
lines changed

6 files changed

+218
-44
lines changed

docs/scripts_examples/analysis_dual_illumination.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"metadata": {},
5555
"outputs": [],
5656
"source": [
57-
"viewer = napari.Viewer()\n",
57+
"viewer = napari.Viewer(show=False)\n",
5858
"o = napari_omaas.OMAAS(viewer)\n",
5959
"viewer.window.add_dock_widget(o, area='right')"
6060
]
@@ -142,7 +142,7 @@
142142
"source": [
143143
" \n",
144144
"# here we create the saving results folder\n",
145-
"results_folder_name = fr\"M:\\PhD students\\Saranda Nimani\\Optical Mapping\\SQT-SupRep\\APD maps\\{genotype}\\{freq_estim_condition}\\{condition}\\{illumination_type}\\{animal_id}\\{os.path.basename(my_file)}\"\n",
145+
"results_folder_name = fr\"APD maps\\{genotype}\\{freq_estim_condition}\\{condition}\\{illumination_type}\\{animal_id}\\{os.path.basename(my_file)}\"\n",
146146
"# results_folder_name = os.path.basename(my_file)[:8]\n",
147147
"# results_folder_path = os.path.normpath(fr\"D:\\Sara\\results_{results_folder_name}\\{freq_estim_condition}\\{condition}\\{illumination_type}\")\n",
148148
"# results_folder_path = os.path.normpath(fr\"{results_folder_name}\\{freq_estim_condition}\\{condition}\\{illumination_type}\")\n",
@@ -182,7 +182,8 @@
182182
"outputs": [],
183183
"source": [
184184
"try:\n",
185-
" viewer.open(path=my_file, plugin= \"napari-omaas\")\n",
185+
" # viewer.open(path=my_file, plugin= \"napari-omaas\")\n",
186+
" viewer.open_sample('napari-omaas', 'heart_sample_3mi')\n",
186187
"except Exception as e:\n",
187188
" raise CustomException(e, sys)"
188189
]

docs/scripts_examples/analysis_red_only.ipynb

Lines changed: 174 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"metadata": {},
8787
"outputs": [],
8888
"source": [
89-
"def viewer_show_las_layer(viewer):\n",
89+
"def show_last_layer(viewer):\n",
9090
" \"\"\"\n",
9191
"\n",
9292
" Helper function to hide all layers but last one.\n",
@@ -107,8 +107,8 @@
107107
"metadata": {},
108108
"outputs": [],
109109
"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",
112112
"o = napari_omaas.OMAAS(viewer)\n",
113113
"viewer.window.add_dock_widget(o, area='right')"
114114
]
@@ -259,12 +259,12 @@
259259
"metadata": {},
260260
"outputs": [],
261261
"source": [
262-
"%%capture\n",
262+
"# %%capture\n",
263263
"# the %%capture command above will hide the ouptut of this cell bc can be very long (only used for the documentation)\n",
264264
"\n",
265265
"try:\n",
266266
" # 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",
268268
"except Exception as e:\n",
269269
" raise CustomException(e, sys)"
270270
]
@@ -332,7 +332,36 @@
332332
"viewer.add_shapes(my_shape)\n",
333333
"\n",
334334
"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"
336365
]
337366
},
338367
{
@@ -351,7 +380,7 @@
351380
},
352381
{
353382
"cell_type": "code",
354-
"execution_count": 14,
383+
"execution_count": 15,
355384
"metadata": {},
356385
"outputs": [],
357386
"source": [
@@ -432,14 +461,11 @@
432461
},
433462
{
434463
"cell_type": "code",
435-
"execution_count": 18,
464+
"execution_count": 19,
436465
"metadata": {},
437466
"outputs": [],
438467
"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)"
443469
]
444470
},
445471
{
@@ -471,7 +497,7 @@
471497
},
472498
{
473499
"cell_type": "code",
474-
"execution_count": null,
500+
"execution_count": 21,
475501
"metadata": {},
476502
"outputs": [],
477503
"source": [
@@ -557,7 +583,7 @@
557583
},
558584
{
559585
"cell_type": "code",
560-
"execution_count": 25,
586+
"execution_count": 28,
561587
"metadata": {},
562588
"outputs": [],
563589
"source": [
@@ -582,16 +608,16 @@
582608
},
583609
{
584610
"cell_type": "code",
585-
"execution_count": 27,
611+
"execution_count": 30,
586612
"metadata": {},
587613
"outputs": [],
588614
"source": [
589-
"viewer_show_las_layer(viewer)"
615+
"show_last_layer(viewer)"
590616
]
591617
},
592618
{
593619
"cell_type": "code",
594-
"execution_count": 28,
620+
"execution_count": 31,
595621
"metadata": {},
596622
"outputs": [],
597623
"source": [
@@ -616,11 +642,11 @@
616642
},
617643
{
618644
"cell_type": "code",
619-
"execution_count": 30,
645+
"execution_count": 33,
620646
"metadata": {},
621647
"outputs": [],
622648
"source": [
623-
"viewer_show_las_layer(viewer)"
649+
"show_last_layer(viewer)"
624650
]
625651
},
626652
{
@@ -733,7 +759,7 @@
733759
},
734760
{
735761
"cell_type": "code",
736-
"execution_count": null,
762+
"execution_count": 39,
737763
"metadata": {},
738764
"outputs": [],
739765
"source": [
@@ -761,7 +787,7 @@
761787
},
762788
{
763789
"cell_type": "code",
764-
"execution_count": 38,
790+
"execution_count": 40,
765791
"metadata": {},
766792
"outputs": [],
767793
"source": [
@@ -794,19 +820,20 @@
794820
},
795821
{
796822
"cell_type": "code",
797-
"execution_count": null,
823+
"execution_count": 42,
798824
"metadata": {},
799825
"outputs": [],
800826
"source": [
801827
"\n",
802828
"%%capture\n",
803829
"# the %%capture command above will hide the ouptut of this cell bc can be very long (only used for the documentation)\n",
804830
"\n",
805-
"# o.plot_last_generated_img()\n",
806-
"# o.preview_AP_splitted_btn.click()\n",
807831
"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",
810837
"for value in [90]:\n",
811838
" viewer.layers.selection.active = target_image\n",
812839
" o.slider_APD_map_percentage.setValue(value)\n",
@@ -823,11 +850,11 @@
823850
},
824851
{
825852
"cell_type": "code",
826-
"execution_count": 68,
853+
"execution_count": 43,
827854
"metadata": {},
828855
"outputs": [],
829856
"source": [
830-
"viewer_show_las_layer(viewer)"
857+
"show_last_layer(viewer)"
831858
]
832859
},
833860
{
@@ -850,7 +877,7 @@
850877
},
851878
{
852879
"cell_type": "code",
853-
"execution_count": 70,
880+
"execution_count": 45,
854881
"metadata": {},
855882
"outputs": [],
856883
"source": [
@@ -872,7 +899,7 @@
872899
},
873900
{
874901
"cell_type": "code",
875-
"execution_count": 72,
902+
"execution_count": 47,
876903
"metadata": {},
877904
"outputs": [],
878905
"source": [
@@ -888,6 +915,114 @@
888915
"nbscreenshot(viewer)"
889916
]
890917
},
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+
},
8911026
{
8921027
"cell_type": "markdown",
8931028
"metadata": {},
@@ -911,15 +1046,22 @@
9111046
"# Here we export last 3 images\n",
9121047
"o.save_img_dir_box_text.setText(str(results_folder_path))\n",
9131048
"# for value in [-1]:\n",
914-
"for value in range(-1, -3, -1):\n",
1049+
"for value in range(-1, -4, -1):\n",
9151050
" viewer.layers.selection.active = viewer.layers[value]\n",
9161051
" o.export_image_btn.click()"
9171052
]
1053+
},
1054+
{
1055+
"cell_type": "code",
1056+
"execution_count": null,
1057+
"metadata": {},
1058+
"outputs": [],
1059+
"source": []
9181060
}
9191061
],
9201062
"metadata": {
9211063
"kernelspec": {
922-
"display_name": "roi_plugin_test",
1064+
"display_name": "Python 3",
9231065
"language": "python",
9241066
"name": "python3"
9251067
},

0 commit comments

Comments
 (0)