Skip to content

Commit

Permalink
Added some error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashorn committed Mar 28, 2015
1 parent 40f6e28 commit 050ff92
Show file tree
Hide file tree
Showing 26 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion cfg/ea_ui_manualheight.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function ea_ui_manualheight(P)
try
load([P.foldername{1},'ea_reconstruction']);
catch
error('No reconstruction information found. Please run reconstruction first.');
ea_error('No reconstruction information found. Please run reconstruction first.');
end
mcfig=figure('name',[patientname,': Manual Height Correction'],'numbertitle','off');

Expand Down
2 changes: 1 addition & 1 deletion ea_autocoord.m
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function ea_autocoord(options)
try
load([options.root,patientname,filesep,'ea_reconstruction']);
catch
error('No reconstruction information found. Please run reconstruction first.');
ea_error('No reconstruction information found. Please run reconstruction first.');
end
mcfig=figure('name',[patientname,': Manual Height Correction'],'numbertitle','off');
ea_manualcorrection(mcfig,coords_mm,trajectory,patientname,options);
Expand Down
1 change: 1 addition & 0 deletions ea_build_DTD.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
if isempty(errStr)
msgStr= sprintf('DTI calculations done, write file dtdStruct as %s',dtdname);
else
ea_error('Error: DTI calculations done, BUT could not write DTD');
msgStr= sprintf('Error: DTI calculations done, BUT could not write DTD');
end

Expand Down
2 changes: 1 addition & 1 deletion ea_checkfiles.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function ea_checkfiles(options)
% load files
if strcmp(options.prefs.patientdir,'Choose Patient Directory')
error('Please choose patient directory first');
ea_error('Please choose patient directory first');
end


Expand Down
10 changes: 5 additions & 5 deletions ea_coreg.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
cfundo=[2,1,3,4];
manual=0;
otherwise
error('Coregistration prefs must be either set to auto or manual. Please modify ea_prefs.m accordingly.');
ea_error('Coregistration prefs must be either set to auto or manual. Please modify ea_prefs.m accordingly.');
end


Expand Down Expand Up @@ -48,7 +48,7 @@
finas{export}=fina; % assign only if worked.
catch
disp('*** Coregistration between transversal and coronar versions failed / Using CT Modality.');
%error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
%ea_error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;
if manual
Expand All @@ -64,7 +64,7 @@
break
else
if costfun==4
error('Problem cannot be solved automatically.')
ea_error('Problem cannot be solved automatically.')
else
disp('Trying with another cost-function');
end
Expand Down Expand Up @@ -106,7 +106,7 @@
disp('*** Coregistration between pre and post versions worked.');
catch
disp('*** Coregistration between pre and post versions failed.');
%error('This normalization cannot be performed automatically with LEAD. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
%ea_error('This normalization cannot be performed automatically with LEAD. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand All @@ -128,7 +128,7 @@
break
else
if costfun==4
error('Problem cannot be solved automatically.')
ea_error('Problem cannot be solved automatically.')
else
disp('Trying with another cost-function');
end
Expand Down
8 changes: 8 additions & 0 deletions ea_error.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function ea_error(msg)
% The general error message function.
% __________________________________________________________________________________
% Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit
% Andreas Horn

errordlg(msg);
error(msg);
2 changes: 1 addition & 1 deletion ea_ftr2trk.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function ea_ftr2trk(ftrfilename,directory,specs,options)
header = get_header(fid);
end

if header.hdr_size~=1000, error('Header length is wrong'), end
if header.hdr_size~=1000, ea_error('FTR-Header length is wrong'), end

% Check orientation
[tmp ix] = max(abs(header.image_orientation_patient(1:3)));
Expand Down
2 changes: 1 addition & 1 deletion ea_gencontrastimage.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@


otherwise
error('Please set Contrast accurately.');
ea_error('Please set Contrast accurately.');

end

Expand Down
8 changes: 4 additions & 4 deletions ea_normalize.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ea_normalize(options)
% Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit
% Andreas Horn

usecombined=0; % if set, eauto will try to fuse coronar and transversal images before normalizing them.
usecombined=0; % if set, LEAD-DBS will try to fuse coronar and transversal images before normalizing them.


if exist([options.root,options.prefs.patientdir,filesep,options.prefs.tranii_unnormalized,'.gz'],'file')
Expand Down Expand Up @@ -70,7 +70,7 @@ function ea_normalize(options)
disp('*** Segmentation of transversal version worked.');
catch
disp('*** Segmentation of transversal version failed.');
error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
ea_error('This normalization cannot be performed automatically with LEAD-DBS. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down Expand Up @@ -139,7 +139,7 @@ function ea_normalize(options)
disp('*** Coregistration between transversal and coronar versions worked.');
catch
disp('*** Coregistration between transversal and coronar versions failed.');
%error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
%ea_error('This normalization cannot be performed automatically with LEAD-DBS. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down Expand Up @@ -172,7 +172,7 @@ function ea_normalize(options)
disp('*** Grand mean normalization (1/3) worked.');
catch
disp('*** Grand mean normalization (1/3) failed.');
error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
ea_error('This normalization cannot be performed automatically with LEAD-DBS. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down
2 changes: 1 addition & 1 deletion ea_normalize_fibers.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function ea_normalize_fibers(options)

[~,preniif]=fileparts(options.prefs.prenii_unnormalized);
if ~exist([options.root,options.patientname,filesep,'y_ea_inv_normparams.nii'],'file');
error('Please run a compatible normalization of the preoperative MRI-volume first. Final (inverse) normalization parameters should be stored as y_ea_inv_normparams.nii inside of the subject folder.');
ea_error('Please run a compatible normalization of the preoperative MRI-volume first. Final (inverse) normalization parameters should be stored as y_ea_inv_normparams.nii inside of the subject folder.');
end


Expand Down
6 changes: 3 additions & 3 deletions ea_normalize_schoenecker.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
disp('*** Segmentation of transversal version worked.');
catch
disp('*** Segmentation of transversal version failed.');
error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
ea_error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down Expand Up @@ -159,7 +159,7 @@
disp('*** Coregistration between transversal and coronar versions worked.');
catch
disp('*** Coregistration between transversal and coronar versions failed.');
%error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
%ea_error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down Expand Up @@ -192,7 +192,7 @@
disp('*** Grand mean normalization (1/3) worked.');
catch
disp('*** Grand mean normalization (1/3) failed.');
error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
ea_error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down
4 changes: 2 additions & 2 deletions ea_normalize_schoenecker_pre.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
disp('*** Coregistration between preop and postop versions worked.');
catch
disp('*** Coregistration between preop and postop versions failed.');
%error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
%ea_error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down Expand Up @@ -202,7 +202,7 @@
disp('*** Grand mean normalization (1/3) worked.');
catch
disp('*** Grand mean normalization (1/3) failed.');
error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
ea_error('This normalization cannot be performed automatically with eAuto. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down
2 changes: 1 addition & 1 deletion ea_normalize_spmdartel.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
cfg_util('run',jobs);
disp('*** Dartel coregistration of preoperative version worked.');
%catch
% error('*** Dartel coregistration failed.');
% ea_error('*** Dartel coregistration failed.');
%end
clear matlabbatch jobs;

Expand Down
2 changes: 1 addition & 1 deletion ea_normalize_spmnewseg.m
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function resize_img(imnames, Voxdim, BB, ismask)
elseif exist('spm_get','file') % should be true for spm2
spm5 = 0;
else
error('Can''t find spm_get or spm_select; please add SPM to path')
ea_error('Can''t find spm_get or spm_select; please add SPM to path')
end

spm_defaults;
Expand Down
2 changes: 1 addition & 1 deletion ea_normalize_spmseg.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
disp('*** Segmentation of preoperative version worked.');
catch
disp('*** Segmentation of transversal version failed.');
error('This normalization cannot be performed automatically with LEAD. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
ea_error('This normalization cannot be performed automatically with LEAD. Try using different software for the normalization step. Examples are to use SPM directly, or to use FSL, Slicer or Bioimaging Suite.');
end
clear matlabbatch jobs;

Expand Down
2 changes: 1 addition & 1 deletion ea_prepare_slice.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
addfactor=addfactor-cnt*0.1;
ea_showdis(['Lowering initial factor to ',num2str(addfactor),'.'],options.verbose);
if cnt>500
error('Trajectory could not be found. Please choose manual entry-point to select trajectory manually and make sure that images are properly normalized in MNI space.');
ea_error('Trajectory could not be found. Please choose manual entry-point to select trajectory manually and make sure that images are properly normalized in MNI space.');
end
else
found=1;
Expand Down
3 changes: 2 additions & 1 deletion ea_reconstruct_trajectory.m
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@


if round(estpoint(2)-options.maskwindow)<0 || round(estpoint(2)+options.maskwindow)>500 || round(estpoint(1)-options.maskwindow)<0 || round(estpoint(1)+options.maskwindow)>500
display('Mask out of bounds. Must have lost trajectory. Try iterating with a different maskwindow again.');
close(progressfig)
ea_error('Mask out of bounds. Must have lost trajectory. Try iterating with a different maskwindow again.');

return
%pause
Expand Down
2 changes: 1 addition & 1 deletion ea_reformat_isomatrix.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
stimmat{2}=isom(:,(size(isom,2)/2)+1:end);

else
error('Wrong Isomatrix provided.');
ea_error('Wrong Isomatrix provided.');
end
end

Expand Down
4 changes: 2 additions & 2 deletions ea_render_view.m
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function ea_keyrelease(resultfig,event)
self.K = [self.K self.K];
end
if self.K(1) > 16
error('To avoid excessive use of memory, K has been limited to max 16. Change the code to fix this on your own risk.');
ea_error('To avoid excessive use of memory, K has been limited to max 16. Change the code to fix this on your own risk.');
end
try
imfilter(zeros(2,2),zeros(2,2));
Expand All @@ -498,7 +498,7 @@ function ea_keyrelease(resultfig,event)
self.aamethod = 'noshrink';
end
else
error('Wrong syntax, run: help myaa');
ea_error('Wrong syntax, run: help myaa');
end

if length(self.K) == 1
Expand Down
5 changes: 5 additions & 0 deletions ea_sample_cuboid.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@
end


% error on maxi empty:
if isempty(maxi)
ea_error('Reconstruction failed. Please adjust mask-size and entry-point parameters and re-run reconstruction.');
end


for coo=1:4
coords(coo,:)=startpt+ntrajvector*maxi +ntrajvector*(coo*reldist);
Expand Down
12 changes: 6 additions & 6 deletions ea_savejson.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
if(~isempty(jsonopt('FileName','',opt)))
fid = fopen(opt.FileName, 'wt');
if ~fid
error('No valid destination for lead-server. Read-only filesystem? Please modify prefs.ls.dir in ea_prefs.m to a correct output destination.');
ea_error('No valid destination for Lead-server. Read-only filesystem? Please modify prefs.ls.dir in ea_prefs.m to a correct output destination.');
end
fwrite(fid,json,'char');
fclose(fid);
Expand All @@ -145,7 +145,7 @@
function txt=cell2json(name,item,level,varargin)
txt='';
if(~iscell(item))
error('input is not a cell');
ea_error('input is not a cell');
end

dim=size(item);
Expand Down Expand Up @@ -175,7 +175,7 @@
function txt=struct2json(name,item,level,varargin)
txt='';
if(~isstruct(item))
error('input is not a struct');
ea_error('input is not a struct');
end
len=numel(item);
padding1=repmat(sprintf('\t'),1,level-1);
Expand Down Expand Up @@ -212,7 +212,7 @@
function txt=str2json(name,item,level,varargin)
txt='';
if(~ischar(item))
error('input is not a string');
ea_error('input is not a string');
end
item=reshape(item, max(size(item),[1 0]));
len=size(item,1);
Expand Down Expand Up @@ -252,7 +252,7 @@
%%-------------------------------------------------------------------------
function txt=mat2json(name,item,level,varargin)
if(~isnumeric(item) && ~islogical(item))
error('input is not an array');
ea_error('input is not an array');
end

padding1=repmat(sprintf('\t'),1,level);
Expand Down Expand Up @@ -422,7 +422,7 @@
opt=setfield(opt,varargin{i},varargin{i+1});
i=i+1;
else
error('input must be in the form of ...,''name'',value,... pairs or structs');
ea_error('input must be in the form of ...,''name'',value,... pairs or structs');
end
i=i+1;
end
Expand Down
2 changes: 1 addition & 1 deletion ea_showelectrode.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
elseif size(options.d3.isomatrix{1},2)==4 % 4 contacts
shifthalfup=0;
else
error('Isomatrix has wrong size. Please specify a correct matrix.')
ea_error('Isomatrix has wrong size. Please specify a correct matrix.')
end
end

Expand Down
2 changes: 1 addition & 1 deletion ea_showisovolume.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ea_showisovolume(resultfig,elstruct,options)
elseif size(options.d3.isomatrix{1},2)==4 % 4 contacts
shifthalfup=0;
else
error('Isomatrix has wrong size. Please specify a correct matrix.')
ea_error('Isomatrix has wrong size. Please specify a correct matrix.')
end
for side=options.sides
cnt=1;
Expand Down
2 changes: 1 addition & 1 deletion ea_write.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function ea_write(options)
try
load([options.root,options.patientname,filesep,'ea_reconstruction']);
catch
error('No reconstruction information found. Please run reconstruction first.');
ea_error('No reconstruction information found. Please run reconstruction first.');
end
for side=1:length(coords_mm)
if size(coords_mm{side},1)~=options.elspec.numel
Expand Down
4 changes: 2 additions & 2 deletions ea_writeplanes.m
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ function ea_screenshot(outn)
self.K = [self.K self.K];
end
if self.K(1) > 16
error('To avoid excessive use of memory, K has been limited to max 16. Change the code to fix this on your own risk.');
ea_error('To avoid excessive use of memory, K has been limited to max 16. Change the code to fix this on your own risk.');
end
try
imfilter(zeros(2,2),zeros(2,2));
Expand All @@ -305,7 +305,7 @@ function ea_screenshot(outn)
self.aamethod = 'noshrink';
end
else
error('Wrong syntax, run: help myaa');
ea_error('Wrong syntax, run: help myaa');
end

if length(self.K) == 1
Expand Down
4 changes: 2 additions & 2 deletions ext_libs/segment/ea_spm_preproc_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
case 'vout'
varargout{1} = vout_job(job);
otherwise
error('Unknown argument ("%s").', arg);
ea_error('Unknown argument ("%s").', arg);
end
return
%_______________________________________________________________________
Expand Down Expand Up @@ -167,7 +167,7 @@

%_______________________________________________________________________
function savefields(fnam,p)
if length(p)>1, error('Can''t save fields.'); end
if length(p)>1, ea_error('Can''t save fields.'); end
fn = fieldnames(p);
if numel(fn)==0, return; end
for i=1:length(fn)
Expand Down

0 comments on commit 050ff92

Please sign in to comment.