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.
This repo contains the following functionality:
-
my_tools.py
contains auxiliary, and image data processing functions. -
process_image.py
runs the image processing, feature extraction and classification on a single image. -
process_all_images.py
runs the image processing and feature extraction on all images. -
features_classification.py
trains and assess model performance based one extracted features. -
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.
-
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.
-
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.
-
images/
andmodels/
folders contains the sample test image and the trained models, respectively. -
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.
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
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.
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.