knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(labelMe)

Introduction

labelMe is an R package for the preparation of a training dataset of ultrasound images for the purposes of an image labeling algorithm. In hospitals, this is commonly done manually, by opening and renaming each DICOM file. Here, the process allows the user to leverage the interface of a web browser, making the process significantly more streamlined and sustainable for the 1000s of labels they will have to prepare to train a given algorithm. It also runs entirely locally, so no need to worry about privacy measures for shielding patient data.

Data preparation

Currently, the application accepts these standard MIME image types: png, jpeg, jpg; DICOM images must be converted before upload.

Data can be uploaded all at once, as the application can support hosting of several thousand images. However, it is recomended that you instead work in chunks of data that you intend to complete within the course of 1 session, ideally organized sequentially by patient. This is due to the navigation design of the application, which is entirely based on the arrow keys, optimized for speed of labeling. Upload of the data is done within the session, by interaction with the file browser input on the right-hand side panel of the interface.

Labeling

Labels are specified on session startup, and can currently support 2 label classes of arbitrary length (2 radio button columns with as many choices as you'd like).

Select a label to pertain to an image by pressing a radio label on each of the columns; this automatically saves your selection to the session's data storage. Navigate between images using the right/left arrow keys until you've completed image labeling. Note that your selection is confirmed by the text displayed immediately below the image This image has been labeled: X, Y (where X and Y are your radio button selections), immediately after completing the selection. This confirms that your label has been stored.

Data Export and Flushing

Once you have completed the labeling, click the "Download DATE-labels.csv" button to download the CSV to your local machine. If the application is open in your web browser, a file named DATE-labels.CSV (where DATE is replaced by YYYY-MM-DD) will be saved to your Downloads folder.

To repeat the labeling effort with the same labels but new images, click the "Flush Data" button on the right-side panel to remove labeled images and all their associated data from the session. Labels are no longer stored or available after flushing, so ensure data export is done prior to flushing.

Tracking Label Proportions

Within app session

Tracking label proportions is not yet possible in the webapp. Simply view summary stats related to your labeling, export the data and load the CSV as a dataframe for the getLabelProportions() function (see code in the section below).

Outside of app session

# Creating test data 
# In the webapp, a compatible CSV is automatically generated:
exampleDF <- data.frame(
    image_key = c(1,2,3,4),
    label_1 = c("Saggital", "Saggital", "Transverse", "Bladder"),
    label_2 = c("Right", "Right", "Left", "NA")
)

# Viewing the data proportions:
getLabelProportions(exampleDF)

If you have another CSV prepared, or have a serialized a dataset to analyze you can simply convert the CSV to a dataframe (for example, via as.data.frame()) and proceed as above

References

Attali, D. (2015 April 21). Supplementing your R package with a Shiny app. Retrieved from https://deanattali.com/2015/04/21/r-package-shiny-app/

Laurent, S. (2019 September 11). Render images for interactive display from folder loaded with shinyDirChoose [StackOverflow page]. Retrieved from https://stackoverflow.com/questions/57891201/render-images-for-interactive-display-from-folder-loaded-with-shinydirchoose

Steipe, B. (2019). rpt (R Package Template) [Github page]. Retrieved from https://github.com/hyginn/rpt

sessionInfo()


gabmorg/labelMe documentation built on Dec. 8, 2019, 12:36 p.m.