Skip to content

Commit

Permalink
fixed issue with individual topography plots
Browse files Browse the repository at this point in the history
  • Loading branch information
Mensen committed Feb 2, 2015
1 parent afe900a commit e965594
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
Binary file modified ResultViewer/Dependencies/ept_ClusRes.mexa64
100644 → 100755
Binary file not shown.
5 changes: 3 additions & 2 deletions ResultViewer/Tools/ept_FactorTopoplots.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [] = ept_FactorTopoplots(Data, e_loc, Results, Factor, Sample)
function ept_FactorTopoplots(Data, e_loc, Results, Factor, Sample)
%% Levels and Statistics Topoplot Tight

% This file is part of the program ept_ResultViewer.
Expand Down Expand Up @@ -30,7 +30,8 @@
b = cellfun(@mean, a, 'UniformOutput', false);
Stats = Results.TFCE_Obs.B(:,Sample)';
else
error('Only main effects currently available: Factor = 1 or 2.')
fprintf('Only main effects currently available: Factor = 1 or 2.');
return
end
else
a = cellfun(@(x) x(:,:,Sample), Data, 'UniformOutput', false);
Expand Down
41 changes: 19 additions & 22 deletions ResultViewer/Tools/ept_IndividualTopoplots.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function H = ept_IndividualTopoplots(Data, e_loc, Results, Factor, Sample)
%% Ept function to plot each individuals topography for a given sample...
% Ept function to plot each individuals topography for a given sample...

% Input
% If channel*frequency*time data then the Sample variable should be
Expand All @@ -12,7 +12,7 @@
Stats = Results.TFCE_Obs.A(:,Sample)';
elseif Factor == 2
Data = Data';
iData = cellfun(@(x) x(:,:,Sample), Data, 'UniformOutput', false);
iData = cellfun(@(x) x(:,:,Sample), Data, 'UniformOutput', false);
b = cellfun(@mean, iData, 'UniformOutput', false);
Stats = Results.TFCE_Obs.B(:,Sample)';
else
Expand All @@ -24,7 +24,7 @@
Stats = Results.TFCE_Obs(:,Sample)';
end

%% Calculate the average ERP over multiple conditions (just cell2mat for single condition TTest)
% Calculate the average ERP over multiple conditions (just cell2mat for single condition TTest)
gData = zeros(size(b,1), numel(b{1}));
% will have to make multiple condition means for iData too...
for i = 1:size(b,2);
Expand All @@ -35,16 +35,17 @@
gData = gData/size(b,2);


%% Calculate plot specific variables
% Calculate plot specific variables
% Find max number of participants in each group and add 3 (TFCE Stats will be twice as large...

numPlots = max(cell2mat(cellfun(@(x) size(x,1), Data, 'UniformOutput', false)))+3;
group_sizes = cellfun(@(x) size(x,1), Data);
numPlots = max(group_sizes(:))+3;

axesPos = (0:1:numPlots)/numPlots; % Determines the starting x-axis point for each plot (last element redundant)
axesWidth = 1/numPlots;
mapLimits = [min(gData(:)), max(gData(:))]; % Calculates the total ERP amplitude range over all groups to adjust the colormaps later

%% Prepare the figure
% Prepare the figure
H.Figure = figure;
set(H.Figure,...
'Name', ['S:' num2str(Sample) ' Factor Topoplots'] ,...
Expand All @@ -60,6 +61,7 @@
for i = 1:numPlots-2 % loop for plots (individuals + group)

H.Axes(i,j) = axes(...
'parent', H.Figure,...
'Position', [axesPos(i) (j-1)/size(iData,1) axesWidth 1/size(iData,1)] ,...
'xtick', [] ,...
'ytick', [] );
Expand All @@ -72,28 +74,23 @@
H.TFCEAxes = axes('Position', [axesPos(end-2), 0, axesWidth*2, 1]);

% Adjusts the maps color scheme so topoplot colours are equal among level topoplots
set(H.Axes,...
'CLim', mapLimits );

%% Plot the actual topoplots of each individual
set(H.Axes,'CLim', mapLimits);

% Plot the actual topoplots of each individual
for j = 1:size(iData,1) % loop for rows (levels)
for i = 1:size(iData{j},1) % loop for plots (individuals + group)

set(H.Figure,'CurrentAxes',H.Axes(i,j))
ept_Topoplot(iData{j}(i,:), e_loc);

% draw each topoplot
ept_Topoplot(iData{j}(i,:), e_loc,...
'Axes', H.Axes(i,j));
end
end

%% Plot group topoplots
% Plot group topoplots
for i = 1:size(gData,1)

set(H.Figure,'CurrentAxes',H.Axes(end,i))
ept_Topoplot(gData(i,:), e_loc);

ept_Topoplot(gData(i,:), e_loc,...
'Axes', H.Axes(end, i));
end

%% Plot the larger TFCE topoplot
set(H.Figure,'CurrentAxes',H.TFCEAxes)
ept_Topoplot(Stats, e_loc);
% Plot the larger TFCE topoplot
ept_Topoplot(Stats, e_loc,...
'Axes', H.TFCEAxes);

0 comments on commit e965594

Please sign in to comment.