MATLAB for Neuroimaging
What is MATLAB?
MATLAB is a programming language and an interactive environment utilized by researchers for versatile reasons. While MATLAB has a graphical interface with point and click on icons to run commands ("MATLAB Desktop"), MATLAB primarily operates through a command line interface.
Applications in Research:
- Advanced statistical testing and data fitting
- Automate routine data processing tasks
- Designing and executing complex experimental tasks, including real-time data collection and behavioral tracking
- Develop computational models and apply machine learning algorithms
- Processing and analyzing neuroimaging data
This resource reviews several foundational MATLAB skills, as well as provides a step-by-step tutorial on using MATLAB batch scripts to run neuroimaging analyses with SPM.
Workspace Basics
Introduces the MATLAB interface, including essential windows like the Command Window, Current Folder, and Workspace. It explains how to customize the interface, navigate directories, and manage the search path to optimize your workflow.
MATLAB Elements and Syntax
Covers the fundamental building blocks of MATLAB, such as variables, arrays, strings, and special characters. It also discusses accessing and manipulating elements within arrays and the importance of syntax, including MATLAB's sensitivity to case and spacing.
Working with Data
Describes data types and classes in MATLAB, such as numeric, character, and logical types. It also covers array operations, such as concatenation, reshaping, and arithmetic operations. The section includes a command cheat sheet for handling data in MATLAB.
Handling Files
Provides an overview of MATLAB file types, including scripts, live scripts, and MAT files. It covers importing and exporting data, and offers a command cheat sheet for file operations, including reading, writing, and managing files in various formats.
Scripts and Functions
Discusses structuring MATLAB code efficiently, with an emphasis on writing functions and using loops and conditional statements. The section includes a cheat sheet for programming commands and provides resources for troubleshooting and debugging in MATLAB.
TUTORIAL: Neuroimaging Analysis with MATLAB and SPM
This section provides a step-by-step guide to analyzing fMRI data using MATLAB and SPM, focusing on scripting and command-line processing instead of the SPM GUI. You'll learn how to download an fMRI dataset from OpenNeuro, preprocess it, and perform first-level and group analyses using pre-written batch scripts available in the matlab-spm-scripts-jsh GitHub repository.