{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MotilA Advanced Batch Processing\n", "\n", "This script demonstrates how to use the **MotilA** pipeline for batch analyzing microglial fine process motility in 4D/5D image stacks.\n", "\n", "### Overview\n", "- Scans and processes multiple registered 4D TIFF image stacks from multiple experimental folders.\n", "- Applies preprocessing steps such as projection, registration, and spectral unmixing.\n", "- Performs image enhancements like histogram equalization and filtering.\n", "- Segments microglia, applies thresholding, and quantifies motility.\n", "- Collects results from all processed stacks into summary tables for cohort analysis.\n", "\n", "### Workflow\n", "1. **Batch processing**\n", " - Iterates over multiple subject folders (`ID_list`) and searches for experiment folders (`project_tag`).\n", " - Processes microglial motility for each dataset according to predefined settings.\n", " - Saves analysis results per subject in a structured output folder.\n", "2. **Batch collection**\n", " - Gathers and combines results across all processed datasets.\n", " - Saves consolidated results into a cohort-level output directory.\n", "\n", "### Usage\n", "- **Modify parameters:** Adjust paths, projection settings, thresholding methods, and filter settings.\n", "- **Run the script:** Execute the script to batch process and collect results.\n", "- **Check outputs:** Processed images, histograms, and motility metrics are saved in structured folders for further analysis and parameter tuning.\n", "\n", "### Dependencies\n", "- Requires **MotilA** to be installed and accessible. Please refer to the [MotilA GitHub repository](https://github.com/FabrizioMusacchio/MotilA#installation) or the [MotilA documentation](https://motila.readthedocs.io/en/latest/overview.html#installation) for installation instructions.\n", "\n", "### Author\n", "Fabrizio Musacchio, March 20, 2025" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Import libraries and download the example data set\n", "First, we import MotilA and other required libraries:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "import motila as mt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can verify the correct import by running the following cell:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Hello, World! Welcome to MotilA!\n" ] } ], "source": [ "mt.hello_world()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Before you proceed, please make sure that you have downloaded the example data from Zenodo:** \n", "\n", "* [Gockel & Nieves-Rivera & Musacchio et al. (2025), doi: 10.5281/zenodo.15061566](https://zenodo.org/records/15061566)\n", "\n", "Place the downloaded and extracted data set into the `example project` folder." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Define MotilA parameters\n", "Next, we define the parameters for the MotilA pipeline.\n", "\n", "### Input/Outut parameters\n", "Define the input/output path and folder and file tags for the batch processing:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "PROJECT_Path = \"../example project/Data/\"\n", " # define the path to the project folder; can be absolute or relative to the\n", " # location of this script\n", "\n", "ID_list = [\"ID240103_P17_1\", \"ID240321_P17_3\"]\n", " # define the list of all IDs to be processed in PROJECT_Path; \n", " # names must be exact names of the ID folders\n", "\n", "project_tag = \"TP000\" # define the tag of the project (folder) to be analyzed;\n", " # all folders in the ID-folders containing this tag will be processed; \n", " # can be just a part of the tag (will be searched for in the folder name)\n", "\n", "reg_tif_file_folder = \"registered\" # name of folder within the (found) project_tag-folder containing the \n", " # registered tif files; must be exact\n", "reg_tif_file_tag = \"reg\" # a Tif file containing this tag will be processed within the reg_tif_file_folder;\n", " # if multiple files containing this tag, folder will be skipped (!)\n", "\n", "RESULTS_foldername = f\"../motility_analysis/\" \n", " # define the folder name (not the full path!) where the results will be saved\n", " # within each project_tag-folder; can also be relative to the project_tag-folder\n", " # (e.g. \"../motility_analysis/\"); default destination will be inside the\n", " # reg_tif_file_folder folder\n", "\n", "metadata_file = \"metadata.xls\" # name of the metadata file in the project_tag-folder; must be exact\n", " # use template provided in the MotilA repository to create the metadata file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**: By placing an excel file (e.g., `metadata.xls`) in the `project_tag` folder for each animal ID folder (listed in `ID_list`), the following parameters set in this notebook will be overwritten by the parameters in the excel file: \n", "\n", "* `two_channel_default`: True/False\n", "* `MG_channel_default`: 0/1\n", "* `N_channel_default`: 0/1\n", "* `spectral_unmixing`: True/False\n", "* `projection_center_default`: integer\n", "\n", "This allows for individual settings for each dataset.\n", "\n", "The table below shows an example of the content of the `metadata.xls` file:\n", "\n", "| Two Channel | Registration Channel | Registration Co-Channel | Microglia Channel | Neuron Channel | Spectral Unmixing | Projection Center 1 |\n", "| ----------- | -------------------- | ----------------------- | ----------------- | -------------- | ----------------- | ------------------- |\n", "| True | 1 | 0 | 0 | 1 | False | 28 |\n", "\n", "A template for this excel files is provided in the *MotilA* repository. In this template, ignore the columns `Registration Channel` and `Registration Co-Channel` as they are not used in this pipeline.\n", "\n", "You can add several projection centers (`Projection Center 1`, `Projection Center 2`, etc.) to the excel file. The pipeline will then create a projection for each center along with the corresponding analysis results." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Projection parameters\n", "MotilA will generate maximum intensity projections along the specified axes. For this, we need to define the projection center and ranges:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# define projection settings:\n", "projection_layers_default = 44 # define number of z-layers to project for motility analysis\n", "projection_center_default = 23 # define the center slice of the projection; a sub-stack of +/- projection_layers will be projected;\n", " # if metadata.xls is present in project_tag folder, this value is ignored and\n", " # the value from the metadata.xls is used instead (in batch processing only!)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Clear previous results?\n", "Define whether to clear the output folder before running the pipeline:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# previous results settings:\n", "clear_previous_results = True # set to True if all files in RESULTS_Path folder should be deleted before processing" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Thresholding parameters\n", "Define the thresholding method and parameters for segmenting microglia. \n", "\n", "As a **thresholding method** (`threshold_method`), you can choose between `otsu`, `li`, `isodata`, `mean`, `triangle`, `yen`, and `minimum`.\n", "\n", "**`blob_pixel_threshold`** defines the minimum number of pixels for a blob to be considered a microglial cell.\n", "\n", "With **`compare_all_threshold_methods`**, a plot is generated comparing all thresholding methods listed above to facilitate the selection of the best method." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# thresholding settings:\n", "threshold_method = \"otsu\" # choose from: otsu, li, isodata, mean, triangle, yen, minimum\n", "blob_pixel_threshold = 100 # define the threshold for the minimal pixel area of a blob during the segmentation\n", "compare_all_threshold_methods = True # if True, all threshold methods will be compared and saved in the plot folder" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Image enhancement parameters\n", "Define the parameters for enhancing the images, such as histogram equalization and filtering.\n", "\n", "With **`hist_equalization`** set to `True`, the pipeline will apply histogram equalization WITHIN each time (3D) stack. This enhances the contrast within each 3D stack.\n", "\n", "With `hist_match` set to `True`, the pipeline will apply histogram matching BETWEEN the time (3D) stacks. This homogenizes the intensity distribution across the time stacks and acts as a bleaching correction." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# image enhancement settings:\n", "hist_equalization = True # enhance the histograms WITHIN EACH projected stack: True or False\n", "hist_equalization_clip_limit = 0.05 # clip limit for the histogram equalization (default is 0.05);\n", " # the higher the value, the more intense the contrast enhancement, \n", " # but also the more noise is amplified \n", "hist_equalization_kernel_size = None # kernel size for the histogram equalization; \n", " # None (default) for automatic, or use a tuple (x,y) for a fixed size;\n", " # when using a tuple, you can start increasing the values from multiples\n", " # of 8, e.g., (8,8), (16,16), (24,24), (32,32), ... (128,128), ...\n", " # start increasing the values if the images start to included block artifacts\n", "hist_match = True # match the histograms ACROSS the stacks : True or False\n", "histogram_ref_stack = 0 # define the stack which should be used as reference for the histogram matching" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Image filtering parameters\n", "Define the parameters for filtering the images, such as median filtering and Gaussian smoothing.\n", "\n", "#### Median filtering\n", "Regarding median filtering, you have the option to filter on the single slices BEFORE the projection (**`median_filter_slices`**) and/or on the projected images (**`median_filter_projections`**). For both options, you can choose from:\n", "\n", "* `False` (no filtering)\n", "* `square` (square kernel): integer numbers (3, 5, 9)\n", "* `circular` (disk-shaped kernel; analogous to the median filter in ImageJ/Fiji): only values >= 0.5 allowed/have an effect\n", "\n", "When you apply median filtering, you need to additionally provide the kernel size (**`median_filter_window_slices`** for single slices and **`median_filter_window_projections`** for projections). Depending on the chosen filtering kernel method, you can choose a kernel size as listed above.\n", "\n", "#### Gaussian smoothing\n", "Gaussian smoothing further enhances the contrast and reduces noise. Set\n", "\n", "* `gaussian_sigma_proj` to 0: no smoothing, or\n", "* `gaussian_sigma_proj` to a value > 0: the standard deviation of the Gaussian kernel." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# filter settings:\n", "median_filter_slices = 'circular' # median filter on SLICES BEFORE projecting\n", " # 'square', 'circular', or False\n", " # circular: floating point numbers allowed, not lower than 0.5 for circular\n", " # square: integer numbers (3, 5, 9)\n", "median_filter_window_slices = 1.55 # median filter window size on SLICES BEFORE projecting\n", " # circular: only values >= 0.5 allowed/have an effect\n", " # square: integer numbers (3, 5, 9)\n", "\n", "median_filter_projections = 'circular' # median filter on PROJECTIONS\n", " # square, circular, or False\n", "median_filter_window_projections = 1.55 # median filter window size on PROJECTIONS\n", " # circular: only values >= 0.5 allowed/have an effect\n", " # square: integer numbers (3, 5, 9)\n", "gaussian_sigma_proj = 1.00 # standard deviation of Gaussian (blur) filter applied on the projected stack\n", " # set to 0 for turning off" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Channel parameters\n", "Define the channel parameters for single-channel or two-channel data:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# channel settings: \n", "two_channel_default = True # define if the stack has two channels; if metadata.xls is present, this value is ignored\n", "MG_channel_default = 0 # define the channel of the Microglia; if metadata.xls is present, this value is ignored\n", "N_channel_default = 1 # define the channel of the Neurons/2nd channel; if metadata.xls is present, this value is ignored" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**: If you stack contains only one channel, set `two_channel_default = False`; any value set in `N_channel_default` will be ignored.\n", "\n", "**Note**: If `metadata.xls` is present in `project_tag` folder, the above defined values (`two_channel_default`, `MG_channel_defaulta`, `N_channel_default`) are ignored and values from the metadata.xls are used instead (**in batch processing only!**)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Registration parameters\n", "*MotilA* provides the option to register the image stacks. Two registration options are available:\n", "\n", "* `regStack3d`: register slices WITHIN each 3D time-stack; `True` or `False`\n", "* `regStack2d`: register projections on each other; `True` or `False`\n", "\n", "With `template_mode`you can define the template mode for the registration. Choose between `mean` (default), `median`, `max`, `min`, `std`, and `var`.\n", "\n", "With `max_xy_shift_correction`, you can define the maximum allowed shift in x and y (and z) direction for the registration. This is useful to avoid overcorrection." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# registration settings:\n", "regStack3d = False # register slices WITHIN each 3D time-stack; True or False\n", "regStack2d = False # register projections on each other; True or False\n", "template_mode = \"max\" # set the template mode for the 3D registration; defines for both 3D and 2D registration\n", " # choose from: mean, median, max, std, var.\n", "max_xy_shift_correction = 100 # set the maximal shift in x/y direction for the 2D registration" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Spectral unmixing parameters\n", "*MotilA* provides the option to perform spectral unmixing on two-channel data. At the moment, only a simple method is implemented, which subtracts the N-channel from the MG-channel. Set `spectral_unmixing` to `True` to enable this feature. \n", "\n", "With `spectral_unmixing_amplifyer_default` you can define the amplification factor for the MG-channel before subtraction. This can be useful to preserve more information in the MG-channel.\n", "\n", "`spectral_unmixing_median_filter_window` defines the kernel size for median filtering of N-channel before subtraction. This can be useful to reduce noise in the N-channel and, thus, achieve a better unmixing result. Allowed are odd integer numbers (3, 5, 9, ...)." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "# spectral unmixing settings:\n", "spectral_unmixing = False # perform spectral unmixing; True or False\n", " # if metadata.xls is present in project_tag folder, this value is \n", " # ignored and the value from the metadata.xls is used instead \n", " # (in batch processing only!)\n", "spectral_unmixing_amplifyer_default =1 # amplifies the MG channel (to save more from it)\n", "spectral_unmixing_median_filter_window =3 # must be integer; 1=off, 3=common, 5=strong, 7=very strong" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Initialize the logger\n", "Initialize the logger to track the progress of the pipeline. The log file will be saved in the same folder as this notebook is located." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "creating logger object...done.\n", "logger started for TEST/DEBUG RUN: BATCH RUN.\n", "Test project: /Volumes/Media/Workspace/MotilA example files/single_file/\n", "Mouse IDs: ['ID240103_P17_1', 'ID240321_P17_3']\n", "Group: TP000\n" ] } ], "source": [ "# init logger:\n", "log = mt.logger_object()\n", "log.log(\"logger started for TEST/DEBUG RUN: BATCH RUN.\")\n", "log.log(\"Test project: \"+str(PROJECT_Path))\n", "log.log(f\"Mouse IDs: {ID_list}\")\n", "log.log(f\"Group: {project_tag}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Run the MotilA pipeline\n", "Finally, we run the *MotilA* pipeline with the defined parameters. Simply execute the following cell to start the processing:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Batch processing of stacks...\n", "============================================================\n", "\n", "Mouse ID240103_P17_1\n", "\n", " TP000-tagged folders found: ['TP000']\n", " 'registered' folder found in TP000.\n", " 1 tif file with tag 'reg' found in 'registered' folder in TP000 in ID240103_P17_1.\n", " processing projection center: 28\n", "Processing file /Volumes/Media/Workspace/MotilA example files/single_file/ID240103_P17_1/TP000/registered/all stacks 4D reg.tif...\n", " folder already exists: /Volumes/Media/Workspace/MotilA example files/single_file/ID240103_P17_1/TP000/registered/../motility_analysis/projection_center_28 \n", "Info: Folder /Volumes/Media/Workspace/MotilA example files/single_file/ID240103_P17_1/TP000/registered/../motility_analysis/projection_center_28 is not empty, deleting all files in it.\n", "Projection center: 28, Projection range: [6, 49]\n", "extracting sub-volumes...\n", " sub-volume extracting process time: 13.9961779118 sec\n", "z-projecting... z-projections process time: 0.1685872078 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.9753479958 sec\n", "circular median-filtering on slices... circular median filtering on slices process time: 15.8177878857 sec\n", "z-projecting... z-projections process time: 0.1693177223 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 8.0895643234 sec\n", "ZARR storage will be deleted (not needed anymore) ...equilizing the histogram for each projected stack ...\n", " histogram equalization process time: 0.83761096 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.4940347672 sec\n", "matching histograms of all stacks to reference stack 0...\n", " histogram matching process time: 1.1796250343 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.373939991 sec\n", "calculating and plotting histogram of each stack...\n", " histogram comparison process time: 1.9085419178 sec\n", "median-filtering... median filtering process time: 0.5903980732 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.4615769386 sec\n", "plotting average brightness per projected stack...\n", " brightness comparison process time: 0.0772707462 sec\n", "Gaussian blur filtering... Gaussian blur filtering process time: 0.1183958054 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.7664232254 sec\n", "binarizing z-projections...\n", " threshold method 'otsu' chosen...\n", " stack 0: otsu-threshold=0.36983110413998027\n", " stack 1: otsu-threshold=0.372918423983694\n", " stack 2: otsu-threshold=0.37518819548257304\n", " stack 3: otsu-threshold=0.3787737600100347\n", " stack 4: otsu-threshold=0.38122529131282723\n", " stack 5: otsu-threshold=0.3809986407770025\n", " stack 6: otsu-threshold=0.3795583747493566\n", " stack 7: otsu-threshold=0.3805557091524643\n", " binarization process time: 17.9451169968 sec\n", "apply connectivity-measurments to exclude too small microglia parts...\n", " stack 0 - number of new labels: 163\n", " stack 1 - number of new labels: 157\n", " stack 2 - number of new labels: 178\n", " stack 3 - number of new labels: 181\n", " stack 4 - number of new labels: 187\n", " stack 5 - number of new labels: 203\n", " stack 6 - number of new labels: 189\n", " stack 7 - number of new labels: 204\n", " connectivity measurment process time: 39.1142780781 sec\n", "plotting detected pixel areas per projected stack...\n", " pixel cell area plotting process time: 0.0715630054 sec\n", "motility analysis...\n", "motility evaluation saved in /Volumes/Media/Workspace/MotilA example files/single_file/ID240103_P17_1/TP000/registered/../motility_analysis/projection_center_28/motility_analysis.xlsx\n", " motility process time: 6.0551810265 sec\n", " total processing timeprocess time: 148.3661689758 sec\n", "\n", "============================================================\n", "\n", "Mouse ID240321_P17_3\n", "\n", " TP000-tagged folders found: ['TP000']\n", " 'registered' folder found in TP000.\n", " 1 tif file with tag 'reg' found in 'registered' folder in TP000 in ID240321_P17_3.\n", " processing projection center: 28\n", "Processing file /Volumes/Media/Workspace/MotilA example files/single_file/ID240321_P17_3/TP000/registered/all stacks 4D reg.tif...\n", " folder already exists: /Volumes/Media/Workspace/MotilA example files/single_file/ID240321_P17_3/TP000/registered/../motility_analysis/projection_center_28 \n", "Info: Folder /Volumes/Media/Workspace/MotilA example files/single_file/ID240321_P17_3/TP000/registered/../motility_analysis/projection_center_28 is not empty, deleting all files in it.\n", "Projection center: 28, Projection range: [6, 49]\n", "extracting sub-volumes...\n", " sub-volume extracting process time: 15.1147332191 sec\n", "z-projecting... z-projections process time: 0.1862490177 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 8.2704539299 sec\n", "circular median-filtering on slices... circular median filtering on slices process time: 20.3186380863 sec\n", "z-projecting... z-projections process time: 0.4330580235 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 8.6353402138 sec\n", "ZARR storage will be deleted (not needed anymore) ...equilizing the histogram for each projected stack ...\n", " histogram equalization process time: 0.7919938564 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.485584259 sec\n", "matching histograms of all stacks to reference stack 0...\n", " histogram matching process time: 1.4922802448 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.1919496059 sec\n", "calculating and plotting histogram of each stack...\n", " histogram comparison process time: 1.3403279781 sec\n", "median-filtering... median filtering process time: 0.6614673138 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.7777638435 sec\n", "plotting average brightness per projected stack...\n", " brightness comparison process time: 0.0788378716 sec\n", "Gaussian blur filtering... Gaussian blur filtering process time: 0.11358428 sec\n", "plotting z-projections...\n", " z-projection plotting process time: 7.6238679886 sec\n", "binarizing z-projections...\n", " threshold method 'otsu' chosen...\n", " stack 0: otsu-threshold=0.52494887948885\n", " stack 1: otsu-threshold=0.5265509924817701\n", " stack 2: otsu-threshold=0.5255229848946956\n", " stack 3: otsu-threshold=0.5259119044263374\n", " stack 4: otsu-threshold=0.5328050023508216\n", " stack 5: otsu-threshold=0.5290614438302713\n", " stack 6: otsu-threshold=0.5323137640446359\n", " stack 7: otsu-threshold=0.5325937224116465\n", " binarization process time: 17.0890438557 sec\n", "apply connectivity-measurments to exclude too small microglia parts...\n", " stack 0 - number of new labels: 70\n", " stack 1 - number of new labels: 67\n", " stack 2 - number of new labels: 62\n", " stack 3 - number of new labels: 61\n", " stack 4 - number of new labels: 71\n", " stack 5 - number of new labels: 86\n", " stack 6 - number of new labels: 83\n", " stack 7 - number of new labels: 76\n", " connectivity measurment process time: 32.127215147 sec\n", "plotting detected pixel areas per projected stack...\n", " pixel cell area plotting process time: 0.077641964 sec\n", "motility analysis...\n", "motility evaluation saved in /Volumes/Media/Workspace/MotilA example files/single_file/ID240321_P17_3/TP000/registered/../motility_analysis/projection_center_28/motility_analysis.xlsx\n", " motility process time: 5.8129241467 sec\n", " total processing timeprocess time: 147.1049427986 sec\n", "\n", "============================================================\n", "\n", "total batch process time: 295.5011789799 sec\n" ] } ], "source": [ "mt.batch_process_stacks(PROJECT_Path=PROJECT_Path, \n", " ID_list=ID_list, \n", " project_tag=project_tag, \n", " reg_tif_file_folder=reg_tif_file_folder,\n", " reg_tif_file_tag=reg_tif_file_tag,\n", " metadata_file=metadata_file,\n", " RESULTS_foldername=RESULTS_foldername,\n", " MG_channel=MG_channel_default, \n", " N_channel=N_channel_default, \n", " two_channel=two_channel_default,\n", " projection_center=projection_center_default, \n", " projection_layers=projection_layers_default,\n", " histogram_ref_stack=histogram_ref_stack, \n", " log=log, \n", " blob_pixel_threshold=blob_pixel_threshold,\n", " regStack2d=regStack2d, \n", " regStack3d=regStack3d, \n", " template_mode=template_mode,\n", " spectral_unmixing=spectral_unmixing, \n", " hist_equalization=hist_equalization, \n", " hist_equalization_clip_limit=hist_equalization_clip_limit,\n", " hist_equalization_kernel_size=hist_equalization_kernel_size,\n", " hist_match=hist_match,\n", " max_xy_shift_correction=max_xy_shift_correction,\n", " threshold_method=threshold_method, \n", " compare_all_threshold_methods=compare_all_threshold_methods,\n", " gaussian_sigma_proj=gaussian_sigma_proj, \n", " spectral_unmixing_amplifyer=spectral_unmixing_amplifyer_default,\n", " median_filter_slices=median_filter_slices, \n", " median_filter_window_slices=median_filter_window_slices,\n", " median_filter_projections=median_filter_projections, \n", " median_filter_window_projections=median_filter_window_projections,\n", " clear_previous_results=clear_previous_results, \n", " spectral_unmixing_median_filter_window=spectral_unmixing_median_filter_window,\n", " debug_output=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. Assessing your results\n", "After running the pipeline, you can assess the results in the specified output folder. The results of each processing step described above are saved in separate tif and PDF files. By carefully investigating these results, you can evaluate the quality of the processing and adjust the parameters if necessary.\n", "\n", "An example assessment is given in the MotilA Quick Start (Single File) notebook." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 6. Batch collection\n", "After processing all datasets, you can collect the results and save them to a central output folder. This allows you to perform cohort-level analyses and visualize the results across all datasets." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, define the parameters for batch collection:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "RESULTS_Path = \"../example project/Analysis/MG_motility/\"\n", " # define the path to the results folder; in here, the combined results\n", " # of the cohort analysis will be saved; can be absolute or relative to the\n", " # location of this script\n", "\n", "motility_folder = \"motility_analysis\" # folder name containing motility analysis results in each ID folder/project_tag folder;\n", " # must be exact; wherein, all projection center folders therein will be processed\n", " # to collect the results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then, start the batch collection by executing the following cell:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting motility data from processed stacks...\n", "Processing ID ID240103_P17_1, project TP000...\n", " Processing projection center projection_center_23...\n", " Processing projection center projection_center_28...\n", "Processing ID ID240321_P17_3, project TP000...\n", " Processing projection center projection_center_28...\n", "Collected data saved in /Volumes/Media/Workspace/MotilA example files/single_file/Analysis/MG_motility\n" ] } ], "source": [ "mt.batch_collect(PROJECT_Path=PROJECT_Path, \n", " ID_list=ID_list, \n", " project_tag=project_tag, \n", " motility_folder=motility_folder,\n", " RESULTS_Path=RESULTS_Path,\n", " log=log)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's investigate the cohort results by loading the summary tables:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
IDproject tagprojection centerdelta tgroupStableGainLossrel Stablerel Gainrel Losstor
0ID240103_P17_1TP000projection_center_23t_0-t_1blinded4339302042282176770.5070250.2386300.2543450.492975
1ID240103_P17_1TP000projection_center_23t_1-t_2blinded4321112124462060470.5080050.2497590.2422360.491995
2ID240103_P17_1TP000projection_center_23t_2-t_3blinded4052111959332393460.4821130.2331180.2847700.517887
3ID240103_P17_1TP000projection_center_23t_3-t_4blinded3951252121882060190.4858100.2608870.2533020.514190
4ID240103_P17_1TP000projection_center_23t_4-t_5blinded3944091986772129040.4893470.2465010.2641520.510653
5ID240103_P17_1TP000projection_center_23t_5-t_6blinded3797872546052132990.4480250.3003510.2516240.551975
6ID240103_P17_1TP000projection_center_23t_6-t_7blinded4237212052242106710.5046600.2444260.2509140.495340
7ID240103_P17_1TP000projection_center_28t_0-t_1blinded4386892060822112930.5124490.2407320.2468190.487551
8ID240103_P17_1TP000projection_center_28t_1-t_2blinded4326482070452121230.5079130.2430630.2490240.492087
9ID240103_P17_1TP000projection_center_28t_2-t_3blinded4231702076762165230.4993930.2450830.2555240.500607
10ID240103_P17_1TP000projection_center_28t_3-t_4blinded4107522134712200940.4864900.2528330.2606770.513510
11ID240103_P17_1TP000projection_center_28t_4-t_5blinded4115762079722126470.4945670.2499080.2555250.505433
12ID240103_P17_1TP000projection_center_28t_5-t_6blinded3923062344922272420.4593530.2745680.2660790.540647
13ID240103_P17_1TP000projection_center_28t_6-t_7blinded4110512120092157470.4900420.2527510.2572070.509958
14ID240321_P17_3TP000projection_center_28t_0-t_1blinded5937952005602051100.5941130.2006670.2052200.405887
15ID240321_P17_3TP000projection_center_28t_1-t_2blinded6020041960551923510.6078330.1979530.1942140.392167
16ID240321_P17_3TP000projection_center_28t_2-t_3blinded5952542008532028050.5959020.2010720.2030260.404098
17ID240321_P17_3TP000projection_center_28t_3-t_4blinded5753152026282207920.5760440.2028850.2210720.423956
18ID240321_P17_3TP000projection_center_28t_4-t_5blinded5748602112762030830.5811250.2135790.2052960.418875
19ID240321_P17_3TP000projection_center_28t_5-t_6blinded5767742047332093620.5820890.2066200.2112910.417911
20ID240321_P17_3TP000projection_center_28t_6-t_7blinded5730082075802084990.5793300.2098700.2107990.420670
\n", "
" ], "text/plain": [ " ID project tag projection center delta t group \\\n", "0 ID240103_P17_1 TP000 projection_center_23 t_0-t_1 blinded \n", "1 ID240103_P17_1 TP000 projection_center_23 t_1-t_2 blinded \n", "2 ID240103_P17_1 TP000 projection_center_23 t_2-t_3 blinded \n", "3 ID240103_P17_1 TP000 projection_center_23 t_3-t_4 blinded \n", "4 ID240103_P17_1 TP000 projection_center_23 t_4-t_5 blinded \n", "5 ID240103_P17_1 TP000 projection_center_23 t_5-t_6 blinded \n", "6 ID240103_P17_1 TP000 projection_center_23 t_6-t_7 blinded \n", "7 ID240103_P17_1 TP000 projection_center_28 t_0-t_1 blinded \n", "8 ID240103_P17_1 TP000 projection_center_28 t_1-t_2 blinded \n", "9 ID240103_P17_1 TP000 projection_center_28 t_2-t_3 blinded \n", "10 ID240103_P17_1 TP000 projection_center_28 t_3-t_4 blinded \n", "11 ID240103_P17_1 TP000 projection_center_28 t_4-t_5 blinded \n", "12 ID240103_P17_1 TP000 projection_center_28 t_5-t_6 blinded \n", "13 ID240103_P17_1 TP000 projection_center_28 t_6-t_7 blinded \n", "14 ID240321_P17_3 TP000 projection_center_28 t_0-t_1 blinded \n", "15 ID240321_P17_3 TP000 projection_center_28 t_1-t_2 blinded \n", "16 ID240321_P17_3 TP000 projection_center_28 t_2-t_3 blinded \n", "17 ID240321_P17_3 TP000 projection_center_28 t_3-t_4 blinded \n", "18 ID240321_P17_3 TP000 projection_center_28 t_4-t_5 blinded \n", "19 ID240321_P17_3 TP000 projection_center_28 t_5-t_6 blinded \n", "20 ID240321_P17_3 TP000 projection_center_28 t_6-t_7 blinded \n", "\n", " Stable Gain Loss rel Stable rel Gain rel Loss tor \n", "0 433930 204228 217677 0.507025 0.238630 0.254345 0.492975 \n", "1 432111 212446 206047 0.508005 0.249759 0.242236 0.491995 \n", "2 405211 195933 239346 0.482113 0.233118 0.284770 0.517887 \n", "3 395125 212188 206019 0.485810 0.260887 0.253302 0.514190 \n", "4 394409 198677 212904 0.489347 0.246501 0.264152 0.510653 \n", "5 379787 254605 213299 0.448025 0.300351 0.251624 0.551975 \n", "6 423721 205224 210671 0.504660 0.244426 0.250914 0.495340 \n", "7 438689 206082 211293 0.512449 0.240732 0.246819 0.487551 \n", "8 432648 207045 212123 0.507913 0.243063 0.249024 0.492087 \n", "9 423170 207676 216523 0.499393 0.245083 0.255524 0.500607 \n", "10 410752 213471 220094 0.486490 0.252833 0.260677 0.513510 \n", "11 411576 207972 212647 0.494567 0.249908 0.255525 0.505433 \n", "12 392306 234492 227242 0.459353 0.274568 0.266079 0.540647 \n", "13 411051 212009 215747 0.490042 0.252751 0.257207 0.509958 \n", "14 593795 200560 205110 0.594113 0.200667 0.205220 0.405887 \n", "15 602004 196055 192351 0.607833 0.197953 0.194214 0.392167 \n", "16 595254 200853 202805 0.595902 0.201072 0.203026 0.404098 \n", "17 575315 202628 220792 0.576044 0.202885 0.221072 0.423956 \n", "18 574860 211276 203083 0.581125 0.213579 0.205296 0.418875 \n", "19 576774 204733 209362 0.582089 0.206620 0.211291 0.417911 \n", "20 573008 207580 208499 0.579330 0.209870 0.210799 0.420670 " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "\n", "title = \"all_motility.xlsx\"\n", "excel_file = Path(RESULTS_Path).joinpath(title)\n", "\n", "pixel_area_df = pd.read_excel(excel_file)\n", "pixel_area_df\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This table contains the motility metrics for each dataset for each ID, time lapse stack, project tag, and projection center. You can use this table to perform cohort-level analyses and visualize the results across all datasets.\n", "\n", "Also a summary table with the mean and standard deviation of the motility metrics for each ID and project tag is generated:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0IDproject tagprojection centeravrg Stableavrg Gainavrg Lossavrg rel Stableavrg rel Gainavrg rel Lossavrg torStable stdGain stdLoss stdrel Stable stdrel Gain stdrel Loss stdtor std
00ID240103_P17_1TP000projection_center_23409184.857143211900.142857215137.5714290.4892840.2533820.2573350.51071620997.06587819821.36668211449.9126030.0210850.0224770.0137000.021085
11ID240103_P17_1TP000projection_center_28417170.285714212678.142857216524.1428570.4928870.2512770.2558370.50711315635.3235849994.4263715627.1284100.0174500.0112990.0065590.017450
22ID240321_P17_3TP000projection_center_28584430.000000203383.571429206000.2857140.5880620.2046640.2072740.41193812093.0573885006.2726278584.4386680.0115000.0055900.0083240.011500
\n", "
" ], "text/plain": [ " Unnamed: 0 ID project tag projection center \\\n", "0 0 ID240103_P17_1 TP000 projection_center_23 \n", "1 1 ID240103_P17_1 TP000 projection_center_28 \n", "2 2 ID240321_P17_3 TP000 projection_center_28 \n", "\n", " avrg Stable avrg Gain avrg Loss avrg rel Stable \\\n", "0 409184.857143 211900.142857 215137.571429 0.489284 \n", "1 417170.285714 212678.142857 216524.142857 0.492887 \n", "2 584430.000000 203383.571429 206000.285714 0.588062 \n", "\n", " avrg rel Gain avrg rel Loss avrg tor Stable std Gain std \\\n", "0 0.253382 0.257335 0.510716 20997.065878 19821.366682 \n", "1 0.251277 0.255837 0.507113 15635.323584 9994.426371 \n", "2 0.204664 0.207274 0.411938 12093.057388 5006.272627 \n", "\n", " Loss std rel Stable std rel Gain std rel Loss std tor std \n", "0 11449.912603 0.021085 0.022477 0.013700 0.021085 \n", "1 5627.128410 0.017450 0.011299 0.006559 0.017450 \n", "2 8584.438668 0.011500 0.005590 0.008324 0.011500 " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "title = \"average_motility.xlsx\"\n", "excel_file = Path(RESULTS_Path).joinpath(title)\n", "\n", "pixel_area_df = pd.read_excel(excel_file)\n", "pixel_area_df\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Similarly, all brightness values and pixel areas are summarized in separate tables for any further analysis:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
IDproject tagprojection centert_iNormalized (btw. 0 and 1) average brightness of each stack
0ID240103_P17_1TP000projection_center_2300.337398
1ID240103_P17_1TP000projection_center_2310.341247
2ID240103_P17_1TP000projection_center_2320.341650
3ID240103_P17_1TP000projection_center_2330.353567
4ID240103_P17_1TP000projection_center_2340.351427
5ID240103_P17_1TP000projection_center_2350.351638
6ID240103_P17_1TP000projection_center_2360.343135
7ID240103_P17_1TP000projection_center_2370.343910
8ID240103_P17_1TP000projection_center_2800.333959
9ID240103_P17_1TP000projection_center_2810.335841
10ID240103_P17_1TP000projection_center_2820.336978
11ID240103_P17_1TP000projection_center_2830.340861
12ID240103_P17_1TP000projection_center_2840.339875
13ID240103_P17_1TP000projection_center_2850.340048
14ID240103_P17_1TP000projection_center_2860.340324
15ID240103_P17_1TP000projection_center_2870.340755
16ID240321_P17_3TP000projection_center_2800.527117
17ID240321_P17_3TP000projection_center_2810.527100
18ID240321_P17_3TP000projection_center_2820.527149
19ID240321_P17_3TP000projection_center_2830.527391
20ID240321_P17_3TP000projection_center_2840.528789
21ID240321_P17_3TP000projection_center_2850.528696
22ID240321_P17_3TP000projection_center_2860.528877
23ID240321_P17_3TP000projection_center_2870.529024
\n", "
" ], "text/plain": [ " ID project tag projection center t_i \\\n", "0 ID240103_P17_1 TP000 projection_center_23 0 \n", "1 ID240103_P17_1 TP000 projection_center_23 1 \n", "2 ID240103_P17_1 TP000 projection_center_23 2 \n", "3 ID240103_P17_1 TP000 projection_center_23 3 \n", "4 ID240103_P17_1 TP000 projection_center_23 4 \n", "5 ID240103_P17_1 TP000 projection_center_23 5 \n", "6 ID240103_P17_1 TP000 projection_center_23 6 \n", "7 ID240103_P17_1 TP000 projection_center_23 7 \n", "8 ID240103_P17_1 TP000 projection_center_28 0 \n", "9 ID240103_P17_1 TP000 projection_center_28 1 \n", "10 ID240103_P17_1 TP000 projection_center_28 2 \n", "11 ID240103_P17_1 TP000 projection_center_28 3 \n", "12 ID240103_P17_1 TP000 projection_center_28 4 \n", "13 ID240103_P17_1 TP000 projection_center_28 5 \n", "14 ID240103_P17_1 TP000 projection_center_28 6 \n", "15 ID240103_P17_1 TP000 projection_center_28 7 \n", "16 ID240321_P17_3 TP000 projection_center_28 0 \n", "17 ID240321_P17_3 TP000 projection_center_28 1 \n", "18 ID240321_P17_3 TP000 projection_center_28 2 \n", "19 ID240321_P17_3 TP000 projection_center_28 3 \n", "20 ID240321_P17_3 TP000 projection_center_28 4 \n", "21 ID240321_P17_3 TP000 projection_center_28 5 \n", "22 ID240321_P17_3 TP000 projection_center_28 6 \n", "23 ID240321_P17_3 TP000 projection_center_28 7 \n", "\n", " Normalized (btw. 0 and 1) average brightness of each stack \n", "0 0.337398 \n", "1 0.341247 \n", "2 0.341650 \n", "3 0.353567 \n", "4 0.351427 \n", "5 0.351638 \n", "6 0.343135 \n", "7 0.343910 \n", "8 0.333959 \n", "9 0.335841 \n", "10 0.336978 \n", "11 0.340861 \n", "12 0.339875 \n", "13 0.340048 \n", "14 0.340324 \n", "15 0.340755 \n", "16 0.527117 \n", "17 0.527100 \n", "18 0.527149 \n", "19 0.527391 \n", "20 0.528789 \n", "21 0.528696 \n", "22 0.528877 \n", "23 0.529024 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "title = \"all_brightness.xlsx\"\n", "excel_file = Path(RESULTS_Path).joinpath(title)\n", "\n", "pixel_area_df = pd.read_excel(excel_file)\n", "pixel_area_df\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
IDproject tagprojection centert_icell area in pixel rel to stack 0cell area in pixel totaltotal fov area in pixel
0ID240103_P17_1TP000projection_center_230100.0000006516071644050
1ID240103_P17_1TP000projection_center_23197.9206796380581644050
2ID240103_P17_1TP000projection_center_23298.9180606445571644050
3ID240103_P17_1TP000projection_center_23392.2249156009441644050
4ID240103_P17_1TP000projection_center_23493.2023446073131644050
5ID240103_P17_1TP000projection_center_23591.0189735930861644050
6ID240103_P17_1TP000projection_center_23697.3580706343921644050
7ID240103_P17_1TP000projection_center_23796.4914436287451644050
8ID240103_P17_1TP000projection_center_280100.0000006498821644050
9ID240103_P17_1TP000projection_center_28199.1827756445711644050
10ID240103_P17_1TP000projection_center_28298.4167906395931644050
11ID240103_P17_1TP000projection_center_28397.0708536308461644050
12ID240103_P17_1TP000projection_center_28496.0363576241231644050
13ID240103_P17_1TP000projection_center_28595.3016096193481644050
14ID240103_P17_1TP000projection_center_28696.4171966265981644050
15ID240103_P17_1TP000projection_center_28795.8420146228601644050
16ID240321_P17_3TP000projection_center_280100.0000007989051603470
17ID240321_P17_3TP000projection_center_28199.4179537942551603470
18ID240321_P17_3TP000projection_center_28299.8815887979591603470
19ID240321_P17_3TP000projection_center_28399.6372537960071603470
20ID240321_P17_3TP000projection_center_28497.3761597779431603470
21ID240321_P17_3TP000projection_center_28598.4016877861361603470
22ID240321_P17_3TP000projection_center_28697.8222697815071603470
23ID240321_P17_3TP000projection_center_28797.7072377805881603470
\n", "
" ], "text/plain": [ " ID project tag projection center t_i \\\n", "0 ID240103_P17_1 TP000 projection_center_23 0 \n", "1 ID240103_P17_1 TP000 projection_center_23 1 \n", "2 ID240103_P17_1 TP000 projection_center_23 2 \n", "3 ID240103_P17_1 TP000 projection_center_23 3 \n", "4 ID240103_P17_1 TP000 projection_center_23 4 \n", "5 ID240103_P17_1 TP000 projection_center_23 5 \n", "6 ID240103_P17_1 TP000 projection_center_23 6 \n", "7 ID240103_P17_1 TP000 projection_center_23 7 \n", "8 ID240103_P17_1 TP000 projection_center_28 0 \n", "9 ID240103_P17_1 TP000 projection_center_28 1 \n", "10 ID240103_P17_1 TP000 projection_center_28 2 \n", "11 ID240103_P17_1 TP000 projection_center_28 3 \n", "12 ID240103_P17_1 TP000 projection_center_28 4 \n", "13 ID240103_P17_1 TP000 projection_center_28 5 \n", "14 ID240103_P17_1 TP000 projection_center_28 6 \n", "15 ID240103_P17_1 TP000 projection_center_28 7 \n", "16 ID240321_P17_3 TP000 projection_center_28 0 \n", "17 ID240321_P17_3 TP000 projection_center_28 1 \n", "18 ID240321_P17_3 TP000 projection_center_28 2 \n", "19 ID240321_P17_3 TP000 projection_center_28 3 \n", "20 ID240321_P17_3 TP000 projection_center_28 4 \n", "21 ID240321_P17_3 TP000 projection_center_28 5 \n", "22 ID240321_P17_3 TP000 projection_center_28 6 \n", "23 ID240321_P17_3 TP000 projection_center_28 7 \n", "\n", " cell area in pixel rel to stack 0 cell area in pixel total \\\n", "0 100.000000 651607 \n", "1 97.920679 638058 \n", "2 98.918060 644557 \n", "3 92.224915 600944 \n", "4 93.202344 607313 \n", "5 91.018973 593086 \n", "6 97.358070 634392 \n", "7 96.491443 628745 \n", "8 100.000000 649882 \n", "9 99.182775 644571 \n", "10 98.416790 639593 \n", "11 97.070853 630846 \n", "12 96.036357 624123 \n", "13 95.301609 619348 \n", "14 96.417196 626598 \n", "15 95.842014 622860 \n", "16 100.000000 798905 \n", "17 99.417953 794255 \n", "18 99.881588 797959 \n", "19 99.637253 796007 \n", "20 97.376159 777943 \n", "21 98.401687 786136 \n", "22 97.822269 781507 \n", "23 97.707237 780588 \n", "\n", " total fov area in pixel \n", "0 1644050 \n", "1 1644050 \n", "2 1644050 \n", "3 1644050 \n", "4 1644050 \n", "5 1644050 \n", "6 1644050 \n", "7 1644050 \n", "8 1644050 \n", "9 1644050 \n", "10 1644050 \n", "11 1644050 \n", "12 1644050 \n", "13 1644050 \n", "14 1644050 \n", "15 1644050 \n", "16 1603470 \n", "17 1603470 \n", "18 1603470 \n", "19 1603470 \n", "20 1603470 \n", "21 1603470 \n", "22 1603470 \n", "23 1603470 " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "title = \"all_pixel_areas.xlsx\"\n", "excel_file = Path(RESULTS_Path).joinpath(title)\n", "\n", "pixel_area_df = pd.read_excel(excel_file)\n", "pixel_area_df\n" ] } ], "metadata": { "kernelspec": { "display_name": "motila", "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.12.9" } }, "nbformat": 4, "nbformat_minor": 2 }