| | function [conf, jobId] = bk_calcKernels(conf, varargin) |
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | conf_.histDir = '' ; |
| | conf_.testHistDir = '' ; |
| | conf_.kerDir = '' ; |
| | conf_.kerDb = struct ; |
| | conf_.kerDescrDir = '' ; |
| | conf_.noClobber = false ; |
| |
|
| | if nargin < 1, conf = conf_ ; return ; end |
| | conf = override(conf_, conf) ; |
| |
|
| | [jobId, taskId] = parallelDriver(varargin{:}, 'numNodes', length(conf.kerDb)) ; |
| | if ~isnan(jobId) & isnan(taskId) ; return ; end |
| |
|
| | ensuredir(conf.kerDir) ; |
| |
|
| | for ki = 1:length(conf.kerDb) |
| |
|
| | |
| | locked = parallelLock(ki, varargin{:}) ; |
| | if ~locked, continue ; end |
| |
|
| | ker = conf.kerDb(ki) ; |
| |
|
| | fprintf('Calculating kernel ''%s''.\n', ker.name) ; |
| |
|
| | if isempty(conf.testHistDir) |
| | |
| | |
| | |
| |
|
| | |
| | kerPath = fullfile(conf.kerDir, ker.name) ; |
| | if conf.noClobber & checkFile(kerPath) |
| | fprintf('\tSkipping to avoid clobbering ''%s''.\n', kerPath) ; |
| | continue ; |
| | end |
| |
|
| | |
| | histPath = fullfile(conf.histDir, ['hist-' ker.histName]) ; |
| | fprintf('\tLoading ''%s''.\n', histPath) ; |
| | hists = load(histPath) ; |
| | hists = hists.hists ; |
| |
|
| | |
| | ker = calcKernel(ker, hists) ; |
| |
|
| | |
| | kerPath = fullfile(conf.kerDir, ker.name) ; |
| | fprintf('\tSaving kernel ''%s''.\n', kerPath) ; |
| | ssave(kerPath, '-STRUCT', 'ker', '-v7.3') ; |
| |
|
| | ker = rmfield(ker, 'matrix') ; |
| |
|
| | |
| | if ~isempty(conf.kerDescrDir) |
| | kerDescrPath = fullfile(conf.kerDir, ['descr-' ker.name]) ; |
| | fprintf('\tSaving kernel descriptor ''%s''.\n', kerDescrPath) ; |
| | ssave(kerDescrPath, '-STRUCT', 'ker', '-v7.3') ; |
| | end |
| |
|
| | else |
| | |
| | |
| | |
| |
|
| | kerPath = fullfile(conf.kerDir, ['test-' ker.name]) ; |
| | if conf.noClobber & checkFile(kerPath) |
| | fprintf('\tSkipping to avoid clobbering ''%s''.\n', kerPath) ; |
| | continue ; |
| | end |
| |
|
| | |
| | histPath = fullfile(conf.histDir, ['hist-' ker.histName]) ; |
| | fprintf('\tLoading ''%s''.\n', histPath) ; |
| | hists = load(histPath) ; |
| | hists = hists.hists ; |
| |
|
| | testHistPath = fullfile(conf.testHistDir, ['hist-' ker.histName]) ; |
| | fprintf('\tLoading ''%s''.\n', testHistPath) ; |
| | testHists = load(testHistPath) ; |
| | testHists = testHists.hists ; |
| |
|
| | |
| | |
| | if ~isempty(conf.kerDescrDir) |
| | kerDescrPath = fullfile(conf.kerDescrDir, ['descr-' ker.name]) ; |
| | fprintf('\tLoading kernel descriptor ''%s''.\n', kerDescrPath) ; |
| | ker = load(kerDescrPath) ; |
| | end |
| |
|
| | |
| | testKer = calcKernel(ker, hists, testHists) ; |
| |
|
| | |
| | kerPath = fullfile(conf.kerDir, ['test-' ker.name]) ; |
| | fprintf('\tSaving kernel ''%s''.\n', kerPath) ; |
| | ssave(kerPath, '-STRUCT', 'testKer', '-v7.3') ; |
| | end |
| |
|
| | end |
| |
|