Skip to content

Commit

Permalink
Fix 'normsetting' being overwritten in cluster or exported job.
Browse files Browse the repository at this point in the history
Close #118.

Also includes a bunch of other fixes and optimizations.
  • Loading branch information
ningfei committed Aug 17, 2017
1 parent 075f01a commit 4f87288
Show file tree
Hide file tree
Showing 47 changed files with 617 additions and 663 deletions.
15 changes: 10 additions & 5 deletions cluster/ea_run_HMS_Orchestra.m
Expand Up @@ -4,10 +4,15 @@ function ea_run_HMS_Orchestra(options)
% to be adapted to suit your needs. Then, you can "Export code" using
% Lead-DBS and simply change the command ea_run to ea_run_cluster.

jobFile = [options.root, options.patientname, filesep, 'job_', ea_generate_guid];
save(jobFile, 'options');

setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS', '1');

cmdstring=['cd ', options.earoot, ' &&' ...
' bsub -q short -W 12:0 -R "rusage[mem=50000]" -R "select[scratch2]"' ...
' -o ', jobFile, '.out' ...
' -e ', jobFile, '.err' ...
' matlab -singleCompThread -nodisplay -r "ea_run runcluster ', jobFile, '"'];

jobID=ea_generate_guid;
options.spmdir=spm('dir');
save([options.root,options.patientname,filesep,'job_',jobID],'options')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS','1')
cmdstring=['cd ',options.earoot,' && bsub -q short -W 12:0 -R "rusage[mem=50000]" -R "select[scratch2]" -o ',[options.root,options.patientname,filesep,'job_',jobID],'.out -e ',[options.root,options.patientname,filesep,'job_',jobID],'.err matlab -singleCompThread -nodisplay -r "ea_run runcluster ',[options.root,options.patientname,filesep,'job_',jobID],'"'];
system(cmdstring);
15 changes: 10 additions & 5 deletions cluster/ea_run_HMS_Orchestra_long.m
Expand Up @@ -4,10 +4,15 @@ function ea_run_HMS_Orchestra_long(options)
% to be adapted to suit your needs. Then, you can "Export code" using
% Lead-DBS and simply change the command ea_run to ea_run_cluster.

jobFile = [options.root, options.patientname, filesep, 'job_', ea_generate_guid];
save(jobFile, 'options');

setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS', '1');

cmdstring=['cd ',options.earoot,' &&' ...
' bsub -q long -R "rusage[mem=50000]" -R "select[scratch2]" -W 168:0' ...
' -o ', jobFile, '.out' ...
' -e ', jobFile, '.err' ...
' matlab -singleCompThread -nodisplay -r "ea_run runcluster ', jobFile, '"'];

jobID=ea_generate_guid;
options.spmdir=spm('dir');
save([options.root,options.patientname,filesep,'job_',jobID],'options')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS','1')
cmdstring=['cd ',options.earoot,' && bsub -q long -R "rusage[mem=50000]" -R "select[scratch2]" -W 168:0 -o ',[options.root,options.patientname,filesep,'job_',jobID],'.out -e ',[options.root,options.patientname,filesep,'job_',jobID],'.err matlab -singleCompThread -nodisplay -r "ea_run runcluster ',[options.root,options.patientname,filesep,'job_',jobID],'"'];
system(cmdstring);
15 changes: 10 additions & 5 deletions cluster/ea_run_HMS_Orchestra_max.m
Expand Up @@ -4,10 +4,15 @@ function ea_run_HMS_Orchestra_max(options)
% to be adapted to suit your needs. Then, you can "Export code" using
% Lead-DBS and simply change the command ea_run to ea_run_cluster.

jobFile = [options.root, options.patientname, filesep, 'job_', ea_generate_guid];
save(jobFile, 'options');

setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS', '1');

cmdstring=['cd ', options.earoot, ' &&' ...
' bsub -q long -R "rusage[mem=20000]" -R "select[scratch2]" -W 720:0' ...
' -o ', jobFile, '.out' ...
' -e ', jobFile, '.err' ...
' matlab -singleCompThread -nodisplay -r "ea_run runcluster ', jobFile, '"'];

