Skip to content
Snippets Groups Projects
Commit 48e0d988 authored by Laura Nervo's avatar Laura Nervo
Browse files

*** NewSegmentationGUI ***

  gtSegmentationInitialise : Set segmentation method to 'doublethr_new' to be distinguished from 'doublethr' (standard segmentation routine)
  NewSegmentationPreGUI    : Check existence of difspot images before running segmentation and asking for their deletion.
  gtSegmentationLaunchOAR  : implemented the OAR submission using more cores on a single machine (default are 6 cores on one machine with 8000 Mb/core)
                             Difspot images should be saved in 2_difspot/00000, 2_difspot/10000, etc...

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>
parent 1fb97ca2
No related branches found
No related tags found
No related merge requests found
function NewSegmentationDoubleThreshold(first_img, last_img, workingdir)
% NEWSEGMENTATIONDOUBLETHRESHOLD Faster, more efficient segmentation of
% blobs and spots
% blobs and spots
%
% NewSegmentationDoubleThreshold(first_img, last_img, workingdir)
%
% ---------------------------------------------------------------
% Replaces previous double threshold segmentation, keeping essentially the
% same parameters and functionality. Designed to work on a single large
% machine, or a few machines. Reduces file I/O time by reading a stack of
......@@ -468,7 +467,7 @@ fprintf('blobID %d output, blob %d from this block \n', blob.difblobID, blob.blo
'graylevel', vals);
end
if stack.writespots
if (stack.writespots)
gtSegmentationBlob2SpotTable(blob, stack)
end
......
......@@ -60,7 +60,7 @@ function NewSegmentationGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% varargin command line arguments to NewSegmentationGUI (see VARARGIN)
% deal with tables, etc
NewSegmentationPreGUI
NewSegmentationPreGUI();
% get segmentation parameters and populate figure
handles = gtSegmentationInitialise(handles);
......
......@@ -151,6 +151,7 @@ else
dbInsertMultiple([parameters.acq.name 'fullmedianvals'], 'ndx', 0:totproj)
end
parameters.seg.method = 'doublethr_new';
% one question - does user want to subtract the background before
% segmentation?
......@@ -161,4 +162,18 @@ parameters.seg.background_subtract = strcmpi(check, 'y');
save(parameters_name, 'parameters')
% create the first '00000' folder by default
[~,msg] = mkdir(fullfile(parameters.acq.name,'2_difspot','00000')); disp(msg)
if exist(fullfile(parameters.acq.name,'2_difspot','00000','difspot00000.edf'),'file')
check = inputwdefault('Do you want to remove all the difspot images before going on? [y/n]','y');
if strcmpi(check, 'y')
delete(fullfile(parameters.acq.name,'2_difspot','*0000','*.edf'));
end
elseif exist(fullfile(parameters.acq.name,'2_difspot','difspot00000.edf'),'file')
check = inputwdefault('Do you want to remove all the difspot images before going on? [y/n]','y');
if strcmpi(check, 'y')
delete(fullfile(parameters.acq.name,'2_difspot','*.edf'));
end
end
end % end of NewSegmentationPreGUI
......@@ -17,6 +17,9 @@ load parameters
handles.parameters = parameters;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~strcmp(handles.parameters.seg.method, 'doublethr_new')
handles.parameters.seg.method = 'doublethr_new';
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% how many images in this scan?
......
......@@ -2,14 +2,16 @@ function handles = gtSegmentationLaunchOAR(handles)
% launch OAR jobs
set(handles.status_label, 'string', 'Launching OAR', 'backgroundColor', 'y')
drawnow
drawnow()
handles.parameters.seg.segmentation_stack_size = 1000;
OARtime = str2num(get(handles.OAR_walltime, 'string'));
OARtmp = ceil(OARtime/60); % minutes
OARm = mod(OARtmp, 60); % minutes
OARh = (OARtmp-OARm)/60; % hours
OAR_walltime = sprintf('%02d:%02d:00', OARh, OARm);
OAR_njobs = str2num(get(handles.OAR_njobs, 'string'));
list = build_list_v2();
ind_tmp = findValueIntoCell(list.seg(:,1), {'segmentation_stack_size'});
list.seg{ind_tmp(1),4} = 2;
handles.parameters.seg = gtModifyStructure(handles.parameters.seg, list.seg, 2, 'Segmentation stack size:');
handles = gtSegmentationSaveParameters(handles);
if strcmpi(handles.parameters.acq.type, '360degree')
totproj = handles.parameters.acq.nproj*2;
......@@ -18,33 +20,74 @@ else
end
totproj = totproj-1;
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp(' ')
disp('You should try running this in a single, large, interactive OAR job')
disp(' ')
disp('I suggest something like this:')
disp(' ')
disp('From rnice6, get an interactive OAR job:')
disp('oarsub -I -p "mem_core_mb=8000" -l nodes=1/core=6,walltime=2')
disp(' ')
disp('then start matlab as normal via python')
disp(' ')
disp('You should have enough RAM to use >1000 images in memory')
disp('Set parameters.seg.segmentation_stack_size = 1000')
disp('Otherwise, default is a conservative 250')
disp(' ')
disp('In the dataset directory, run:')
disp(sprintf('NewSegmentationDoubleThreshold(0, %d, pwd)', totproj))
disp(' ')
disp('...and see what happens. Best of luck!')
disp(' ')
disp('If things work, we can automate properly...')
disp('Andy, 30/08/2013')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
set(handles.status_label, 'string', 'OAR (not!) launched', 'backgroundColor', 'g')
drawnow()
check = inputwdefault('Launch Segmentation with OAR? [y/n]', 'y');
if strcmpi(check,'y')
% should be one big job
handles.parameters.oar.njobs = str2num(get(handles.OAR_njobs, 'string'));
OARtime = str2num(get(handles.OAR_walltime, 'string'));
OARtmp = ceil(OARtime/60); % minutes
OARm = mod(OARtmp, 60); % minutes
OARh = (OARtmp-OARm)/60; % hours
handles.parameters.oar.walltime = sprintf('%02d:%02d:00', OARh, OARm);
handles.parameters.oar.mem_core_mb = 8000; %Mb
handles.parameters.oar.node = 1;
handles.parameters.oar.core = 6;
list = build_list_v2();
list.oar(end+1,:) = {'mem_core_mb','Memory for each core in Mb','double', 2};
list.oar(end+1,:) = {'node','Number of nodes','double', 2};
list.oar(end+1,:) = {'core','Number of cores per node','double', 2};
handles.parameters.oar = gtModifyStructure(handles.parameters.oar, list.oar, 2, 'OAR parameters:');
parameters = handles.parameters;
save('parameters.mat','parameters')
disp('Using OAR parameters:')
disp(handles.parameters.oar)
pause(0.5);
OAR_make('NewSegmentationDoubleThreshold', 0, totproj, ...
handles.parameters.oar.njobs, handles.parameters.acq.dir, 1, ...
'mem_core_mb', handles.parameters.oar.mem_core_mb, ...
'node', handles.parameters.oar.node, ...
'core', handles.parameters.oar.core, ...
'walltime', handles.parameters.oar.walltime);
set(handles.status_label, 'string', 'OAR launched', 'backgroundColor', 'g')
drawnow()
else
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp(' ')
disp('You should try running this in a single, large, interactive OAR job')
disp(' ')
disp('I suggest something like this:')
disp(' ')
disp('From rnice6, get an interactive OAR job:')
disp('oarsub -I -p "mem_core_mb=8000" -l nodes=1/core=6,walltime=2')
disp(' ')
disp('then start matlab as normal via python')
disp(' ')
disp('You should have enough RAM to use >1000 images in memory')
disp('Set parameters.seg.segmentation_stack_size = 1000')
disp('Otherwise, default is a conservative 250')
disp(' ')
disp('In the dataset directory, run:')
fprintf('NewSegmentationDoubleThreshold(0, %d, pwd)\n', totproj)
disp(' ')
disp('...and see what happens. Best of luck!')
disp(' ')
disp('If things work, we can automate properly...')
disp('Andy, 30/08/2013')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
set(handles.status_label, 'string', 'OAR (not!) launched', 'backgroundColor', 'g')
drawnow()
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment