You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: DEM_demo_modes_fMRI.m
    path of file: ./repos/spm12/toolbox/DEM
    
    the code of the file until where you have to start completion: function DEM_demo_modes_fMRI
% Demonstration of spectral DCM for fMRI with eigenvector constraints
%__________________________________________________________________________
% This demonstration routine illustrates the inversion of resting state
% fMRI timeseries using a generative model of the adjacency matrix. This
% model is based upon the eigenmodes of the functional connectivity matrix,
% which are the eigenvectors of the effective connectivity matrix or
% Jacobian - assuming the effective connectivity is symmetrical. This means
% it is only necessary to estimate the eigenvalues; in other words, one
% unknown parameter per node.
%
% Simulated timeseries are generated and inverted under typical priors.
% This routine then performs a model space search over the decay rates of
% stable (dissipative) modes and the number of unstable modes.
% This illustrates: (i) the increase in model evidence afforded by
% hierarchical constraints (when they are true) and (ii) the identification
% of the principle modes underlying connectivity.
%
% NB: To see the model optimisation delete the 'return' at about line 200
% 
% see also: DEM_demo_connectivity_fMRI
%           spm_dcm_fmri_mode_gen
%           spm_dcm_fmri_mode
%__________________________________________________________________________
% Copyright (C) 2014 Wellcome Trust Centre for Neuroimaging

% Karl Friston
% $Id: DEM_demo_modes_fMRI.m 5838 2014-01-18 18:40:37Z karl $


% Simulate timeseries
%==========================================================================
rng('default')

% DEM Structure: create random inputs
% -------------------------------------------------------------------------
ED    = 3;                               % embedding dimensional
DE    = 1;                               % log decay of stable modes (secs)
T     = 1024;                            % number of observations (scans)
TR    = 2;                               % repetition time or timing
n     = 6;                               % number of regions or nodes
t     = (1:T)*TR;                        % observation times


% empirical covariance matrix
% -------------------------------------------------------------------------
Cy    = [
    1.0073   -0.4669   -0.3647    0.5984    0.4378    0.6177
   -0.4669    0.8979    0.2469   -0.4208   -0.2764   -0.4382
   -0.3647    0.2469    0.4027   -0.2821   -0.1795   -0.2702
    0.5984   -0.4208   -0.2821    0.7553    0.4419    0.6125
    0.4378   -0.2764   -0.1795    0.4419    0.4634    0.3947
    0.6177   -0.4382   -0.2702    0.6125    0.3947    0.9421];


% modes and exponents
% -------------------------------------------------------------------------
u     = spm_svd(Cy);


% priors
% -------------------------------------------------------------------------
options.nmax       = 8;                % effective number of nodes
options.Nmax       = 64;               % maximum number of iterationsno
options.two_state  = 0;
options.induced    = 1;
options.stochastic = 0;
options.nonlinear  = 0;
options.decay      = DE;
options.precision  = 0;


A   = full(sparse(1:ED,1,1,n,1));
B   = zeros(n,n,0);
C   = zeros(n,n);
D   = zeros(n,n,0);


% true parameters (reciprocal connectivity)
% -------------------------------------------------------------------------
[pP,pC,x]  = spm_dcm_fmri_priors(A,B,C,D,options);
pP.A(1:ED) = linspace(2,0,ED); 
pA         = spm_dcm_fmri_mode_gen(pP.A,u); 

    
function DEM_demo_modes_fMRI
% Demonstration of spectral DCM for fMRI with eigenvector constraints
%__________________________________________________________________________
% This demonstration routine illustrates the inversion of resting state
% fMRI timeseries using a generative model of the adjacency matrix. This
% model is based upon the eigenmodes of the functional connectivity matrix,
% which are the eigenvectors of the effective connectivity matrix or
% Jacobian - assuming the effective connectivity is symmetrical. This means
% it is only necessary to estimate the eigenvalues; in other words, one
% unknown parameter per node.
%
% Simulated timeseries are generated and inverted under typical priors.
% This routine then performs a model space search over the decay rates of
% stable (dissipative) modes and the number of unstable modes.
% This illustrates: (i) the increase in model evidence afforded by
% hierarchical constraints (when they are true) and (ii) the identification
% of the principle modes underlying connectivity.
%
% NB: To see the model optimisation delete the 'return' at about line 200
% 
% see also: DEM_demo_connectivity_fMRI
%           spm_dcm_fmri_mode_gen
%           spm_dcm_fmri_mode
%__________________________________________________________________________
% Copyright (C) 2014 Wellcome Trust Centre for Neuroimaging

% Karl Friston
% $Id: DEM_demo_modes_fMRI.m 5838 2014-01-18 18:40:37Z karl $


% Simulate timeseries
%==========================================================================
rng('default')

% DEM Structure: create random inputs
% -------------------------------------------------------------------------
ED    = 3;                               % embedding dimensional
DE    = 1;                               % log decay of stable modes (secs)
T     = 1024;                            % number of observations (scans)
TR    = 2;                               % repetition time or timing
n     = 6;                               % number of regions or nodes
t     = (1:T)*TR;                        % observation times


% empirical covariance matrix
% -------------------------------------------------------------------------
Cy    = [
    1.0073   -0.4669   -0.3647    0.5984    0.4378    0.6177
   -0.4669    0.8979    0.2469   -0.4208   -0.2764   -0.4382
   -0.3647    0.2469    0.4027   -0.2821   -0.1795   -0.2702
    0.5984   -0.4208   -0.2821    0.7553    0.4419    0.6125
    0.4378   -0.2764   -0.1795    0.4419    0.4634    0.3947
    0.6177   -0.4382   -0.2702    0.6125    0.3947    0.9421];


% modes and exponents
% -------------------------------------------------------------------------
u     = spm_svd(Cy);


% priors
% -------------------------------------------------------------------------
options.nmax       = 8;                % effective number of nodes
options.Nmax       = 64;               % maximum number of iterationsno
options.two_state  = 0;
options.induced    = 1;
options.stochastic = 0;
options.nonlinear  = 0;
options.decay      = DE;
options.precision  = 0;


A   = full(sparse(1:ED,1,1,n,1));
B   = zeros(n,n,0);
C   = zeros(n,n);
D   = zeros(n,n,0);


% true parameters (reciprocal connectivity)
% -------------------------------------------------------------------------
[pP,pC,x]  = spm_dcm_fmri_priors(A,B,C,D,options);
pP.A(1:ED) = linspace(2,0,ED); 
pA         = spm_dcm_fmri_mode_gen(pP.A,u); 
pP.C       = eye(n,n);
pP.transit = randn(n,1)*exp(-4);
disp(pA)

% simulate response to end