Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions limo_add_plots.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function limo_add_plots(varargin)
elseif strcmpi(varargin{i},'dimvalue') % for Time-Frequency
dimvalue = varargin{i+1};
elseif strcmpi(varargin{i},'variable') % for arrays of many variables
infile = {varargin{i+1}};
v = varargin{i+1};
elseif strcmpi(varargin{i},'figure') % for arrays of many variables
fig = varargin{i+1};
elseif contains(varargin{i},'LIMO.mat')
Expand All @@ -61,6 +61,8 @@ function limo_add_plots(varargin)
end
end

interactive = isempty(infile);

% ERSP hack
if length(infile) == 1 && ...
~isempty(restrict) && length(dimvalue) > 1 %#ok<*ISCL>
Expand Down Expand Up @@ -212,6 +214,10 @@ function limo_add_plots(varargin)
end

% store each iteration into Data
% Single condition subject summaries store subjects on the fourth axis.
if subjects_plot && ndims(tmp) == 4 && size(tmp,3) == 1
tmp = reshape(tmp,size(tmp,1),size(tmp,2),size(tmp,4));
end
if strcmpi('diff',datatype)
if size(tmp,1) == 1
if ndims(tmp) == 4
Expand All @@ -231,7 +237,7 @@ function limo_add_plots(varargin)
Data(1,:,:) = D; clear D;
elseif size(tmp,1) > 1 && size(tmp,3) == 1 && subjects_plot==0 % only 1 variable not squeezed yet
Data = squeeze(tmp(:,:,1,:));
elseif size(tmp,1) > 1 && size(tmp,3) == 3
elseif size(tmp,1) > 1 && size(tmp,3) == 3 && subjects_plot == 0
Data = tmp;
else % many subjects for instance
if ~exist('v','var')
Expand Down Expand Up @@ -426,7 +432,11 @@ function limo_add_plots(varargin)
% updates
turn = turn+1;
if length(infile) < turn
infile{turn} = '';
if interactive
infile{turn} = '';
else
out = 1; % The supplied list is complete. Do not ask for another file.
end
end

if colorindex <7
Expand All @@ -435,6 +445,6 @@ function limo_add_plots(varargin)
colorindex = 1;
end
clear data tmp
pause(1);
if interactive, pause(1); end
end
limo_results
if interactive, limo_results; end
28 changes: 18 additions & 10 deletions limo_batch.m
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
end

if ~isfield(batch_contrast,'mat')
errordlg('the field batch_contrast.mat is missing'); return
error('LIMO:InvalidContrast', 'The field batch_contrast.mat is required for a command line contrast.');
end
end
end
Expand All @@ -255,7 +255,7 @@
if ~isstruct(STUDY); clear STUDY; end
end

if isempty(STUDY)
if exist('STUDY','var') && (~isstruct(STUDY) || isempty(STUDY))
clear STUDY
end

Expand Down Expand Up @@ -422,7 +422,7 @@

% get subject name
if contains(root,'sub-') % could be STUDY not BIDS but derivatives from study use sub-
subname = ['sub-' extractAfter(root,'sub-') '_desc-'];
subname = [limo_get_subname(root) '_desc-'];
else % not from STUDY but still sub-
subname = limo_get_subname(pipeline(subject).import.files_in);
if ~isempty(subname) % no sub- would be empty and just plain files without prefixes will be saved
Expand Down Expand Up @@ -475,9 +475,12 @@
start = 0;
end

subname = STUDY.datasetinfo(subject).subject;
subname = limo_get_subname(fileparts(batch_contrast.LIMO_files{subject}));
if ~isempty(subname)
subname = [subname '_desc-'];
end
for c=1:size(batch_contrast.mat,1)
name{c} = [fileparts(batch_contrast.LIMO_files{subject}) filesep subname '_desc-con_' num2str(c+start) '.mat'];
name{c} = [fileparts(batch_contrast.LIMO_files{subject}) filesep subname 'con_' num2str(c+start) '.mat'];
end
pipeline(subject).n_contrast.files_out = name; % name{1};
LIMO_files.con{subject} = name;
Expand Down Expand Up @@ -623,7 +626,10 @@

