Jean-Philippe Boucher, Université du Québec À Montréal (🐦 @J_P_Boucher)
Arthur Charpentier, Université du Québec À Montréal (🐦 @freakonometrics)
Ewen Gallic, Aix-Marseille Université (🐦 @3wen)
This hands-on session focuses on pictures. The objective is to manipulate images to perform classification tasks.
The first application consists in detecting Parkinson’s disease from hand-drawn images of spirals and waves. This application is inspired by Adrian Rosebrock’s tutorial.
The idea is to compare spiral or wave images drawn by patients with Parkinson’s disease or by patients without it. Patients with Parkinson’s disease, as shown in Zham et al. (2017), draw less quickly and with less pressure than other test subjects. In the tutorial, Adrian Rosebrock mentions that João Paulo Folador, a Brazilian Ph.D. student explored the following idea: maybe it is possible to detect Parkinson’s disease from the sole images, without measuring speed and pressure of the pen on paper.
In this first part of the hands-on session, we will train a classifier to automatically detect whether a patient is suffering from Parkinson’s disease.
To that end, we have a set of image data organized as follows:
Spiral data:
Wave data:
We will adopt the following strategy:
The hand-drawings of the subjects are provided as PNG files, according to the following tree structure (we will focus on the spiral test only):
pictures
├── donnees
│ └── dataset-parkinson
│ └── spiral
│ └── testing
│ │ └── healthy
│ │ │ └── V01HE01.png
│ │ │ └── ...
│ │ │ └── V55HE15.png
│ │ └── parkinson
│ │ │ └── V01PE01.png
│ │ │ └── ...
│ │ │ └── V15PE015.png
│ └── training
│ │ └── healthy
│ │ │ └── V01HE02.png
│ │ │ └── ...
│ │ │ └── V55HE11.png
│ │ └── parkinson
│ │ │ └── V01PE02.png
│ │ │ └── ...
│ │ │ └── V15PE03.png
The file names can be used to determine whether or not the individual has Parkinson’s disease (P for Parkinson’s or H for Healthy). The data are already split into a training and a testing sample.
To load images into R, the {OpenImageR
} package can be used. To easily manipulate data, we will also need {tidyverse
}.
To load an image into R, the imager::load.image()
function just needs the path to the file. It returns an object of class 'cimg'
.
Let us load an image from a healthy subject:
path <- "../donnees/dataset-parkinson/spiral/training/healthy/V01HE02.png"
image <- imager::load.image(path)
class(image)
## [1] "cimg" "imager_array" "numeric"
## Image. Width: 256 pix Height: 256 pix Depth: 1 Colour channels: 3
A quick peek at the structure of the image shows that the object is made up of a four-dimensional array:
## 'cimg' num [1:256, 1:256, 1, 1:3] 0.953 0.949 0.953 0.941 0.941 ...
The drawing of the healthy subject can be plotted using the plot()
function: