-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
One can now export code instead of running commands with Lead-DBS.
- Loading branch information
1 parent
73af804
commit 5245766
Showing
9 changed files
with
606 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function ea_export(options) | ||
% This function exports jobs created by the GUI of Lead-DBS. It is | ||
% distributed within Lead-DBS toolbox (www.lead-dbs.org) | ||
% __________________________________________________________________________________ | ||
% Copyright (C) 2016 Charite University Medicine Berlin, Movement Disorders Unit | ||
% Andreas Horn | ||
|
||
|
||
|
||
[fn,pth]=uiputfile('*.m','Specify location for new job file...','lead_job.m'); | ||
if ~fn % user pressed cancel | ||
return | ||
end | ||
exp=ea_gencode(options,'options'); | ||
|
||
fID=fopen([pth,fn],'w'); | ||
|
||
% export comments | ||
fprintf(fID,'%s\n',['% - Lead-DBS Job created on ',date,':']); | ||
fprintf(fID,'%s\n',['% --------------------------------------']); | ||
fprintf(fID,'\n'); | ||
fprintf(fID,'\n'); | ||
|
||
for e=1:length(exp) | ||
fprintf(fID,'%s\n',exp{e}); | ||
end | ||
fprintf(fID,'\n'); | ||
fprintf(fID,'%s\n','% Execute job:'); | ||
fprintf(fID,'%s\n','% ---------------------------------------'); | ||
fprintf(fID,'\n'); | ||
fprintf(fID,'%s\n',['ea_run(''run'',options);']); | ||
|
||
edit([pth,fn]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
function ea_run(cmd,options) | ||
% This function is the main execution function of Lead-DBS. It is | ||
% distributed within Lead-DBS toolbox (www.lead-dbs.org) | ||
% __________________________________________________________________________________ | ||
% Copyright (C) 2016 Charite University Medicine Berlin, Movement Disorders Unit | ||
% Andreas Horn | ||
|
||
|
||
try | ||
options.lc=load([fileparts(which('lead')),filesep,'connectomics',filesep,'lc_options.mat']); | ||
catch | ||
options.lc=[]; | ||
end | ||
|
||
if options.d3.autoserver && options.d3.write | ||
choice = questdlg('Are you sure you want to export results to the server automatically?', ... | ||
'Auto Server-Export', ... | ||
'Cancel','Yes','Cancel'); | ||
% Handle response | ||
switch choice | ||
case 'Cancel' | ||
return | ||
end | ||
end | ||
|
||
clc | ||
uipatdirs=getappdata(gcf,'uipatdir'); | ||
|
||
if isempty(uipatdirs) | ||
uipatdirs={'No Patient Selected'}; | ||
end | ||
|
||
prefs=ea_prefs(''); | ||
if length(uipatdirs)>1 && ~isempty(which('parpool')) && prefs.pp.do % do parallel processing if available and set in ea_prefs. | ||
try delete(gcp); end | ||
pp=parpool(prefs.pp.profile,prefs.pp.csize); | ||
|
||
for pat=1:length(uipatdirs) | ||
% set patient specific options | ||
opts{pat}=options; | ||
opts{pat}.root=[fileparts(uipatdirs{pat}),filesep]; | ||
[~,thispatdir]=fileparts(uipatdirs{pat}); | ||
opts{pat}.patientname=thispatdir; | ||
end | ||
|
||
parfor pat=1:length(uipatdirs) | ||
|
||
% run main function | ||
try | ||
switch cmd | ||
case 'run' | ||
ea_autocoord(opts{pat}); | ||
case 'export' | ||
ea_error('Exporting code not optimized for parallel processing as of yet. Please turn off parallel processing in ea_prefs.m'); | ||
end | ||
catch | ||
warning([opts{pat}.patientname,' failed. Please run this patient again and adjust parameters. Moving on to next patient.' ]); | ||
end | ||
|
||
end | ||
delete(pp); | ||
|
||
else | ||
|
||
for pat=1:length(uipatdirs) | ||
% set patient specific options | ||
options.root=[fileparts(uipatdirs{pat}),filesep]; | ||
[root,thispatdir]=fileparts(uipatdirs{pat}); | ||
options.patientname=thispatdir; | ||
% run main function | ||
|
||
if length(uipatdirs)>1 % multi mode. Dont stop at errors. | ||
try | ||
switch cmd | ||
case 'run' | ||
ea_autocoord(options); | ||
case 'export' | ||
ea_export(options); | ||
end | ||
catch | ||
warning([options.patientname,' failed. Please run this patient again and adjust parameters. Moving on to next patient.' ]); | ||
end | ||
else | ||
switch cmd | ||
case 'run' | ||
ea_autocoord(options); | ||
case 'export' | ||
ea_export(options); | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.