Skip to content

Commit

Permalink
limo_tfce data_range fixed
Browse files Browse the repository at this point in the history
in the latest copy/paste issue :-( for bootstrap fixed data_range + got
the loop for extent changed to sum(idx) --- spotted by le Guillaume
  • Loading branch information
CPernet committed Apr 3, 2014
1 parent 4391635 commit 589cc19
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -213,3 +213,4 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg
*.asv
106 changes: 54 additions & 52 deletions limo_tfce.m
Expand Up @@ -14,12 +14,14 @@
% OUPUT tfce_score is a map of scores
%
% Ref
% Pernet, C., Nichols, T.E., Latinus, M. & Rousselet, G.A.
% Cluster-based computational methods for mass univariate analysis of
% event-related brain potentials/fields. - in prep
% Pernet, C., Latinus, M., Nichols, T.E., & Rousselet, G.A.
% Cluster-based computational methods for mass univariate analyses
% of event-related brain potentials/fields: a simulation study
% Journal Of Neuroscience Method - submitted
%
% Cyril Pernet v2 27-01-2014
% -----------------------------
% Cyril Pernet v3 03-04-2014
% fixed indices / got the loop faster /
% --------------------------------------
% Copyright (C) LIMO Team 2010


Expand Down Expand Up @@ -98,7 +100,7 @@
extent_map = zeros(1,x); % same as cluster map but contains extent value instead
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
tfce(1,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -125,10 +127,10 @@
for h=min(pos_data(:)):pos_increment:max(pos_data(:))
waitbar(index/nsteps);
[clustered_map, num] = bwlabel((pos_data > h));
extent_map = zeros(1,x); % same as cluster map but contains extent value instead
extent_map = zeros(1,x);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
pos_tfce(1,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -141,10 +143,10 @@
for h=min(neg_data(:)):neg_increment:max(neg_data(:))
waitbar((hindex+index)/nsteps);
[clustered_map, num] = bwlabel((neg_data > h));
extent_map = zeros(1,x); % same as cluster map but contains extent value instead
extent_map = zeros(1,x);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
neg_tfce(1,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand Down Expand Up @@ -174,7 +176,7 @@
data_range = range(tmp_data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -189,10 +191,10 @@

for h=min(tmp_data(:)):increment:max(tmp_data(:))
[clustered_map, num] = bwlabel((tmp_data > h));
extent_map = zeros(1,x); % same as cluster map but contains extent value instead
extent_map = zeros(1,x);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
tfce(1,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -211,10 +213,10 @@
tmp_data = squeeze(data(:,boot));

% define increment size
data_range = range(data(:));
data_range = range(tmp_data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -234,10 +236,10 @@
pos_tfce = NaN(1,x,l); index = 1;
for h=min(pos_data(:)):pos_increment:max(pos_data(:))
[clustered_map, num] = bwlabel((pos_data > h));
extent_map = zeros(1,x); % same as cluster map but contains extent value instead
extent_map = zeros(1,x);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
pos_tfce(1,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -248,10 +250,10 @@
neg_tfce = NaN(1,x,l); index = 1;
for h=min(neg_data(:)):neg_increment:max(neg_data(:))
[clustered_map, num] = bwlabel((neg_data > h));
extent_map = zeros(1,x); % same as cluster map but contains extent value instead
extent_map = zeros(1,x);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
neg_tfce(1,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand Down Expand Up @@ -288,7 +290,7 @@
data_range = range(data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -313,7 +315,7 @@
extent_map = zeros(x,y); % same as cluster map but contains extent value instead
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx); % not a 'true' sum since there is no overlap
extent_map(idx) = sum(idx);
end
tfce(:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -340,10 +342,10 @@
for h=min(pos_data(:)):pos_increment:max(pos_data(:))
waitbar(index/nsteps);
[clustered_map, num] = limo_ft_findcluster((pos_data > h), channeighbstructmat,2);
extent_map = zeros(x,y); % same as cluster map but contains extent value instead
extent_map = zeros(x,y);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
pos_tfce(:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -356,10 +358,10 @@
for h=min(neg_data(:)):neg_increment:max(neg_data(:))
waitbar((hindex+index)/nsteps);
[clustered_map, num] = limo_ft_findcluster((neg_data > h), channeighbstructmat,2);
extent_map = zeros(x,y); % same as cluster map but contains extent value instead
extent_map = zeros(x,y);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
neg_tfce(:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -386,10 +388,10 @@
waitbar(boot/b);
tmp_data = squeeze(data(:,:,boot));
% define increment size
data_range = range(data(:));
data_range = range(tmp_data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -403,10 +405,10 @@

for h=min(tmp_data(:)):increment:max(tmp_data(:))
[clustered_map, num] = limo_ft_findcluster((tmp_data > h), channeighbstructmat,2);
extent_map = zeros(x,y); % same as cluster map but contains extent value instead
extent_map = zeros(x,y);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
tfce(:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -425,10 +427,10 @@
tmp_data = squeeze(data(:,:,boot));

% define increment size
data_range = range(data(:));
data_range = range(tmp_data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -448,10 +450,10 @@
pos_tfce = NaN(x,y,l); index = 1;
for h=min(pos_data(:)):pos_increment:max(pos_data(:))
[clustered_map, num] = limo_ft_findcluster((pos_data > h), channeighbstructmat,2);
extent_map = zeros(x,y); % same as cluster map but contains extent value instead
extent_map = zeros(x,y);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
pos_tfce(:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -462,10 +464,10 @@
neg_tfce = NaN(x,y,l); index = 1;
for h=min(neg_data(:)):neg_increment:max(neg_data(:))
[clustered_map, num] = limo_ft_findcluster((neg_data > h), channeighbstructmat,2);
extent_map = zeros(x,y); % same as cluster map but contains extent value instead
extent_map = zeros(x,y);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
neg_tfce(:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand Down Expand Up @@ -500,7 +502,7 @@
data_range = range(data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -526,10 +528,10 @@
catch
[clustered_map,num] = bwlabel((data > h)); % this allow continuous mapping
end
extent_map = zeros(x,y,z); % same as cluster map but contains extent value instead
extent_map = zeros(x,y,z);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
tfce(:,:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand Down Expand Up @@ -560,10 +562,10 @@
catch
[clustered_map,num] = bwlabel((pos_data > h));
end
extent_map = zeros(x,y,z); % same as cluster map but contains extent value instead
extent_map = zeros(x,y,z);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
pos_tfce(:,:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -580,10 +582,10 @@
catch
[clustered_map,num] = bwlabel((neg_data > h));
end
extent_map = zeros(x,y,z); % same as cluster map but contains extent value instead
extent_map = zeros(x,y,z);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
neg_tfce(:,:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -610,10 +612,10 @@
waitbar(boot/b);
tmp_data = squeeze(data(:,:,:,boot));
% define increment size
data_range = range(data(:));
data_range = range(tmp_data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -631,10 +633,10 @@
catch
[clustered_map,num] = bwlabel((tmp_data > h));
end
extent_map = zeros(x,y,z); % same as cluster map but contains extent value instead
extent_map = zeros(x,y,z);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
tfce(:,:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -653,10 +655,10 @@
tmp_data = squeeze(data(:,:,:,boot));

% define increment size
data_range = range(data(:));
data_range = range(tmp_data(:));
if data_range > 1
precision = round(data_range / dh);
if precision > 200 % arbitrary decision to limit precision to 200th of the data range - needed as sometime under H0 one value can be very wrong
if precision > 200
increment = data_range / 200;
else
increment = data_range / precision;
Expand All @@ -680,10 +682,10 @@
catch
[clustered_map,num] = bwlabel((pos_data > h));
end
extent_map = zeros(x,y,z); % same as cluster map but contains extent value instead
extent_map = zeros(x,y,z);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
pos_tfce(:,:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand All @@ -698,10 +700,10 @@
catch
[clustered_map,num] = bwlabel((neg_data > h));
end
extent_map = zeros(x,y,z); % same as cluster map but contains extent value instead
extent_map = zeros(x,y,z);
for i=1:num
idx = clustered_map(:) == i;
extent_map(idx) = extent_map(idx) + sum(idx);
extent_map(idx) = sum(idx);
end
neg_tfce(:,:,:,index) = (extent_map.^E).*h^H.*increment;
index = index +1;
Expand Down

0 comments on commit 589cc19

Please sign in to comment.