{
  "name": "unet-lungs-segmentation",
  "display_name": "Mouse lungs segmentation",
  "visibility": "public",
  "icon": "",
  "categories": [],
  "schema_version": "0.2.1",
  "on_activate": null,
  "on_deactivate": null,
  "contributions": {
    "commands": [
      {
        "id": "unet-lungs-segmentation.predict",
        "title": "Lungs segmentation",
        "python_name": "unet_lungs_segmentation.napari_plugin:LungsSegmentationWidget",
        "short_title": null,
        "category": null,
        "icon": null,
        "enablement": null
      }
    ],
    "readers": null,
    "writers": null,
    "widgets": [
      {
        "command": "unet-lungs-segmentation.predict",
        "display_name": "Lungs segmentation",
        "autogenerate": false
      }
    ],
    "sample_data": [
      {
        "key": "lung_ct",
        "display_name": "Mouse lung CT scan",
        "uri": "https://zenodo.org/record/8099852/files/lungs_ct.tif",
        "reader_plugin": null
      }
    ],
    "themes": null,
    "menus": {},
    "submenus": null,
    "keybindings": null,
    "configuration": []
  },
  "package_metadata": {
    "metadata_version": "2.1",
    "name": "unet-lungs-segmentation",
    "version": "1.0.9",
    "dynamic": null,
    "platform": null,
    "supported_platform": null,
    "summary": "3D U-Net model for the segmentation of the lungs in mice CT scans.",
    "description": "# \ud83d\udc2d Lungs segmentation in mice CT scans\n\nWe provide a neural network model for segmenting the lungs of the mice. The model is based on the [U-Net](https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/) architecture.\n\n<p align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/qchapp/lungs-segmentation/refs/heads/master/images/main_fig.png\" height=\"500\">\n</p>\n\nThe goal of our tool is to provid a reliable way to segment the lungs in mouse CT scans. The U-net model produces a binary mask representing the segmentation of the lungs.\n\n## Try the model \n\n- [Install the package](#installation)\n- [Follow the usage instructions](#usage-in-napari)\n\n## Installation\n\nWe recommend performing the installation in a clean Python environment.\n\nThe code requires `python>=3.9`, as well as `pytorch>=2.0`. Please install Pytorch first and separately following the instructions for your platform on [pytorch.org](https://pytorch.org/get-started/locally/).\n\nInstall `unet_lungs_segmentation` using *pip* after you've installed Pytorch:\n\n```sh\npip install unet_lungs_segmentation\n```\n\nor clone the repository and install with:\n\n```sh\ngit clone https://github.com/qchapp/lungs-segmentation.git\npip install -e .\n```\n\n## Models\n\nThe model weights (~1 GB) will be automatically downloaded from [Hugging Face](https://huggingface.co/qchapp/unet-lungs-segmentation-weights).\n\n\n## Usage in Napari\n\n[Napari](https://napari.org/stable/) is a multi-dimensional image viewer for python. To use our model in Napari, start the viewer with\n\n```sh\nnapari\n```\n\nTo open an image, use `File > Open files` or drag-and-drop an image into the viewer window. If you want to open medical image formats such as NIFTI directly, consider installing the [napari-medical-image-formats](https://pypi.org/project/napari-medical-image-formats/) plugin.\n\n**Sample data**: To test the model, you can run it on our provided sample image. In Napari, open the image from `File > Open Sample > Mouse lung CT scan`.\n\nNext, in the menu bar select `Plugins > Lungs segmentation (unet_lungs_segmentation)`. Select an image and run it by pressing the \"Segment lungs\" button.\n\n<p align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/qchapp/lungs-segmentation/refs/heads/master/images/napari-screenshot.png\" height=\"500\">\n</p>\n\n## Usage as a library\n\nYou can run a model in just a few lines of code to produce a segmentation mask from an image (represented as a numpy array).\n\n```py\nfrom unet_lungs_segmentation import LungsPredict\n\nlungs_predict = LungsPredict()\nmask = lungs_predict.segment_lungs(your_image)\n```\nor if you want to apply a specific `threshold` (`float` between 0 and 1):\n```py\nmask = lungs_predict.segment_lungs(your_image, threshold)\n```\n\n## Usage as a CLI\n\nRun inference on an image from the command-line. For example:\n\n```sh\nuls_predict_image -i /path/to/folder/image_001.tif [-t <threshold>]\n```\n\nThe `<threshold>` will be applied to the predicted image in order to have a binary mask. A default threshold of 0.5 will be applied if none is given. Should be a `float` between 0 and 1.\n\nThe command will save the segmentation next to the image:\n```\nfolder/\n    \u251c\u2500\u2500 image_001.tif\n    \u251c\u2500\u2500 image_001_mask.tif\n```\n\nRun inference in batch on all images in a folder:\n\n```sh\nuls_predict_folder -i /path/to/folder/ [-t <threshold>]\n```\nWill produce:\n```\nfolder/\n    \u251c\u2500\u2500 image_001.tif\n    \u251c\u2500\u2500 image_001_mask.tif\n    \u251c\u2500\u2500 image_002.tif\n    \u251c\u2500\u2500 image_002_mask.tif\n```\n\n## Dataset\n\nOur model was trained using a dataset of `355` images coming from 17 different experiments, 2 different scanners and validated on `62` images.\n\n## Issues\n\nIf you encounter any problems, please fill an issue along with a detailed description.\n\n## License\n\nThis model is licensed under the [BSD-3](LICENSE.txt) license.\n\n## Carbon footprint of this project\n\nAs per the online tool [*Green algorithms*](http://calculator.green-algorithms.org/), the footprint of training this model was estimated to be around 584 g CO2e.\n",
    "description_content_type": "text/markdown",
    "keywords": null,
    "home_page": "https://github.com/qchapp/lungs-segmentation.git",
    "download_url": null,
    "author": "Quentin Chappuis, Center for Imaging, Ecole Polytechnique Federale de Lausanne (EPFL)",
    "author_email": "quentin.chappuis@epfl.ch",
    "maintainer": null,
    "maintainer_email": null,
    "license": "BSD-3-Clause",
    "classifier": [
      "Development Status :: 2 - Pre-Alpha",
      "Framework :: napari",
      "Intended Audience :: Developers",
      "License :: OSI Approved :: BSD License",
      "Operating System :: OS Independent",
      "Programming Language :: Python",
      "Programming Language :: Python :: 3",
      "Programming Language :: Python :: 3.8",
      "Programming Language :: Python :: 3.9",
      "Programming Language :: Python :: 3.10",
      "Topic :: Scientific/Engineering :: Image Processing"
    ],
    "requires_dist": [
      "magicgui",
      "qtpy",
      "napari[all]>=0.4.16",
      "napari-label-focus",
      "tifffile",
      "scikit-image",
      "matplotlib",
      "csbdeep",
      "python-dotenv",
      "huggingface-hub",
      "tox; extra == \"testing\"",
      "pytest; extra == \"testing\"",
      "pytest-cov; extra == \"testing\"",
      "pytest-qt; extra == \"testing\"",
      "napari; extra == \"testing\"",
      "pyqt5; extra == \"testing\""
    ],
    "requires_python": ">=3.8",
    "requires_external": null,
    "project_url": [
      "Source Code, https://github.com/qchapp/lungs-segmentation.git"
    ],
    "provides_extra": [
      "testing"
    ],
    "provides_dist": null,
    "obsoletes_dist": null
  },
  "npe1_shim": false
}