source: trunk/src/series/check_data_files.m @ 573

Last change on this file since 573 was 573, checked in by sommeria, 8 years ago

clean the head of the series fcts

File size: 9.1 KB
Line 
1%%'check_data_files': check the existence, type and status of the files selected by series.fig
2%------------------------------------------------------------------------
3% function GUI_input=check_data_files(Param)
4%
5%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
6%OUTPUT
7% GUI_input=list of options in the GUI series.fig needed for the function
8%
9%INPUT:
10% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
11% In batch mode, Param is the name of the corresponding xml file containing the same information
12% In the absence of input (as activated when the current Action is selected
13% in series), the function ouput GUI_input set the activation of the needed GUI elements
14%
15% Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param)
16%    .InputTable: cell of input file names, (several lines for multiple input)
17%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
18%    .OutputSubDir: name of the subdirectory for data outputs
19%    .OutputDir: directory for data outputs, including path
20%    .Action: .ActionName: name of the current activated function
21%             .ActionPath:   path of the current activated function
22%    .IndexRange: set the file or frame indices on which the action must be performed
23%    .FieldTransform: .TransformName: name of the selected transform function
24%                     .TransformPath:   path  of the selected transform function
25%                     .TransformHandle: corresponding function handle
26%    .InputFields: sub structure describing the input fields withfields
27%              .FieldName: name of the field
28%              .VelType: velocity type
29%              .FieldName_1: name of the second field in case of two input series
30%              .VelType_1: velocity type of the second field in case of two input series
31%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
34function ParamOut=check_data_files(Param)
35
36%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
37if ~exist('Param','var') % case with no input parameter
38    ParamOut={'NbViewMax';'';...% max nbre of input file series (default='' , no limitation)
39        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
40        'NbSlice';'on'; ...%nbre of slices ('off' by default)
41        'VelType';'off';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
42        'FieldName';'off';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
43        'FieldTransform'; 'off';...%can use a transform function
44        'ProjObject';'off';...%can use projection object(option 'off'/'on',
45        'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
46        'OutputDirExt';'';...%set the output dir extension
47               ''};
48        return
49end
50
51%%%%%%%%%%%%  STANDARD PART  %%%%%%%%%%%%
52%% select different modes,  RUN, parameter input, BATCH
53% BATCH  case: read the xml file for batch case
54if ischar(Param)
55        Param=xml2struct(Param);
56        checkrun=0;
57% RUN case: parameters introduced as the input structure Param
58else
59    if isfield(Param,'Specific')&& strcmp(Param.Specific,'?')
60        checkrun=1;% will only search interactive input parameters (preparation of BATCH mode)
61    else
62        checkrun=2; % indicate the RUN option is used
63    end
64    hseries=guidata(Param.hseries);%handles of the GUI series
65end
66ParamOut=Param; %default output
67%OutputDir=[Param.OutputSubDir Param.OutputDirExt];NO OUTPUT FILE
68   
69%% root input file(s) and type
70RootPath=Param.InputTable(:,1);
71RootFile=Param.InputTable(:,3);
72SubDir=Param.InputTable(:,2);
73NomType=Param.InputTable(:,4);
74FileExt=Param.InputTable(:,5);
75[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
76%%%%%%%%%%%%
77% The cell array filecell is the list of input file names, while
78% filecell{iview,fileindex}:
79%        iview: line in the table corresponding to a given file series
80%        fileindex: file index within  the file series,
81% i1_series(iview,ref_j,ref_i)... are the corresponding arrays of indices i1,i2,j1,j2, depending on the input line iview and the two reference indices ref_i,ref_j
82% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
83%%%%%%%%%%%%
84NbSlice=1;%default
85if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
86    NbSlice=Param.IndexRange.NbSlice;
87end
88nbview=numel(i1_series);%number of input file series (lines in InputTable)
89nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
90nbfield_i=size(i1_series{1},2); %nb of fields for the i index
91nbfield=nbfield_j*nbfield_i; %total number of fields
92nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
93nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
94
95%determine the file type on each line from the first input file
96ImageTypeOptions={'image','multimage','mmreader','video'};
97NcTypeOptions={'netcdf','civx','civdata'};
98for iview=1:nbview
99    [FileType{iview},FileInfo{iview},Object{iview}]=get_file_type(filecell{iview,1});
100    CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
101    CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
102end
103
104%% MAIN LOOP ON VIEWS (INPUT LINES)
105for iview=1:nbview
106    if isequal(FileType{iview},'mmreader')||isequal(FileType{iview},'video')||isequal(FileType{iview},'multimage')
107        [tild,FileInfo]=get_file_type(filecell{iview,1});
108        Tabchar{1}=filecell{iview,1};%info.Filename;
109        Tabchar{2}=FileInfo.FileModDate;
110        Tabchar{3}=[num2str(FileInfo.FramesPerSecond) ' frames/s '];
111        Tabchar{4}=FileInfo.ImageType;
112        Tabchar{5}=['  compression' FileInfo.VideoCompression];
113        Tabchar{6}=[ 'quality ' num2str(FileInfo.Quality)];   
114    else
115        Tabchar={};
116        %LOOP ON SLICES
117        for i_slice=1:NbSlice
118            index_slice=i_slice:NbSlice:nbfield;
119            filefound={};
120            datnum=zeros(1,nbfield_j);
121            for ifile=1:nbfield_i
122                stopstate=get(hseries.RUN,'BusyAction');
123                if isequal(stopstate,'queue')% enable STOP command
124                    update_waitbar(hseries.Waitbar,ifile/nbfield_i)         
125                    file=filecell{iview,index_slice(ifile)};
126                    [Path,Name,ext]=fileparts(file);
127                    detect=exist(file,'file'); % check the existence of the file
128                    if detect==0
129                        lastfield='not found';
130                    else
131                        datfile=dir(file);
132                        if isfield(datfile,'datenum')
133                            datnum(ifile)=datfile.datenum;
134                            filefound(ifile)={datfile.name};
135                        end                     
136                        lastfield='';
137                        [FileType{iview},FileInfo,Object]=get_file_type(file);
138                        if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata')
139                            if isfield(FileInfo,'CivStage')
140                            liststage={'civ1','fix1','patch1','civ2','fix2','patch2'};
141                            lastfield=liststage{FileInfo.CivStage};
142                            end
143                        end
144                        lastfield=[FileType{iview} ', ' lastfield];                   
145                    end
146                    Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
147                    Tabchar(ifile+1,i_slice)={[file '...' lastfield]};
148                end
149            end
150        end
151        if isempty(filefound)
152            if NbSlice>1
153                message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
154            else
155                 message='no file found';
156            end
157        else
158            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
159            filefound=filefound(find(datnum));
160            [first,ind]=min(datnum);
161            [last,indlast]=max(datnum);
162            message={['oldest modification:  ' filefound{ind} ' : ' datestr(first)];...
163                ['latest modification:  ' filefound{indlast} ' : ' datestr(last)]};
164        end
165        if ~isempty(Tabchar)
166          Tabchar=reshape(Tabchar,NbSlice*(nbfield_i+1),1);
167        end
168    end
169    hfig=figure(iview);
170    clf
171    if iview>1
172        pos=get(iview-1,'Position');
173        pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
174        set(hfig,'Position',pos)
175    end
176    set(hfig,'name',['check_data_files:view= ' num2str(iview)])
177    set(hfig,'MenuBar','none')% suppress the menu bar
178    set(hfig,'NumberTitle','off')%suppress the fig number in the title
179    h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'});
180    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
181end
Note: See TracBrowser for help on using the repository browser.