In this tutorial, we'll learn how to use an interactive open-source toolkit, the xROI R package that facilitates the process of time series extraction and improves the quality of the final data. The xROI package provides a responsive environment for scientists to interactively:
a) delineate regions of interest (ROIs), b) handle field of view (FOV) shifts, and c) extract and export time series data characterizing color-based metrics.
Using the xROI R package, the user can detect FOV shifts with minimal difficulty. The software gives user the opportunity to re-adjust mask files or redraw new ones every time an FOV shift occurs.
The R language and Shiny package were used as the main development tool for xROI,
interactivity. While Shiny apps are primarily used for web-based applications to
be used online, the package authors used Shiny for its graphical user interface
capabilities. In other words, both the User Interface (UI) and server modules are run
locally from the same machine and hence no internet connection is required (after
installation). The xROI's UI element presents a side-panel for data entry and
three main tab-pages, each responsible for a specific task. The server-side
element consists of R and bash scripts. Image processing and geospatial features
were performed using the
Geospatial Data Abstraction Library (GDAL) and the
raster R packages.
The xROI R package has been published on The Comprehensive R Archive Network (CRAN). The latest tested xROI package can be installed from the CRAN packages repository by running the following command in an R environment.
utils::install.packages('xROI', repos = "http://cran.us.r-project.org" )
Alternatively, the latest beta release of xROI can be directly downloaded and installed from the development GitHub repository.
# install devtools first utils::install.packages('devtools', repos = "http://cran.us.r-project.org" ) # use devtools to install from GitHub devtools::install_github("bnasr/xROI")
xROI depends on many R packages including:
RCurl. All the required libraries and
packages will be automatically installed with installation of xROI. The package
offers a fully interactive high-level interface as well as a set of low-level
functions for ROI processing.
A comprehensive user manual for low-level image processing using xROI is available from CRAN xROI.pdf. While the user manual includes a set of examples for each function; here we will learn to use the graphical interactive mode.
Launch() function, as we'll do below, opens up the interactive
mode in your operating system’s default web browser. The landing page offers an
example dataset to explore different modules or upload a new dataset of images.
You can launch the interactive mode can be launched from an interactive R environment.
# load xROI library(xROI) # launch xROI Launch()
Or from the command line (e.g. bash in Linux, Terminal in macOS and Command Prompt in Windows machines) where an R engine is already installed.
Rscript -e “xROI::Launch(Interactive = TRUE)”
When you are done with the xROI interface you can close the tab in your browser and end the session in R by using one of the following options
In RStudio: Press the
To get some hands-on experience with
xROI, we can analyze images from the
of the PhenoCam network.
You can download the data set from this link (direct download).
Follow the steps below:
First,save and extract (unzip) the file on your computer.
Second, open the data set in
xROI by setting the file path to your data
# launch data in ROI # first edit the path below to the dowloaded directory you just extracted xROI::Launch('/path/to/extracted/directory') # alternatively, you can run without specifying a path and use the interface to browse
Now, draw an ROI and the metadata.
Then, save the metadata and explore its content.
Now we can explore if there is any FOV shift in the dataset using the
CLI processer tab.
Finally, we can go to the
Time series extraction tab. Extract the time-series. Save the output and explore the dataset in R.
Download and extract the data set from this link (direct download, 218 MB) and follow the above steps to extract the time-series.
Get Lesson Code
If you have questions or comments on this content, please contact us.