MATLAB for Brain and Cognitive Scientists

by Cohen

ISBN: 9780262364515 | Copyright 2017

Click here to preview

Instructor Requests

Digital Exam/Desk Copy Print Desk Copy Ancillaries
Tabs
Expand/Collapse All
Contents (pg. v)
Preface (pg. xv)
I Introductions (pg. 1)
1 What Is MATLAB and Why Use It? (pg. 3)
1.1 “I Want to Be a Scientist; Do I Also Need to Be a Good Programmer?” (pg. 3)
1.2 Octave (pg. 4)
1.3 Python, Julia, C, R, SPSS, HTML, and So Forth (pg. 5)
1.4 How Long Does It Take to Become a Good Programmer? (pg. 6)
1.5 How to Learn How to Program (pg. 6)
1.6 The Three Steps of Programming (pg. 7)
1.7 How Best to Learn from This Book (pg. 8)
1.8 Exercises and Their Solutions (pg. 10)
1.9 Written Interviews (pg. 11)
1.10 Where Is All the Code? (pg. 11)
1.11 Can I Use the Code in This Book for Real Data Analyses? (pg. 11)
1.12 Is This Book Right for You? (pg. 12)
1.13 Are You Excited? (pg. 12)
2 The Philosophy of Data Analysis (pg. 15)
2.1 Keep It Simple (pg. 15)
2.2 Stay Close to the Data (pg. 16)
2.3 Understand Your Analyses (pg. 17)
2.4 Use Simulations, but Trust Real Data (pg. 17)
2.5 Beware the Paralysis of Analysis (pg. 18)
2.6 Be Careful of Overfitting (pg. 19)
2.7 Noise in Neuroscience Data (pg. 21)
2.8 Avoid Circular Inference (pg. 22)
2.9 Get Free Data (pg. 23)
3 Do Replicable Research (pg. 25)
3.1 Avoid Mistakes in Data Analysis (pg. 26)
3.2 Have a “Large Enough” N (pg. 27)
3.3 Maximize Level 1 Data Count (pg. 27)
3.4 Try Different Analysis Parameters, and Trust Analytic Convergence (pg. 28)
3.5 Don’t Be Afraid to Report Small or Null Effects, but Be Honest About Them (pg. 29)
3.6 Do Split-Half Replication (pg. 29)
3.7 Independent Replications (pg. 29)
3.8 Write a Clear Methods Section (pg. 30)
3.9 Make Your Analysis Code or Data Available (pg. 30)
4 The MATLAB Program (pg. 31)
4.1 The MATLAB Program Graphical User Interface (pg. 31)
4.2 Layouts and Visual Preferences (pg. 32)
4.3 Color-Coordinating MATLAB (pg. 35)
4.4 Where Does the Code Go? (pg. 35)
4.5 MATLAB Files and Formats (pg. 37)
4.6 Changing Directories inside MATLAB (pg. 38)
4.7 The MATLAB Path (pg. 38)
4.8 Comments (pg. 40)
4.9 Cells (pg. 41)
4.10 Keyboard Shortcuts (pg. 41)
4.11 Help Box and Reporting Variable Content (pg. 43)
4.12 The Code Analyzer (pg. 45)
4.13 Back Up Your Scripts, and Use Only One Version (pg. 46)
4.14 MATLAB Etiquette (pg. 46)
5 Variables (pg. 49)
5.1 Creating and Destroying Variables (pg. 49)
5.2 Whos Are My Variables? (pg. 50)
5.3 Variable Naming Conventions and Tips (pg. 50)
5.4 Variables for Numbers (pg. 52)
5.5 Variables for Truth (pg. 54)
5.6 Variables for Strings (pg. 55)
5.7 Variables for Cells (pg. 56)
5.8 Variables for Structures (pg. 56)
5.9 The Colon Operator (pg. 57)
5.10 Accessing Parts of Variables via Indexing (pg. 58)
5.11 Initializing Variables (pg. 60)
5.12 Soft-coding versus Hard-coding (pg. 61)
5.13 Keep It Simple (pg. 62)
5.14 Exercises (pg. 62)
6 Functions (pg. 67)
6.1 Introduction to Functions (pg. 67)
6.2 Outputs as Inputs (pg. 68)
6.3 Multiple Inputs, Multiple Outputs (pg. 69)
6.4 Help (pg. 70)
6.5 Functions Are Files (pg. 71)
6.6 Writing Your Own Function (pg. 72)
6.7 Functions in Functions (pg. 74)
6.8 Arguments In (pg. 74)
6.9 Think Global, Act Local (pg. 75)
6.10 Stepping into Functions (pg. 76)
6.11 When to Use Your Own Functions (pg. 79)
6.12 When to Modify Existing Functions (pg. 80)
6.13 Timing Functions Using the Profiler (pg. 80)
6.14 Exercises (pg. 80)
7 Control Statements (pg. 85)
7.1 The Anatomy of a Control Statement (pg. 85)
7.2 If-then (pg. 85)
7.3 For-loop (pg. 91)
7.4 Skipping Forward (pg. 93)
7.5 While-loop (pg. 94)
7.6 Try-catch (pg. 97)
7.7 Switch-case (pg. 98)
7.8 Pause (pg. 98)
7.9 Exercises (pg. 99)
8 Input-Output (pg. 103)
8.1 Copy-Paste (pg. 103)
8.2 Loading .mat Files (pg. 103)
8.3 Saving .mat Files (pg. 107)
8.4 Importing Text Files (pg. 109)
8.5 Exporting Text Files (pg. 112)
8.6 Importing and Exporting Microsoft Excel Files (pg. 113)
8.7 Importing and Exporting Hardware-Specific Data Files (pg. 113)
8.8 Interacting with Your Operating System via MATLAB (pg. 114)
8.9 Exercises (pg. 114)
9 Plotting (pg. 117)
9.1 What You Need to Know Before You Know Anything Else (pg. 117)
9.2 Plotting Lines (pg. 119)
9.3 Bars (pg. 121)
9.4 Scatter Plots (pg. 122)
9.5 Histograms (pg. 123)
9.6 Subplots (pg. 124)
9.7 Patch (pg. 127)
9.8 Images (pg. 128)
9.9 Get, Set, and Handle (pg. 132)
9.10 Text in Plots (pg. 135)
9.11 Interacting with MATLAB Plots (pg. 137)
9.12 Creating a Color Axis (pg. 138)
9.13 Saving Figures as Picture Files (pg. 140)
9.14 Exercises (pg. 141)
II Foundations (pg. 145)
10 Matrix Algebra (pg. 147)
10.1 Vectors (pg. 147)
10.2 Vector Addition and Multiplication (pg. 150)
10.3 Matrices (pg. 153)
10.4 Finding Your Way around a Matrix (pg. 155)
10.5 Matrix Multiplication (pg. 156)
10.6 When to Use .* and ./ versus * and / ? (pg. 158)
10.7 Linear Independence and Rank (pg. 159)
10.8 The Matrix Inverse (pg. 160)
10.9 Solving Ax = b (pg. 161)
10.10 Making Symmetric Squares from Rectangles (pg. 162)
10.11 Full and Sparse Matrices (pg. 163)
10.12 Exercises (pg. 164)
11 The Fourier Transform (pg. 167)
11.1 Sine Waves (pg. 167)
11.2 The Imaginary Operator and Complex Numbers (pg. 168)
11.3 The Complex Dot Product (pg. 171)
11.4 Time Domain and Frequency Domain (pg. 175)
11.5 The Slow Fourier Transform (pg. 176)
11.6 Frequencies from the Fourier Transform (pg. 177)
11.7 The Fast Fourier Transform (pg. 180)
11.8 Fourier Coefficients as Complex Numbers (pg. 181)
11.9 DC Offsets in the Fourier Transform (pg. 182)
11.10 Zero-Padding the Fourier Transform (pg. 184)
11.11 The Inverse Fourier Transform (pg. 186)
11.12 The 2D Fourier Transform (pg. 187)
11.13 Exercises (pg. 188)
12 Convolution (pg. 193)
12.1 Time-Domain Convolution (pg. 194)
12.2 The Convolution Theorem (pg. 196)
12.3 Convolution Implemented in the Frequency Domain (pg. 198)
12.4 Convolution in Two Dimensions (pg. 200)
12.5 Exercises (pg. 201)
13 Interpolation and Extrapolation (pg. 205)
13.1 The MATLAB Functions griddedInterpolant and scatteredInterpolant (pg. 206)
13.2 Interpolation in Two Dimensions Using scatteredInterpolant (pg. 208)
13.3 Using interp* Functions (pg. 212)
13.4 Zero-Padding Theorem and Zero-Padding (pg. 213)
13.5 Down-sampling (pg. 214)
13.6 Exercises (pg. 218)
14 Signal Detection Theory (pg. 221)
14.1 The Four Categories of Correspondence (pg. 221)
14.2 Discrimination (pg. 222)
14.3 Isosensitivity Curves (a.k.a. ROC Curves) (pg. 224)
14.4 Response Bias (pg. 226)
14.5 Conditional Accuracy Functions (pg. 227)
14.6 Exercises (pg. 231)
15 Nonparametric Statistics (pg. 233)
15.1 The Idea of Permutation-Based Statistics (pg. 233)
15.2 Creating an Empirical Null Hypothesis Test (pg. 234)
15.3 Creating a Null Hypothesis Distribution (pg. 238)
15.4 Evaluating Significance (pg. 240)
15.5 Example with Real Data (pg. 241)
15.6 Extreme Value–Based Correction for Multiple Comparisons (pg. 244)
15.7 Meta-permutation Tests (pg. 246)
15.8 Exercises (pg. 246)
16 Covariance and Correlation (pg. 249)
16.1 Simulating and Measuring Bivariate Covariance (pg. 249)
16.2 Multivariate Covariance (pg. 252)
16.3 From Covariance to Correlation (pg. 255)
16.4 Pearson and Spearman Correlations (pg. 259)
16.5 Statistical Significance of Correlation Coefficients (pg. 261)
16.6 Geometric Interpretation of Correlation (pg. 262)
16.7 Exercises (pg. 263)
17 Principal Components Analysis (pg. 265)
17.1 Eigendecomposition (pg. 265)
17.2 Simple Example with 2D Random Data (pg. 267)
17.3 PCA and Coordinate Transformation (pg. 271)
17.4 Eigenfaces (pg. 272)
17.5 Independent Components Analysis (pg. 278)
17.6 Exercises (pg. 280)
III Analyses of Time Series (pg. 285)
18 Frequency Analyses (pg. 287)
18.1 Blitz Review of the Fourier Transform (pg. 287)
18.2 Frequency Resolution (pg. 288)
18.3 Edge Artifacts and Data Tapering (pg. 289)
18.4 Many FFTs for Many Trials (pg. 291)
18.5 Defining and Extracting Frequency Ranges (pg. 297)
18.6 Effects of Nonstationarities (pg. 301)
18.7 Spectral Coherence (pg. 302)
18.8 Steady-State Evoked Potentials (pg. 305)
18.9 Exercises (pg. 306)
19 Time-Frequency Analysis (pg. 311)
19.1 Complex Morlet Wavelets (pg. 312)
19.2 Morlet Wavelet Convolution (pg. 314)
19.3 From Line to Plane (pg. 314)
19.4 From Single Trial to Super-trial (pg. 319)
19.5 Edge Artifacts (pg. 323)
19.6 STFFT (pg. 325)
19.7 Baseline Normalization (pg. 327)
19.8 Time-Frequency Analysis in Real EEG Data (pg. 330)
19.9 Exercises (pg. 331)
20 Time Series Filtering (pg. 335)
20.1 Running-Mean Filter (pg. 335)
20.2 Running-Median Filter (pg. 337)
20.3 Edges in the Frequency Domain (pg. 339)
20.4 Gaussian Narrow-Band Filtering (pg. 341)
20.5 Finite Impulse Response Filter (pg. 345)
20.6 The Hilbert Transform (pg. 350)
20.7 Exercises (pg. 351)
21 Fluctuation Analysis (pg. 355)
21.1 Root Mean Square to Measure Fluctuations (pg. 355)
21.2 Fluctuations in Time Series (pg. 355)
21.3 Multichannel RMS (pg. 356)
21.4 Detrended Fluctuation Analysis (pg. 358)
21.5 Demeaned Fluctuation Analysis (pg. 362)
21.6 Local and Global Minima and Maxima (pg. 363)
21.7 Exercises (pg. 367)
IV Analyses of Action Potentials (pg. 369)
22 Spikes in Full and Sparse Matrices (pg. 371)
22.1 Spike Times as Full Matrices and as Sparse Vectors (pg. 371)
22.2 Mean Spike Count in Spikes per Second (pg. 375)
22.3 Peri-event Time Spike Histogram (pg. 376)
22.4 Exercises (pg. 377)
23 Spike Timing (pg. 379)
23.1 Spike Rhythmicity (pg. 379)
23.2 Spike Rhythmicity via the Frequency Domain (pg. 381)
23.3 Cross-Neuron Spike-Time Correlations (pg. 383)
23.4 Spike-Field Coherence (pg. 384)
23.5 Frequency-Specific Spike-Field Coherence (pg. 387)
23.6 Exercises (pg. 389)
24 Spike Sorting (pg. 393)
24.1 Spike Amplitude and Width (pg. 393)
24.2 Spike Features via Principal Components Analysis (pg. 395)
24.3 Spike Features via Independent Components Analysis (pg. 400)
24.4 Clustering Spikes into Discrete Groups (pg. 402)
24.5 Exercises (pg. 403)
V Analyses of Images (pg. 405)
25 Magnetic Resonance Images (pg. 407)
25.1 Importing and Plotting MRI Data (pg. 407)
25.2 fMRI Data as a Four-Dimensional Volume (pg. 408)
25.3 fMRI Statistics and Thresholding (pg. 412)
25.4 Exercises (pg. 415)
26 Image Segmentation (pg. 417)
26.1 Threshold-Based Segmentation (pg. 417)
26.2 Intensity-Based Segmentation (pg. 421)
26.3 Once More, with Calcium (pg. 423)
26.4 Defining Grids in Images (pg. 428)
26.5 Fractals and Boxes (pg. 433)
26.6 Exercises (pg. 436)
27 Image Smoothing and Sharpening (pg. 439)
27.1 Two-Dimensional Mean Filtering (pg. 439)
27.2 Two-Dimensional Median Filter (pg. 441)
27.3 Gaussian Kernel Smoothing (pg. 442)
27.4 Image Filtering in the Frequency Domain (pg. 443)
27.5 Exercises (pg. 447)
VI Modeling and Model Fitting (pg. 451)
28 Linear Methods to Fit Models to Data (pg. 453)
28.1 Least-Squares Fitting (pg. 453)
28.2 Evaluating Model Fits (pg. 455)
28.3 Polynomial Fitting Using polyfit and polyval (pg. 459)
28.4 Example: Reaction Time and EEG Activity (pg. 462)
28.5 Data Transformations Adjust Distributions (pg. 465)
28.6 Exercises (pg. 467)
29 Nonlinear Methods to Fit Models to Data (pg. 471)
29.1 Nonlinear Model Fitting with fminsearch (pg. 471)
29.2 Nonlinear Model Fitting: Piece-wise Regression (pg. 473)
29.3 Nonlinear Model Fitting: Gaussian Function (pg. 477)
29.4 Nonlinear Model Fitting: Caught in Local Minima (pg. 479)
29.5 Discretizing and Binning Data (pg. 480)
29.6 Exercises (pg. 482)
30 Neural and Cognitive Simulations (pg. 487)
30.1 Integrate-and-Fire Neurons (pg. 487)
30.2 From Neuron to Networks (pg. 490)
30.3 Izhikevich Neurons (pg. 492)
30.4 Rescorla-Wagner (pg. 494)
30.5 Exercises (pg. 500)
31 Classification and Clustering (pg. 503)
31.1 Neural Networks with Backpropagation Learning (pg. 503)
31.2 K-means Clustering (pg. 508)
31.3 Support Vector Machines (pg. 511)
31.4 Exercises (pg. 515)
VII User Interfaces and Movies (pg. 519)
32 Graphical User Interfaces (pg. 521)
32.1 Basic GUIs (pg. 521)
32.2 Getting to Know GUIDE (pg. 522)
32.3 Writing Code in GUI Functions (pg. 524)
32.4 Exercises (pg. 529)
33 Movies (pg. 531)
33.1 Waving Lines (pg. 531)
33.2 Moving Gabor Patches (pg. 534)
33.3 Spinning Heads (pg. 540)
33.4 Exercises (pg. 543)
References (pg. 545)
Index (pg. 549)

Mike X. Cohen

Mike X Cohen is Assistant Professor in the Donders Institute for Brain, Cognition, and Behavior at the Radboud University and University Medical Center, Nijmegan, the Netherlands. He is the author of Analyzing Neural Time Series Data: Theory and Practice(MIT Press).


eTextbook
Go paperless today! Available online anytime, nothing to download or install.

Features

  • Highlighting
  • Bookmarking
  • Note-taking