3 %> @brief Merges several
"Wire txt" files into a dataset
5 %> @c data.groupcodes is made from file name. File name is trimmed at the trimdot-th dot counted from right to left. E.g.,
6 %> This allows one to trim
"sample.0.dat" at the penultimate dot (ignodedoctount=2) or "sample.dat" at the last dot
9 %> data.obsnames will contain the file names
11 %> For reference on parameters, please check @ref mergetool.m
16 %> @param trimdot See pirtool
20 function [data, flag_error] =
wire2data(wild, trimdot, flag_image, height)
22 if ~exist('trimdot', 'var')
26 [filenames, groupcodes] =
resolve_dir(wild, trimdot, flag_image);
28 no_files = length(filenames);
31 if no_files/height ~= floor(no_files/height)
32 irerror('Wire2Data: Invalid image height!');
37 idxs = find(wild == '/');
41 path_ = wild(1:idxs(end));
51 filename = fullfile(path_, filenames{i});
53 M = dlmread(filename);
59 % Checks against previous size
62 irerror(sprrintf('Wire2Data: Wrong number of data points: expected=%d; found=%d
', nf, n1));
69 % Initializes dataset
if first row
70 data.X = zeros(no_files, nf);
71 data.classes = zeros(no_files, 1);
72 data.obsnames = cell(no_files, 1);
73 data.groupcodes = cell(no_files, 1);
75 data.classlabels = {
'Class 0'};
82 data.obsnames{ii} = filenames{i};
83 data.groupcodes{ii} = groupcodes{i};
87 cnt_error = cnt_error+1;
88 errors{end+1} = filename;
96 irverbose(sprintf(
'NOTICE: only %d/%d files were successfully read. Import failed on following files:', no_files-cnt_error, no_files));
100 flag_error = cnt_error;
102 % Trims matrices rows because were overdimensioned
103 data.X = data.X(1:ii, :);
104 data.classes = data.classes(1:ii, :);
105 data.obsnames = data.obsnames(1:ii, :);
106 data.groupcodes = data.groupcodes(1:ii, :);
111 data.height = height;
function irverbose(in s, in level)
function progress2_change(in prgrss, in title, in perc, in i, in n)
function progress2_open(in title, in perc, in i, in n)
function resolve_dir(in wild, in trimdot, in flag_image)
function wire2data(in wild, in trimdot, in flag_image, in height)
function progress2_close(in prgrss)