{
"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",
" ID | \n",
" project tag | \n",
" projection center | \n",
" delta t | \n",
" group | \n",
" Stable | \n",
" Gain | \n",
" Loss | \n",
" rel Stable | \n",
" rel Gain | \n",
" rel Loss | \n",
" tor | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_0-t_1 | \n",
" blinded | \n",
" 433930 | \n",
" 204228 | \n",
" 217677 | \n",
" 0.507025 | \n",
" 0.238630 | \n",
" 0.254345 | \n",
" 0.492975 | \n",
"
\n",
" \n",
" | 1 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_1-t_2 | \n",
" blinded | \n",
" 432111 | \n",
" 212446 | \n",
" 206047 | \n",
" 0.508005 | \n",
" 0.249759 | \n",
" 0.242236 | \n",
" 0.491995 | \n",
"
\n",
" \n",
" | 2 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_2-t_3 | \n",
" blinded | \n",
" 405211 | \n",
" 195933 | \n",
" 239346 | \n",
" 0.482113 | \n",
" 0.233118 | \n",
" 0.284770 | \n",
" 0.517887 | \n",
"
\n",
" \n",
" | 3 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_3-t_4 | \n",
" blinded | \n",
" 395125 | \n",
" 212188 | \n",
" 206019 | \n",
" 0.485810 | \n",
" 0.260887 | \n",
" 0.253302 | \n",
" 0.514190 | \n",
"
\n",
" \n",
" | 4 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_4-t_5 | \n",
" blinded | \n",
" 394409 | \n",
" 198677 | \n",
" 212904 | \n",
" 0.489347 | \n",
" 0.246501 | \n",
" 0.264152 | \n",
" 0.510653 | \n",
"
\n",
" \n",
" | 5 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_5-t_6 | \n",
" blinded | \n",
" 379787 | \n",
" 254605 | \n",
" 213299 | \n",
" 0.448025 | \n",
" 0.300351 | \n",
" 0.251624 | \n",
" 0.551975 | \n",
"
\n",
" \n",
" | 6 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" t_6-t_7 | \n",
" blinded | \n",
" 423721 | \n",
" 205224 | \n",
" 210671 | \n",
" 0.504660 | \n",
" 0.244426 | \n",
" 0.250914 | \n",
" 0.495340 | \n",
"
\n",
" \n",
" | 7 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_0-t_1 | \n",
" blinded | \n",
" 438689 | \n",
" 206082 | \n",
" 211293 | \n",
" 0.512449 | \n",
" 0.240732 | \n",
" 0.246819 | \n",
" 0.487551 | \n",
"
\n",
" \n",
" | 8 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_1-t_2 | \n",
" blinded | \n",
" 432648 | \n",
" 207045 | \n",
" 212123 | \n",
" 0.507913 | \n",
" 0.243063 | \n",
" 0.249024 | \n",
" 0.492087 | \n",
"
\n",
" \n",
" | 9 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_2-t_3 | \n",
" blinded | \n",
" 423170 | \n",
" 207676 | \n",
" 216523 | \n",
" 0.499393 | \n",
" 0.245083 | \n",
" 0.255524 | \n",
" 0.500607 | \n",
"
\n",
" \n",
" | 10 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_3-t_4 | \n",
" blinded | \n",
" 410752 | \n",
" 213471 | \n",
" 220094 | \n",
" 0.486490 | \n",
" 0.252833 | \n",
" 0.260677 | \n",
" 0.513510 | \n",
"
\n",
" \n",
" | 11 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_4-t_5 | \n",
" blinded | \n",
" 411576 | \n",
" 207972 | \n",
" 212647 | \n",
" 0.494567 | \n",
" 0.249908 | \n",
" 0.255525 | \n",
" 0.505433 | \n",
"
\n",
" \n",
" | 12 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_5-t_6 | \n",
" blinded | \n",
" 392306 | \n",
" 234492 | \n",
" 227242 | \n",
" 0.459353 | \n",
" 0.274568 | \n",
" 0.266079 | \n",
" 0.540647 | \n",
"
\n",
" \n",
" | 13 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_6-t_7 | \n",
" blinded | \n",
" 411051 | \n",
" 212009 | \n",
" 215747 | \n",
" 0.490042 | \n",
" 0.252751 | \n",
" 0.257207 | \n",
" 0.509958 | \n",
"
\n",
" \n",
" | 14 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_0-t_1 | \n",
" blinded | \n",
" 593795 | \n",
" 200560 | \n",
" 205110 | \n",
" 0.594113 | \n",
" 0.200667 | \n",
" 0.205220 | \n",
" 0.405887 | \n",
"
\n",
" \n",
" | 15 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_1-t_2 | \n",
" blinded | \n",
" 602004 | \n",
" 196055 | \n",
" 192351 | \n",
" 0.607833 | \n",
" 0.197953 | \n",
" 0.194214 | \n",
" 0.392167 | \n",
"
\n",
" \n",
" | 16 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_2-t_3 | \n",
" blinded | \n",
" 595254 | \n",
" 200853 | \n",
" 202805 | \n",
" 0.595902 | \n",
" 0.201072 | \n",
" 0.203026 | \n",
" 0.404098 | \n",
"
\n",
" \n",
" | 17 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_3-t_4 | \n",
" blinded | \n",
" 575315 | \n",
" 202628 | \n",
" 220792 | \n",
" 0.576044 | \n",
" 0.202885 | \n",
" 0.221072 | \n",
" 0.423956 | \n",
"
\n",
" \n",
" | 18 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_4-t_5 | \n",
" blinded | \n",
" 574860 | \n",
" 211276 | \n",
" 203083 | \n",
" 0.581125 | \n",
" 0.213579 | \n",
" 0.205296 | \n",
" 0.418875 | \n",
"
\n",
" \n",
" | 19 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_5-t_6 | \n",
" blinded | \n",
" 576774 | \n",
" 204733 | \n",
" 209362 | \n",
" 0.582089 | \n",
" 0.206620 | \n",
" 0.211291 | \n",
" 0.417911 | \n",
"
\n",
" \n",
" | 20 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" t_6-t_7 | \n",
" blinded | \n",
" 573008 | \n",
" 207580 | \n",
" 208499 | \n",
" 0.579330 | \n",
" 0.209870 | \n",
" 0.210799 | \n",
" 0.420670 | \n",
"
\n",
" \n",
"
\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",
" Unnamed: 0 | \n",
" ID | \n",
" project tag | \n",
" projection center | \n",
" avrg Stable | \n",
" avrg Gain | \n",
" avrg Loss | \n",
" avrg rel Stable | \n",
" avrg rel Gain | \n",
" avrg rel Loss | \n",
" avrg tor | \n",
" Stable std | \n",
" Gain std | \n",
" Loss std | \n",
" rel Stable std | \n",
" rel Gain std | \n",
" rel Loss std | \n",
" tor std | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" 0 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 409184.857143 | \n",
" 211900.142857 | \n",
" 215137.571429 | \n",
" 0.489284 | \n",
" 0.253382 | \n",
" 0.257335 | \n",
" 0.510716 | \n",
" 20997.065878 | \n",
" 19821.366682 | \n",
" 11449.912603 | \n",
" 0.021085 | \n",
" 0.022477 | \n",
" 0.013700 | \n",
" 0.021085 | \n",
"
\n",
" \n",
" | 1 | \n",
" 1 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 417170.285714 | \n",
" 212678.142857 | \n",
" 216524.142857 | \n",
" 0.492887 | \n",
" 0.251277 | \n",
" 0.255837 | \n",
" 0.507113 | \n",
" 15635.323584 | \n",
" 9994.426371 | \n",
" 5627.128410 | \n",
" 0.017450 | \n",
" 0.011299 | \n",
" 0.006559 | \n",
" 0.017450 | \n",
"
\n",
" \n",
" | 2 | \n",
" 2 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 584430.000000 | \n",
" 203383.571429 | \n",
" 206000.285714 | \n",
" 0.588062 | \n",
" 0.204664 | \n",
" 0.207274 | \n",
" 0.411938 | \n",
" 12093.057388 | \n",
" 5006.272627 | \n",
" 8584.438668 | \n",
" 0.011500 | \n",
" 0.005590 | \n",
" 0.008324 | \n",
" 0.011500 | \n",
"
\n",
" \n",
"
\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",
" ID | \n",
" project tag | \n",
" projection center | \n",
" t_i | \n",
" Normalized (btw. 0 and 1) average brightness of each stack | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 0 | \n",
" 0.337398 | \n",
"
\n",
" \n",
" | 1 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 1 | \n",
" 0.341247 | \n",
"
\n",
" \n",
" | 2 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 2 | \n",
" 0.341650 | \n",
"
\n",
" \n",
" | 3 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 3 | \n",
" 0.353567 | \n",
"
\n",
" \n",
" | 4 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 4 | \n",
" 0.351427 | \n",
"
\n",
" \n",
" | 5 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 5 | \n",
" 0.351638 | \n",
"
\n",
" \n",
" | 6 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 6 | \n",
" 0.343135 | \n",
"
\n",
" \n",
" | 7 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 7 | \n",
" 0.343910 | \n",
"
\n",
" \n",
" | 8 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 0 | \n",
" 0.333959 | \n",
"
\n",
" \n",
" | 9 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 1 | \n",
" 0.335841 | \n",
"
\n",
" \n",
" | 10 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 2 | \n",
" 0.336978 | \n",
"
\n",
" \n",
" | 11 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 3 | \n",
" 0.340861 | \n",
"
\n",
" \n",
" | 12 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 4 | \n",
" 0.339875 | \n",
"
\n",
" \n",
" | 13 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 5 | \n",
" 0.340048 | \n",
"
\n",
" \n",
" | 14 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 6 | \n",
" 0.340324 | \n",
"
\n",
" \n",
" | 15 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 7 | \n",
" 0.340755 | \n",
"
\n",
" \n",
" | 16 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 0 | \n",
" 0.527117 | \n",
"
\n",
" \n",
" | 17 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 1 | \n",
" 0.527100 | \n",
"
\n",
" \n",
" | 18 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 2 | \n",
" 0.527149 | \n",
"
\n",
" \n",
" | 19 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 3 | \n",
" 0.527391 | \n",
"
\n",
" \n",
" | 20 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 4 | \n",
" 0.528789 | \n",
"
\n",
" \n",
" | 21 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 5 | \n",
" 0.528696 | \n",
"
\n",
" \n",
" | 22 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 6 | \n",
" 0.528877 | \n",
"
\n",
" \n",
" | 23 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 7 | \n",
" 0.529024 | \n",
"
\n",
" \n",
"
\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",
" ID | \n",
" project tag | \n",
" projection center | \n",
" t_i | \n",
" cell area in pixel rel to stack 0 | \n",
" cell area in pixel total | \n",
" total fov area in pixel | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 0 | \n",
" 100.000000 | \n",
" 651607 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 1 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 1 | \n",
" 97.920679 | \n",
" 638058 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 2 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 2 | \n",
" 98.918060 | \n",
" 644557 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 3 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 3 | \n",
" 92.224915 | \n",
" 600944 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 4 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 4 | \n",
" 93.202344 | \n",
" 607313 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 5 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 5 | \n",
" 91.018973 | \n",
" 593086 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 6 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 6 | \n",
" 97.358070 | \n",
" 634392 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 7 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_23 | \n",
" 7 | \n",
" 96.491443 | \n",
" 628745 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 8 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 0 | \n",
" 100.000000 | \n",
" 649882 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 9 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 1 | \n",
" 99.182775 | \n",
" 644571 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 10 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 2 | \n",
" 98.416790 | \n",
" 639593 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 11 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 3 | \n",
" 97.070853 | \n",
" 630846 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 12 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 4 | \n",
" 96.036357 | \n",
" 624123 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 13 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 5 | \n",
" 95.301609 | \n",
" 619348 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 14 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 6 | \n",
" 96.417196 | \n",
" 626598 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 15 | \n",
" ID240103_P17_1 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 7 | \n",
" 95.842014 | \n",
" 622860 | \n",
" 1644050 | \n",
"
\n",
" \n",
" | 16 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 0 | \n",
" 100.000000 | \n",
" 798905 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 17 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 1 | \n",
" 99.417953 | \n",
" 794255 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 18 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 2 | \n",
" 99.881588 | \n",
" 797959 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 19 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 3 | \n",
" 99.637253 | \n",
" 796007 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 20 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 4 | \n",
" 97.376159 | \n",
" 777943 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 21 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 5 | \n",
" 98.401687 | \n",
" 786136 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 22 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 6 | \n",
" 97.822269 | \n",
" 781507 | \n",
" 1603470 | \n",
"
\n",
" \n",
" | 23 | \n",
" ID240321_P17_3 | \n",
" TP000 | \n",
" projection_center_28 | \n",
" 7 | \n",
" 97.707237 | \n",
" 780588 | \n",
" 1603470 | \n",
"
\n",
" \n",
"
\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
}