%% Save txt files and warn users
if ~isfield(model.defaults,'verbose')
model.defaults.verbose = ''; % if not specified, assume GUI feedback
model.defaults.verbose = '';
if nargin > 1
model.defaults.verbose = 'noGUI'; % Fully specified calls must not wait on a dialog.
end
end
cd(LIMO_files.LIMO)

Expand Down Expand Up @@ -702,10 +708,12 @@
if sum(failed) == N % all subjects
if strcmpi(model.defaults.verbose,'noGUI')
warning('LIMO batch done but all subjects failed.')
if strcmpi(model.defaults.method,'OLS')
warning('This can be related to a matrix rank issue (more varables than trials)')
else
warning('This is typically due to low number of trials, using smaller windows or setting estimation to OLS often solves this.')
if isfield(model.defaults,'method')
if strcmpi(model.defaults.method,'OLS')
warning('This can be related to a matrix rank issue (more varables than trials)')
else
warning('This is typically due to low number of trials, using smaller windows or setting estimation to OLS often solves this.')
end
end
% warning('It can also be a psom/disk access issue, try setting psom to false in limo_settings_script.m')
else
Expand Down
9 changes: 6 additions & 3 deletions limo_best_electrodes.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
for i=Ns:-1:1
tmp = load(name{i});
if isfield(tmp,'LIMO')
tmp = load(fullfile(tmp.LIMO.dir,'R2.mat'));
resultfile = fullfile(tmp.LIMO.dir, [limo_get_subname(tmp.LIMO.dir) '_desc-R2.mat']);
if ~exist(resultfile,'file')
resultfile = fullfile(tmp.LIMO.dir,'R2.mat'); % legacy and second level outputs
end
tmp = load(resultfile);
end
tmp = tmp.(cell2mat(fieldnames(tmp)));

Expand All @@ -95,7 +99,7 @@
end

LIMO = load([fileparts(name{i}) filesep 'LIMO.mat']); LIMO = LIMO.LIMO;
if ~isempty(LIMO.data.chanlocs(channel_vector(i)).urchan)
if isfield(LIMO.data.chanlocs,'urchan') && ~isempty(LIMO.data.chanlocs(channel_vector(i)).urchan)
urchan_vector(i) = LIMO.data.chanlocs(channel_vector(i)).urchan;
end
fprintf('subject %g analysed \n',i);
Expand Down Expand Up @@ -171,4 +175,3 @@
end
end


39 changes: 22 additions & 17 deletions limo_central_tendency_and_ci.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
%% file selection and checkings
% -----------------------------
current_dir = pwd; warning off
interactive = nargin == 1; % The one argument form is the GUI entry point.
result = []; % the output if requested
data = []; % the matrix of data to compute summary stats on

Expand Down Expand Up @@ -939,12 +940,13 @@

if strcmpi(Estimator2,'Mean') || strcmpi(Estimator2,'All')
disp('Compute the Mean estimator and 95% CI ...')
index = 1; h = waitbar(0,'computing','name','% done');
index = 1; h = [];
if interactive, h = waitbar(0,'computing','name','% done'); end
if strcmpi(limo.Analysis,'Time-Frequency')
M = NaN(size(data,1),size(data,2),size(data,3),size(data,4),3);
for k = 1:size(data,4)
for channel =1:size(data,1)
waitbar(index/(size(data,4)*size(data,1)));
if interactive, waitbar(index/(size(data,4)*size(data,1)), h); end
index = index+1;
if strcmpi(Analysis_type,'1 channel only')
for f=size(data,2):-1:1
Expand All @@ -968,7 +970,7 @@
M = NaN(size(data,1),size(data,2),size(data,3),3);
for k = 1:size(data,3)
for channel =1:size(data,1)
waitbar(index/(size(data,3)*size(data,1)));
if interactive, waitbar(index/(size(data,3)*size(data,1)), h); end
index = index+1;
tmp = squeeze(data(channel,:,k,:));
Y = tmp(:,~isnan(tmp(1,:)));
Expand All @@ -979,7 +981,7 @@
end
end
end
close(h);
if interactive, close(h); end

