IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
detect_spectrum_type.m
Go to the documentation of this file.
1 %>@ingroup ioio
2 %>@file
3 %> @brief Attempts to detect type of single-spectrum files
4 %>
5 %> Possible outcomes are 'pir', 'opus', 'wire', or []
6 %> @sa mergetool.m
7 
8 %> @param wild
9 %> @return String. Possible outcomes are [], 'pir', 'opus', 'wire'
10 function s = detect_spectrum_type(wild)
11 s = [];
12 % Extracts first file name
13 trimdot = 0;
14 flag_image = 0;
15 [filenames, groupcodes] = resolve_dir(wild, trimdot, flag_image); %#ok<NASGU>
16 
17 if isempty(filenames)
18  irerror('No files in directory');
19 end;
20 
21 wild_new = fullfile(fileparts(wild), filenames{1});
22 
23 totry = {'pir', 'opus', 'wire'};
24 
25 for it = 1:numel(totry)
26  flag_ok = 0;
27  try
28  flag_error = 0;
29  s_code = sprintf('[mint, flag_error] = %s2data(''%s'', 0, 0, 0);', totry{it}, wild_new);
30  eval(s_code);
31  flag_ok = ~flag_error;
32  catch ME
33  irverbose('detect_spectrum_type() caught error:');
34  irverbose(ME.getReport());
35  end;
36 
37  if flag_ok
38  irverbose(sprintf('<<< YES %s !!! >>>', totry{it}), 1);
39  break;
40  else
41  % Not this one
42  irverbose(sprintf('<<< Not %s ... >>>', totry{it}), 1);
43  end;
44 end;
45 if flag_ok
46  s = totry{it};
47 end;
function irverbose(in s, in level)
function irerror(in s)
function resolve_dir(in wild, in trimdot, in flag_image)
function detect_spectrum_type(in wild)