source: trunk/src/series/time_series.m @ 457

Last change on this file since 457 was 457, checked in by sommeria, 12 years ago

merg_i_j transformed to the new standards.
Various improvements

File size: 28.2 KB
Line 
1%'time_series': extract a time series, used with series.fig
2% this function can be used as a template for applying a global operation on a series of input fields
3%------------------------------------------------------------------------
4% function GUI_input=time_series(Param)
5%
6%%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%%
7%
8% This function is used in four modes by the GUI series:
9%           1) config GUI: with no input argument, the function determine the suitable GUI configuration
10%           2) interactive input: the function is used to interactively introduce input parameters, and then stops
11%           3) RUN: the function itself runs, when an appropriate input  structure Param has been introduced.
12%           4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input.
13%
14% This function is used in four modes by the GUI series:
15%           1) config GUI: with no input argument, the function determine the suitable GUI configuration
16%           2) interactive input: the function is used to interactively introduce input parameters, and then stops
17%           3) RUN: the function itself runs, when an appropriate input  structure Param has been introduced.
18%           4) BATCH: the function itself proceeds in BATCH mode, using an xml file 'Param' as input.
19%
20%OUTPUT
21% GUI_input=list of options in the GUI series.fig needed for the function
22%
23%INPUT:
24% In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series.
25% In batch mode, Param is the name of the corresponding xml file containing the same information
26% In the absence of input (as activated when the current Action is selected
27% in series), the function ouput GUI_input set the activation of the needed GUI elements
28%
29% Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param)
30%    .InputTable: cell of input file names, (several lines for multiple input)
31%                      each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension}
32%    .OutputSubDir: name of the subdirectory for data outputs
33%    .OutputDir: directory for data outputs, including path
34%    .Action: .ActionName: name of the current activated function
35%             .ActionPath:   path of the current activated function
36%    .IndexRange: set the file or frame indices on which the action must be performed
37%    .FieldTransform: .TransformName: name of the selected transform function
38%                     .TransformPath:   path  of the selected transform function
39%                     .TransformHandle: corresponding function handle
40%    .InputFields: sub structure describing the input fields withfields
41%              .FieldName: name of the field
42%              .VelType: velocity type
43%              .FieldName_1: name of the second field in case of two input series
44%              .VelType_1: velocity type of the second field in case of two input series
45%    .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object)
46%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47%
48function ParamOut=time_series(Param)
49
50%% requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
51if ~exist('Param','var')
52    ParamOut={'RootPath';'two';...%nbre of possible input series (options 'on'/'two'/'many', default:'one')
53        'SubDir';'on';... % subdirectory of derived files (PIV fields), ('on' by default)
54        'RootFile';'on';... %root input file name ('on' by default)
55        'FileExt';'on';... %input file extension ('on' by default)
56        'NomType';'on';...%type of file indexing ('on' by default)
57        'NbSlice';'on'; ...%nbre of slices ('off' by default)
58        'VelTypeMenu';'two';...% menu for selecting the velocity type (civ1,..) options 'off'/'one'/'two', 'off' by default)
59        'FieldMenu';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
60        'CoordType';'on';...%can use a transform function 'off' by default
61        'GetObject';'on';...%can use projection object ,'off' by default
62        'OutputDirExt';'.series'...
63        %'GetMask';'on'...%can use mask option   ,'off' by default
64        %'PARAMETER'; options: name of the user defined parameter',repeat a line for each parameter
65               ''};
66    return %exit the function
67end
68
69%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%%
70%% select different modes,  RUN, parameter input, BATCH
71% BATCH  case: read the xml file for batch case
72ParamOut=Param; %default output
73if ischar(Param)
74    if strcmp(Param,'input?')
75        checkrun=1;% will inly search input parameters (preparation of BATCH mode)
76    else
77        Param=xml2struct(Param);
78        checkrun=0;
79    end
80% RUN case: parameters introduced as the input structure Param
81else
82    hseries=guidata(Param.hseries);%handles of the GUI series
83    WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series
84    checkrun=2; % indicate the RUN option is used
85end
86
87%% root input file(s) and type
88RootPath=Param.InputTable(:,1);
89RootFile=Param.InputTable(:,3);
90SubDir=Param.InputTable(:,2);
91NomType=Param.InputTable(:,4);
92FileExt=Param.InputTable(:,5);
93
94% get the set of input file names (cell array filecell), and the lists of
95% input file or frame indices i1_series,i2_series,j1_series,j2_series
96[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
97% filecell{iview,fileindex}: cell array representing the list of file names
98%        iview: line in the table corresponding to a given file series
99%        fileindex: file index within  the file series,
100% 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
101% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
102% set of frame indices used for movie or multimage input
103% numbers of slices and file indices
104
105NbSlice=1;%default
106if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
107    NbSlice=Param.IndexRange.NbSlice;
108end
109nbview=numel(i1_series);%number of input file series (lines in InputTable)
110nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
111nbfield_i=size(i1_series{1},2); %nb of fields for the i index
112nbfield=nbfield_j*nbfield_i; %total number of fields
113nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
114nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
115
116%determine the file type on each line from the first input file
117ImageTypeOptions={'image','multimage','mmreader','video'};
118NcTypeOptions={'netcdf','civx','civdata'};
119for iview=1:nbview
120    if ~exist(filecell{iview,1}','file')
121        msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist'])
122        return
123    end
124    [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1});
125    CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images
126    CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files
127    if ~isempty(j1_series{iview})
128        frame_index{iview}=j1_series{iview};
129    else
130        frame_index{iview}=i1_series{iview};
131    end
132end
133
134%% calibration data and timing: read the ImaDoc files
135mode=''; %default
136timecell={};
137itime=0;
138NbSlice_calib={};
139XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
140for iview=1:nbview%Loop on views
141    SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.'
142    filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder
143    if ~exist(filexml,'file')
144        filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder
145        if ~exist(filexml,'file')
146            filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file
147            if ~exist(filexml,'file')
148                filexml='';
149            end
150        end
151    end
152    if ~isempty(filexml)
153        [XmlData{iview},error]=imadoc2struct(filexml);
154    end
155    if isfield(XmlData{iview},'Time')
156        itime=itime+1;
157        timecell{itime}=XmlData{iview}.Time;
158    end
159    if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
160        NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform
161        if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
162            msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
163        end
164    end
165end
166
167%% check coincidence in time for several input file series
168multitime=0;
169if isempty(timecell)
170    time=[];
171elseif length(timecell)==1
172    time=timecell{1};
173elseif length(timecell)>1
174    multitime=1;
175    for icell=1:length(timecell)
176        if ~isequal(size(timecell{icell}),size(timecell{1}))
177            msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
178            time=timecell{1};
179            multitime=0;
180            break
181        end
182    end
183end
184if multitime
185    for icell=1:length(timecell)
186        time(icell,:,:)=timecell{icell};
187    end
188    diff_time=max(max(diff(time)));
189    if diff_time>0
190        msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)])
191    end   
192end
193if size(time,2) < i2_series{1}(end) ||( ~isempty(j2_series{1}) && size(time,3) < j2_series{1}(end))% time array absent or too short in ImaDoc xml file'
194    time=[];
195end
196
197%% coordinate transform or other user defined transform
198transform_fct='';%default
199if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle')
200    transform_fct=Param.FieldTransform.TransformHandle;
201end
202%%%%%%%%%%%% END STANDARD PART  %%%%%%%%%%%%
203 % EDIT FROM HERE
204
205%% check the validity of  input file types
206if CheckImage{1}
207    FileExtOut='.png'; % write result as .png images for image inputs
208elseif CheckNc{1}
209    FileExtOut='.nc';% write result as .nc files for netcdf inputs
210else
211    msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}])
212    return
213end
214if nbview==2 && ~isequal(CheckImage{1},CheckImage{2})
215        msgbox_uvmat('ERROR','input must be two image series or two netcdf file series')
216    return
217end
218NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
219if NbSlice~=nbfield_j
220    answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]);
221    if ~strcmp(answer,'Yes')
222        return
223    end
224end
225
226%% Set field names and velocity types
227InputFields{1}=[];%default (case of images)
228if isfield(Param,'InputFields')
229    InputFields{1}=Param.InputFields;
230end
231if nbview==2
232    InputFields{2}=[];%default (case of images)
233    if isfield(Param,'InputFields')
234        InputFields{2}=Param.InputFields{1};%default
235        if isfield(Param.InputFields,'FieldName_1')
236            InputFields{2}.FieldName=Param.InputFields.FieldName_1;
237            if isfield(Param.InputFields,'VelType_1')
238                InputFields{2}.VelType=Param.InputFields.VelType_1;
239            end
240        end
241    end
242end
243%%% TO UPDATE
244if isequal(FieldName,'get_field...')
245    hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
246    if numel(hget_field)>1
247        delete(hget_field(2:end)) % delete multiple occurerence of the GUI get_fioeld
248    elseif isempty(hget_field)
249        filename=filecell{1,1};
250      % filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),num_j2{1}(1),SubDir{1});
251       idetect(iview)=exist(filename,'file');
252       hget_field=get_field(filename);
253       return
254    end
255    SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
256    if isempty(SubField)
257        delete(hget_field)
258        filename=filecell{1,1};
259       %filename=name_generator(filebase{1},i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),j2_series{1}(1),SubDir{1});
260        hget_field=get_field(filename);
261        SubField=read_get_field(hget_field); %read the names of the variables to plot in the get_field GUI
262    end
263end
264%%%%%%%
265
266%% Initiate output fields
267%initiate the output structure as a copy of the first input one (reproduce fields)
268[DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1);
269if ~isempty(errormsg)
270    msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg])
271    return
272end
273time_1=[];
274if isfield(DataOut,'Time')
275    time_1=DataOut.Time(1);
276end
277if CheckNc{iview}
278    if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute))
279        DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute];
280    end
281    DataOut.Conventions='uvmat';
282    DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}];
283    ActionKey='Action';
284    while isfield(DataOut,ActionKey)
285        ActionKey=[ActionKey '_1'];
286    end
287    DataOut.(ActionKey)=Param.Action;
288    DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}];
289    if isfield(DataOut,'Time')
290        DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}];
291    end
292end
293
294
295
296
297%% detect whether the two files are 'images' or 'netcdf'
298testcivx=0;
299% FileExt=get(hseries.FileExt,'String');
300if ~isequal(FieldName,{'get_field...'})
301    testcivx=isequal(FileType{1},'netcdf');
302end
303% VelType_str=get(hseries.VelTypeMenu,'String');
304% VelType_val=get(hseries.VelTypeMenu,'Value');
305% VelType{1}=VelType_str{VelType_val};
306% if nbview==2
307%     VelType_str=get(hseries.VelTypeMenu_1,'String');
308%     VelType_val=get(hseries.VelTypeMenu_1,'Value');
309%     VelType{2}=VelType_str{VelType_val};
310% end
311
312%% LOOP ON SLICES
313nbmissing=0; %number of undetected files
314for i_slice=1:NbSlice
315    dt=[];
316    %%%%%%%%%%%%%%%%%%%%%%%%%%%%  LOOP ON FIELDS WITHIN  A SLICE
317    filecounter=0;
318    for ifile=i_slice:NbSlice:nbfield
319        if checkrun
320            update_waitbar(hseries.waitbar_frame,WaitbarPos,ifile/nbfield)
321            stopstate=get(hseries.RUN,'BusyAction');
322        else
323            stopstate='queue';
324        end
325        errormsg='';
326        if isequal(stopstate,'queue')% enable STOP command
327            % loop on views (in case of multiple input series)
328            for iview=1:nbview
329                filename=filecell{iview,ifile};
330               % filename=name_generator(filebase{iview},...
331                %    i1_series{iview}(ifile),j1_series{iview}(ifile),FileExt{iview},NomType{iview},1,i2_series{iview}(ifile),j2_series{iview}(ifile),SubDir{iview});
332                if exist(filename,'file')
333                    try
334                        Data{iview}=[]; %default
335                        if ~isequal(FileType{iview},'netcdf')
336                            Data{iview}.ListVarName={'A'};
337                            Data{iview}.AName='image';
338                            switch FileType{iview}
339                                case 'movie'
340                                    A=read(MovieObject{iview},i1_series{iview}(ifile));
341                                case 'avi'
342                                    mov=aviread(filename,i1_series{iview}(ifile));
343                                    A=frame2im(mov(1));
344                                case 'vol'
345                                    A=imread(filename);
346                                case 'multimage'
347                                    A=imread(filename,i1_series{iview}(ifile));
348                                case 'image'
349                                    A=imread(filename);
350                            end
351                            Data{iview}.ListVarName={'AY','AX','A'}; %
352                            npy=size(A,1);
353                            npx=size(A,2);
354                            nbcolor=size(A,3);
355                            if nbcolor==3
356                                Data{iview}.VarDimName={'AY','AX',{'AY','AX','rgb'}};
357                            else
358                                Data{iview}.VarDimName={'AY','AX',{'AY','AX'}};
359                            end
360                            Data{iview}.AY=[npy-0.5 0.5];
361                            Data{iview}.AX=[0.5 npx-0.5];
362                            Data{iview}.A=double(A);
363                            Data{iview}.CoordUnit='pixel';
364                        elseif testcivx
365                            [Data{iview},VelTypeOut]=read_civxdata(filename,FieldName,VelType);
366                            if ~isequal(FieldName,{''})
367                                Data{iview}=calc_field(FieldName,Data{iview});%calculate field (vort..)
368                            end
369                        else
370                            [Data{iview},var_detect]=nc2struct(filename,SubField.ListVarName); %read the corresponding input data
371                            Data{iview}.VarAttribute=SubField.VarAttribute;
372                        end
373                        if ~isempty(NbSlice_calib)  % z index
374                            Data{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1;
375                        end
376                    catch ME
377                        errormsg=ME.message;
378                    end
379                else
380                    errormsg=[filename ' is missing'];
381                end
382                if isempty(errormsg)
383                    % coordinate transform (or other user defined transform)
384                    if ~isempty(transform_fct)
385                        if nbview==2
386                            [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2});
387                            if isempty(Data{2})
388                                Data(2)=[];
389                            end
390                        else
391                            Data{1}=transform_fct(Data{1},XmlData{1});
392                        end
393                    end
394                    if length(Data)==2
395                        [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields
396                    else
397                        Field=Data{1};
398                    end
399                    if test_object
400                        [Field,errormsg]=proj_field(Field,ProjObject);
401                    end
402                end
403                filecounter=filecounter+1;
404               
405                % initiate the time series at the first iteration
406                if filecounter==1
407                    % stop program if the first field reading is in error
408                    if ~isempty(errormsg)
409                        msgbox_uvmat('ERROR',['error in time_series/sub_field:' errormsg])
410                        return
411                    end
412                    RecordData=Field;%default
413                    RecordData.NbDim=Field.NbDim+1; %add the time dimension for plots
414                    nbvar=length(Field.ListVarName);
415                    if nbvar==0
416                        msgbox_uvmat('ERROR','no input variable selected in get_field')
417                        return
418                    end
419                    testsum=2*ones(1,nbvar);%initiate flag for action on each variable
420                    if isfield(Field,'VarAttribute') % look for coordinate and flag variables
421                        for ivar=1:nbvar
422                            if length(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'Role')
423                                var_role=Field.VarAttribute{ivar}.Role;%'role' of the variable
424                                if isequal(var_role,'errorflag')
425                                    msgbox_uvmat('ERROR','do not handle error flags in time series')
426                                    return
427                                end
428                                if isequal(var_role,'warnflag')
429                                    testsum(ivar)=0;  % not recorded variable
430                                    eval(['RecordData=rmfield(RecordData,''' Field.ListVarName{ivar} ''');']);%remove variable
431                                end
432                                if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|...
433                                        isequal(var_role,'coord_z')|isequal(var_role,'coord')
434                                    testsum(ivar)=1; %constant coordinates, record without time evolution
435                                end
436                            end
437                            % check whether the variable ivar is a dimension variable
438                            DimCell=Field.VarDimName{ivar};
439                            if ischar(DimCell)
440                                DimCell={DimCell};
441                            end
442                            if numel(DimCell)==1 && isequal(Field.ListVarName{ivar},DimCell{1})%detect dimension variables
443                                testsum(ivar)=1;
444                            end
445                        end
446                    end
447                    for ivar=1:nbvar
448                        if testsum(ivar)==2
449                            eval(['RecordData.' Field.ListVarName{ivar} '=[];'])
450                        end
451                    end
452                    RecordData.ListVarName=[{'Time'} RecordData.ListVarName];
453                end
454               
455                % add data to the current field
456                for ivar=1:length(Field.ListVarName)
457                    VarName=Field.ListVarName{ivar};
458                    VarVal=Field.(VarName);
459                    if testsum(ivar)==2% test for recorded variable
460                        if isempty(errormsg)
461                            if isequal(ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode
462                                if isempty(VarVal)
463                                    msgbox_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))])
464                                    return
465                                end
466                                VarVal=mean(VarVal,1);
467                            end
468                            VarVal=shiftdim(VarVal,-1); %shift dimension
469                            RecordData.(VarName)=cat(1,RecordData.(VarName),VarVal);%concanete the current field to the time series
470                        else
471                            RecordData.(VarName)=cat(1,RecordData.(VarName),0);% put each variable to 0 in case of input reading error
472                        end
473                    elseif testsum(ivar)==1% variable representing fixed coordinates
474                        eval(['VarInit=RecordData.' VarName ';']);
475                        if isempty(errormsg) && ~isequal(VarVal,VarInit)
476                            msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName])
477                            return
478                        end
479                    end
480                end
481               
482                % record the time:
483                if isempty(time)% time read in ncfiles
484                    if isfield(Field,'Time')
485                        RecordData.Time(filecounter,1)=Field.Time;
486                    else
487                        RecordData.Time(filecounter,1)=ifile;%default
488                    end
489                else % time from ImaDoc prevails  TODO: correct
490                  %  RecordData.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2;
491                  RecordData.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise
492                end
493               
494                % record the number of missing input fields
495                if ~isempty(errormsg)
496                    nbmissing=nbmissing+1;
497                    display(['ifile=' num2str(ifile) ':' errormsg])
498                end
499            end
500        end
501    end
502    %%%%%%% END OF LOOP WITHIN A SLICE
503   
504    %remove time for global attributes if exists
505    Time_index=find(strcmp('Time',RecordData.ListGlobalAttribute));
506    if ~isempty(Time_index)
507        RecordData.ListGlobalAttribute(Time_index)=[];
508    end
509    RecordData.Conventions='uvmat';
510    for ivar=1:numel(RecordData.ListVarName)
511        VarName=RecordData.ListVarName{ivar};
512        eval(['RecordData.' VarName '=squeeze(RecordData.' VarName ');']) %remove singletons
513    end
514   
515    % add time dimension
516    for ivar=1:length(Field.ListVarName)
517        DimCell=Field.VarDimName(ivar);
518        if testsum(ivar)==2%variable used as time series
519            RecordData.VarDimName{ivar}=[{'Time'} DimCell];
520        elseif testsum(ivar)==1
521            RecordData.VarDimName{ivar}=DimCell;
522        end
523    end
524    indexremove=find(~testsum);
525    if ~isempty(indexremove)
526        RecordData.ListVarName(1+indexremove)=[];
527        RecordData.VarDimName(indexremove)=[];
528        if isfield(RecordData,'Role') && ~isempty(RecordData.Role{1})%generaliser aus autres attributs
529            RecordData.Role(1+indexremove)=[];
530        end
531    end
532   
533    %shift variable attributes
534    if isfield(RecordData,'VarAttribute')
535        RecordData.VarAttribute=[{[]} RecordData.VarAttribute];
536    end
537    RecordData.VarDimName=[{'Time'} RecordData.VarDimName];
538    RecordData.Action=Param.Action;%name of the processing programme
539    test_time=diff(RecordData.Time)>0;% test that the readed time is increasing (not constant)
540    if ~test_time
541        RecordData.Time=[1:filecounter];
542    end
543   
544    % display nbmissing
545    if ~isequal(nbmissing,0)
546        msgbox_uvmat('WARNING',[num2str(nbmissing) ' files skipped: missing files or bad input, see command window display'])
547    end
548   
549    %name of result file
550   % [filemean]=...
551    %    name_generator(filebase_out,i1_series{1}(i_slice),j1_series{1}(i_slice),'.nc','_i1-i2_j1-j2',1,i2_series{end}(ifile),j2_series{end}(ifile),subdir_result);
552    filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice));
553    errormsg=struct2nc(filemean,RecordData); %save result file
554    if isempty(errormsg)
555        display([filemean ' written'])
556    else
557        msgbox_uvmat('ERROR',['error in Series/struct2nc: ' errormsg])
558    end
559end
560
561%% plot the time series (the last one in case of multislices)
562figure
563haxes=axes;
564plot_field(RecordData,haxes)
565
566%% display the result file using the GUI get_field
567hget_field=findobj(allchild(0),'name','get_field');
568if ~isempty(hget_field)
569    delete(hget_field)
570end
571get_field(filemean,RecordData)
572   
573%------------------------------------------------------------------------
574% --- Executes on selection change in CoordType.
575function CoordType_Callback(hObject, eventdata, handles)
576%------------------------------------------------------------------------
577menu_str=get(handles.CoordType,'String');
578ind_coord=get(handles.CoordType,'Value');
579coord_option=menu_str{ind_coord};
580if isequal(coord_option,'more...');
581    fct_name='';
582    if exist('./TMP/current_usr_fct.mat','file')% if a file is found
583        h=load('./TMP/current_usr_fct.mat');
584        if isfield(h,'fct_name');
585            fct_name=h.fct_name;
586        end
587    end
588    prompt = {'Enter the name of the transform function'};
589    dlg_title = 'user defined transform';
590    num_lines= 1;
591    [FileName, PathName, filterindex] = uigetfile( ...
592       {'*.m', ' (*.m)';
593        '*.m',  '.m files '; ...
594        '*.*', 'All Files (*.*)'}, ...
595        'Pick a file', fct_name);
596    fct_name=fullfile(PathName,FileName);
597    addpath(PathName);%add the path to the selected fct
598    [errormsg,date_str]=check_functions;%check whether new functions can oversed the uvmat package A UTILISER
599    if ~exist(fct_name,'file')
600           warndlg(['image procesing fct ' fct_name ' not found'])
601    else
602        transform=FileName(1:end-2);%
603        update_menu(handles.CoordType,transform)%add the selected fct to the menu
604  %      set(handles.mouse_coord,'String',menu([1:end-1])')%update the mouse coord menu
605      %save ('./TMP/current_usr_fct.mat','fct_name');
606    end   
607end
608ind_coord=get(handles.CoordType,'Value');   
609
610%---------------------------------------------------------------------
611% % --- Executes on selection change in ProjObject.
612% function ProjObject_Callback(hObject, eventdata, handles)
613%
614% list_object=get(handles.ProjObject,'String');
615% index=get(handles.ProjObject,'Value');
616% hseries=get(handles.ProjObject,'Parent');
617% SeriesData=get(hseries,'UserData');
618% Obj=SeriesData.ProjObject{index};
619% [SeriesData.hset_object,SeriesData.sethandles]=set_object(SeriesData.ProjObject{index});
620% set(hseries,'UserData',SeriesData);
621
Note: See TracBrowser for help on using the repository browser.