if nargout ==0
if nargin == 3 || nargin == 4
Expand All @@ -1000,12 +1002,13 @@
% --------------------------------------------------------------
if strcmpi(Estimator2,'Trimmed mean') || strcmpi(Estimator2,'All')
disp('Compute 20% Trimmed Mean estimator and 95% CI ...')
index = 1; h = waitbar(0,'computing','name','% done');
index = 1; h = [];
if interactive, h = waitbar(0,'computing','name','% done'); end
if strcmpi(limo.Analysis,'Time-Frequency')
TM = NaN(size(data,1),size(data,2),size(data,3),size(data,4),3);
for k = 1:size(data,4)
for channel =1:size(data,1)
waitbar(index/(size(data,4)*size(data,1)));
if interactive, waitbar(index/(size(data,4)*size(data,1)), h); end
index = index+1;
if strcmpi(Analysis_type,'1 channel only')
for f=size(data,2):-1:1
Expand All @@ -1029,7 +1032,7 @@
TM = NaN(size(data,1),size(data,2),size(data,3),3);
for k=1:size(data,3) % for each parameter
for channel =1:size(data,1)
waitbar(index/(size(data,3)*size(data,1)));
if interactive, waitbar(index/(size(data,3)*size(data,1)), h); end
index = index+1;
tmp = squeeze(data(channel,:,k,:));
Y = tmp(:,~isnan(tmp(1,:)));
Expand All @@ -1040,7 +1043,7 @@
end
end
end
close(h);
if interactive, close(h); end

if nargout ==0
if nargin == 3 || nargin == 4
Expand All @@ -1062,11 +1065,13 @@
% -----------------------------------------------------
if strcmpi(Estimator2,'HD') || strcmpi(Estimator2,'All')
disp('Compute Harrell-Davis estimator and 95% CI ...')
index = 1; h = [];
if interactive, h = waitbar(0,'computing','name','% done'); end
if strcmpi(limo.Analysis,'Time-Frequency')
HD = NaN(size(data,1),size(data,2),size(data,3),size(data,4),3);
for k = 1:size(data,4)
for channel =1:size(data,1)
waitbar(index/(size(data,4)*size(data,1)));
if interactive, waitbar(index/(size(data,4)*size(data,1)), h); end
index = index+1;
if strcmpi(Analysis_type,'1 channel only')
for f=size(data,2):-1:1
Expand All @@ -1088,10 +1093,9 @@
end
else
HD = NaN(size(data,1),size(data,2),size(data,3),3);
index = 1; h = waitbar(0,'computing','name','% done');
for k=1:size(data,3)
for channel =1:size(data,1)
waitbar(index/(size(data,3)*size(data,1)));
if interactive, waitbar(index/(size(data,3)*size(data,1)), h); end
index = index+1;
tmp = squeeze(data(channel,:,k,:));
Y = tmp(:,~isnan(tmp(1,:)));
Expand All @@ -1102,7 +1106,7 @@
end
end
end
close(h);
if interactive, close(h); end

if nargout ==0
if nargin == 3 || nargin == 4
Expand All @@ -1123,12 +1127,13 @@
% -------------------------------------------------
if strcmpi(Estimator2,'Median') || strcmpi(Estimator2,'All')
disp('Compute Median estimator and 95% CI ...')
index = 1; h = waitbar(0,'computing','name','% done');
index = 1; h = [];
if interactive, h = waitbar(0,'computing','name','% done'); end
if strcmpi(limo.Analysis,'Time-Frequency')
Med = NaN(size(data,1),size(data,2),size(data,3),size(data,4),3);
for k = 1:size(data,4)
for channel =1:size(data,1)
waitbar(index/(size(data,4)*size(data,1)));
if interactive, waitbar(index/(size(data,4)*size(data,1)), h); end
index = index+1;
if strcmpi(Analysis_type,'1 channel only')
for f=size(data,2):-1:1
Expand All @@ -1152,7 +1157,7 @@
Med = NaN(size(data,1),size(data,2),size(data,3),3);
for k=1:size(data,3)
for channel =1:size(data,1)
waitbar(index/(size(data,3)*size(data,1)));
if interactive, waitbar(index/(size(data,3)*size(data,1)), h); end
index = index+1;
tmp = squeeze(data(channel,:,k,:));
Y = tmp(:,~isnan(tmp(1,:)));
Expand All @@ -1163,7 +1168,7 @@
end
end
end
close(h);
if interactive, close(h); end

if nargout ==0
if nargin == 3 || nargin == 4
Expand Down Expand Up @@ -1191,4 +1196,4 @@
else
disp('computation done');
end
limo_random_effect
if interactive, limo_random_effect; end
Loading