jobID=ea_generate_guid;
options.spmdir=spm('dir');
save([options.root,options.patientname,filesep,'job_',jobID],'options')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS','1')
cmdstring=['cd ',options.earoot,' && bsub -q long -R "rusage[mem=20000]" -R "select[scratch2]" -W 720:0 -o ',[options.root,options.patientname,filesep,'job_',jobID],'.out -e ',[options.root,options.patientname,filesep,'job_',jobID],'.err matlab -singleCompThread -nodisplay -r "ea_run runcluster ',[options.root,options.patientname,filesep,'job_',jobID],'"'];
system(cmdstring);
15 changes: 10 additions & 5 deletions cluster/ea_run_HMS_Orchestra_medium.m
Expand Up @@ -4,10 +4,15 @@ function ea_run_HMS_Orchestra_medium(options)
% to be adapted to suit your needs. Then, you can "Export code" using
% Lead-DBS and simply change the command ea_run to ea_run_cluster.

jobFile = [options.root, options.patientname, filesep, 'job_', ea_generate_guid];
save(jobFile, 'options');

setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS', '1');

cmdstring=['cd ', options.earoot, ' &&' ...
' bsub -q medium -R "rusage[mem=70000]" -R "select[scratch2]" -W 119:0' ...
' -o ', jobFile,'.out' ...
' -e ', jobFile,'.err' ...
' matlab -singleCompThread -nodisplay -r "ea_run runcluster ', jobFile, '"'];

jobID=ea_generate_guid;
options.spmdir=spm('dir');
save([options.root,options.patientname,filesep,'job_',jobID],'options')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS','1')
cmdstring=['cd ',options.earoot,' && bsub -q medium -R "rusage[mem=70000]" -R "select[scratch2]" -W 119:0 -o ',[options.root,options.patientname,filesep,'job_',jobID],'.out -e ',[options.root,options.patientname,filesep,'job_',jobID],'.err matlab -singleCompThread -nodisplay -r "ea_run runcluster ',[options.root,options.patientname,filesep,'job_',jobID],'"'];
system(cmdstring);
14 changes: 9 additions & 5 deletions cluster/ea_run_Martinos_Launchpad.m
Expand Up @@ -4,11 +4,15 @@ function ea_run_Martinos_Launchpad(options)
% to be adapted to suit your needs. Then, you can "Export code" using
% Lead-DBS and simply change the command ea_run to ea_run_cluster.

jobFile = [options.root, options.patientname, filesep, 'job_', ea_generate_guid];
save(jobFile, 'options');

