pml_utilities 4.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. pml_utilities-4.0.0/LICENSE.md +17 -0
  2. pml_utilities-4.0.0/MANIFEST.in +3 -0
  3. pml_utilities-4.0.0/PKG-INFO +164 -0
  4. pml_utilities-4.0.0/README.md +92 -0
  5. pml_utilities-4.0.0/demos/asap7_spine_pipeline.ipynb +345 -0
  6. pml_utilities-4.0.0/demos/lsp_user_guide.ipynb +1818 -0
  7. pml_utilities-4.0.0/demos/mbo_user_guide.ipynb +1080 -0
  8. pml_utilities-4.0.0/mbo_utilities/__init__.py +220 -0
  9. pml_utilities-4.0.0/mbo_utilities/_cellpose_model.py +95 -0
  10. pml_utilities-4.0.0/mbo_utilities/_shortcut.py +180 -0
  11. pml_utilities-4.0.0/mbo_utilities/_sysmem.py +346 -0
  12. pml_utilities-4.0.0/mbo_utilities/_writers.py +2089 -0
  13. pml_utilities-4.0.0/mbo_utilities/analysis/__init__.py +57 -0
  14. pml_utilities-4.0.0/mbo_utilities/analysis/dff.py +257 -0
  15. pml_utilities-4.0.0/mbo_utilities/analysis/filters.py +129 -0
  16. pml_utilities-4.0.0/mbo_utilities/analysis/linescan.py +176 -0
  17. pml_utilities-4.0.0/mbo_utilities/analysis/mesc_placement.py +329 -0
  18. pml_utilities-4.0.0/mbo_utilities/analysis/phasecorr.py +119 -0
  19. pml_utilities-4.0.0/mbo_utilities/analysis/roi_traces.py +487 -0
  20. pml_utilities-4.0.0/mbo_utilities/analysis/scanphase.py +556 -0
  21. pml_utilities-4.0.0/mbo_utilities/analysis/slow_fast.py +219 -0
  22. pml_utilities-4.0.0/mbo_utilities/analysis/spike_average.py +330 -0
  23. pml_utilities-4.0.0/mbo_utilities/analysis/trace_readouts.py +244 -0
  24. pml_utilities-4.0.0/mbo_utilities/annotation/__init__.py +81 -0
  25. pml_utilities-4.0.0/mbo_utilities/annotation/display.py +387 -0
  26. pml_utilities-4.0.0/mbo_utilities/annotation/domains.py +327 -0
  27. pml_utilities-4.0.0/mbo_utilities/annotation/events.py +90 -0
  28. pml_utilities-4.0.0/mbo_utilities/annotation/model.py +234 -0
  29. pml_utilities-4.0.0/mbo_utilities/annotation/ngff.py +469 -0
  30. pml_utilities-4.0.0/mbo_utilities/annotation/slow_fast.py +495 -0
  31. pml_utilities-4.0.0/mbo_utilities/annotation/store.py +485 -0
  32. pml_utilities-4.0.0/mbo_utilities/annotation/traces.py +267 -0
  33. pml_utilities-4.0.0/mbo_utilities/arrays/__init__.py +311 -0
  34. pml_utilities-4.0.0/mbo_utilities/arrays/_average_view.py +309 -0
  35. pml_utilities-4.0.0/mbo_utilities/arrays/_base.py +950 -0
  36. pml_utilities-4.0.0/mbo_utilities/arrays/_channel_view.py +92 -0
  37. pml_utilities-4.0.0/mbo_utilities/arrays/_inverted_view.py +139 -0
  38. pml_utilities-4.0.0/mbo_utilities/arrays/_phasecorr_view.py +255 -0
  39. pml_utilities-4.0.0/mbo_utilities/arrays/_registration.py +777 -0
  40. pml_utilities-4.0.0/mbo_utilities/arrays/bin.py +261 -0
  41. pml_utilities-4.0.0/mbo_utilities/arrays/bruker.py +190 -0
  42. pml_utilities-4.0.0/mbo_utilities/arrays/compression.py +136 -0
  43. pml_utilities-4.0.0/mbo_utilities/arrays/demixing.py +337 -0
  44. pml_utilities-4.0.0/mbo_utilities/arrays/features/__init__.py +203 -0
  45. pml_utilities-4.0.0/mbo_utilities/arrays/features/_base.py +91 -0
  46. pml_utilities-4.0.0/mbo_utilities/arrays/features/_chunks.py +89 -0
  47. pml_utilities-4.0.0/mbo_utilities/arrays/features/_dim_labels.py +316 -0
  48. pml_utilities-4.0.0/mbo_utilities/arrays/features/_dim_spec.py +208 -0
  49. pml_utilities-4.0.0/mbo_utilities/arrays/features/_dim_tags.py +453 -0
  50. pml_utilities-4.0.0/mbo_utilities/arrays/features/_frame_average.py +196 -0
  51. pml_utilities-4.0.0/mbo_utilities/arrays/features/_motion.py +49 -0
  52. pml_utilities-4.0.0/mbo_utilities/arrays/features/_phase_correction.py +327 -0
  53. pml_utilities-4.0.0/mbo_utilities/arrays/features/_pyramid.py +315 -0
  54. pml_utilities-4.0.0/mbo_utilities/arrays/features/_roi.py +234 -0
  55. pml_utilities-4.0.0/mbo_utilities/arrays/features/_segmentation.py +121 -0
  56. pml_utilities-4.0.0/mbo_utilities/arrays/features/_selection.py +91 -0
  57. pml_utilities-4.0.0/mbo_utilities/arrays/features/_slicing.py +601 -0
  58. pml_utilities-4.0.0/mbo_utilities/arrays/features/_stats.py +24 -0
  59. pml_utilities-4.0.0/mbo_utilities/arrays/features/_summary_stats.py +396 -0
  60. pml_utilities-4.0.0/mbo_utilities/arrays/h5.py +391 -0
  61. pml_utilities-4.0.0/mbo_utilities/arrays/isoview/__init__.py +57 -0
  62. pml_utilities-4.0.0/mbo_utilities/arrays/isoview/array.py +2405 -0
  63. pml_utilities-4.0.0/mbo_utilities/arrays/isoview/consolidate.py +1822 -0
  64. pml_utilities-4.0.0/mbo_utilities/arrays/lab4.py +257 -0
  65. pml_utilities-4.0.0/mbo_utilities/arrays/masknmf_run.py +283 -0
  66. pml_utilities-4.0.0/mbo_utilities/arrays/mesc.py +1780 -0
  67. pml_utilities-4.0.0/mbo_utilities/arrays/mesc_geometry.py +375 -0
  68. pml_utilities-4.0.0/mbo_utilities/arrays/mp4.py +921 -0
  69. pml_utilities-4.0.0/mbo_utilities/arrays/numpy.py +434 -0
  70. pml_utilities-4.0.0/mbo_utilities/arrays/suite2p.py +995 -0
  71. pml_utilities-4.0.0/mbo_utilities/arrays/tiff.py +1569 -0
  72. pml_utilities-4.0.0/mbo_utilities/arrays/zarr.py +716 -0
  73. pml_utilities-4.0.0/mbo_utilities/assets/app_settings/icon.ico +0 -0
  74. pml_utilities-4.0.0/mbo_utilities/assets/app_settings/icon.png +0 -0
  75. pml_utilities-4.0.0/mbo_utilities/assets/docs/file_formats.md +39 -0
  76. pml_utilities-4.0.0/mbo_utilities/assets/docs/gui_quickstart.md +44 -0
  77. pml_utilities-4.0.0/mbo_utilities/assets/docs/mesc.md +84 -0
  78. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Akronim-Regular.ttf +0 -0
  79. pml_utilities-4.0.0/mbo_utilities/assets/fonts/DroidSans.ttf +0 -0
  80. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Font_Awesome_6_Free-Solid-900.otf +0 -0
  81. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Inconsolata-Medium.ttf +0 -0
  82. pml_utilities-4.0.0/mbo_utilities/assets/fonts/JetBrainsMono/JetBrainsMonoNerdFont-Bold.ttf +0 -0
  83. pml_utilities-4.0.0/mbo_utilities/assets/fonts/JetBrainsMono/OFL.txt +93 -0
  84. pml_utilities-4.0.0/mbo_utilities/assets/fonts/JetBrainsMono/README.md +48 -0
  85. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Roboto/LICENSE.txt +202 -0
  86. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Roboto/Roboto-Bold.ttf +0 -0
  87. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Roboto/Roboto-BoldItalic.ttf +0 -0
  88. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Roboto/Roboto-Regular.ttf +0 -0
  89. pml_utilities-4.0.0/mbo_utilities/assets/fonts/Roboto/Roboto-RegularItalic.ttf +0 -0
  90. pml_utilities-4.0.0/mbo_utilities/assets/fonts/SourceCodePro-Regular.ttf +0 -0
  91. pml_utilities-4.0.0/mbo_utilities/assets/fonts/fontawesome-webfont.ttf +0 -0
  92. pml_utilities-4.0.0/mbo_utilities/assets/static/canvas_client.js +167 -0
  93. pml_utilities-4.0.0/mbo_utilities/assets/static/icon_caiman_python.svg +1 -0
  94. pml_utilities-4.0.0/mbo_utilities/assets/static/icon_mbo_home.png +0 -0
  95. pml_utilities-4.0.0/mbo_utilities/assets/static/icon_mbo_home.svg +1 -0
  96. pml_utilities-4.0.0/mbo_utilities/assets/static/icon_suite2p.svg +1 -0
  97. pml_utilities-4.0.0/mbo_utilities/assets/static/lbm_mat_favicon.svg +1 -0
  98. pml_utilities-4.0.0/mbo_utilities/assets/static/logo_utilities.png +0 -0
  99. pml_utilities-4.0.0/mbo_utilities/assets/static/mbo.png +0 -0
  100. pml_utilities-4.0.0/mbo_utilities/assets/static/mbo_home_icon.png +0 -0
  101. pml_utilities-4.0.0/mbo_utilities/assets/static/mbo_hub_saph.svg +1 -0
  102. pml_utilities-4.0.0/mbo_utilities/assets/static/mbo_icon.ico +0 -0
  103. pml_utilities-4.0.0/mbo_utilities/assets/static/mbo_icon_dark.ico +0 -0
  104. pml_utilities-4.0.0/mbo_utilities/assets/static/utilities.png +0 -0
  105. pml_utilities-4.0.0/mbo_utilities/behavior/__init__.py +175 -0
  106. pml_utilities-4.0.0/mbo_utilities/behavior/tdml.py +139 -0
  107. pml_utilities-4.0.0/mbo_utilities/cli.py +2527 -0
  108. pml_utilities-4.0.0/mbo_utilities/dashboard.py +966 -0
  109. pml_utilities-4.0.0/mbo_utilities/env_cache.py +335 -0
  110. pml_utilities-4.0.0/mbo_utilities/file_io.py +315 -0
  111. pml_utilities-4.0.0/mbo_utilities/gpu.py +531 -0
  112. pml_utilities-4.0.0/mbo_utilities/gui/__init__.py +78 -0
  113. pml_utilities-4.0.0/mbo_utilities/gui/_availability.py +25 -0
  114. pml_utilities-4.0.0/mbo_utilities/gui/_colormaps.py +38 -0
  115. pml_utilities-4.0.0/mbo_utilities/gui/_dialogs.py +421 -0
  116. pml_utilities-4.0.0/mbo_utilities/gui/_edge_window.py +25 -0
  117. pml_utilities-4.0.0/mbo_utilities/gui/_files.py +144 -0
  118. pml_utilities-4.0.0/mbo_utilities/gui/_fpl_config.py +45 -0
  119. pml_utilities-4.0.0/mbo_utilities/gui/_gpu_cache.py +65 -0
  120. pml_utilities-4.0.0/mbo_utilities/gui/_gpu_status.py +140 -0
  121. pml_utilities-4.0.0/mbo_utilities/gui/_help_viewer.py +324 -0
  122. pml_utilities-4.0.0/mbo_utilities/gui/_imgui_helpers.py +797 -0
  123. pml_utilities-4.0.0/mbo_utilities/gui/_isoview_crop_state.py +286 -0
  124. pml_utilities-4.0.0/mbo_utilities/gui/_isoview_orient_state.py +60 -0
  125. pml_utilities-4.0.0/mbo_utilities/gui/_keyboard.py +307 -0
  126. pml_utilities-4.0.0/mbo_utilities/gui/_metadata.py +824 -0
  127. pml_utilities-4.0.0/mbo_utilities/gui/_metadata_editor.py +436 -0
  128. pml_utilities-4.0.0/mbo_utilities/gui/_ndviewer.py +1189 -0
  129. pml_utilities-4.0.0/mbo_utilities/gui/_notebook.py +47 -0
  130. pml_utilities-4.0.0/mbo_utilities/gui/_options_popup.py +486 -0
  131. pml_utilities-4.0.0/mbo_utilities/gui/_popups.py +641 -0
  132. pml_utilities-4.0.0/mbo_utilities/gui/_save_as.py +1131 -0
  133. pml_utilities-4.0.0/mbo_utilities/gui/_selection_ui.py +288 -0
  134. pml_utilities-4.0.0/mbo_utilities/gui/_setup.py +176 -0
  135. pml_utilities-4.0.0/mbo_utilities/gui/_stats.py +1266 -0
  136. pml_utilities-4.0.0/mbo_utilities/gui/_theme.py +179 -0
  137. pml_utilities-4.0.0/mbo_utilities/gui/_top_strip.py +377 -0
  138. pml_utilities-4.0.0/mbo_utilities/gui/_worker.py +512 -0
  139. pml_utilities-4.0.0/mbo_utilities/gui/canvas_server.py +456 -0
  140. pml_utilities-4.0.0/mbo_utilities/gui/curation_server.py +137 -0
  141. pml_utilities-4.0.0/mbo_utilities/gui/curation_viewer.py +483 -0
  142. pml_utilities-4.0.0/mbo_utilities/gui/dashboard_app.py +1373 -0
  143. pml_utilities-4.0.0/mbo_utilities/gui/dashboard_morphology.py +511 -0
  144. pml_utilities-4.0.0/mbo_utilities/gui/dashboard_readouts.py +263 -0
  145. pml_utilities-4.0.0/mbo_utilities/gui/data_vis.py +164 -0
  146. pml_utilities-4.0.0/mbo_utilities/gui/event_curation.py +1903 -0
  147. pml_utilities-4.0.0/mbo_utilities/gui/gateway.py +902 -0
  148. pml_utilities-4.0.0/mbo_utilities/gui/imgui/__init__.py +56 -0
  149. pml_utilities-4.0.0/mbo_utilities/gui/imgui/behavior.py +310 -0
  150. pml_utilities-4.0.0/mbo_utilities/gui/imgui/crop.py +32 -0
  151. pml_utilities-4.0.0/mbo_utilities/gui/imgui/labels.py +127 -0
  152. pml_utilities-4.0.0/mbo_utilities/gui/imgui/lines.py +311 -0
  153. pml_utilities-4.0.0/mbo_utilities/gui/imgui/motion.py +140 -0
  154. pml_utilities-4.0.0/mbo_utilities/gui/imgui/movie_player.py +109 -0
  155. pml_utilities-4.0.0/mbo_utilities/gui/imgui/panels.py +131 -0
  156. pml_utilities-4.0.0/mbo_utilities/gui/imgui/scatter.py +233 -0
  157. pml_utilities-4.0.0/mbo_utilities/gui/imgui/summary.py +518 -0
  158. pml_utilities-4.0.0/mbo_utilities/gui/imgui/table.py +310 -0
  159. pml_utilities-4.0.0/mbo_utilities/gui/imgui/vnoiser_help.py +1042 -0
  160. pml_utilities-4.0.0/mbo_utilities/gui/launch.py +78 -0
  161. pml_utilities-4.0.0/mbo_utilities/gui/linescan_viewer.py +325 -0
  162. pml_utilities-4.0.0/mbo_utilities/gui/manual_roi.py +1472 -0
  163. pml_utilities-4.0.0/mbo_utilities/gui/masknmf_vis.py +190 -0
  164. pml_utilities-4.0.0/mbo_utilities/gui/mesc_reference.py +565 -0
  165. pml_utilities-4.0.0/mbo_utilities/gui/panels/__init__.py +7 -0
  166. pml_utilities-4.0.0/mbo_utilities/gui/panels/debug_log.py +35 -0
  167. pml_utilities-4.0.0/mbo_utilities/gui/playhead.py +75 -0
  168. pml_utilities-4.0.0/mbo_utilities/gui/reg_denoise_viewer.py +178 -0
  169. pml_utilities-4.0.0/mbo_utilities/gui/roi/__init__.py +3 -0
  170. pml_utilities-4.0.0/mbo_utilities/gui/roi/_shared.py +414 -0
  171. pml_utilities-4.0.0/mbo_utilities/gui/roi/curation.py +821 -0
  172. pml_utilities-4.0.0/mbo_utilities/gui/roi/jobs.py +720 -0
  173. pml_utilities-4.0.0/mbo_utilities/gui/roi/keys.py +117 -0
  174. pml_utilities-4.0.0/mbo_utilities/gui/roi/overlay.py +363 -0
  175. pml_utilities-4.0.0/mbo_utilities/gui/roi/selection.py +604 -0
  176. pml_utilities-4.0.0/mbo_utilities/gui/roi/trace_table.py +330 -0
  177. pml_utilities-4.0.0/mbo_utilities/gui/roi/traces_panel.py +907 -0
  178. pml_utilities-4.0.0/mbo_utilities/gui/roi_runs.py +756 -0
  179. pml_utilities-4.0.0/mbo_utilities/gui/run_gui.py +1390 -0
  180. pml_utilities-4.0.0/mbo_utilities/gui/slice.py +99 -0
  181. pml_utilities-4.0.0/mbo_utilities/gui/slow_fast_panels.py +284 -0
  182. pml_utilities-4.0.0/mbo_utilities/gui/spike_average_viewer.py +407 -0
  183. pml_utilities-4.0.0/mbo_utilities/gui/studio_server.py +173 -0
  184. pml_utilities-4.0.0/mbo_utilities/gui/tasks.py +1152 -0
  185. pml_utilities-4.0.0/mbo_utilities/gui/viewers/__init__.py +84 -0
  186. pml_utilities-4.0.0/mbo_utilities/gui/viewers/pollen_calibration.py +1274 -0
  187. pml_utilities-4.0.0/mbo_utilities/gui/viewers/time_series.py +97 -0
  188. pml_utilities-4.0.0/mbo_utilities/gui/widgets/__init__.py +145 -0
  189. pml_utilities-4.0.0/mbo_utilities/gui/widgets/_base.py +74 -0
  190. pml_utilities-4.0.0/mbo_utilities/gui/widgets/_orient.py +16 -0
  191. pml_utilities-4.0.0/mbo_utilities/gui/widgets/diagnostics.py +1062 -0
  192. pml_utilities-4.0.0/mbo_utilities/gui/widgets/file_dialog.py +790 -0
  193. pml_utilities-4.0.0/mbo_utilities/gui/widgets/grid_search.py +460 -0
  194. pml_utilities-4.0.0/mbo_utilities/gui/widgets/gui_logger.py +277 -0
  195. pml_utilities-4.0.0/mbo_utilities/gui/widgets/imgui_debug.py +105 -0
  196. pml_utilities-4.0.0/mbo_utilities/gui/widgets/isoview_crop.py +759 -0
  197. pml_utilities-4.0.0/mbo_utilities/gui/widgets/isoview_deadpixel.py +805 -0
  198. pml_utilities-4.0.0/mbo_utilities/gui/widgets/isoview_segment.py +860 -0
  199. pml_utilities-4.0.0/mbo_utilities/gui/widgets/menu_bar.py +333 -0
  200. pml_utilities-4.0.0/mbo_utilities/gui/widgets/mesc_units.py +764 -0
  201. pml_utilities-4.0.0/mbo_utilities/gui/widgets/page_axis.py +97 -0
  202. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/__init__.py +324 -0
  203. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/_base.py +77 -0
  204. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/_s2p_schema.py +696 -0
  205. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/isoview.py +3078 -0
  206. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/masknmf.py +1013 -0
  207. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/settings.py +3779 -0
  208. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/suite2p.py +522 -0
  209. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/vnoiser.py +2488 -0
  210. pml_utilities-4.0.0/mbo_utilities/gui/widgets/pipelines/vnoiser_hints.py +423 -0
  211. pml_utilities-4.0.0/mbo_utilities/gui/widgets/preview_data.py +1213 -0
  212. pml_utilities-4.0.0/mbo_utilities/gui/widgets/process_manager.py +599 -0
  213. pml_utilities-4.0.0/mbo_utilities/gui/widgets/progress_bar.py +236 -0
  214. pml_utilities-4.0.0/mbo_utilities/gui/widgets/projections.py +699 -0
  215. pml_utilities-4.0.0/mbo_utilities/gui/widgets/simple_selector.py +120 -0
  216. pml_utilities-4.0.0/mbo_utilities/gui/widgets/summary_image.py +885 -0
  217. pml_utilities-4.0.0/mbo_utilities/gui/widgets/tabs.py +213 -0
  218. pml_utilities-4.0.0/mbo_utilities/gui/widgets/tile_grid.py +1256 -0
  219. pml_utilities-4.0.0/mbo_utilities/gui/widgets/widget_toggles.py +213 -0
  220. pml_utilities-4.0.0/mbo_utilities/gui/widgets/window_functions.py +214 -0
  221. pml_utilities-4.0.0/mbo_utilities/hpc/__init__.py +52 -0
  222. pml_utilities-4.0.0/mbo_utilities/hpc/check.py +201 -0
  223. pml_utilities-4.0.0/mbo_utilities/hpc/cli.py +427 -0
  224. pml_utilities-4.0.0/mbo_utilities/hpc/cluster.py +145 -0
  225. pml_utilities-4.0.0/mbo_utilities/hpc/config.py +387 -0
  226. pml_utilities-4.0.0/mbo_utilities/hpc/history.py +131 -0
  227. pml_utilities-4.0.0/mbo_utilities/hpc/logs.py +328 -0
  228. pml_utilities-4.0.0/mbo_utilities/hpc/pipeline.py +654 -0
  229. pml_utilities-4.0.0/mbo_utilities/hpc/slurm.py +150 -0
  230. pml_utilities-4.0.0/mbo_utilities/hpc/submit.py +206 -0
  231. pml_utilities-4.0.0/mbo_utilities/install.py +540 -0
  232. pml_utilities-4.0.0/mbo_utilities/lazy_array.py +441 -0
  233. pml_utilities-4.0.0/mbo_utilities/log.py +76 -0
  234. pml_utilities-4.0.0/mbo_utilities/masknmf/__init__.py +42 -0
  235. pml_utilities-4.0.0/mbo_utilities/masknmf/asap7.py +254 -0
  236. pml_utilities-4.0.0/mbo_utilities/masknmf/outputs.py +234 -0
  237. pml_utilities-4.0.0/mbo_utilities/masknmf/params.py +371 -0
  238. pml_utilities-4.0.0/mbo_utilities/masknmf/qc.py +840 -0
  239. pml_utilities-4.0.0/mbo_utilities/masknmf/reg_denoise.py +383 -0
  240. pml_utilities-4.0.0/mbo_utilities/masknmf/runner.py +788 -0
  241. pml_utilities-4.0.0/mbo_utilities/metadata/__init__.py +132 -0
  242. pml_utilities-4.0.0/mbo_utilities/metadata/_filename_parser.py +245 -0
  243. pml_utilities-4.0.0/mbo_utilities/metadata/base.py +769 -0
  244. pml_utilities-4.0.0/mbo_utilities/metadata/io.py +1200 -0
  245. pml_utilities-4.0.0/mbo_utilities/metadata/output.py +602 -0
  246. pml_utilities-4.0.0/mbo_utilities/metadata/params.py +425 -0
  247. pml_utilities-4.0.0/mbo_utilities/metadata/scanimage.py +547 -0
  248. pml_utilities-4.0.0/mbo_utilities/notebook_templates.py +95 -0
  249. pml_utilities-4.0.0/mbo_utilities/pipeline_registry.py +169 -0
  250. pml_utilities-4.0.0/mbo_utilities/preferences.py +568 -0
  251. pml_utilities-4.0.0/mbo_utilities/reader.py +519 -0
  252. pml_utilities-4.0.0/mbo_utilities/results.py +1368 -0
  253. pml_utilities-4.0.0/mbo_utilities/roi_workflow.py +1381 -0
  254. pml_utilities-4.0.0/mbo_utilities/squeeze.py +99 -0
  255. pml_utilities-4.0.0/mbo_utilities/vnoiser/__init__.py +34 -0
  256. pml_utilities-4.0.0/mbo_utilities/vnoiser/params.py +344 -0
  257. pml_utilities-4.0.0/mbo_utilities/vnoiser/pipeline.py +1189 -0
  258. pml_utilities-4.0.0/mbo_utilities/vnoiser/session.py +629 -0
  259. pml_utilities-4.0.0/mbo_utilities/writer.py +526 -0
  260. pml_utilities-4.0.0/pml_utilities.egg-info/PKG-INFO +164 -0
  261. pml_utilities-4.0.0/pml_utilities.egg-info/SOURCES.txt +600 -0
  262. pml_utilities-4.0.0/pml_utilities.egg-info/dependency_links.txt +1 -0
  263. pml_utilities-4.0.0/pml_utilities.egg-info/entry_points.txt +23 -0
  264. pml_utilities-4.0.0/pml_utilities.egg-info/requires.txt +69 -0
  265. pml_utilities-4.0.0/pml_utilities.egg-info/top_level.txt +2 -0
  266. pml_utilities-4.0.0/pollen/__init__.py +0 -0
  267. pml_utilities-4.0.0/pollen/_pollen_analysis.py +1032 -0
  268. pml_utilities-4.0.0/pollen/pollen_calibration_mbo.py +1293 -0
  269. pml_utilities-4.0.0/pyproject.toml +215 -0
  270. pml_utilities-4.0.0/setup.cfg +4 -0
  271. pml_utilities-4.0.0/setup.py +32 -0
  272. pml_utilities-4.0.0/tests/test_annotation.py +425 -0
  273. pml_utilities-4.0.0/tests/test_arrays.py +1132 -0
  274. pml_utilities-4.0.0/tests/test_asap7.py +121 -0
  275. pml_utilities-4.0.0/tests/test_behavior.py +242 -0
  276. pml_utilities-4.0.0/tests/test_bruker.py +169 -0
  277. pml_utilities-4.0.0/tests/test_colormaps.py +17 -0
  278. pml_utilities-4.0.0/tests/test_compression_array.py +92 -0
  279. pml_utilities-4.0.0/tests/test_contrast_reset.py +251 -0
  280. pml_utilities-4.0.0/tests/test_convert_vnoiser_results.py +57 -0
  281. pml_utilities-4.0.0/tests/test_curation_server.py +151 -0
  282. pml_utilities-4.0.0/tests/test_dashboard.py +708 -0
  283. pml_utilities-4.0.0/tests/test_data_vis.py +472 -0
  284. pml_utilities-4.0.0/tests/test_demixing.py +253 -0
  285. pml_utilities-4.0.0/tests/test_domain_file.py +181 -0
  286. pml_utilities-4.0.0/tests/test_effective_rate.py +221 -0
  287. pml_utilities-4.0.0/tests/test_event_curation.py +1803 -0
  288. pml_utilities-4.0.0/tests/test_fpl_config.py +215 -0
  289. pml_utilities-4.0.0/tests/test_frame_average.py +530 -0
  290. pml_utilities-4.0.0/tests/test_help_viewer.py +127 -0
  291. pml_utilities-4.0.0/tests/test_imagej_stack.py +149 -0
  292. pml_utilities-4.0.0/tests/test_imgui_debug.py +72 -0
  293. pml_utilities-4.0.0/tests/test_imgui_helpers.py +109 -0
  294. pml_utilities-4.0.0/tests/test_install.py +403 -0
  295. pml_utilities-4.0.0/tests/test_inverted_view.py +97 -0
  296. pml_utilities-4.0.0/tests/test_lab4.py +295 -0
  297. pml_utilities-4.0.0/tests/test_lazyarray_contract.py +108 -0
  298. pml_utilities-4.0.0/tests/test_linescan_extract.py +326 -0
  299. pml_utilities-4.0.0/tests/test_linescan_traces.py +590 -0
  300. pml_utilities-4.0.0/tests/test_manual_roi.py +3898 -0
  301. pml_utilities-4.0.0/tests/test_masknmf_pipeline.py +612 -0
  302. pml_utilities-4.0.0/tests/test_masknmf_preprocessing.py +245 -0
  303. pml_utilities-4.0.0/tests/test_masknmf_run.py +129 -0
  304. pml_utilities-4.0.0/tests/test_mesc.py +1353 -0
  305. pml_utilities-4.0.0/tests/test_mesc_geometry.py +489 -0
  306. pml_utilities-4.0.0/tests/test_mesc_placement.py +434 -0
  307. pml_utilities-4.0.0/tests/test_mesc_reference.py +525 -0
  308. pml_utilities-4.0.0/tests/test_mesc_tab.py +613 -0
  309. pml_utilities-4.0.0/tests/test_metadata.py +179 -0
  310. pml_utilities-4.0.0/tests/test_metadata_module.py +1060 -0
  311. pml_utilities-4.0.0/tests/test_motion_plot.py +148 -0
  312. pml_utilities-4.0.0/tests/test_natural_rank.py +276 -0
  313. pml_utilities-4.0.0/tests/test_ndviewer.py +1134 -0
  314. pml_utilities-4.0.0/tests/test_notebook_templates.py +72 -0
  315. pml_utilities-4.0.0/tests/test_numpy_dims.py +209 -0
  316. pml_utilities-4.0.0/tests/test_page_axis.py +55 -0
  317. pml_utilities-4.0.0/tests/test_phasecorr_view.py +98 -0
  318. pml_utilities-4.0.0/tests/test_pipeline_window.py +393 -0
  319. pml_utilities-4.0.0/tests/test_playhead.py +55 -0
  320. pml_utilities-4.0.0/tests/test_provenance_rebase.py +97 -0
  321. pml_utilities-4.0.0/tests/test_reg_denoise.py +71 -0
  322. pml_utilities-4.0.0/tests/test_results.py +536 -0
  323. pml_utilities-4.0.0/tests/test_results_array.py +296 -0
  324. pml_utilities-4.0.0/tests/test_roi_model.py +424 -0
  325. pml_utilities-4.0.0/tests/test_roi_runs.py +596 -0
  326. pml_utilities-4.0.0/tests/test_roi_workflow.py +593 -0
  327. pml_utilities-4.0.0/tests/test_roundtrip.py +192 -0
  328. pml_utilities-4.0.0/tests/test_selection_indices.py +55 -0
  329. pml_utilities-4.0.0/tests/test_serve.py +293 -0
  330. pml_utilities-4.0.0/tests/test_shape5d.py +186 -0
  331. pml_utilities-4.0.0/tests/test_slice.py +73 -0
  332. pml_utilities-4.0.0/tests/test_slow_fast.py +451 -0
  333. pml_utilities-4.0.0/tests/test_spike_average.py +295 -0
  334. pml_utilities-4.0.0/tests/test_squeeze.py +79 -0
  335. pml_utilities-4.0.0/tests/test_suite2p_formats.py +133 -0
  336. pml_utilities-4.0.0/tests/test_suite2p_results.py +139 -0
  337. pml_utilities-4.0.0/tests/test_summary_stats.py +166 -0
  338. pml_utilities-4.0.0/tests/test_to_video.py +288 -0
  339. pml_utilities-4.0.0/tests/test_top_strip.py +473 -0
  340. pml_utilities-4.0.0/tests/test_trace_display.py +387 -0
  341. pml_utilities-4.0.0/tests/test_trace_readouts.py +137 -0
  342. pml_utilities-4.0.0/tests/test_viewer_io.py +196 -0
  343. pml_utilities-4.0.0/tests/test_viewer_pipeline.py +737 -0
  344. pml_utilities-4.0.0/tests/test_vnoiser_help.py +155 -0
  345. pml_utilities-4.0.0/tests/test_vnoiser_pipeline.py +1482 -0
  346. pml_utilities-4.0.0/tests/test_voltage_traces.py +633 -0
  347. pml_utilities-4.0.0/tests/test_zarr_chunking.py +441 -0
