<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Georgia, sans-serif;">
<p style="margin: 0px; line-height: normal;"><font face="Times">Dear fieldtripers, </font></p>
<p style="margin: 0px; line-height: normal;"><font face="Times"><br>
</font></p>
<p style="margin: 0px; line-height: normal;"><font face="Times">This is a follow-up question to a previous question with the same mail-topic. </font></p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;"><font face="Times">I have included my code below to show what I am doing (in case I have made errors) and print screens (which are also attached) of the variables I get after the ft_componentanalysis that I get. </font></p>
<p style="margin: 0px; line-height: normal;"><font face="Times"><br>
</font></p>
<p style="margin: 0px; line-height: normal;"><font face="Times">Sadly, I cannot see any variable named comp.trial (see Unknown.tiff, or</font><span style="font-family: Times;"> </span><span style="font-family: Times;">Unknown-1.tiff)</span><span style="font-family: Times;">.
 Also, when running the PCA in matlab, I get a coefficient array that has as many entries as there are time-points in my trials (see </span><span style="font-family: Times;">Unknown.tiff-2)</span><span style="font-family: Times;"> . Why am I not getting that
 in ft? Is it possible to get that using ft?</span></p>
<p style="margin: 0px; line-height: normal;"><font face="Times"><br>
</font></p>
<p style="margin: 0px; line-height: normal;"><font face="Times">Very Best,</font></p>
<p style="margin: 0px; line-height: normal;"><font face="Times">Isac</font></p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">————————————————— The code —————————————————</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">clear all; close all;</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% Load </p>
<p style="margin: 0px; line-height: normal;">load('averages_for_ft.mat')</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% define layout</p>
<p style="margin: 0px; line-height: normal;">cfg = [];</p>
<p style="margin: 0px; line-height: normal;">cfg.elec=PreOdd_ft{1, 1}.elec; </p>
<p style="margin: 0px; line-height: normal;">cfg.rotate=90; %rotation around the z-axis in degrees (default = [], which means automatic)</p>
<p style="margin: 0px; line-height: normal;">layout = ft_prepare_layout(cfg)</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% Make the computations</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">% Dummy varibles </p>
<p style="margin: 0px; line-height: normal;">Cond1 = [];</p>
<p style="margin: 0px; line-height: normal;">Cond2 = [];</p>
<p style="margin: 0px; line-height: normal;">theDiff = [];</p>
<p style="margin: 0px; line-height: normal;">theDiff_ft = {};</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% Start loop</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">for i=1:size(Cond1_ft,2)</p>
<p style="margin: 0px; line-height: normal;">    </p>
<p style="margin: 0px; line-height: normal;">    %Get the basic condtitions</p>
<p style="margin: 0px; line-height: normal;">    curr_Cond2 = Cond2_ft{i}.avg;</p>
<p style="margin: 0px; line-height: normal;">    curr_Cond1 = Cond1_ft{i}.avg;</p>
<p style="margin: 0px; line-height: normal;">    </p>
<p style="margin: 0px; line-height: normal;">    %Get the basic condtitions</p>
<p style="margin: 0px; line-height: normal;">    cfg = [];</p>
<p style="margin: 0px; line-height: normal;">    curr_Cond2_ft = ft_timelockanalysis(cfg, Cond2_ft{i});</p>
<p style="margin: 0px; line-height: normal;">    curr_Cond1_ft = ft_timelockanalysis(cfg, Cond1_ft{i});</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">    % Then take the difference of the averages using ft_math</p>
<p style="margin: 0px; line-height: normal;">    cfg  = [];</p>
<p style="margin: 0px; line-height: normal;">    cfg.operation = 'subtract';</p>
<p style="margin: 0px; line-height: normal;">    cfg.parameter = 'avg';</p>
<p style="margin: 0px; line-height: normal;">    curr_difference = ft_math(cfg,curr_Cond1_ft,curr_Cond2_ft);</p>
<p style="margin: 0px; line-height: normal;">    curr_difference_avg = curr_difference.avg;</p>
<p style="margin: 0px; line-height: normal;">    </p>
<p style="margin: 0px; line-height: normal;">    % Creating a struct with the subjectwise differences between conditions</p>
<p style="margin: 0px; line-height: normal;">    theDiff_ft{i} = curr_difference</p>
<p style="margin: 0px; line-height: normal;">    </p>
<p style="margin: 0px; line-height: normal;">    % constructing concatenated averaged sets for the PCA. </p>
<p style="margin: 0px; line-height: normal;">    Cond2 = [Cond2 curr_Cond2];</p>
<p style="margin: 0px; line-height: normal;">    Cond1 = [Cond1 curr_Cond1];</p>
<p style="margin: 0px; line-height: normal;">    theDiff = [theDiff curr_difference_avg];</p>
<p style="margin: 0px; line-height: normal;">end</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% Create dummy subjects in order to run the PCA over subjects</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">dummy_Cond2 = Cond2_ft{1};</p>
<p style="margin: 0px; line-height: normal;">dummy_Cond2.avg = Cond2; </p>
<p style="margin: 0px; line-height: normal;">dummy_Cond2.time = 1:1:size(Cond2,2);</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">dummy_Cond1 = Cond1_ft{1};</p>
<p style="margin: 0px; line-height: normal;">dummy_Cond1.avg = Cond1; </p>
<p style="margin: 0px; line-height: normal;">dummy_Cond1.time = 1:1:size(Cond1,2);</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">dummy_theDiff = Cond1_ft{1};</p>
<p style="margin: 0px; line-height: normal;">dummy_theDiff.avg = theDiff; </p>
<p style="margin: 0px; line-height: normal;">dummy_theDiff.time = 1:1:size(theDiff,2);</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% Run the PCA</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">cfg = [];</p>
<p style="margin: 0px; line-height: normal;">cfg.method  = 'pca';</p>
<p style="margin: 0px; line-height: normal;">cfg.layout = layout;</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">Cond1_comp = ft_componentanalysis(cfg, dummy_Cond1);</p>
<p style="margin: 0px; line-height: normal;">Cond2_comp = ft_componentanalysis(cfg, dummy_Cond2);</p>
<p style="margin: 0px; line-height: normal;">theDiff_comp = ft_componentanalysis(cfg, dummy_theDiff);</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">%% Revert back to subject level</p>
<p style="margin: 0px; line-height: normal;"><br>
</p>
<p style="margin: 0px; line-height: normal;">cfgCond2 = [];</p>
<p style="margin: 0px; line-height: normal;">cfgCond2.unmixing = Cond2_comp.unmixing;</p>
<p style="margin: 0px; line-height: normal;">cfgCond2.topolabel = Cond2_comp.topolabel;</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">cfgCond1 = [];</p>
<p style="margin: 0px; line-height: normal;">cfgCond1.unmixing = Cond1_comp.unmixing;</p>
<p style="margin: 0px; line-height: normal;">cfgCond1.topolabel = Cond1_comp.topolabel;</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">cfgtheDiff = [];</p>
<p style="margin: 0px; line-height: normal;">cfgtheDiff.unmixing = theDiff_comp.unmixing;</p>
<p style="margin: 0px; line-height: normal;">cfgtheDiff.topolabel = theDiff_comp.topolabel;</p>
<p style="margin: 0px; line-height: normal;"> </p>
<p style="margin: 0px; line-height: normal;">for i=1:size(Cond1_ft,2)</p>
<p style="margin: 0px; line-height: normal;">    Cond1_rs{i} = ft_componentanalysis(cfgCond1, Cond1_ft{i});</p>
<p style="margin: 0px; line-height: normal;">    Cond2_rs{i} = ft_componentanalysis(cfgCond2, Cond2_ft{i});</p>
<p style="margin: 0px; line-height: normal;">    theDiff_rs{i}= ft_componentanalysis(cfgtheDiff, theDiff_ft{i} );</p>
<p style="margin: 0px; line-height: normal;">end</p>
<div><br>
</div>
<p style="margin: 0px; line-height: normal;"><font face="Times"><br>
</font></p>
<p style="margin: 0px; line-height: normal;">————————————————— The variables/results  —————————————————</p>
<p style="margin: 0px; line-height: normal;"><font face="Times"><br>
</font></p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<br>
</p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<br>
</p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<img src="blob:file:///25c7f168-f1ef-42b6-b91b-ebe409f5d638"></p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<br>
</p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<br>
</p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<img src="blob:file:///a9d85786-dc6d-43eb-82b1-f8d017cf0e70"></p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<br>
</p>
<p style="font-size: 10px; color: rgb(37, 153, 45); font-family: Courier; margin: 0px; line-height: normal;">
<img src="blob:file:///36835eb8-97ee-4ff5-b449-a06caa91a9cf"></p>
</body>
</html>