I am trying to use that code included in the file "start_blob_batch_user_training.m" in the ifcb-analysis set (https://github.com/hsosik/ifcb-analysis).
function [ ] = start_blob_batch_user_training(in_dir_base , out_dir_blob_base, parallel_proc_flag)
%function [ ] = start_blob_batch_user_training(in_dir_base , out_dir_blob_base, parallel_proc_flag)
%For example:
%start_blob_batch_user_training('C:\work\IFCB\user_training_test_data\data\2014\', 'C:\work\IFCB\user_training_test_data\blobs\2014\', false)
%IFCB image processing: configure and initiate batch processing for blob extraction
%Heidi M. Sosik, Woods Hole Oceanographic Institution, Aug 2015
%
%example input variables
% in_dir_base = 'C:\work\IFCB\user_training_test_data\data\2014\'; %USER local data location (where are your *.roi files)
% out_dir_blob_base = 'C:\work\IFCB\user_training_test_data\blobs\2014\'; %USER local data location for blob reults
% parallel_proc_flag = false; %USER true to enable parallel processing
if ~exist('parallel_proc_flag', 'var')
parallel_proc_flag = false; %default
end
if ~exist(out_dir_blob_base, 'dir'),
mkdir(out_dir_blob_base)
end;
daydir = dir([in_dir_base 'D*']);
%daydir = dir([in_dir_base 'IFCB1_2015_160*']);
daydir = daydir([daydir.isdir]);
bins = [];
in_dir = [];
out_dir_blob = [];
for ii = 1:length(daydir)
in_dir_temp = [in_dir_base daydir(ii).name filesep];
bins_temp = dir([in_dir_temp '*.adc']);
if ~isempty(bins_temp)
bins_temp = regexprep({bins_temp.name}', '.adc', '');
daystr = char(bins_temp(1)); daystr = daystr(1:9);
%%TEMP FOR OLD MVCO STYLE v2
% daystr = char(bins_temp(1)); daystr = daystr(2:9);
% daystr = char(bins_temp(1)); daystr = daystr(7:14);
out_dir_blob_temp = [out_dir_blob_base daystr filesep];
bins_done = dir([out_dir_blob_temp '*.zip']);
bins_done = regexprep({bins_done.name}', '_blobs_v2.zip', '');
[bins_temp,ia] = setdiff(bins_temp, bins_done);
end
if ~isempty(bins_temp)
daystr = char(bins_temp); daystr = daystr(:,1:9);
% daystr = char(bins_temp); daystr = daystr(:,1:14);
in_dir = [in_dir; repmat(cellstr(in_dir_temp),length(bins_temp),1)];
out_dir_blob_temp = cellstr([repmat(out_dir_blob_temp,length(bins_temp),1)]);
out_dir_blob = [out_dir_blob; out_dir_blob_temp];
bins = [bins; bins_temp];
end;
end;
nfiles = length(bins);
disp(['processing ' num2str(nfiles) ' files'])
if nfiles > 0
batch_blobs(in_dir, out_dir_blob, bins, parallel_proc_flag);
end
end
I first referenced the path of the input directory and the output directory (macos) :
in_dir_base = '/Users/user/Documents/user_training_test_data/data/2014/';
out_dir_blob_base = '/Users/user/Documents/user_training_test_data/blobs/2014/';
But when I launch the code I receive that error :
"Not enough input arguments.
Error in start_blob_batch_user_training (line 17)
if ~exist(out_dir_blob_base, 'dir'),"
How could this be fixed?
For the dataset, I used the "Test data" provided the in the instructions of the ifcb-analysis set (https://github.com/hsosik/ifcb-analysis/wiki/Blob-extraction,-feature-extraction,-and-classifier-application#instructions-for-blob-extraction)
Unfortunately, *.roi files are too voluminous to be added as a reproductible example here...
After some test I realised the problem came from the fact the function needed to be launched from another matlab file. Of course, the other file need to define the variables in_dir_base , out_dir_blob_base, parallel_proc_flag
and after launch the function.
The code in the new file is then the following :
in_dir_base = 'Path/to/data/';
out_dir_blob_base = 'Path/to/output/';
parallel_proc_flag = false;
start_blob_batch_user_training(in_dir_base , out_dir_blob_base, parallel_proc_flag)
Launching the code from the newly created Matlab instead of inside the "start_blob_batch_user_training.m" fix the error.