|
1 | 1 | function H = ept_IndividualTopoplots(Data, e_loc, Results, Factor, Sample)
|
2 |
| -%% Ept function to plot each individuals topography for a given sample... |
| 2 | +% Ept function to plot each individuals topography for a given sample... |
3 | 3 |
|
4 | 4 | % Input
|
5 | 5 | % If channel*frequency*time data then the Sample variable should be
|
|
12 | 12 | Stats = Results.TFCE_Obs.A(:,Sample)';
|
13 | 13 | elseif Factor == 2
|
14 | 14 | Data = Data';
|
15 |
| - iData = cellfun(@(x) x(:,:,Sample), Data, 'UniformOutput', false); |
| 15 | + iData = cellfun(@(x) x(:,:,Sample), Data, 'UniformOutput', false); |
16 | 16 | b = cellfun(@mean, iData, 'UniformOutput', false);
|
17 | 17 | Stats = Results.TFCE_Obs.B(:,Sample)';
|
18 | 18 | else
|
|
24 | 24 | Stats = Results.TFCE_Obs(:,Sample)';
|
25 | 25 | end
|
26 | 26 |
|
27 |
| -%% Calculate the average ERP over multiple conditions (just cell2mat for single condition TTest) |
| 27 | +% Calculate the average ERP over multiple conditions (just cell2mat for single condition TTest) |
28 | 28 | gData = zeros(size(b,1), numel(b{1}));
|
29 | 29 | % will have to make multiple condition means for iData too...
|
30 | 30 | for i = 1:size(b,2);
|
|
35 | 35 | gData = gData/size(b,2);
|
36 | 36 |
|
37 | 37 |
|
38 |
| -%% Calculate plot specific variables |
| 38 | +% Calculate plot specific variables |
39 | 39 | % Find max number of participants in each group and add 3 (TFCE Stats will be twice as large...
|
40 | 40 |
|
41 |
| -numPlots = max(cell2mat(cellfun(@(x) size(x,1), Data, 'UniformOutput', false)))+3; |
| 41 | +group_sizes = cellfun(@(x) size(x,1), Data); |
| 42 | +numPlots = max(group_sizes(:))+3; |
42 | 43 |
|
43 | 44 | axesPos = (0:1:numPlots)/numPlots; % Determines the starting x-axis point for each plot (last element redundant)
|
44 | 45 | axesWidth = 1/numPlots;
|
45 | 46 | mapLimits = [min(gData(:)), max(gData(:))]; % Calculates the total ERP amplitude range over all groups to adjust the colormaps later
|
46 | 47 |
|
47 |
| -%% Prepare the figure |
| 48 | +% Prepare the figure |
48 | 49 | H.Figure = figure;
|
49 | 50 | set(H.Figure,...
|
50 | 51 | 'Name', ['S:' num2str(Sample) ' Factor Topoplots'] ,...
|
|
60 | 61 | for i = 1:numPlots-2 % loop for plots (individuals + group)
|
61 | 62 |
|
62 | 63 | H.Axes(i,j) = axes(...
|
| 64 | + 'parent', H.Figure,... |
63 | 65 | 'Position', [axesPos(i) (j-1)/size(iData,1) axesWidth 1/size(iData,1)] ,...
|
64 | 66 | 'xtick', [] ,...
|
65 | 67 | 'ytick', [] );
|
|
72 | 74 | H.TFCEAxes = axes('Position', [axesPos(end-2), 0, axesWidth*2, 1]);
|
73 | 75 |
|
74 | 76 | % Adjusts the maps color scheme so topoplot colours are equal among level topoplots
|
75 |
| -set(H.Axes,... |
76 |
| - 'CLim', mapLimits ); |
77 |
| - |
78 |
| -%% Plot the actual topoplots of each individual |
| 77 | +set(H.Axes,'CLim', mapLimits); |
79 | 78 |
|
| 79 | +% Plot the actual topoplots of each individual |
80 | 80 | for j = 1:size(iData,1) % loop for rows (levels)
|
81 | 81 | for i = 1:size(iData{j},1) % loop for plots (individuals + group)
|
82 |
| - |
83 |
| - set(H.Figure,'CurrentAxes',H.Axes(i,j)) |
84 |
| - ept_Topoplot(iData{j}(i,:), e_loc); |
85 |
| - |
| 82 | + % draw each topoplot |
| 83 | + ept_Topoplot(iData{j}(i,:), e_loc,... |
| 84 | + 'Axes', H.Axes(i,j)); |
86 | 85 | end
|
87 | 86 | end
|
88 | 87 |
|
89 |
| -%% Plot group topoplots |
| 88 | +% Plot group topoplots |
90 | 89 | for i = 1:size(gData,1)
|
91 |
| - |
92 |
| - set(H.Figure,'CurrentAxes',H.Axes(end,i)) |
93 |
| - ept_Topoplot(gData(i,:), e_loc); |
94 |
| - |
| 90 | + ept_Topoplot(gData(i,:), e_loc,... |
| 91 | + 'Axes', H.Axes(end, i)); |
95 | 92 | end
|
96 | 93 |
|
97 |
| -%% Plot the larger TFCE topoplot |
98 |
| -set(H.Figure,'CurrentAxes',H.TFCEAxes) |
99 |
| -ept_Topoplot(Stats, e_loc); |
| 94 | +% Plot the larger TFCE topoplot |
| 95 | +ept_Topoplot(Stats, e_loc,... |
| 96 | + 'Axes', H.TFCEAxes); |
0 commit comments