REDCap interface
Version 1.1.0 (6.1 KB) by
Oliver_Kripfgans
Matlab REDCap interface with basic commands to read and write data. The user needs proper token and user rights to a REDCap server.
REDCap interface
Oliver D. Kripfgans, University of Michigan, 2019-2021
General notes
- The user needs an API token to communicate with REDCap server. Inquire with your administrator about obtaining a token.
- The user needs to have proper User Rights within the Project, such as 'Data Export Tool' ('Full Data Set'), 'API' ('Export', 'Import')
- The user may have to be on the database network or via VPN
- Read the examples provided, the REDCap manual and use the API playground. REDCap is very useful but under reported via google etc
REDCap.m Inputs
- 'arm' - cell array list of all arms available
- 'event' - cell array list of all events available, per arm
- 'exportfieldnames' - provides a table with fieldnames used for export
- 'filename' - returns the filename of a file associated with a field
- 'generateNextRecordName' - number of next record (when generated)
- 'init' - sets up token, url, etc.
- 'read' - reads records, fields, files, etc. Reading a field provides the field content. Reading a file requires a pathname underwhich the file is to be stored. On macOS (and Unix) the path can be for example: '~/Downloads'. On Windows 10 the path can for exmaple be: 'C:\Users\--username--\Downloads'.
- 'report' - cell array list of specified report, very useful way to extract large data amount
- 'write' - writes records, fields, files, etc. to REDCap. The maximum file size may vary. In the present setup it is ~35 MB per file. Writing a field requires the field content in exactly the format specified within REDCap! Writing a file requires a pathname from which the file is read from. Successful write replies with a '{"count": 1}', indicating that one content was written.
REDCap.m Outputs
Errors within REDCap.m are reported as:
- 0 : normal execution, no error
- -1.2: malformed input arguments to REDCap.m
- -1.3: too few arguments
- -1.4: unknown command
- -1.5: URL for REDCap server not declared
- -1.6: token not declared
Errors within redcap server/database are reported as: '{"error":"....error description ...."}'
Compatibility/Requirements
Requires system/unix calls for curl etc. as well as the webwrite command (and weboptions).
Acknowledgements
REDCap Database software from Vanderbilt University (https://redcap.vanderbilt.edu).
Built on the basis of exmaple code for other, non-Matlab, code, provided by REDCap examples.
Cite As
Oliver_Kripfgans (2024). REDCap interface (https://www.mathworks.com/matlabcentral/fileexchange/101809-redcap-interface), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2021b
Compatible with R2021b to R2023b
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.