{ "cells": [ { "cell_type": "markdown", "id": "9e89713d", "metadata": {}, "source": [ "# Plot Examples" ] }, { "cell_type": "markdown", "id": "c0520aa5", "metadata": {}, "source": [ "This file is an example of how to do data curation for your 3D segmented datasets, using the MorphoPlot module, with data located on your hard drive. You can create a python script, complete it with the following code and run it alongside the MorphoNet application.\n", "You just need to copy and edit this file, than start it running : python3 TestMorphoPlot.py\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "e987bc27", "metadata": {}, "outputs": [], "source": [ "import morphonet" ] }, { "cell_type": "markdown", "id": "598cff38", "metadata": {}, "source": [ "The variable below is the path to the raw images of your dataset (the raw images are any image you want to be able to see alongside your segmented data, such as an image of the membranes of your dataset for instance). A dataset does not require raw data necessarily. You can use the path of a single file, or use a regular expression to automatically select several files respecting a naming convention. here, it means that it will automatically include all files respecting the name below ({:03d} meaning any 3 numbers." ] }, { "cell_type": "code", "execution_count": null, "id": "94f58dea", "metadata": {}, "outputs": [], "source": [ "raw_files = \"DATASET/PLOT/RAW/fuse_t{:03d}.inr.gz\"" ] }, { "cell_type": "markdown", "id": "92d351ec", "metadata": {}, "source": [ "This variable is the path to the segmentation image(s) file(s), which uses the same system as the raw images variable. for example if images names are : seg_t000.inr.gz , seg_t001.inr.gz, seg_t010.inr.gz, ... writing seg_t{:03d}.inr.gz as a value for segment_files will select them all. Segmented images is not necessary for a dataset, but if you need at least raw images or raw images to be able to visualize anything.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "2b17ffd7", "metadata": {}, "outputs": [], "source": [ "segment_files = \"DATASET/PLOT/SEG/raw_t{:03d}.inr.gz\"" ] }, { "cell_type": "markdown", "id": "0b04753e", "metadata": {}, "source": [ "This is the path to a properties file, with xml format as described in MorphoNet [format](https://morphonet.org/help_format) help\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "2145eeae", "metadata": {}, "outputs": [], "source": [ "properties_file = \"DATASET/PLOT/properties.xml\"" ] }, { "cell_type": "markdown", "id": "2613cedf", "metadata": {}, "source": [ "This is the starting time point of your dataset\n" ] }, { "cell_type": "code", "execution_count": null, "id": "c858252d", "metadata": {}, "outputs": [], "source": [ "begin = 0" ] }, { "cell_type": "markdown", "id": "f53b03bf", "metadata": {}, "source": [ "And the final time point of your dataset. MorphoPlot will look into the images files in raw_files and segment_files, and all integer values between begin and end will be loaded if they exist.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "aa2db629", "metadata": {}, "outputs": [], "source": [ "end = 0" ] }, { "cell_type": "markdown", "id": "54134b84", "metadata": {}, "source": [ "Then you can create the MorphoPlot instance, in which you will input the parameters of the dataset, and start the curation.\n", "\n", "**Parameters**\n", "\n", "start_browser : (bool)\n", " if True, starting the curation will load MorphoNet in the firefox browser with the curation page open. This is btter suited when you can not or do not want to use the desktop application, as the browser version is slower. \n", " \n", "clear_temp : (bool)\n", " MorphoNet use temporary files to increase the speed of the loading. If True, this will clear previous temporary files and create them again when starting curation (so will be slower, but will regenerate your 3D mesh data if you have given a wrong parameter for instance)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "68b50e8c", "metadata": {}, "outputs": [], "source": [ "mc=morphonet.Plot(start_browser=False, clear_temp=True)" ] }, { "cell_type": "markdown", "id": "4fa1e94d", "metadata": {}, "source": [ "This next call will bind the values created before to the curation, but will still wait for the start of the curation\n", "\n", "**Parameters**\n", "\n", "begin : (int)\n", " First time point to load for curation (same begin than previously explained above)\n", "\n", "end : (int)\n", " Last time point to laod for curation, every int between begin and end. Every interger between begin and end will be considered as a time point. If you have only one time point, set end=begin\n", " \n", "background : (int) (optional)\n", " The value in the segmentation images that correspond to background. Change this value only if you know what you are doing.\n", "\n", "segment : (string)\n", " Path written above to segment files in your hard drive\n", " \n", "raw : (string)\n", " Path written above to raw images files in your hard drive\n", "\n", "xml_file : (string)\n", " Path written above to properties file in your hard drive\n", "\n", "factor : (int)\n", " decimation factor applied to the data, a high value will generate data faster but with a lower quality\n", "\n", "memory : (int)\n", " the number of time point the system can hold in memory, if more time points are loaded, the oldest loaded one will be unloaded (and will automatically reload if needed)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "17a84f77", "metadata": {}, "outputs": [], "source": [ "mc.set_dataset(begin=begin,end=end,background=1,segment=segment_files,raw=raw_files,xml_file=properties_file,factor=5,memory = 20)" ] }, { "cell_type": "markdown", "id": "bfea218f", "metadata": {}, "source": [ "This call will create a new property to be used in the curation\n", "\n", "**Parameters**\n", "\n", "name : (string)\n", " name of the property\n", "\n", "type : (string)\n", " type of property to load : string , float , label , time , group , ..., you can see [here](https://morphonet.org/help_format) for additional help\n" ] }, { "cell_type": "code", "execution_count": null, "id": "3f9439b9", "metadata": {}, "outputs": [], "source": [ "prop=mc.create_property(\"preloaded_empty_property\",\"string\")" ] }, { "cell_type": "markdown", "id": "fa6f2c42", "metadata": {}, "source": [ "You can then start the curation ! Data is computed and will be sent to a MorphoNet viewer instance ready for curation\n" ] }, { "cell_type": "code", "execution_count": null, "id": "afb5a190", "metadata": {}, "outputs": [], "source": [ "mc.curate()" ] } ], "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 }