@@ -0,0 +1,17 @@
1
+ This software license is the 3-clause BSD license plus a fourth clause that prohibits redistribution for commercial purposes without further permission.
2
+
3
+ BSD 3-Clause License
4
+
5
+ Copyright (c) 2024, Miller Brain Observatory.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8
+
9
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10
+
11
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12
+
13
+ Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
14
+
15
+ Redistributions for commercial purposes are not permitted without the written permission of all code authors. For purposes of this license, commercial purposes is the incorporation of mbo_utilities into anything for which you will charge fees or other compensation. Contact mbo@rockefeller.edu for more information.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,3 @@
1
+ include demos/mbo_user_guide.ipynb
2
+ include demos/lsp_user_guide.ipynb
3
+ include demos/asap7_spine_pipeline.ipynb
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: pml_utilities
3
+ Version: 4.0.0
4
+ Summary: Readers, pipelines and viewers for imaging data; the beta channel of mbo_utilities
5
+ License-Expression: BSD-3-Clause
6
+ Project-URL: Homepage, https://github.com/FlynnOConnell/pml_utilities
7
+ Project-URL: Documentation, https://millerbrainobservatory.github.io/mbo_utilities/
8
+ Project-URL: Repository, https://github.com/FlynnOConnell/pml_utilities
9
+ Project-URL: Upstream, https://github.com/MillerBrainObservatory/mbo_utilities
10
+ Keywords: Microscopy,ScanImage,multiROI,Tiff
11
+ Requires-Python: <3.14,>=3.12.7
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE.md
14
+ Requires-Dist: click
15
+ Requires-Dist: numpy>=2.2.5
16
+ Requires-Dist: scipy
17
+ Requires-Dist: h5py
18
+ Requires-Dist: tifffile>=2025.3.30
19
+ Requires-Dist: zarr>=3.1.3
20
+ Requires-Dist: numcodecs>=0.16
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: packaging
23
+ Provides-Extra: gui
24
+ Requires-Dist: fastplotlib[imgui]<0.8,>=0.7.0; extra == "gui"
25
+ Requires-Dist: imgui-bundle<1.92.900,>=1.92.801; extra == "gui"
26
+ Requires-Dist: rendercanvas>=2.7.2; extra == "gui"
27
+ Requires-Dist: wgpu>=0.30.1; extra == "gui"
28
+ Requires-Dist: glfw; extra == "gui"
29
+ Requires-Dist: cmap>=0.7.2; extra == "gui"
30
+ Requires-Dist: matplotlib>=3.10.1; extra == "gui"
31
+ Requires-Dist: opencv-contrib-python-headless; extra == "gui"
32
+ Requires-Dist: scikit-image; extra == "gui"
33
+ Requires-Dist: imageio; extra == "gui"
34
+ Requires-Dist: psutil>=7.0; extra == "gui"
35
+ Provides-Extra: qt
36
+ Requires-Dist: pyqt6>=6.7; extra == "qt"
37
+ Provides-Extra: video
38
+ Requires-Dist: imageio[ffmpeg]; extra == "video"
39
+ Provides-Extra: codecs
40
+ Requires-Dist: imagecodecs>=2026.6.6; extra == "codecs"
41
+ Provides-Extra: pyramid
42
+ Requires-Dist: numba>=0.60.0; extra == "pyramid"
43
+ Provides-Extra: dask
44
+ Requires-Dist: dask>=2025.3.0; extra == "dask"
45
+ Provides-Extra: hpc
46
+ Requires-Dist: submitit>=1.5.0; extra == "hpc"
47
+ Provides-Extra: server
48
+ Requires-Dist: pml_utilities[gui]; extra == "server"
49
+ Requires-Dist: uvicorn>=0.30; extra == "server"
50
+ Requires-Dist: websockets>=13; extra == "server"
51
+ Requires-Dist: simplejpeg>=1.8; extra == "server"
52
+ Requires-Dist: av>=14; extra == "server"
53
+ Provides-Extra: suite2p
54
+ Requires-Dist: pml_utilities[gui]; extra == "suite2p"
55
+ Requires-Dist: suite2p>=1.1.0; extra == "suite2p"
56
+ Requires-Dist: rastermap>=0.9; extra == "suite2p"
57
+ Provides-Extra: napari
58
+ Requires-Dist: napari; extra == "napari"
59
+ Requires-Dist: napari-ome-zarr; extra == "napari"
60
+ Requires-Dist: napari-animation; extra == "napari"
61
+ Requires-Dist: pyqt6>=6.7; extra == "napari"
62
+ Requires-Dist: qtpy; extra == "napari"
63
+ Provides-Extra: notebooks
64
+ Requires-Dist: jupyterlab>=4.2.6; extra == "notebooks"
65
+ Requires-Dist: ipykernel; extra == "notebooks"
66
+ Requires-Dist: ipywidgets<9,>=8.0.0; extra == "notebooks"
67
+ Requires-Dist: jupyter_rfb>=0.5.1; extra == "notebooks"
68
+ Requires-Dist: seaborn>=0.13.2; extra == "notebooks"
69
+ Provides-Extra: all
70
+ Requires-Dist: pml_utilities[codecs,dask,gui,hpc,napari,notebooks,pyramid,qt,server,suite2p,video]; extra == "all"
71
+ Dynamic: license-file
72
+
73
+ > [!NOTE]
74
+ > Install `pml_utilities` in a virtual environment with [uv](https://docs.astral.sh/uv/):
75
+ >
76
+ > ```bash
77
+ > uv venv --python 3.12.9
78
+ > .venv\Scripts\activate.ps1 # Windows PowerShell
79
+ > source .venv/bin/activate # Linux, macOS
80
+ > uv pip install "pml_utilities[gui]"
81
+ > ```
82
+
83
+ <p align="center">
84
+ <img src="https://raw.githubusercontent.com/FlynnOConnell/pml_utilities/main/mbo_utilities/assets/static/logo_utilities.png" height="110" alt="MBO Utilities logo">
85
+ </p>
86
+
87
+ # pml_utilities
88
+
89
+ Readers, pipelines and viewers for imaging data, for the Program in Memory Longevity
90
+ (PML). It installs the `mbo_utilities` Python package and the `mbo` command.
91
+
92
+ > **Beta channel.** `pml_utilities` is
93
+ > [mbo_utilities](https://github.com/MillerBrainObservatory/mbo_utilities) plus
94
+ > features that are still in beta. A feature lands here first and moves into the core
95
+ > `mbo_utilities` once it settles, so expect changes between releases. The
96
+ > documentation is [mbo_utilities'](https://millerbrainobservatory.github.io/mbo_utilities/).
97
+
98
+ - **Lazy reading and writing** of ScanImage and other TIFFs, Femtonics MESc, Bruker
99
+ and lab4 HDF5, Zarr, suite2p folders, NumPy and IsoView trees, each as one
100
+ `(T, C, Z, Y, X)` array
101
+ - **The Studio**, a GPU viewer built on [fastplotlib](https://fastplotlib.org):
102
+ hand-drawn ROIs, traces, motion correction and behavior on one time axis
103
+ - **Pipelines** from the Studio or the command line: suite2p and, installed
104
+ separately, MaskNMF and the voltage imaging pipelines, each writing one results zarr
105
+ - **MESc line-scan tools**: named ROIs, trace figures (`mbo dashboard`) and event
106
+ curation (`mbo curate`)
107
+
108
+ ## Extras
109
+
110
+ Python 3.12.7 to 3.13. The base install reads and writes every format and has no
111
+ window. `pml_utilities` and the PyPI `mbo_utilities` install the same package, so they
112
+ cannot share an environment.
113
+
114
+ ```bash
115
+ uv pip install "pml_utilities[gui]" # The Studio
116
+ uv pip install "pml_utilities[all]" # every extra
117
+ ```
118
+
119
+ | Extra | Adds |
120
+ |-------|------|
121
+ | `gui` | The Studio and the ROI, trace and curation tools; the ROI tool also needs masknmf, installed separately |
122
+ | `suite2p` | suite2p and rastermap; then `uv pip install --no-deps lbm-suite2p-python` |
123
+ | `server` | `mbo serve`, The Studio in a browser |
124
+ | `hpc` | submitit, to run suite2p on SLURM |
125
+ | `napari` | the napari viewer mode |
126
+ | `notebooks` | JupyterLab, for the notebooks `mbo init` writes |
127
+ | `video` | ffmpeg, for mp4 export |
128
+ | `codecs` | imagecodecs, for compressed TIFFs |
129
+ | `pyramid` | numba, for mode-downsampled zarr pyramids |
130
+ | `dask` | `files_to_dask` |
131
+ | `qt` | PyQt6 window backend; glfw is the default |
132
+
133
+ `mbo --check-install` lists every package, the GPU, and the install command for
134
+ anything missing, including Qt's system libraries on a minimal Linux install.
135
+
136
+ ## Use
137
+
138
+ ```bash
139
+ mbo # open The Studio
140
+ mbo /path/to/data # open a file or folder
141
+ mbo info /path/to/data # shape and metadata
142
+ mbo convert IN OUT # convert between formats
143
+ mbo dashboard scan.mesc # trace figures of a .mesc unit's ROIs
144
+ mbo curate scan.mesc # event curation of a line scan
145
+ mbo --help # every command
146
+ ```
147
+
148
+ ```python
149
+ import mbo_utilities as mbo
150
+
151
+ arr = mbo.imread("scan.mesc", unit="MUnit_3") # lazy, (T, C, Z, Y, X)
152
+ mbo.imwrite(arr, "out", ext=".zarr")
153
+ ```
154
+
155
+ ## Uninstall
156
+
157
+ ```bash
158
+ uv pip uninstall pml_utilities
159
+ rm -rf ~/.mbo # settings, logs and caches
160
+ ```
161
+
162
+ ## Issues
163
+
164
+ Report problems on [GitLab](https://gitlab.com/losonczylab/pml_utilities/-/issues).
@@ -0,0 +1,92 @@
1
+ > [!NOTE]
2
+ > Install `pml_utilities` in a virtual environment with [uv](https://docs.astral.sh/uv/):
3
+ >
4
+ > ```bash
5
+ > uv venv --python 3.12.9
6
+ > .venv\Scripts\activate.ps1 # Windows PowerShell
7
+ > source .venv/bin/activate # Linux, macOS
8
+ > uv pip install "pml_utilities[gui]"
9
+ > ```
10
+
11
+ <p align="center">
12
+ <img src="https://raw.githubusercontent.com/FlynnOConnell/pml_utilities/main/mbo_utilities/assets/static/logo_utilities.png" height="110" alt="MBO Utilities logo">
13
+ </p>
14
+
15
+ # pml_utilities
16
+
17
+ Readers, pipelines and viewers for imaging data, for the Program in Memory Longevity
18
+ (PML). It installs the `mbo_utilities` Python package and the `mbo` command.
19
+
20
+ > **Beta channel.** `pml_utilities` is
21
+ > [mbo_utilities](https://github.com/MillerBrainObservatory/mbo_utilities) plus
22
+ > features that are still in beta. A feature lands here first and moves into the core
23
+ > `mbo_utilities` once it settles, so expect changes between releases. The
24
+ > documentation is [mbo_utilities'](https://millerbrainobservatory.github.io/mbo_utilities/).
25
+
26
+ - **Lazy reading and writing** of ScanImage and other TIFFs, Femtonics MESc, Bruker
27
+ and lab4 HDF5, Zarr, suite2p folders, NumPy and IsoView trees, each as one
28
+ `(T, C, Z, Y, X)` array
29
+ - **The Studio**, a GPU viewer built on [fastplotlib](https://fastplotlib.org):
30
+ hand-drawn ROIs, traces, motion correction and behavior on one time axis
31
+ - **Pipelines** from the Studio or the command line: suite2p and, installed
32
+ separately, MaskNMF and the voltage imaging pipelines, each writing one results zarr
33
+ - **MESc line-scan tools**: named ROIs, trace figures (`mbo dashboard`) and event
34
+ curation (`mbo curate`)
35
+
36
+ ## Extras
37
+
38
+ Python 3.12.7 to 3.13. The base install reads and writes every format and has no
39
+ window. `pml_utilities` and the PyPI `mbo_utilities` install the same package, so they
40
+ cannot share an environment.
41
+
42
+ ```bash
43
+ uv pip install "pml_utilities[gui]" # The Studio
44
+ uv pip install "pml_utilities[all]" # every extra
45
+ ```
46
+
47
+ | Extra | Adds |
48
+ |-------|------|
49
+ | `gui` | The Studio and the ROI, trace and curation tools; the ROI tool also needs masknmf, installed separately |
50
+ | `suite2p` | suite2p and rastermap; then `uv pip install --no-deps lbm-suite2p-python` |
51
+ | `server` | `mbo serve`, The Studio in a browser |
52
+ | `hpc` | submitit, to run suite2p on SLURM |
53
+ | `napari` | the napari viewer mode |
54
+ | `notebooks` | JupyterLab, for the notebooks `mbo init` writes |
55
+ | `video` | ffmpeg, for mp4 export |
56
+ | `codecs` | imagecodecs, for compressed TIFFs |
57
+ | `pyramid` | numba, for mode-downsampled zarr pyramids |
58
+ | `dask` | `files_to_dask` |
59
+ | `qt` | PyQt6 window backend; glfw is the default |
60
+
61
+ `mbo --check-install` lists every package, the GPU, and the install command for
62
+ anything missing, including Qt's system libraries on a minimal Linux install.
63
+
64
+ ## Use
65
+
66
+ ```bash
67
+ mbo # open The Studio
68
+ mbo /path/to/data # open a file or folder
69
+ mbo info /path/to/data # shape and metadata
70
+ mbo convert IN OUT # convert between formats
71
+ mbo dashboard scan.mesc # trace figures of a .mesc unit's ROIs
72
+ mbo curate scan.mesc # event curation of a line scan
73
+ mbo --help # every command
74
+ ```
75
+
76
+ ```python
77
+ import mbo_utilities as mbo
78
+
79
+ arr = mbo.imread("scan.mesc", unit="MUnit_3") # lazy, (T, C, Z, Y, X)
80
+ mbo.imwrite(arr, "out", ext=".zarr")
81
+ ```
82
+
83
+ ## Uninstall
84
+
85
+ ```bash
86
+ uv pip uninstall pml_utilities
87
+ rm -rf ~/.mbo # settings, logs and caches
88
+ ```
89
+
90
+ ## Issues
91
+
92
+ Report problems on [GitLab](https://gitlab.com/losonczylab/pml_utilities/-/issues).
@@ -0,0 +1,345 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Masknmf: ASAP7 voltage indicator, single channel"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "metadata": {},
13
+ "source": [
14
+ "from pathlib import Path\n",
15
+ "\n",
16
+ "import fastplotlib as fpl\n",
17
+ "import matplotlib.pyplot as plt\n",
18
+ "import numpy as np\n",
19
+ "\n",
20
+ "import mbo_utilities as mbo\n",
21
+ "import masknmf"
22
+ ],
23
+ "execution_count": null,
24
+ "outputs": []
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "metadata": {},
29
+ "source": [
30
+ "MESC_PATH = Path(\"D:/demo/scan.mesc\").expanduser()\n",
31
+ "UNIT = \"MSession_0/MUnit_0\"\n",
32
+ "CHANNEL = 0\n",
33
+ "EXCLUDE_INITIAL_FRAMES = 200\n",
34
+ "OUTPUT_FOLDER = MESC_PATH.parent / \"masknmf_asap7\" / UNIT.replace(\"/\", \"_\")\n",
35
+ "DEVICE = \"cuda\""
36
+ ],
37
+ "execution_count": null,
38
+ "outputs": []
39
+ },
40
+ {
41
+ "cell_type": "code",
42
+ "metadata": {},
43
+ "source": [
44
+ "MESC_PATH.is_file()"
45
+ ],
46
+ "execution_count": null,
47
+ "outputs": []
48
+ },
49
+ {
50
+ "cell_type": "markdown",
51
+ "metadata": {},
52
+ "source": [
53
+ "## Load and invert indicator"
54
+ ]
55
+ },
56
+ {
57
+ "cell_type": "code",
58
+ "metadata": {},
59
+ "source": [
60
+ "arr = mbo.imread(MESC_PATH, unit=UNIT)\n",
61
+ "fs = arr.fs\n",
62
+ "\n",
63
+ "raw = np.asarray(arr[EXCLUDE_INITIAL_FRAMES:, CHANNEL, 0], dtype=np.float32)\n",
64
+ "movie = masknmf.OphysArray(raw, negative_indicator=True, include_mean=True) #, device=\"cpu\") # [:].numpy()\n",
65
+ "movie.shape"
66
+ ],
67
+ "execution_count": null,
68
+ "outputs": []
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "metadata": {},
73
+ "source": [
74
+ "panels = {\"raw\": raw, \"inverted\": movie}\n",
75
+ "ndw = fpl.NDWidget(names=list(panels), shape=(1, 2), size=(1200, 400))\n",
76
+ "for name, data in panels.items():\n",
77
+ " image = ndw[name].add_nd_image(data, [\"time\", \"m\", \"n\"], [\"m\", \"n\"], spatial_func=None, name=name)\n",
78
+ " image.graphic.cmap = \"gray\"\n",
79
+ "ndw.show()"
80
+ ],
81
+ "execution_count": null,
82
+ "outputs": []
83
+ },
84
+ {
85
+ "cell_type": "markdown",
86
+ "metadata": {},
87
+ "source": [
88
+ "## Denoise before registration\n",
89
+ "\n",
90
+ "tiny movie, tiny block size. The raw movie is compressed as recorded, not inverted: the inverted movie (`2 * mean - x`) appears to move the other way, so shifts estimated on it come out flipped."
91
+ ]
92
+ },
93
+ {
94
+ "cell_type": "code",
95
+ "metadata": {},
96
+ "source": [
97
+ "block_sizes = [4, 4]\n",
98
+ "moco_strategy = masknmf.CompressStrategy(block_sizes=block_sizes,\n",
99
+ " max_components=20,\n",
100
+ " max_consecutive_failures=1,\n",
101
+ " temporal_avg_factor=2,\n",
102
+ " spatial_avg_factor=4,\n",
103
+ " frame_batch_size=300)\n",
104
+ "pmd_moco = moco_strategy.compress(raw)\n",
105
+ "pmd_moco.to(DEVICE)"
106
+ ],
107
+ "execution_count": null,
108
+ "outputs": []
109
+ },
110
+ {
111
+ "cell_type": "markdown",
112
+ "metadata": {},
113
+ "source": [
114
+ "## Register\n",
115
+ "\n",
116
+ "Shifts are estimated on the denoised raw movie and applied to the inverted movie the pipeline uses."
117
+ ]
118
+ },
119
+ {
120
+ "cell_type": "code",
121
+ "metadata": {},
122
+ "source": [
123
+ "corrector = masknmf.RigidMotionCorrector(max_shifts=[40, 40])\n",
124
+ "corrector.compute_template(pmd_moco)\n",
125
+ "moco_array = corrector.motion_correct(reference_movie=pmd_moco, target_movie=movie)\n",
126
+ "\n",
127
+ "registered = moco_array[:].cpu().numpy()\n",
128
+ "pmd_registered = corrector.motion_correct(reference_movie=pmd_moco)[:].cpu().numpy()\n",
129
+ "shifts = moco_array.shifts.cpu().numpy()"
130
+ ],
131
+ "execution_count": null,
132
+ "outputs": []
133
+ },
134
+ {
135
+ "cell_type": "markdown",
136
+ "metadata": {},
137
+ "source": [
138
+ "## Save the registered ribbon\n",
139
+ "\n",
140
+ "Both channels, not inverted, moved by the shifts estimated on the denoised raw ASAP7 movie: one ImageJ TIFF (T, C, Z, Y, X) and the shifts in px. Its first frame is frame `EXCLUDE_INITIAL_FRAMES` of the recording."
141
+ ]
142
+ },
143
+ {
144
+ "cell_type": "code",
145
+ "metadata": {},
146
+ "source": [
147
+ "REGISTERED_FOLDER = OUTPUT_FOLDER / \"registered\"\n",
148
+ "REGISTERED_FOLDER.mkdir(parents=True, exist_ok=True)\n",
149
+ "channels = [\n",
150
+ " corrector.motion_correct(\n",
151
+ " reference_movie=pmd_moco,\n",
152
+ " target_movie=arr[EXCLUDE_INITIAL_FRAMES:, c, 0].astype(np.float32),\n",
153
+ " )[:].cpu().numpy()\n",
154
+ " for c in range(arr.nc)\n",
155
+ "]\n",
156
+ "metadata = {\n",
157
+ " \"fs\": arr.fs,\n",
158
+ " \"dx\": arr.dx,\n",
159
+ " \"dy\": arr.dy,\n",
160
+ " \"channel_names\": arr.metadata[\"channel_names\"],\n",
161
+ " \"first_frame\": EXCLUDE_INITIAL_FRAMES,\n",
162
+ "}\n",
163
+ "ribbon = np.stack(channels, axis=1)[:, :, None]\n",
164
+ "mbo.imwrite(ribbon, REGISTERED_FOLDER, ext=\".tiff\", metadata=metadata, overwrite=True)\n",
165
+ "np.save(REGISTERED_FOLDER / \"shifts.npy\", shifts)\n",
166
+ "sorted(REGISTERED_FOLDER.iterdir())"
167
+ ],
168
+ "execution_count": null,
169
+ "outputs": []
170
+ },
171
+ {
172
+ "cell_type": "markdown",
173
+ "metadata": {},
174
+ "source": [
175
+ "## Compare"
176
+ ]
177
+ },
178
+ {
179
+ "cell_type": "code",
180
+ "metadata": {},
181
+ "source": [
182
+ "panels = {\n",
183
+ " \"raw\": movie,\n",
184
+ " \"pmd(raw)\": pmd_moco,\n",
185
+ " \"registered\": registered,\n",
186
+ " \"pmd(registered)\": pmd_registered,\n",
187
+ "}\n",
188
+ "ndw = fpl.NDWidget(names=list(panels), shape=(2, 2), size=(900, 700))\n",
189
+ "for name, data in panels.items():\n",
190
+ " image = ndw[name].add_nd_image(data, [\"time\", \"m\", \"n\"], [\"m\", \"n\"], spatial_func=None, name=name)\n",
191
+ " image.graphic.cmap = \"gray\"\n",
192
+ "ndw.show()"
193
+ ],
194
+ "execution_count": null,
195
+ "outputs": []
196
+ },
197
+ {
198
+ "cell_type": "code",
199
+ "metadata": {},
200
+ "source": [
201
+ "from masknmf.demixing.demixing_results import DemixingResults\n",
202
+ "from masknmf.visualization.demixing_vis import SingleSessionDemixingVis"
203
+ ],
204
+ "execution_count": null,
205
+ "outputs": []
206
+ },
207
+ {
208
+ "cell_type": "code",
209
+ "metadata": {},
210
+ "source": [
211
+ "vis = SingleSessionDemixingVis(moco_array, raw=movie)\n",
212
+ "vis.show()"
213
+ ],
214
+ "execution_count": null,
215
+ "outputs": []
216
+ },
217
+ {
218
+ "cell_type": "markdown",
219
+ "metadata": {},
220
+ "source": [
221
+ "The same registration with no denoising: template and shifts estimated on the raw movie, not inverted."
222
+ ]
223
+ },
224
+ {
225
+ "cell_type": "code",
226
+ "metadata": {},
227
+ "source": [
228
+ "movie_cpu = masknmf.OphysArray(raw, negative_indicator=False, device=\"cpu\")\n",
229
+ "corrector_raw = masknmf.RigidMotionCorrector(max_shifts=[40, 40])\n",
230
+ "corrector_raw.compute_template(movie_cpu)\n",
231
+ "shifts_raw = corrector_raw.motion_correct(movie_cpu).shifts.cpu().numpy()"
232
+ ],
233
+ "execution_count": null,
234
+ "outputs": []
235
+ },
236
+ {
237
+ "cell_type": "code",
238
+ "metadata": {},
239
+ "source": [
240
+ "t = (EXCLUDE_INITIAL_FRAMES + np.arange(movie.shape[0])) / fs\n",
241
+ "figure = fpl.Figure(shape=(2, 1), names=[[\"y shift (px)\"], [\"x shift (px)\"]], size=(1000, 500))\n",
242
+ "for subplot, k in zip(figure, (0, 1)):\n",
243
+ " subplot.add_line(np.column_stack([t, shifts_raw[:, k]]).astype(np.float32), colors=\"gray\", name=\"estimated on raw\")\n",
244
+ " subplot.add_line(np.column_stack([t, shifts[:, k]]).astype(np.float32), colors=\"royalblue\", name=\"estimated on denoised\")\n",
245
+ "figure[0, 0].controller.add_camera(figure[1, 0].camera, include_state={\"x\", \"width\"})\n",
246
+ "figure[1, 0].controller.add_camera(figure[0, 0].camera, include_state={\"x\", \"width\"})\n",
247
+ "figure.show(maintain_aspect=False)\n"
248
+ ],
249
+ "execution_count": null,
250
+ "outputs": []
251
+ },
252
+ {
253
+ "cell_type": "markdown",
254
+ "metadata": {},
255
+ "source": [
256
+ "## Pipeline\n"
257
+ ]
258
+ },
259
+ {
260
+ "cell_type": "code",
261
+ "metadata": {},
262
+ "source": [
263
+ "# `mad_correlation_threshold` decreased to 0.6 instead of 0.8 where no signals are found\n",
264
+ "MAD_CORRELATION_THRESHOLD = 0.6\n",
265
+ "\n",
266
+ "passes = []\n",
267
+ "for _ in range(2):\n",
268
+ " init_config = masknmf.SuperpixelInitConfig(mad_correlation_threshold=MAD_CORRELATION_THRESHOLD,\n",
269
+ " residual_threshold=0.1,\n",
270
+ " sign=\"positive\")\n",
271
+ " nmf_config = masknmf.NMFConfig(support_threshold=(0.95, 0.7),\n",
272
+ " ring_model_start_pt=41,\n",
273
+ " min_brightness=0.0,\n",
274
+ " merge_threshold=0.7,\n",
275
+ " reassign_background=False)\n",
276
+ " passes.append(masknmf.SinglepassDemixingConfig(init_config, nmf_config))\n",
277
+ "demixing_config = masknmf.MultipassDemixingConfig(passes)"
278
+ ],
279
+ "execution_count": null,
280
+ "outputs": []
281
+ },
282
+ {
283
+ "cell_type": "code",
284
+ "metadata": {},
285
+ "source": [
286
+ "pipeline = masknmf.GlutamateCalciumSpinePipeline(output_folder=OUTPUT_FOLDER,\n",
287
+ " demixing_config=demixing_config,\n",
288
+ " device=DEVICE)\n",
289
+ "run_folder = pipeline.run(glutamate_channel=movie,\n",
290
+ " calcium_channel=None,\n",
291
+ " exclude_initial_frames=0)\n",
292
+ "run_folder"
293
+ ],
294
+ "execution_count": null,
295
+ "outputs": []
296
+ },
297
+ {
298
+ "cell_type": "markdown",
299
+ "metadata": {},
300
+ "source": [
301
+ "## Results\n",
302
+ "\n",
303
+ "To reopen an earlier run, set `run_folder` to it and skip the run cell."
304
+ ]
305
+ },
306
+ {
307
+ "cell_type": "code",
308
+ "metadata": {},
309
+ "source": [
310
+ "results_path = run_folder / \"results.glutamate.hdf5\"\n",
311
+ "spines = masknmf.DemixingResults.from_hdf5(results_path, device=DEVICE)\n",
312
+ "dendrite = masknmf.DemixingResults.from_hdf5(results_path, prefix=\"global\", device=DEVICE)\n",
313
+ "spines.spatial_demixed.shape, dendrite.spatial_demixed.shape"
314
+ ],
315
+ "execution_count": null,
316
+ "outputs": []
317
+ },
318
+ {
319
+ "cell_type": "code",
320
+ "metadata": {},
321
+ "source": [
322
+ "vis = masknmf.SingleSessionDemixingVis(spines,\n",
323
+ " frame_timings=t,\n",
324
+ " results_path=results_path,\n",
325
+ " raw=movie,\n",
326
+ " device=DEVICE)\n",
327
+ "vis.show()"
328
+ ],
329
+ "execution_count": null,
330
+ "outputs": []
331
+ }
332
+ ],
333
+ "metadata": {
334
+ "kernelspec": {
335
+ "display_name": "Python 3 (ipykernel)",
336
+ "language": "python",
337
+ "name": "python3"
338
+ },
339
+ "language_info": {
340
+ "name": "python"
341
+ }
342
+ },
343
+ "nbformat": 4,
344
+ "nbformat_minor": 5
345
+ }