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

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

bugs corrected. One step further for using compiled fcts and cluster with series

File size: 8.7 KB
RevLine 
[573]1%%'check_data_files': check the existence, type and status of the files selected by series.fig
[330]2%------------------------------------------------------------------------
[447]3% function GUI_input=check_data_files(Param)
[330]4%
[447]5%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
[330]6%OUTPUT
7% GUI_input=list of options in the GUI series.fig needed for the function
8%
9%INPUT:
[447]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
[330]14%
[447]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%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[330]33
[457]34function ParamOut=check_data_files(Param)
[447]35
[592]36%% input preparation mode (no RUN)
37if isstruct(Param) && isequal(Param.Action.RUN,0)
[594]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)
[592]46    ParamOut.OutputDirExt='';%set the output dir extension (blank=no output dir)
47return
[330]48end
[478]49%%%%%%%%%%%%  STANDARD PART  %%%%%%%%%%%%
[594]50
51%% read input parameters from an xml file if input is a file name (batch mode)
52checkrun=1;
[478]53if ischar(Param)
[594]54    Param=xml2struct(Param);% read Param as input file (batch case)
55    checkrun=0;
[374]56end
[594]57
[447]58%% root input file(s) and type
59RootPath=Param.InputTable(:,1);
60RootFile=Param.InputTable(:,3);
61SubDir=Param.InputTable(:,2);
62NomType=Param.InputTable(:,4);
63FileExt=Param.InputTable(:,5);
[478]64[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
[592]65if isempty(i1_series)
66    return
67end
[478]68%%%%%%%%%%%%
69% The cell array filecell is the list of input file names, while
70% filecell{iview,fileindex}:
71%        iview: line in the table corresponding to a given file series
72%        fileindex: file index within  the file series,
73% 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
74% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
75%%%%%%%%%%%%
[447]76NbSlice=1;%default
[478]77if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
[447]78    NbSlice=Param.IndexRange.NbSlice;
79end
[455]80nbview=numel(i1_series);%number of input file series (lines in InputTable)
[478]81nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
82nbfield_i=size(i1_series{1},2); %nb of fields for the i index
83nbfield=nbfield_j*nbfield_i; %total number of fields
84nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
85nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
[330]86
[447]87%determine the file type on each line from the first input file
88ImageTypeOptions={'image','multimage','mmreader','video'};
89NcTypeOptions={'netcdf','civx','civdata'};
90for iview=1:nbview
91    [FileType{iview},FileInfo{iview},Object{iview}]=get_file_type(filecell{iview,1});
92    CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
93    CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
94end
[330]95
[447]96%% MAIN LOOP ON VIEWS (INPUT LINES)
[330]97for iview=1:nbview
[455]98    if isequal(FileType{iview},'mmreader')||isequal(FileType{iview},'video')||isequal(FileType{iview},'multimage')
[470]99        [tild,FileInfo]=get_file_type(filecell{iview,1});
100        Tabchar{1}=filecell{iview,1};%info.Filename;
101        Tabchar{2}=FileInfo.FileModDate;
102        Tabchar{3}=[num2str(FileInfo.FramesPerSecond) ' frames/s '];
103        Tabchar{4}=FileInfo.ImageType;
104        Tabchar{5}=['  compression' FileInfo.VideoCompression];
[594]105        Tabchar{6}=[ 'quality ' num2str(FileInfo.Quality)];
[330]106    else
107        Tabchar={};
108        %LOOP ON SLICES
109        for i_slice=1:NbSlice
[447]110            index_slice=i_slice:NbSlice:nbfield;
[340]111            filefound={};
[451]112            datnum=zeros(1,nbfield_j);
[447]113            for ifile=1:nbfield_i
[594]114                if checkrun
115                    stopstate=get(Param.RUNHandle,'BusyAction');
116                    update_waitbar(Param.WaitbarHandle,ifile/nbfield_i)
117                else
118                    stopstate='queue';
119                end
[330]120                if isequal(stopstate,'queue')% enable STOP command
[447]121                    file=filecell{iview,index_slice(ifile)};
[330]122                    [Path,Name,ext]=fileparts(file);
123                    detect=exist(file,'file'); % check the existence of the file
124                    if detect==0
125                        lastfield='not found';
126                    else
127                        datfile=dir(file);
128                        if isfield(datfile,'datenum')
129                            datnum(ifile)=datfile.datenum;
[451]130                            filefound(ifile)={datfile.name};
[594]131                        end
[330]132                        lastfield='';
[470]133                        [FileType{iview},FileInfo,Object]=get_file_type(file);
134                        if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata')
[377]135                            if isfield(FileInfo,'CivStage')
[594]136                                liststage={'civ1','fix1','patch1','civ2','fix2','patch2'};
137                                lastfield=liststage{FileInfo.CivStage};
[377]138                            end
139                        end
[594]140                        lastfield=[FileType{iview} ', ' lastfield];
[330]141                    end
142                    Tabchar(1,i_slice)={['slice #' num2str(i_slice)]};
[447]143                    Tabchar(ifile+1,i_slice)={[file '...' lastfield]};
[330]144                end
145            end
146        end
[340]147        if isempty(filefound)
[330]148            if NbSlice>1
149                message=['no set of ' num2str(NbSlice) ' (NbSlices) files found'];
150            else
[594]151                message='no file found';
[330]152            end
153        else
154            datnum=datnum(find(datnum));%keep the non zero values corresponding to existing files
[451]155            filefound=filefound(find(datnum));
[330]156            [first,ind]=min(datnum);
157            [last,indlast]=max(datnum);
[451]158            message={['oldest modification:  ' filefound{ind} ' : ' datestr(first)];...
159                ['latest modification:  ' filefound{indlast} ' : ' datestr(last)]};
[594]160        end
[330]161        if ~isempty(Tabchar)
[594]162            Tabchar=reshape(Tabchar,NbSlice*(nbfield_i+1),1);
[330]163        end
164    end
165    hfig=figure(iview);
166    clf
167    if iview>1
168        pos=get(iview-1,'Position');
169        pos(1)=pos(1)+(iview-1)*pos(1)/nbview;
170        set(hfig,'Position',pos)
171    end
[427]172    set(hfig,'name',['check_data_files:view= ' num2str(iview)])
173    set(hfig,'MenuBar','none')% suppress the menu bar
174    set(hfig,'NumberTitle','off')%suppress the fig number in the title
[361]175    h=uicontrol('Style','listbox', 'Position', [20 20 500 300], 'String', Tabchar, 'Callback', {'open_uvmat'});
[330]176    hh=uicontrol('Style','listbox', 'Position', [20 340 500 40], 'String', message);
177end
Note: See TracBrowser for help on using the repository browser.