{ "cells": [ { "cell_type": "markdown", "id": "3f81a577", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# Python Segmentation API\n" ] }, { "cell_type": "code", "id": "460d0f4d", "metadata": { "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2025-04-16T12:05:24.113414Z", "start_time": "2025-04-16T12:05:22.890071Z" } }, "source": [ "# must run in an environment where polarityJaM is installed\n", "from polarityjam import Plotter\n", "from polarityjam import RuntimeParameter, PlotParameter, ImageParameter\n", "from polarityjam import PolarityJamLogger\n", "from polarityjam import load_segmenter\n", "from polarityjam import SegmentationMode\n", "from polarityjam import SegmentationParameter\n", "from polarityjam.utils.io import read_image\n", "\n", "from pathlib import Path" ], "outputs": [], "execution_count": 2 }, { "cell_type": "code", "id": "574d0e3f", "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2025-04-16T12:05:24.122158Z", "start_time": "2025-04-16T12:05:24.118377Z" } }, "source": [ "# Setup a logger to only report WARNINGS, Put \"INFO\" or \"DEBUG\" to get more information\n", "plog = PolarityJamLogger(\"WARNING\")" ], "outputs": [], "execution_count": 3 }, { "cell_type": "markdown", "id": "1285ac7b", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Setup your data\n", "\n", "We expect you to be already familiar with basic usage of polarityjam. Hence we will shorten necessary data preparation steps. Please look at the Python API section of the documentation for more information." ] }, { "cell_type": "code", "id": "0880cbee", "metadata": { "pycharm": { "name": "#%%\n" }, "ExecuteTime": { "end_time": "2025-04-16T12:05:24.188385Z", "start_time": "2025-04-16T12:05:24.165388Z" } }, "source": [ "### ADAPT ME ###\n", "path_root = Path(\"\")\n", "input_file = path_root.joinpath(\"data/golgi_nuclei/set_2/060721_EGM2_18dyn_02.tif\")\n", "output_path = path_root.joinpath(\"polarityjam_out/\")\n", "output_file_prefix = \"060721_EGM2_18dyn_02\"\n", "### ADAPT ME ###\n", "\n", "img = read_image(input_file)\n", "\n", "# Parameters\n", "params_image = ImageParameter()\n", "params_image.channel_organelle = 0 # golgi channel\n", "params_image.channel_nucleus = 2\n", "params_image.channel_junction = 3\n", "params_image.channel_expression_marker = 3\n", "params_image.pixel_to_micron_ratio = 2.4089\n", "\n", "# Parameters\n", "params_runtime = RuntimeParameter()\n", "params_plot = PlotParameter()\n", "params_plot.dpi = 96\n", "\n", "# plotter object\n", "plotter = Plotter(params_plot)" ], "outputs": [], "execution_count": 4 }, { "cell_type": "markdown", "id": "1ca79ac1", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "## Several segmentation algorithms in parallel\n", "Polarity-JaM currently supports three segmentation algorithms out of the box.\n", "\n", "Here, we show how easy it is to switch from one to another and how to compare performance." ] }, { "metadata": {}, "cell_type": "markdown", "source": [ "