Home > vbmeg > functions > tool_box > dynamics_movie > test_fig > basic_tool > load_ar_dynamics.m

load_ar_dynamics

PURPOSE ^

load AR dynamics parameter

SYNOPSIS ^

function [Jpred, Ipred] = load_ar_dynamics(id, p, input)

DESCRIPTION ^

 load AR dynamics parameter

 load parameters
 id.I_from : start vertex index
 id.I_to   : end vertex index

 2014-11-10 Masa-aki Sato

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [Jpred, Ipred] = load_ar_dynamics(id, p, input)
0002 % load AR dynamics parameter
0003 %
0004 % load parameters
0005 % id.I_from : start vertex index
0006 % id.I_to   : end vertex index
0007 %
0008 % 2014-11-10 Masa-aki Sato
0009 %
0010 % Copyright (C) 2011, ATR All Rights Reserved.
0011 % License : New BSD License(see VBMEG_LICENSE.txt)
0012 
0013 if isempty(p.arfile)
0014     % id.I_from : start vertex index
0015     NP = length(id.I_from);
0016     w  = (rand(NP,1) + 2)*p.omega;
0017     t  = 0:p.dt:2*pi;
0018     Jpred = sin(w*t);
0019     Ipred = 1:NP;
0020 elseif ~isempty(whos('-file', p.arfile, 'wsevents'))
0021     load(p.arfile);
0022     parcel_from_list = pairs(:, 1);
0023     Npair = length(parcel_from_list);
0024     
0025     Ntime = size(wsevents, 2);
0026     Jpred = zeros(Npair, Ntime);
0027     for k=1:Npair
0028         Jpred(k, :) = wsevents(parcel_from_list(k), :);
0029     end
0030     Ipred = 1:Npair;
0031 elseif ~isempty(whos('-file', p.arfile, 'MAR'))
0032     load(p.arfile,'MAR','Delta','omega','Index_orig')
0033     
0034     if nargin==3
0035         omega = input;
0036     end
0037     
0038     % Predicted currents (Output of the system with the input 'omega')
0039     [Jpred] = forward_prediction(MAR, Delta, omega);
0040     
0041     %plot(Jpred(Index_orig==I_from(nv),:))
0042     
0043     % Index_orig correspond to Jpred
0044     
0045     % Convert from-index to index of Jpred
0046     NP = length(Index_orig);
0047     NM = max([Index_orig(:); id.I_from(:)]);
0048     ID = zeros(NM,1);
0049     
0050     % index convert table
0051     ID(Index_orig) = 1:NP;
0052     
0053     % convert from-index to index of Jpred
0054     I_from = ID(id.I_from);
0055     
0056     % exclude index outside of Index_orig
0057     Ipred = find(I_from > 0);
0058     
0059     Jpred = Jpred(I_from(Ipred),:);
0060     
0061     if length(Ipred) < length(I_from),
0062         fprintf('There are mismatch between Index_orig and Index_from!!\n\n')
0063     end
0064 else
0065     load(p.arfile, 'Z', 'Index_orig')
0066     Jpred = Z;
0067     
0068     % Convert from-index to index of Jpred
0069     NP = length(Index_orig);
0070     NM = max([Index_orig(:); id.I_from(:)]);
0071     ID = zeros(NM,1);
0072     
0073     % index convert table
0074     ID(Index_orig) = 1:NP;
0075     
0076     % convert from-index to index of Jpred
0077     I_from = ID(id.I_from);
0078     
0079     % exclude index outside of Index_orig
0080     Ipred = find(I_from > 0);
0081     
0082     Jpred = Jpred(I_from(Ipred),:);
0083     
0084     if length(Ipred) < length(I_from),
0085         fprintf('There are mismatch between Index_orig and Index_from!!\n\n')
0086     end
0087 end
0088

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005