jobID=ea_generate_guid;
options.spmdir=spm('dir');
save([options.root,options.patientname,filesep,'job_',jobID],'options')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS','1')
cmdstring=['cd ',options.earoot,' && pbsubmit -q matlab -O ',[options.root,options.patientname,filesep,'job_',jobID],'.out -E ',[options.root,options.patientname,filesep,'job_',jobID],'.err -c "matlab.new -singleCompThread -nodisplay -r "''ea_run runcluster ',[options.root,options.patientname,filesep,'job_',jobID],'''"'];
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS', '1');

cmdstring=['cd ', options.earoot, ' &&' ...
' pbsubmit -q matlab' ...
' -O ', jobFile, '.out' ...
' -E ', jobFile, '.err' ...
' -c "matlab.new -singleCompThread -nodisplay -r "''ea_run runcluster ', jobFile, '''"'];

system(cmdstring);
28 changes: 15 additions & 13 deletions cluster/ea_run_Martinos_Launchpad_compile.m
Expand Up @@ -4,22 +4,24 @@ function ea_run_Martinos_Launchpad_compile(options)
% to be adapted to suit your needs. Then, you can "Export code" using
% Lead-DBS and simply change the command ea_run to ea_run_cluster.

jobFile = [options.root, options.patientname, filesep, 'job_', ea_generate_guid];
save(jobFile, 'options');

jobID=ea_generate_guid;
options.spmdir=spm('dir');
save([options.root,options.patientname,filesep,'job_',jobID],'options')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS','1')
setenv('ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS', '1');

cmdstring=['cd ',options.earoot,' && pbsubmit -q highio -O ',[options.root,options.patientname,filesep,'job_',jobID],'.out',...
' -E ',[options.root,options.patientname,filesep,'job_',jobID],'.err',...
' -c "',[ea_getearoot,'cluster',filesep,'run_ea_run_binary.sh'],...
' ','/usr/pubsw/common/matlab/8.6',...
' runcluster ''',ea_path_helper([options.root,options.patientname,filesep,'job_',jobID]),'''"'];
cmdstring=['cd ', options.earoot, ' &&' ...
' pbsubmit -q highio' ...
' -O ',jobFile,'.out', ...
' -E ', jobFile, '.err', ...
' -c "', [ea_getearoot, 'cluster', filesep, 'run_ea_run_binary.sh'], ...
' /usr/pubsw/common/matlab/8.6',...
' runcluster ''', ea_path_helper(jobFile), '''"'];

if ~exist([ea_getearoot,'cluster',filesep,'ea_run_binary'],'file');
mcc('-m','ea_run','-o',['ea_run_binary']);
movefile('ea_run_binary',['cluster',filesep,'ea_run_binary']);
movefile('run_ea_run_binary.sh',['cluster',filesep,'run_ea_run_binary.sh']);
if ~exist([ea_getearoot, 'cluster', filesep, 'ea_run_binary'],'file')
mcc('-m', 'ea_run', '-o', 'ea_run_binary');
movefile('ea_run_binary', ['cluster', filesep, 'ea_run_binary']);
movefile('run_ea_run_binary.sh', ['cluster', filesep, 'run_ea_run_binary.sh']);
end

keyboard
system(cmdstring);
13 changes: 3 additions & 10 deletions common/ea_prefs_default.m
@@ -1,4 +1,4 @@
function prefs=ea_prefs(patientname)
function prefs = ea_prefs(patientname)

% determine preferences here. For filenames, the variable 'patientname' can
% be used in string-handling. This variable will be a string with the same name as the patient
Expand All @@ -7,7 +7,7 @@
% load loaded prefs (-> prefs.lp)
try
load([ea_getearoot,'ea_prefs']);
prefs.lp=lp;
prefs.lp = lp;
end

%% adjust to user
Expand Down Expand Up @@ -46,9 +46,6 @@
prefs.gctnii='glpostop_ct.nii';
prefs.tp_gctnii=['tp_',prefs.gctnii];




%% connectome files:
prefs.rest_prefix='res*.nii'; % raw resting state fMRI data search string
prefs.rest_default='rest.nii'; % default for dcm2nii export.
Expand Down Expand Up @@ -81,7 +78,6 @@
prefs.bvec='dti.bvec';
prefs.sampledtidicom='sample_dti_dicom.dcm'; % sample DICOM file of DTI image (used for trackvis export).


prefs.normmatrix='lmat.txt';

%% Normalization:
Expand Down Expand Up @@ -179,7 +175,6 @@
prefs.native.warp='inverse'; % set to 'tpm' in case you wish to create a atlas-specific tpm to warp atlases, set to 'inverse' to apply the inverse transform of your normalization.

%% lead server:

prefs.ls.autosave=0;

%% environment
Expand All @@ -189,8 +184,6 @@
%% xelatex executable path:
prefs.ltx.pdfconverter=''; % set path to xelatex here (for PDF export)



prefs.ls.dir=''; % set path to lead server here (for web export)
prefs.ixi.dir=''; % set path to ixi database here
prefs.ixi.meanage=60; % mean age used if no patient/subject age is specified in folder.
prefs.ixi.meanage=60; % mean age used if no patient/subject age is specified in folder.
11 changes: 5 additions & 6 deletions connectomics/lead_connectome.m
Expand Up @@ -305,20 +305,19 @@ function runsavebutn_Callback(hObject, eventdata, handles)

% check wether this is run or save (independent or dependent mode)

cfig=handles.leadfigure;
options=ea_handles2options(handles);
options.uipatdirs=getappdata(handles.leadfigure,'uipatdir');
options.leadprod = 'connectome';
isindependent=getappdata(handles.leadfigure,'isindependent');
options.uipatdirs=getappdata(cfig,'uipatdir');
ea_savelcopts(handles)

% run execution:
ea_busyaction('on',cfig,'connectome');
ea_busyaction('on', handles.leadfigure, 'connectome');

if isindependent
if getappdata(handles.leadfigure,'isindependent')
ea_run('run',options);
end
ea_busyaction('off',cfig,'connectome');

ea_busyaction('off', handles.leadfigure, 'connectome');


% --- Executes on button press in degree_centrality.
Expand Down
31 changes: 11 additions & 20 deletions dev/lead_md/leadMD.m
Expand Up @@ -66,30 +66,23 @@ function leadMD_OpeningFcn(hObject, eventdata, handles, varargin)
options.prefs=ea_prefs('');

% load atlassets
as = dir(ea_space(options,'atlases'));
asc=cell(0);
cnt=1;
for i=1:length(as)
if as(i).isdir
asc{cnt}=as(i).name;
cnt=cnt+1;
end
end
atlases = dir(ea_space(options,'atlases'));
atlases = {atlases(cell2mat({atlases.isdir})).name};
atlases = atlases(cellfun(@(x) ~strcmp(x(1),'.'), atlases));

excludes={'.','..'};
asc(ismember(asc,excludes))=[];
if options.prefs.env.dev
asc{end+1}='Segment patient anatomy';
atlases{end+1} = 'Segment patient anatomy';
end
asc{end+1}='Use none';

set(handles.atlassetpopup,'String',asc);
atlases{end+1} = 'Use none';

set(handles.atlassetpopup,'String',asc);
[~,defix]=ismember(options.prefs.atlases.default,asc);
set(handles.atlassetpopup,'Value',defix);
set(handles.atlassetpopup, 'String', atlases);

set(handles.versiontxt,'String',['v',ea_getvsn('local')]);
set(handles.atlassetpopup, 'String', atlases);
[~,defix]=ismember(options.prefs.atlases.default, atlases);
set(handles.atlassetpopup, 'Value', defix);

set(handles.versiontxt, 'String', ['v', ea_getvsn('local')]);


% get electrode model specs and place in popup
Expand All @@ -102,8 +95,6 @@ function leadMD_OpeningFcn(hObject, eventdata, handles, varargin)
axis off;
axis equal;



% UIWAIT makes leadMD wait for user response (see UIRESUME)
% uiwait(handles.figure1);

Expand Down
6 changes: 3 additions & 3 deletions ea_amendtoolboxoptions.m
Expand Up @@ -2,11 +2,11 @@

if ~isfield(options,'lc') % might be predefined from an exported script..
try
options.lc=options.prefs.machine.lc;
options.lc = options.prefs.machine.lc;
catch
options.lc=[];
options.lc = [];
end
end

% append 2D options.
options.d2=ea_tdhandles2options([],options.d2);
options.d2 = ea_tdhandles2options([], options.d2);
17 changes: 7 additions & 10 deletions ea_autocoord.m
Expand Up @@ -10,9 +10,11 @@ function ea_autocoord(options)
% Copyright (C) 2014 Charite University Medicine Berlin, Movement Disorders Unit
% Andreas Horn

% set patientdir
options.prefs.patientdir = options.patientname;

% get accurate electrode specifications and save it in options.
options=ea_resolve_elspec(options);
options.prefs=ea_prefs(options.patientname);

directory = [options.root,options.patientname,filesep];

Expand Down Expand Up @@ -83,7 +85,7 @@ function ea_autocoord(options)
end

% Reslice(interpolate) preoperative anatomical image if needed
try ea_resliceanat(options); end
try ea_resliceanat(options); end

try
fs = fopen([directory,'.pp'],'w');
Expand Down Expand Up @@ -113,14 +115,10 @@ function ea_autocoord(options)
% 1. coreg all available preop MRI
ea_checkcoregallmri(options,0,1); % check and coregister all preoperative MRIs here.

% 2. then coreg post to pre MRI:
%try % fix me - can we get rid of this try/catch here?
% 2. then coreg postop MRI to preop MRI
ea_coregmr(options);

%end

% 3. finally perform normalization based on dominant or all preop
% MRIs:
% 3. finally perform normalization based on dominant or all preop MRIs
ea_dumpnormmethod(options,options.normalize.method,'normmethod'); % has to come first due to applynormalization.
eval([options.normalize.method,'(options)']); % triggers the normalization function and passes the options struct to it.

Expand Down Expand Up @@ -156,8 +154,7 @@ function ea_autocoord(options)

if options.doreconstruction
ea_checkfiles(options);
prefs=ea_prefs;
if ~prefs.env.dev % hard set to TRAC/CORE if not in dev mode.
if ~options.prefs.env.dev % hard set to TRAC/CORE if not in dev mode.
options.reconmethod=1;
end

Expand Down

0 comments on commit 4f87288

Please sign in to comment.