{ "cells": [ { "cell_type": "markdown", "id": "216a3b3a", "metadata": {}, "source": [ "# Plot Module : Getting started\n", "\n", "This module called MorphoPlot provides various functions to directly plot your own data on the MorphoNet windows without sending anything to the MorphoNet database.\n", "\n", "Please follow the documentation for more detail of each function.\n", "\n", "## Curation \n", "\n", "The main purpose of the MorphoPlot module is to curate your data segmented data using the 3D viewer.\n", "\n", "\n", "The API allows you to curate 3D segmented datasets, using MorphoNet along with a python script.\n", "\n", "\n", "An example of a curation script : " ] }, { "cell_type": "code", "execution_count": 7, "id": "7d5d1c70", "metadata": {}, "outputs": [], "source": [ "import morphonet\n", "mc=morphonet.Plot(start_browser=False)" ] }, { "cell_type": "code", "execution_count": null, "id": "567bda57", "metadata": {}, "outputs": [], "source": [ "mc.set_dataset(begin=0,end=10,raw=\"myrawdata_t{:03d}.inr\",segment=\"mysegmentdata_t{:03d}.inr\",xml_file=\"propertiesfile.xml\")\n", "mc.curate()" ] }, { "cell_type": "markdown", "id": "77974248", "metadata": {}, "source": [ "You can follow this [tutorial](https://morphonet.org/helpfiles/Tutorials/MorphoNet_Tutorial2.html) for a full detailed example. \n", "\n", "\n", "## Plugins\n", "\n", "In order to perform actions, MorphoNet uses plugins (called morphoplugins).\n", "\n", "A plugin is a python function that is applied to your dataset (for instance fusing two labels of a segmented image together). These functions are displayed onto the MorphoNet graphical interface and can be called from the 3D viewer, and apply on any dataset.\n", "\n", "[//]: # (The concept of the plugin is to define in Python a specific treatment that you would like to apply to your data. And then this method will be directly callable from the 3D viewer upon specific interactions.)\n", "\n", "You can find the documentation for the MorphoPlugins [here](https://morphonet.org/helpfiles/API/morphonet.plot.html#morphoplugins) \n", "\n", "The list of default plugins included in MorphoNet are available [here](https://morphonet.org/helpfiles/API/morphonet.plugins.html)\n", "\n", "### Create your own plugin ! \n", "\n", "In order to apply your own image processing algorithms, you can create your own plugins.\n", "\n", "This [MARS.py](https://morphonet.org/helpfiles/plugins/MARS.py) file is an example how to create a plugin in MorphoNet.\n", "You will also need [vt_tools.py](https://morphonet.org/helpfiles/plugins/vt_tools.py) in order to be able to execute this plugin.\n", "\n", "Your class (in the above example called MARS) has to derivate from ```MorphoPlugin```\n", "\n", "You also have to add your new plugin in your curation script (in this example, it is located in the plugins folder of the API), like this:" ] }, { "cell_type": "code", "execution_count": null, "id": "b3e2f3cb", "metadata": {}, "outputs": [], "source": [ "from plugins.MARS import MARS\n", "mc.add_plugin(MARS())" ] }, { "cell_type": "markdown", "id": "ab018907", "metadata": {}, "source": [ "## Create a property \n", "\n", "In order to annotate your datasets, you can create and add properties. \n", "\n", "For example, by adding the following line in your main code : \n" ] }, { "cell_type": "code", "execution_count": null, "id": "b0f21579", "metadata": {}, "outputs": [], "source": [ "info=mc.create_property(\"Cell_Name\",\"string\")" ] }, { "cell_type": "markdown", "id": "2c37f6f4", "metadata": {}, "source": [ "You can now name cells of an embryo by selecting a cell in the viewer and entering its name in a text field. \n", "\n", "\n", "**Documentation :** \n", "\n", "- To learn more about the parameters that can be used, see : [here](https://morphonet.org/helpfiles/API/morphonet.plot.html#morphonet.plot.Plot.create_property)\n", "- To learn more about how curate existing information, please see [here](https://morphonet.org/help_app), in the **Properties** section\n", "\n", "**Tips :**\n", "\n", "- To avoid any problems when using this function, do not use spaces in the info_name (here = \"Cell_Name\" in this example) and in the info_type (here = \"string\" in this example) parameters. \n", "- Put this function in your main code before the \"mc.curate()\" function. \"mc.curate()\" sends the data to the 3D viewer, so if a property is created afterwards, it is not sent.\n", "\n", "\n", "## Simulation \n", "\n", "MorphoPlot can also be use for simulation. You can focus on the physcial model of your system and use the 3D viewer to plot your model.\n", "\n", "You can follow this [tutorial](https://morphonet.org/helpfiles/Tutorials/MorphoNet_Tutorial3.html) for a full simulation example.\n", " \n", "This example show you how to simply plot multiples cubes in the browser" ] }, { "cell_type": "code", "execution_count": null, "id": "c7aa08f8", "metadata": {}, "outputs": [], "source": [ "#...\n", "import morphonet\n", "mp=morphonet.Plot(start_browser=False)\n", "mp.add_primitive(\"cube\",obj)\n", "#...\n", "obj=\"#Test Primitives\\n\"\n", "for c in self.cells:\n", " obj+=\"p \"+str(tp)+\",\"+str(c.id)+\" cube (\"+str(c.p.position.x)+\",\"+str(c.p.position.y)+\",\"+str(c.p.position.z)+\") \"+str(c.radius)+\" (1,1,1,1) \\n\"\n", "mp.plot_at(tp,obj)\n", "#...\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "b467dc52", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }