/chagas_detection

This repository contains the codes for T. cruzi detection in mobile phone images.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Introduction

Chagas detection is a tool for the detection of T. cruzi trypomastigote forms in blood smear images. In particular, it provides a machine learning based method for the detection of parasites in images acquired using a mobile phone camera. This repository contains the codes for T. cruzi detection. The images for training and testing the model are available at Zenodo.

DOI Python Contributions welcome License

Functionality

T. cruzi detection image analysis pipeline.

This repo contains the following functionality:

  1. my_tools.py contains auxiliary, and image data processing functions.

  2. process_image.py runs the image processing, feature extraction and classification on a single image.

  3. process_all_images.py runs the image processing and feature extraction on all images.

  4. features_classification.py trains and assess model performance based one extracted features.

  5. images_info.csv contains image metadata

    • filename: the image file name.
    • width: image width in pixels.
    • height: image height in pixels.
    • n_structures: number of labeled parasite structures.
    • resize_factor: scale factor to reduce image.
    • set: image used for model training or testing.
  6. positions_data.csv contains the position of each parasite object (nucleus or kinetoplast) in the respective image.

    • filename: the image file name.
    • x, y: the structure position (x, y) in the image.
    • structure: the name of the annotated structure.
    • set: image used for model training or testing.
    • new_x, new_y: the structure position (x, y) in the image after resizing.
  7. features_data.csv contains the extracted feature values from each image.

    • filename: the image file name.
    • parasite_ID: the number of the parasite in the image.
    • label: the parasite segment number
    • centroid_x, centroid_y: the position (x, y) of the parasite in given 100 x 100 pixel^2^ area.
    • area : curvature_energy: geometric, color texture and invariant moment features of the parasites.
    • structure: presence (True) or absence (False) of the parasite in the segmented region.
  8. images/ and models/ folders contains the sample test image and the trained models, respectively.

  9. object_selection_knn.py Script to select samples for the training/test dataset

NOTE: This tool is a command-line Python script, without graphical user interface (GUI) at the moment. Since these analysis steps are often performed in different datasets, all the provided functions should be fast to implement and automate. It is not intended for diagnosis, but for research purpose only.

Installation

The simplest way to install this tool is to clone this repository and create an Anaconda (or mini-conda) environment with the required libraries. An Anaconda install guide is available here. To clone this repository open a terminal window and type:

git clone https://github.com/csbl-br/chagas_detection.git

Usage

Example of detection T. cruzi in low-resolution image.

Save the image at ./images/ folder and run process_image.py to analyze single file.

$ python3 process_image.py

Run process_all_images.py to extract features from all images, followed by feature_classification.py to train a model.


License

These codes are free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation (GNU General Public License v3.0). It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY and LIABILITY; without even the implied warranty of fitness for a particular purpose, including diagnostic. See the GNU General Public License for more details.