**Welcome**
This repository provides ROI time series data and analysis scripts underlying our study "The hidden brain-state dynamics of tACS aftereffects" in Neuroimage (2022): https://www.sciencedirect.com/science/article/pii/S1053811922008345
**Setup**
The Matlab scripts provided here are set up such that they should be executable with minimal preparation. For the analysis to run, scripts require the fieldtrip toolbox (https://www.fieldtriptoolbox.org/) and the HMM-MAR toolbox (https://github.com/OHBA-analysis/HMM-MAR/). The code assumes that both toolboxes can be found in the toolboxes folder. For our analysis fieldtrip-20200331 was used. Paths to the data are dynamically determined by the script, given that the folder structure provided here remains as is. All Paths are defined in the beginning of the code.
**Some notes on code execution**
The analysis is computationally demanding. In particular we recommend using a workstation with at least 16GB RAM. The code was tested on a windows computer with 16GB RAM, Intel(R) Core(TM) i7-8700 CPU (3.2GHz) equipped with an SSD. Execution time of the HMM training in our experience ranged from 5 to 12 hours.
The order in which the scripts have to be executed is indicated by letters (A-C) preceding the script names. Scripts preceeded by a letter and number (e.g. C1,C2) indicate scripts, non-essential to the main analysis pipeline, that can be executed after running the main analysis step.
Please note that the HMM training includes random initialization and optimization steps. While the results several runs should be consistent in general, it is likely that some variation may occur (e.g., the order of states might be different in each run of the analysis, while their general appearance should be reproduced)