IMF - Toolbox
Command line Manual



Command Line Commands


List of Commands

Example of a Batch Job

This batch job plots all IGPP-flat files and all IWF-flat files that are in one folder (input parameter path). The error flags are interpolated and the unfiltered and the ‘PC 3’-filtered signals are plotted. To make a batch job more stable, additional try .., catch ..., end statements can be implemented.

function IMF_BATCH(path)

% Examlpe of a batch job
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%parameter in:
%
%path : Path of the Flat-files

%
%parameter out:
%
% none
%
% This batch job interpolates error flags and plots the unfiltered signals as
% well as PC 3 - filtered signals.
% (PC 3: 0.022Hz - 0.1Hz, Cauer, 6th order, zero phase)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% initialize
IMF_ini;


% files should not automatically be loaded into the main menory!!
%XXXXXXXXXXXXXXXXXXXXXXXXXXXX
global g_auto_add_last;
g_auto_add_last = 0;
%XXXXXXXXXXXXXXXXXXXXXXXXXXXX



name = dir(path)


[n,m] = size(name);


% big log viewer and scaling 'automatic MATLAB'
IMF_plot_options('display','log big','scaling','MATLAB');


for i = 1:n
if name(i).isdir == 0
if length(name(i).name) > 4;
if (strcmpi(name(i).name((length(name(i).name)-3):length(name(i).name)),'.hed') == 1) ...
| (strcmpi(name(i).name((length(name(i).name)-3):length(name(i).name)),'.ffh') == 1)
%read flat
IDs = IMF_read_flat('','',name(i).name,path);
%IDs is longer than 1 if the flat file is bigger than g_max_bytes
[dummy,nn] = size(IDs);
%get highest file ID
maxID = IDs{nn};
%increment highest file ID
ID_num = maxID+1;
for ii = 1:nn
% load file
IMF_load_wsp(IDs{ii});
% select whole file ID
IMF_select('ID',IDs{ii});
% count number of data series
count = IMF_count_data;
for iii = 1:3:count
if count - iii < 1
% last subplot
IMF_plot('plot1',[num2str(IDs{ii}) '.' num2str(iii)], ...
'Calc','interr');
print;
IMF_plot('plot1',[num2str(IDs{ii}) '.' num2str(iii)], ...
'Calc','interr','PC 3');
print;
elseif count - iii < 2
% last 2 subplots
IMF_plot('plot1',[num2str(IDs{ii}) '.' num2str(iii)], ...
'Calc','interr', ...
'plot2',[num2str(IDs{ii}) '.' num2str(iii+1)], ...
'Calc','interr');
print;
IMF_plot('plot1',[num2str(IDs{ii}) '.' num2str(iii)], ...
'Calc','interr','PC 3', ...
'plot2',[num2str(IDs{ii}) '.' num2str(iii+1)], ...
'Calc','interr', ...
'Calc','PC 3');
print;
else %three subplots
IMF_plot('plot1',[num2str(IDs{ii}) '.' num2str(iii)], ...
'Calc','interr', ...
'plot2',[num2str(IDs{ii}) '.' num2str(iii+1)], ...
'Calc','interr', ...
'plot3',[num2str(IDs{ii}) '.' num2str(iii+2)], ...
'Calc','interr');
print;
IMF_plot('plot1',[num2str(IDs{ii}) '.' num2str(iii)], ...
'Calc','interr','PC 3', ...
'plot2',[num2str(IDs{ii}) '.' num2str(iii+1)], ...
'Calc','interr', ...
'Calc','PC 3', ...
'plot3',[num2str(IDs{ii}) '.' num2str(iii+2)], ...
'Calc','interr', ...
'Calc','PC 3');
print;
end;
end;
end;
%delete the created ws*.MAT-files
IMF_delete_mat(IDs);
%reset selections and history
IMF_reset_all;
end;
end;
end;
end;
%renumber the ws*.MAT-files
IMF_reorganize;



Example of a Recursive Batch Job

Very often data are stored in structures of directories. The next batch job calls the routine ‘IMF_BATCH’ (described in the previous section) in a recursive way to work on subdirectories also.

function IMF_BATCH_REC(path)
% Examlpe of a recursive batch job
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%parameter in:
%
%path : main path of the Flat-files
%
%parameter out:
%
% none
%
% This batch job calls other batch jobs to work recursive on sub directories
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


IMF_ini;

global g_os;

%cut off slash or backslash
if strcmp(path(end),g_os) == 1
path=path(1:end-1);
end;

%first call
path_cell = find_sub_path(path,{});
in_path_cell{1}=path;
%concatenate main path
path_cell = cat(2,in_path_cell,path_cell);

[m,n]=size(path_cell);

%call the batch job in a loop
for i = 1:n
path = path_cell{i}
IMF_BATCH(path)
end;


function path_cell = find_sub_path(dir_path,path_cell);
% recursive search for sub directories

global g_os

%g_os='\'; %'DOS'
%g_os='/'; UNIX, LINUX

D = dir(dir_path);

K = [D.isdir];
pos = find(K == 1);

for i = pos
if (strcmpi(D(i).name,'.') == 0) & (strcmpi(D(i).name,'..') == 0)
name_cell{1} = [dir_path g_os D(i).name];
path_cell = cat(2,path_cell,name_cell);
path_cell = find_sub_path([dir_path g_os D(i).name],path_cell);
end;
end;


[ Previous | Reference Summary | Next ]