{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Flourescence intensities in plant roots" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ ".. figure:: ../images/example_plantroot.png\n", " :alt: A plant root with diffusing fluorescence proteins\n", "\n", " Left: image of a plant root in ClickPoints. Right: fluorescence intensities of the cells over time.\n", "\n", "In the example, we show how the mask panting feature of ClickPoints can be used to evaluate fluorescence intensities in\n", "microscope recordings.\n", "\n", "Images of an *Arabidopsis thaliana* root tip, obtained using a two-photon confocal microscope [Gerlitz2016]_, recorded at\n", "1 min time intervals are used. The plant roots expressed a photoactivatable green fluorescent protein, which after\n", "activation with a UV pulse diffuses from the activated cells to the neighbouring cells.\n", "\n", "For each time step a mask is painted to cover each cell in each time step.\n", "\n", "The fluorescence intensities be evaluated using a python script." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "nbsphinx": "hidden" }, "outputs": [], "source": [ "import os\n", "from urllib.request import urlretrieve\n", "import warnings\n", "warnings.simplefilter(\"ignore\")\n", "\n", "# load the database from the example repository and the first image as an example\n", "urls = [\"https://bitbucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/plant_root.cdb\", \"https://bytebucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/1-0min.tif\", \"https://bytebucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/1-2min.tif\", \"https://bytebucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/1-4min.tif\", \"https://bytebucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/1-6min.tif\", \"https://bytebucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/1-8min.tif\", \"https://bytebucket.org/fabry_biophysics/clickpointsexamples/raw/tip/PlantRoot/1-10min.tif\"]\n", "for url in urls:\n", " file = os.path.basename(url)\n", " if not os.path.exists(file):\n", " print(\"Downloading File\", file)\n", " urlretrieve(url, file)" ] }, { "cell_type": "raw", "metadata": {}, "source": [ "Open the the database where the masks are painted:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "path plant_root.cdb\n", "Open database with version 18\n" ] } ], "source": [ "import re\n", "import numpy as np\n", "from matplotlib import pyplot as plt\n", "import clickpoints\n", "\n", "# open the ClickPoints database\n", "db = clickpoints.DataFile(\"plant_root.cdb\")" ] }, { "cell_type": "raw", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Get a list of :py:class:`Image` objects (:py:meth:`~.DataFile.getImages`) and a list of all :py:class:`MaskType` objects (:py:meth:`~.DataFile.getMaskTypes`). Then we iterate over the images, load the green channel of the image (image.data[:, :, 1]) and get the mask data for that image (image.mask.data). The mask data is a numpy array with the same dimensions as the image having 0s for the background and the value mask_type.index for each pixel that belongs to the mask_type. Therefore we iterate over all the mask types and filter the pixels of the mask that belong to each type. This mask can then be used to filter the pixels of the green channel that belong to the :py:class:`MaskType`." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Image 1-0min.tif\n", "Image 1-2min.tif\n", "Image 1-4min.tif\n", "Image 1-6min.tif\n", "Image 1-8min.tif\n", "Image 1-10min.tif\n" ] } ], "source": [ "# get images and mask_types\n", "images = db.getImages()\n", "mask_types = db.getMaskTypes()\n", "\n", "# regular expression to get time from filename\n", "regex = re.compile(r\".*(?P\\d*)-(?P