{ "cells": [ { "metadata": {}, "cell_type": "markdown", "source": "# Tutorial 2: Peak Detection", "id": "4c48d03aad328d99" }, { "metadata": {}, "cell_type": "markdown", "source": [ "Peak detection relies on [`mlgidDETECT`](https://github.com/mlgid-project/mlgidDETECT) package.\n", "First, create the mlgidBASE class instance:\n", "\n" ], "id": "98af50c67672ea3e" }, { "metadata": { "ExecuteTime": { "end_time": "2026-04-07T13:04:20.781169652Z", "start_time": "2026-04-07T13:04:18.305491794Z" } }, "cell_type": "code", "source": [ "from mlgidbase import mlgidBASE\n", "filename = '../../example/BA2PbI4.h5'\n", "analysis = mlgidBASE(filename=filename)" ], "id": "317d95356153e07f", "outputs": [], "execution_count": 1 }, { "metadata": {}, "cell_type": "markdown", "source": [ "Then run detection:\n", "\n", "---\n", "#### **Minimal Code Example**" ], "id": "48a0e8474c1c8867" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "analysis.run_detection()", "id": "dcb3019b7a7c8b11" }, { "metadata": {}, "cell_type": "markdown", "source": [ "---\n", "\n", "### Parameters\n", "\n", "- `entry` (str) — Data file entry to process. Defaults to `None` (all entries). OPTIONAL\n", "- `frame_num` (int/List[int]) — Frame number in each entry for detection / list of frames. Defaults to `None` (all frames).\n", "- `config_file` (str) — Path to detection configuration file. Defaults to `None` (default parameters). OPTIONAL\n", "- `model_type` (str) — Name of the model `dino` or `faster_rcnn`. OPTIONAL" ], "id": "574c715f5391f556" }, { "metadata": {}, "cell_type": "markdown", "source": [ "---\n", "\n", "### Decription\n", "The user can specify a single entry or process all entries in the file by setting `entry=None`. The `frame_num` parameter accepts either a single `int` or a `list` of frame indices to process.\n", "\n", "The detection configuration can be loaded from a [YAML file](https://github.com/mlgid-project/mlgidDETECT/blob/main/detr.yaml). Additionally, the detection model can be selected via the `model_type` parameter. Currently, two models are supported: `dino` and `faster_rcnn`, as described in the recent work by C. Völter.\n", "\n", "Informational logs indicate whether the detection model is being loaded. After the initial load, both the model and its configuration remain fixed; any subsequent configuration inputs will be ignored. To apply a different configuration, a new `mlgidBASE` instance must be created with the desired settings." ], "id": "78373fce7dbc5716" }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": [ "analysis = mlgidBASE(filename=filename)\n", "analysis.run_detection(\n", " entry='entry_0000',\n", " frame_num=0,\n", " config_detect='../../example/config.yaml',\n", " model_type = 'faster_rcnn')" ], "id": "6e28e53639b727f4" }, { "metadata": {}, "cell_type": "markdown", "source": "The results can be visualized using `silx view` or loaded from the saved file, as shown in [Tutorial 8](tutorial_08_get_data.ipynb).", "id": "97cc66d88894ed1" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }