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

Last change on this file since 767 was 649, checked in by sommeria, 11 years ago

open_uvmat integrated in check_data_files

File size: 9.5 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%% input preparation mode (no RUN)
37if isstruct(Param) && isequal(Param.Action.RUN,0)
38    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
39    ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
40    ParamOut.NbSlice='on';%nbre of slices ('off' by default)
41    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
42    ParamOut.FieldName='off';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
43    ParamOut.FieldTransform = 'off';%can use a transform function
44    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
45    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
46    ParamOut.OutputDirExt='';%set the output dir extension (blank=no output dir)
47    return
48end
49%%%%%%%%%%%%  STANDARD PART  %%%%%%%%%%%%
50
51%% read input parameters from an xml file if input is a file name (batch mode)
52checkrun=1;
53if ischar(Param)
54    Param=xml2struct(Param);% read Param as input file (batch case)
55    checkrun=0;
56end
57hseries=findobj(allchild(0),'Tag','series');
58RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
59WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
60
61%% root input file(s) and type
62RootPath=Param.InputTable(:,1);
63RootFile=Param.InputTable(:,3);
64SubDir=Param.InputTable(:,2);
65NomType=Param.InputTable(:,4);
66FileExt=Param.InputTable(:,5);
67[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
68if isempty(i1_series)
69    return
70end
71%%%%%%%%%%%%
72% The cell array filecell is the list of input file names, while
73% filecell{iview,fileindex}:
74%        iview: line in the table corresponding to a given file series
75%        fileindex: file index within  the file series,
76% 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
77% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
78%%%%%%%%%%%%
79NbSlice=1;%default
80if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
81    NbSlice=Param.IndexRange.NbSlice;
82end
83nbview=numel(i1_series);%number of input file series (lines in InputTable)
84nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
85nbfield_i=size(i1_series{1},2); %nb of fields for the i index
86nbfield=nbfield_j*nbfield_i; %total number of fields
87nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
88nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
89
90%determine the file type on each line from the first input file
91ImageTypeOptions={'image','multimage','mmreader','video'};
92NcTypeOptions={'netcdf','civx','civdata'};
93for iview=1:nbview
94    [FileType{iview},FileInfo{iview},Object{iview}]=get_file_type(filecell{iview,1});
95    CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
96    CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
97end
98
99%% MAIN LOOP ON VIEWS (INPUT LINES)
100for iview=1:nbview
101    if isequal(FileType{iview},'mmreader')||isequal(FileType{iview},'video')||isequal(FileType{iview},'multimage')
102        [tild,FileInfo]=get_file_type(filecell{iview,1});
103        Tabchar{1}=filecell{iview,1};%info.Filename;
104        Tabchar{2}='';
105        Tabchar{3}=[num2str(FileInfo.FrameRate) ' frames/s '];
106        message='';
107        %         Tabchar{4}='';
108        %         Tabchar{5}=['  compression' FileInfo.VideoCompression];
109        %         Tabchar{6}=[ 'quality ' num2str(FileInfo.Quality)];
110    else
111        Tabchar={};
112        %LOOP ON SLICES
113        for i_slice=1:NbSlice
114            index_slice=i_slice:NbSlice:nbfield;
115            filefound={};
116            datnum=zeros(1,nbfield_j);
117            for ifile=1:nbfield_i
118                update_waitbar(WaitbarHandle,ifile/nbfield_i)
119                if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
120                    disp('program stopped by user')
121                    break
122                end
123                file=filecell{iview,index_slice(ifile)};
124                [Path,Name,ext]=fileparts(file);
125                detect=exist(file,'file'); % check the existence of the file
126                if detect==0
127                    lastfield='not found';
128                else
129                    datfile=dir(file);
130                    if isfield(datfile,'datenum')
131                        datnum(ifile)=datfile.datenum;
132                        filefound(ifile)={datfile.name};
133                    end
134                    lastfield='';
135                    [FileType{iview},FileInfo,Object]=get_file_type(file);
136                    if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata')
137                        if isfield(FileInfo,'CivStage')
138                            liststage={'civ1','fix1','patch1','civ2','fix2','patch2'};
139                            lastfield=liststage{FileInfo.CivStage};
140                        end
141                    end
142                    lastfield=[FileType{iview} ', ' lastfield];
143                end
144                Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
145                Tabchar(ifile+1,i_slice)={[file '...' lastfield]};
146            end
147        end
148        if isempty(filefound)
149            if NbSlice>1
150                message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
151            else
152                message='no file found';
153            end
154        else
155            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
156            filefound=filefound(find(datnum));
157            [first,ind]=min(datnum);
158            [last,indlast]=max(datnum);
159            message={['oldest modification:  ' filefound{ind} ' : ' datestr(first)];...
160                ['latest modification:  ' filefound{indlast} ' : ' datestr(last)]};
161        end
162        if ~isempty(Tabchar)
163            Tabchar=reshape(Tabchar,NbSlice*(nbfield_i+1),1);
164        end
165    end
166    hfig=figure(iview);
167    clf
168    if iview>1
169        pos=get(iview-1,'Position');
170        pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
171        set(hfig,'Position',pos)
172    end
173    set(hfig,'name',['check_data_files:view= ' num2str(iview)])
174    set(hfig,'MenuBar','none')% suppress the menu bar
175    set(hfig,'NumberTitle','off')%suppress the fig number in the title
176    h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'});
177    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
178end
179
180% 'open_uvmat': open with uvmat the  field selected in the list of 'series/check_data_files'
181%------------------------------------------------------------------------
182%function open_uvmat(hObject, eventdata)
183%
184% INPUT:
185% hObject: handle of uicontrol object containing the list
186% eventdata: not used
187function open_uvmat(hObject, eventdata)
188%------------------------------------------------------------------------
189list=get(hObject,'String');
190index=get(hObject,'Value');
191rootroot=get(hObject,'UserData');
192filename=list{index};
193ind_dot=strfind(filename,'...');
194if ~isempty(ind_dot)
195filename=filename(1:ind_dot-1);
196end
197filename=fullfile(rootroot,filename);
198if exist(filename,'file')%visualise the vel field if it exists
199    uvmat(filename)
200    set(gcbo,'Value',1)
201end
Note: See TracBrowser for help on using the repository browser.