Skip to content
Snippets Groups Projects
Commit 10291599 authored by Wolfgang Ludwig's avatar Wolfgang Ludwig
Browse files

Support for carrying over en existing parameter file

parent 67f7cfa8
No related branches found
No related tags found
No related merge requests found
......@@ -22,205 +22,218 @@ function bbdir = gtFindDirectBeamBB(acq)
% to be more tolerant of missing images
% (incorporating Sabine's modifications for interlaced scans)
%
% Version 003 March 2020 by W Ludwig
% now allows checking an existing bounding box.
%
% Operates at the start of preprocessing, so images have been undistorted and
% interlaced images renamed, and placed in the 0_rawdata/scanname/ folder
%
%
refarea = 100;
refarea = 200;
lim_directbeam = 0.4;
ref = get_refimage(acq);
disp(' ');
disp('Determining direct beam bounding box...');
disp(' ');
% get the first reference image
name1 = fullfile(acq.dir,'0_rawdata',acq.name,'refHST0000.edf');
name2 = fullfile(acq.dir,'0_rawdata',acq.name,'ref0000_0000.edf');
if exist(name1, 'file')
ref0 = edf_read(name1);
elseif exist(name2, 'file')
ref0 = edf_read(name2);
if ~isempty(acq.bbdir)
bbdir = display_bbdir(acq, acq.bbdir, ref);
else
disp('No initial reference image found!');
ref0 = [];
end
disp(' ');
disp('Determining direct beam bounding box...');
disp(' ');
% if possible get the last reference image
% after renaming of interlaced scans, so no special naming conventions
if strcmp(acq.type, '360degree')
totproj = 2*acq.nproj;
elseif strcmp(acq.type, '180degree')
totproj = acq.nproj;
else
gtError('ACQ:invalid_parameter', ...
'Unknown type of scan: "%s". Check parameters.acq.type!', acq.type);
end
name1 = fullfile(acq.dir, '0_rawdata', acq.name, sprintf('refHST%04d.edf', totproj));
name2 = fullfile(acq.dir, '0_rawdata', acq.name, sprintf('ref0000_%04d.edf', totproj));
if exist(name1, 'file')
ref1 = edf_read(name1);
elseif exist(name2, 'file')
ref1 = edf_read(name2);
else
disp('No final reference image found...');
ref1 = [];
end
% calculate mean value m in central part of the image
m = gtImgMeanValue(ref(round(acq.ydet/2-refarea:acq.ydet/2+refarea+1), ...
round(acq.xdet/2-refarea:acq.xdet/2+refarea+1)));
cen = double(ref > (lim_directbeam*m)); % should correspond to direct beam footprint
% find the direct beam region bb automatically (supposes fairly homogeneous
% beam profile - attention with ID11 data here... !
marker = zeros(acq.ydet, acq.xdet);
marker(round(acq.ydet/2), round(acq.xdet/2)) = 1;
cen = imreconstruct(marker, cen);
tmp = regionprops(cen, 'BoundingBox');
if isempty(tmp)
disp('Please select (zoom onto) the direct beam area and disable zoom afterwards');
hfig = figure('name', 'Direct beam bounding box');
colormap gray;
imagesc(ref);
drawnow;
h = zoom(hfig); set(h, 'Enable', 'on'); waitfor(h, 'Enable', 'off'), hold on;
disp('-> Now click top-left and bottom-right corners for final selection');
bbdir = ginput(2);
bbdir = round([bbdir(1, 1) bbdir(1, 2) bbdir(2, 1)-bbdir(1, 1)+1 bbdir(2, 2)-bbdir(1, 2)+1]);
% Make sure the bbox width and height are even numbers (needed for correlation)
bbdir(3:4) = ceil(bbdir(3:4)/2)*2;
cen = gtPlaceSubImage(ones(bbdir(4),bbdir(3)), zeros(acq.ydet, acq.xdet), bbdir(1), bbdir(2));
else
bbdir = tmp.BoundingBox;
end
% get dark image
darkname = fullfile(acq.dir,'0_rawdata',acq.name,'dark.edf');
if exist(darkname, 'file')
d = edf_read(darkname);
%shouldn't need these work arounds
% elseif exist('darkend0000.edf', 'file')
% % try to make it
% d = edf_read('darkend0000.edf')/acq.ndark;
% else
% % work around
% d = ones(size(ref0))*median(ref0(:));
end
% Tighten bb until it's fully filled
bbdir = [ceil(bbdir(1:2)), bbdir(3:4)-1];
goon = true;
while goon
cenbb = gtCrop(cen, bbdir);
goon = false;
if any(~cenbb(:, 1)) % tighten bb on the left
bbdir(1) = bbdir(1)+1;
bbdir(3) = bbdir(3)-1;
goon = true;
end
if any(~cenbb(:, end)) % tighten bb on the right
bbdir(3) = bbdir(3)-1;
goon = true;
end
cenbb = gtCrop(cen, bbdir);
if any(~cenbb(1, :)) % tighten bb at the top
bbdir(2) = bbdir(2)+1;
bbdir(4) = bbdir(4)-1;
goon = true;
end
if any(~cenbb(end, :)) % tighten bb at the bottom
bbdir(4) = bbdir(4)-1;
goon = true;
end
end
% apply dark image
if ~isempty(ref0)
ref0 = ref0-d;
end
if ~isempty(ref1)
ref1 = ref1-d;
end
% Loosen bb if it can be on any side
goon = true;
while goon
goon = false;
tmpbb = bbdir+[-1 0 1 0]; % loose bb on the left
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
end
tmpbb = bbdir+[0 0 1 0]; % loose bb on the right
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
end
tmpbb = bbdir+[0 -1 0 1]; % loose bb at the top
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
end
tmpbb = bbdir+[0 0 0 1]; % loose bb at the bottom
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
end
end
%take the minimum of the two references if available
if (~isempty(ref0) && ~isempty(ref1))
ref = min(ref0, ref1); % min of ref-s at beginning and end of scan
elseif (~isempty(ref0))
ref = ref0;
else % no images found!
disp('%%%%%%% missing images %%%%%%%%');
disp('no reference images found in this directory!');
disp('using a default guess');
disp('%%%%%%% missing images %%%%%%%%');
disp(' ');
bbdir = [512 512 1024 1024];
return
% make sure the bbox width and height are even numbers (needed for correlation)
bbdir(3:4) = ceil(bbdir(3:4)/2)*2;
bbdir = display_bbdir(acq, bbdir, ref);
end
end % end of function
% calculate mean value m in central part of the image
m = gtImgMeanValue(ref(round(acq.ydet/2-refarea:acq.ydet/2+refarea+1), ...
round(acq.xdet/2-refarea:acq.xdet/2+refarea+1)));
cen = double(ref > (lim_directbeam*m)); % should correspond to direct beam footprint
% find the direct beam region bb automatically (supposes fairly homogeneous
% beam profile - attention with ID11 data here... !
marker = zeros(acq.ydet, acq.xdet);
marker(round(acq.ydet/2), round(acq.xdet/2)) = 1;
cen = imreconstruct(marker, cen);
tmp = regionprops(cen, 'BoundingBox');
bbdir = tmp.BoundingBox;
% Tighten bb until it's fully filled
bbdir = [ceil(bbdir(1:2)), bbdir(3:4)-1];
goon = true;
while goon
cenbb = gtCrop(cen, bbdir);
goon = false;
if any(~cenbb(:, 1)) % tighten bb on the left
bbdir(1) = bbdir(1)+1;
bbdir(3) = bbdir(3)-1;
goon = true;
end
if any(~cenbb(:, end)) % tighten bb on the right
bbdir(3) = bbdir(3)-1;
goon = true;
end
cenbb = gtCrop(cen, bbdir);
if any(~cenbb(1, :)) % tighten bb at the top
bbdir(2) = bbdir(2)+1;
bbdir(4) = bbdir(4)-1;
goon = true;
end
if any(~cenbb(end, :)) % tighten bb at the bottom
bbdir(4) = bbdir(4)-1;
goon = true;
function bbdir = display_bbdir(acq, bbdir, ref)
hfig = figure('name', 'Direct beam bounding box');
% plot bbox found, its center-line and center-line of image
bbcenter_abs = ((2*bbdir(1))+bbdir(3)-1)/2;
colormap gray;
imagesc(ref);
drawnow;
hold on;
plot([bbdir(1), bbdir(1)+bbdir(3)-1, bbdir(1)+bbdir(3)-1, bbdir(1), bbdir(1)], [bbdir(2), bbdir(2), bbdir(2)+bbdir(4)-1, bbdir(2)+bbdir(4)-1, bbdir(2)], 'r-');
plot([acq.xdet/2+0.5 acq.xdet/2+0.5], [1 acq.ydet], 'b-.'); % centre of the ccd
plot([bbcenter_abs bbcenter_abs], [bbdir(2) bbdir(2)+bbdir(4)-1], 'c-.'); % centre of the direct beam
% interactive check
questionMsg = 'Are you satisfied with this bounding box for the direct beam? [y/n]';
while (strcmpi(inputwdefault(questionMsg, 'n'), 'n'))
disp('Please select (zoom onto) the direct beam area and disable zoom afterwards');
figure(hfig), clf, imagesc(ref), h = zoom(hfig); set(h, 'Enable', 'on'); waitfor(h, 'Enable', 'off'), hold on;
disp('-> Now click top-left and bottom-right corners for final selection');
bbdir = ginput(2);
bbdir = round([bbdir(1, 1) bbdir(1, 2) bbdir(2, 1)-bbdir(1, 1)+1 bbdir(2, 2)-bbdir(1, 2)+1]);
% Make sure the bbox width and height are even numbers (needed for correlation)
bbdir(3:4) = ceil(bbdir(3:4)/2)*2;
% Plot the new bounding box
plot([bbdir(1), bbdir(1)+bbdir(3)-1, bbdir(1)+bbdir(3)-1, bbdir(1), bbdir(1)], [bbdir(2), bbdir(2), bbdir(2)+bbdir(4)-1, bbdir(2)+bbdir(4)-1, bbdir(2)], 'r-');
bbcenter_abs = ((2*bbdir(1))+bbdir(3)-1)/2;
plot([acq.xdet/2+0.5 acq.xdet/2+0.5], [1 acq.ydet], 'b-.');
plot([bbcenter_abs bbcenter_abs], [bbdir(2) bbdir(2)+bbdir(4)-1], 'c-.'); % centre of the direct beam
end
close(hfig);
end
% Loosen bb if it can be on any side
goon = true;
while goon
goon = false;
tmpbb = bbdir+[-1 0 1 0]; % loose bb on the left
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
function ref = get_refimage(acq)
% get dark image
darkname = fullfile(acq.dir,'0_rawdata',acq.name,'dark.edf');
if exist(darkname, 'file')
d = edf_read(darkname);
end
tmpbb = bbdir+[0 0 1 0]; % loose bb on the right
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
% get the first reference image
name1 = fullfile(acq.dir,'0_rawdata',acq.name,'refHST0000.edf');
name2 = fullfile(acq.dir,'0_rawdata',acq.name,'ref0000_0000.edf');
if exist(name1, 'file')
ref0 = edf_read(name1) - d;
elseif exist(name2, 'file')
ref0 = edf_read(name2) - d;
else
disp('No initial reference image found!');
ref0 = [];
end
tmpbb = bbdir+[0 -1 0 1]; % loose bb at the top
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
% if possible get the last reference image
% after renaming of interlaced scans, so no special naming conventions
if strcmp(acq.type, '360degree')
totproj = 2*acq.nproj;
elseif strcmp(acq.type, '180degree')
totproj = acq.nproj;
else
gtError('ACQ:invalid_parameter', ...
'Unknown type of scan: "%s". Check parameters.acq.type!', acq.type);
end
tmpbb = bbdir+[0 0 0 1]; % loose bb at the bottom
tmpim = gtCrop(cen, tmpbb);
if all(tmpim(:))
bbdir = tmpbb;
goon = true;
name1 = fullfile(acq.dir, '0_rawdata', acq.name, sprintf('refHST%04d.edf', totproj));
name2 = fullfile(acq.dir, '0_rawdata', acq.name, sprintf('ref0000_%04d.edf', totproj));
if exist(name1, 'file')
ref1 = edf_read(name1) - d;
elseif exist(name2, 'file')
ref1 = edf_read(name2) - d;
else
disp('No final reference image found...');
ref1 = [];
end
end
% make sure the bbox width and height are even numbers (needed for correlation)
bbdir(3:4) = ceil(bbdir(3:4)/2)*2;
% plot bbox found, its center-line and center-line of image
bbcenter_abs = ((2*bbdir(1))+bbdir(3)-1)/2;
hfig = figure('name', 'Direct beam bounding box');
colormap gray;
imagesc(ref);
drawnow;
hold on;
plot([bbdir(1), bbdir(1)+bbdir(3)-1, bbdir(1)+bbdir(3)-1, bbdir(1), bbdir(1)], [bbdir(2), bbdir(2), bbdir(2)+bbdir(4)-1, bbdir(2)+bbdir(4)-1, bbdir(2)], 'r-');
plot([acq.xdet/2+0.5 acq.xdet/2+0.5], [1 acq.ydet], 'b-.'); % centre of the ccd
plot([bbcenter_abs bbcenter_abs], [bbdir(2) bbdir(2)+bbdir(4)-1], 'c-.'); % centre of the direct beam
% interactive check
questionMsg = 'Are you satisfied with this bounding box for the direct beam? [y/n]';
while (strcmpi(inputwdefault(questionMsg, 'n'), 'n'))
disp('Please select (zoom onto) the direct beam area and disable zoom afterwards');
figure(hfig), clf, imagesc(ref), h = zoom(hfig); set(h, 'Enable', 'on'); waitfor(h, 'Enable', 'off'), hold on;
disp('-> Now click top-left and bottom-right corners for final selection');
bbdir = ginput(2);
bbdir = round([bbdir(1, 1) bbdir(1, 2) bbdir(2, 1)-bbdir(1, 1)+1 bbdir(2, 2)-bbdir(1, 2)+1]);
% Make sure the bbox width and height are even numbers (needed for correlation)
bbdir(3:4) = ceil(bbdir(3:4)/2)*2;
% Plot the new bounding box
plot([bbdir(1), bbdir(1)+bbdir(3)-1, bbdir(1)+bbdir(3)-1, bbdir(1), bbdir(1)], [bbdir(2), bbdir(2), bbdir(2)+bbdir(4)-1, bbdir(2)+bbdir(4)-1, bbdir(2)], 'r-');
bbcenter_abs = ((2*bbdir(1))+bbdir(3)-1)/2;
plot([acq.xdet/2+0.5 acq.xdet/2+0.5], [1 acq.ydet], 'b-.');
plot([bbcenter_abs bbcenter_abs], [bbdir(2) bbdir(2)+bbdir(4)-1], 'c-.'); % centre of the direct beam
end
close(hfig);
end % end of function
%take the minimum of the two references if available
if (~isempty(ref0) && ~isempty(ref1))
ref = min(ref0, ref1); % min of ref-s at beginning and end of scan
elseif (~isempty(ref0))
ref = ref0;
else % no images found!
disp('%%%%%%% missing images %%%%%%%%');
disp('no reference images found in this directory!');
disp('using a default guess');
disp('%%%%%%% missing images %%%%%%%%');
disp(' ');
bbdir = [512 512 1024 1024];
return
end
end
\ No newline at end of file
......@@ -34,7 +34,7 @@ try
name_ref1 = name_ref0;
else
sprintf('Using images DURING scan for determination of rotation axis posistion\n')
% SECOND CHOICE: IMAGES DURING SCAN
% SECOND CHOICE: IMAGES DURING SCAN
% WL May 2009
% changed to use per default the images at end of scan - should be more accurate;
indx_next = acq.nproj/(acq.interlaced_turns+1);
......@@ -51,7 +51,10 @@ try
end
end
% If there is already a sample bounding box, we will use it
if ~isempty(acq.bb)
bbdir = acq.bb;
end
im0 = edf_read(name_curr, bbdir, 'nodisp');
im1 = edf_read(name_next, bbdir, 'nodisp');
ref0 = edf_read(name_ref0, bbdir, 'nodisp');
......@@ -82,15 +85,7 @@ try
im0 = (im0-d)./(ref0-d);
im1 = (im1-d)./(ref1-d);
% determine centre of rotation
% shift=[];
% assignin('base', 'shift', shift);
shift = gtFindShifts(im0, fliplr(im1), 'block', 'on');
% set(gcf,'name','Manual correlation to find rotation axis...')
% while isempty(shift)
% drawnow;
% shift = evalin('base','shift');
% end
% working in the direct beam bounding box
rotu = bbdir(1) - 1 + (bbdir(3)/2) + 0.5 + (shift(2)/2);
......
function acqbb = gtFindSampleEdges(acq, prep, bb)
function acqbb = gtFindSampleEdges(acq, prep)
% GTFINDSAMPLEEDGES
% acqbb = gtFindSampleEdges(acq, prep, bb)
% ----------------------------------------
......@@ -22,7 +22,11 @@ function acqbb = gtFindSampleEdges(acq, prep, bb)
disp('Trying to determine a tight BoundingBox around the sample and a region for intensity normalization');
intervals = 6;
if ~isempty(prep.bbox)
bb = prep.bbox;
else
bb = acq.bbdir;
end
%use bb when reading the files in.
ims = zeros(bb(4),bb(3));
count = 0; %how many images read?
......@@ -78,8 +82,8 @@ for ii = 0:round(im_turn/intervals):im_turn
end
if (count > 0)
ims = min(ims, [], 3); % using minimum for better contrast at edges...
ims = min(ims, [], 3); % using minimum for better contrast at edges..
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% analyse images
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -147,6 +151,22 @@ if (count > 0)
disp('default "last" value')
last = bb(3)-prep.margin+1;
end
disp('centering bb on rotx')
%rotation axis position
bb_rotu = acq.rotu-bb(1)+1;
% check that enough of a margin is left for normalisation
min_first = prep.margin + 1;
max_last = bb(3) - prep.margin;
% shouldn't exceed either of these
max_width = min(bb_rotu-min_first, max_last-bb_rotu);
% we have previously tried to guess first and last
width = max(bb_rotu-first, last-bb_rotu);
% apply the limit
width = min(width, max_width);
first = floor(bb_rotu-width);
last = ceil(bb_rotu+width);
else
disp('%%%%%%% missing images %%%%%%%%')
disp('no useful images found! - using defaults')
......@@ -165,24 +185,6 @@ else
end
disp('centering bb on rotx')
%rotation axis position
bb_rotu = acq.rotu-bb(1)+1;
% check that enough of a margin is left for normalisation
min_first = prep.margin + 1;
max_last = bb(3) - prep.margin;
% shouldn't exceed either of these
max_width = min(bb_rotu-min_first, max_last-bb_rotu);
% we have previously tried to guess first and last
width = max(bb_rotu-first, last-bb_rotu);
% apply the limit
width = min(width, max_width);
first = floor(bb_rotu-width);
last = ceil(bb_rotu+width);
%pass to operator for final decision
h = figure();
......@@ -223,7 +225,7 @@ close(h);
incr = 1;
end
if ((first > prep.margin+incr+1) && (last < bb(3)-prep.margin-incr-1))
if ((first > prep.margin+incr) && (last < bb(3)-prep.margin-incr+1))
first = first-incr;
last = last+incr;
else
......
......@@ -170,7 +170,7 @@ if (parameters.acq.no_direct_beam)
check = inputwdefault('Is it like a taper scan with the sample still in the images? [y/n]', 'y');
if strcmpi(check,'y')
% define the sample envelope - assume centred on direct beam
labgeo_tmp = gtGeoSamEnvFromAcq(parameters.labgeo, parameters.acq);
labgeo_tmp = gtGeoSamEnvFromAcq(parameters.labgeo, parameters.detgeo, parameters.acq);
parameters.labgeo.samenvtop = labgeo_tmp.samenvtop;
parameters.labgeo.samenvbot = labgeo_tmp.samenvbot;
parameters.labgeo.samenvrad = labgeo_tmp.samenvrad;
......@@ -214,21 +214,23 @@ else
check = inputwdefault(['Do you want to (re)-define the Sample BoundingBox (currently ' sprintf('[%d %d %d %d]',parameters.acq.bb) ')? [y/n]'], 'n');
end
if strcmpi(check,'y')
parameters.acq.bb = gtFindSampleEdges(parameters.acq,parameters.prep,bbdir);
parameters.prep.bbox = parameters.acq.bb+[-parameters.prep.margin 0 2*parameters.prep.margin 0];
% define the sample envelope - assume centred on direct beam
labgeo_tmp = gtGeoSamEnvFromAcq(parameters.labgeo, parameters.acq);
parameters.labgeo.samenvtop = labgeo_tmp.samenvtop;
parameters.labgeo.samenvbot = labgeo_tmp.samenvbot;
parameters.labgeo.samenvrad = labgeo_tmp.samenvrad;
parameters.acq.bb = gtFindSampleEdges(parameters.acq,parameters.prep);
end
parameters.prep.bbox = parameters.acq.bb+[-parameters.prep.margin 0 2*parameters.prep.margin 0];
save(parameters_name,'parameters');
end % end no_direct_beam case
% Update Detector reference position
parameters.detgeo = gtGeoDetDefaultParameters(parameters.acq);
save(parameters_name,'parameters');
if isempty(parameters.acq.masterdir)
parameters.detgeo = gtGeoDetDefaultParameters(parameters.acq);
save(parameters_name,'parameters');
end
% Calculate sample envelope
labgeo_tmp = gtGeoSamEnvFromAcq(parameters.labgeo, parameters.detgeo, parameters.acq);
parameters.labgeo.samenvtop = labgeo_tmp.samenvtop;
parameters.labgeo.samenvbot = labgeo_tmp.samenvbot;
parameters.labgeo.samenvrad = labgeo_tmp.samenvrad;
if isempty(parameters.acq.maxradius)
check='y';
......
......@@ -93,7 +93,43 @@ redColor = sprintf(gtGetANSIColour('red'));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create parameters structure, move/correct datafiles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copy parameters from a different acquisition
check = inputwdefault('Would you like to copy an existing parameter file? [y/n]', 'y');
if strcmpi(check, 'y')
masterpath = uigetdir('../','Select a directory');
p = gtLoadParameters(masterpath);
p.acq.dir = pwd;
p.acq.name = gtGetLastDirName(p.acq.dir);
p.acq.pair_tablename = sprintf('%sspotpairs', p.acq.name);
p.acq.calib_tablename = sprintf('%spaircalib', p.acq.name);
p.acq.collection_dir = pwd;
p.acq.collection_dir_old = pwd;
p.acq.masterdir = masterpath;
gtSaveParameters(p);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set up the database tables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gtDBSetupTables(p.acq);
% Make directories
disp(['Setting up directory structure in ' p.acq.dir]);
[~,msg] = mkdir( fullfile(p.acq.dir, '0_rawdata') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '0_rawdata', p.acq.name)); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '0_rawdata', 'Orig') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '1_preprocessing') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '1_preprocessing', 'full') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '1_preprocessing', 'abs') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '1_preprocessing', 'ext') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '2_difspot') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '3_pairmatching') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '4_grains') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '5_reconstruction') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '6_rendering') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '7_fed') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '8_analysis') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, '8_analysis', 'figures') ); disp(msg);
[~,msg] = mkdir( fullfile(p.acq.dir, 'OAR_log') ); disp(msg);
end
% If the parameters are already set up, start moving and correction
if exist(fullfile(pwd,'parameters.mat'), 'file')
disp('A parameters.mat file already exists in this directory');
......@@ -155,9 +191,9 @@ end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set up directory structure.
% If in a visitor directory, make a DCT_Analysis directory, otherwise
% use ID11/graintracking.
parameters.acq.dir = gtSetAnalysisDir(pwd());
% For the moment we process in the acquisition directory - this will have to
% change with ESRF data policy
parameters.acq.dir = pwd; % gtSetAnalysisDir(pwd());
hasChosen = false;
while (~hasChosen)
......@@ -181,6 +217,12 @@ freeSpace = round(jdir.getUsableSpace() / 10^6);
fprintf('You have about %d Mb free space\n', freeSpace);
jdir.delete();
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set up the database tables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gtDBSetupTables(parameters.acq);
% Make directories
disp(['Setting up directory structure in ' parameters.acq.dir]);
[~,msg] = mkdir(parameters.acq.dir); disp(msg);
......@@ -244,7 +286,7 @@ else
parameters.acq = gtAddMatFile(parameters.acq, params_acq, true, false, false);
clear params_acq;
parameters = gtCheckParameters(parameters, 'acq', 'verbose', true);
%parameters = %gtCheckParameters(parameters, 'acq', 'verbose', true);
gtSaveParameters(parameters);
% Default SAMPLE REFERENCE
......@@ -252,7 +294,7 @@ else
% omega=0.
parameters.samgeo = gtGeoSamDefaultParameters();
parameters = gtCheckParameters(parameters, 'samgeo', 'verbose', true);
%parameters = %gtCheckParameters(parameters, 'samgeo', 'verbose', true);
gtSaveParameters(parameters);
% Default RECONSTRUCTION REFERENCE
......@@ -260,7 +302,7 @@ else
% but scaled to microns.
parameters.recgeo = gtGeoRecDefaultParameters();
parameters = gtCheckParameters(parameters, 'recgeo', 'verbose', true);
%parameters = %gtCheckParameters(parameters, 'recgeo', 'verbose', true);
gtSaveParameters(parameters);
end
......@@ -293,11 +335,13 @@ if isfield(info, 'motor')
parameters.acq.rotation_name = 'pmo';
elseif ismember('diffrz', tmp_motors)
parameters.acq.rotation_name = 'diffrz';
elseif ismember('srot', tmp_motors)
parameters.acq.rotation_name = 'srot';
else
parameters.acq.rotation_name = 'unknown';
end
else
parameters.acq.rotation_name = 'unknown';
parameters.acq.rotation_name = 'diffrz';
end
......@@ -342,7 +386,7 @@ else
end
parameters = gtCheckParameters(parameters, 'labgeo', 'verbose', true);
%parameters = %gtCheckParameters(parameters, 'labgeo', 'verbose', true);
gtSaveParameters(parameters);
header = 'Parameters dealing with arbitrary geometry:';
......
......@@ -3,13 +3,9 @@ function handles = gtSegmentationLaunchOAR(handles)
set(handles.status_label, 'string', 'Launching OAR', 'backgroundColor', 'y')
drawnow()
totproj = gtAcqTotNumberOfImages(handles.parameters) - 1;
handles.parameters.seg.segmentation_stack_size = 600;
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);
......@@ -30,7 +26,7 @@ if strcmpi(check,'Yes')
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};
......@@ -38,7 +34,7 @@ if strcmpi(check,'Yes')
list.oar(end+1,:) = {'core','Number of cores per node','double', 2};
handles.parameters.oar = gtModifyStructure(handles.parameters.oar, list.oar, 2, 'OAR parameters:');
handles.parameters.seg.segmentation_stack_size = ceil(totproj ./ handles.parameters.oar.njobs);
parameters = handles.parameters;
save('parameters.mat','parameters')
......
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