REDCap is an online database that allows you to store experimental data. It also has an API that can be used to access data without logging directly into the system.
This repository contains MATLAB code that can pull the entire dataset from the database and store it as an Excel file on your local computer. Additional functions show how to parse the data and summarize specific portions.
It may be possible to adapt the MATLAB code to access the REDCap API using webwrite.
For now, the code uses Curl, which you need to add yourself to the Code directory - see next section.
You also need to add JSONlab to your MATLAB path - see below.
Curl is a separate program that allows you to post commands to a server and save responses to a file. It’s complicated, but this code just uses some basic functionality.
To pull data from REDCap, you need to add an executable version of Curl to the Code directory, so that when MATLAB issues a system command starting “curl something” it can launch the program.
The REDCap data is downloaded in JSON format. MATLAB has a jsondecode function but it’s fiddly.
Instead, this code uses loadjson(file_string) from JSONlab which parses the file directly into a MATLAB structure. This code was a MATLAB pick of the week.
Download the package and make sure it is on your path when you run this code.