{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":71698,"databundleVersionId":7906362,"sourceType":"competition"}],"dockerImageVersionId":30698,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"# Example notebook for BugNIST 2024 dataset\nThis notebooks plots the volumes in 2d and 3d.\n\n<font color=#FF0000>**The notebook needs to run locally for the plots to work**</font>\n\n## Overview\n### Goal\nWe welcome you to the BugNIST challenge, which is part of the FGVC11 workshop at CVPR 2024. Here you will compete in detecting and classifying objects in volumes under domain shift and hereby contribute to advancing methods for the analysis of volumetric data. Based on volumes containing one bug each, your task is to train a model that can detect and classify bugs in volumes that contain several bugs mixed with other materials.\n\n### Why does it matter?\nIn volumetric imaging, it is often necessary to detect and classify objects that are densely packed in a mixture of other objects or materials that are not of interest. Annotating such data is tedious and difficult, and instead, it is much easier to scan some representative examples of the type of objects that should be detected. The problem is that individually scanned objects are placed in a context that is very different from the mixed objects that we wish to detect. This is a domain shift, where the objects of interest have the same appearance, but the context surrounding the objects is different.\n\nTo promote the development of new methods for domain adaptation in volumetric scans, we have created the BugNIST dataset, which is the basis for the BugNIST challenge. The dataset is based on 12 types of bugs such as larvae, pupae, grasshoppers, etc. The training data is more than 700 micro-CT scans of individual bugs of each type, whereas the test data is mixtures.\n\n## Description\nWe provide the scans of individual bugs for training, a validation set of mixtures with annotated center point coordinates and bug type, and two test sets of mixtures without annotations for the public and private leaderboards. Your task is to build a model that predicts the center points and bug type for the mixed volumes.\n\nFor training the model, the total number of volumes of individual bugs is 9185. There are 388 mixtures, where a validation set of 78 is provided with center point annotation and 155 mixture volumes are for the public and private leader boards respectively.\n\n","metadata":{}},{"cell_type":"code","source":"!pip install -q qim3d","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import qim3d\nimport qim3d.processing.filters as filters\n\nimport os","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Exploration\nWe start by visualizing an example insect volume (`BugNIST_DATA/train/AC/bcrick_1_000.tif`) from the training set in both 2D and 3D.","metadata":{}},{"cell_type":"code","source":"data_dir = \"bugnist2024\"\nvol = qim3d.io.load(os.path.join(data_dir, \"BugNIST_DATA/train/AC/bcrick_1_000.tif\"))","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"qim3d.viz.orthogonal(vol)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"qim3d.viz.vol(vol) ","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### For validation\nWe can then do the same for a mixture volume (`BugNIST_DATA/val/val_000.tif`) from the validation set.\nFrom the 3d visualization, we can see that the mixture volume contains multiple bugs.\nThe bugs a close together and some are even touching each other. This makes the task of detecting and classifying the bugs more challenging.\nThe background is also not uniform and contains noise from the material that the bugs are placed in.","metadata":{}},{"cell_type":"code","source":"vol = qim3d.io.load(os.path.join(data_dir, \"BugNIST_DATA/validation/mix_03_001.tif\"))","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"qim3d.viz.orthogonal(vol)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"qim3d.viz.vol(vol) ","metadata":{},"execution_count":null,"outputs":[]}]}