Skip to main content
Social Sci LibreTexts

9.10: Matlab Scripts For This Chapter

  • Page ID
    137627
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    I’ve created a set of three scripts that shows how to implement the artifact correction approach described in this chapter. There are three scripts, which you can find in the Chapter_9 folder. The script names begin with MMN_artifact_correction_ and then end in phase1, phase2, or phase3. They divide the process into—you guessed it!—three phases.

    • The first phase takes the original dataset and creates a copy that is optimized for the ICA decomposition by filtering from 1-30 Hz, downsampling to 100 Hz, deleting the break periods, and rejecting segments that contain huge C.R.A.P. artifacts.
    • The second phase performs the ICA decomposition on this optimized dataset. I put that in a separate script because it takes quite a while to run.
    • The third phase transfers the ICA weights to the original dataset, removes the artifactual ICs, and then interpolates any bad channels.

    The script processes the data from Subjects 1–10. I spent an entire afternoon going through the data carefully, deciding which channels should be interpolated, determining which ICs to remove, etc. But even after devoting that much time, I did only a superficial job. You can probably do better if you spend more time.

    While I was going through the data to determine the various parameters for a given participant, I put the parameters in a set of spreadsheets. The scripts then read from these spreadsheets. For the first two phases, I didn’t actually run the scripts on all 10 participants at once. As noted in the comments inside the scripts, you can modify the scripts slightly to work on one participant at a time. I went back and forth between the scripts and the GUI to set the various parameters. You won’t need to do that to run the scripts, because all the parameters are in the spreadsheets (which are provided in the Chapter_9 folder). However, you’ll probably want to adopt this one-participant-at-a-time approach when you’re analyzing your own data.

    Note that the Excel spreadsheets contain a column for comments. These comments aren’t used by the scripts, but they’re very useful in helping you to remember why you made various decisions. Your future self will thank you.


    This page titled 9.10: Matlab Scripts For This Chapter is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Steven J Luck directly on the LibreTexts platform.

    • Was this article helpful?