Ignore:
Timestamp:
Jan 16, 2012, 12:51:23 AM (12 years ago)
Author:
sommeria
Message:

fgunctions under series adapted to the renovated GUI series

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/aver_stat.m

    r361 r374  
    11%'aver_stat': calculate field average, used with series.fig
    22%------------------------------------------------------------------------
    3 % function GUI_input=aver_stat(num_i1,num_i2,num_j1,num_j2,Series)
     3% function GUI_input=aver_stat(Param)
    44%
    55%OUTPUT
     
    77%
    88%INPUT:
    9 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    10 %num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    11 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
    12 %num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
    13 %Series: Matlab structure containing information set by the series interface
     9% Param: structure containing all the parameters read on the GUI series
     10%  or name of the xml file containing these parameters (BATCH case)
    1411%
    1512function GUI_input=aver_stat(Param)
     
    1815%----------------------------------------------------------------------
    1916%INPUT:
    20 %num_i1: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
     17%i1_series: series of first indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    2118%num_i2: series of second indices i (given from the series interface as first_i:incr_i:last_i, mode and list_pair_civ)
    22 %num_j1: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
     19%j1_series: series of first indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ )
    2320%num_j2: series of second indices j (given from the series interface as first_j:incr_j:last_j, mode and list_pair_civ)
    2421%OTHER INPUTS given by the structure Series
     
    4441%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4542
    46 %% Input parameters: read the xml file fior batch case
     43%% input parameters
     44% read the xml file for batch case
    4745if ischar(Param) && ~isempty(find(regexp('Param','.xml$')))
    4846    Param=xml2struct(Param);
    49     else
    50         hseries=guidata(Param.hseries);%handles of the GUI series
     47else %  RUN case: parameters introduced as the input structure Param
     48    hseries=guidata(Param.hseries);%handles of the GUI series
    5149    WaitbarPos=get(hseries.waitbar_frame,'Position');
    5250end
    53 Param
    54 Param.IndexRange
     51[filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param);
     52
     53%% coordinate transform or other user defined transform (TODO: case BATCH ?)
     54transform_fct='';%default
     55if isfield(Param,'transform_fct') % transform function handle
     56    transform_fct=Param.transform_fct;
     57end
    5558
    5659%% projection object
     
    6770
    6871%% root input file and type
    69 % if ~iscell(Series.RootPath)% case of a single input field series
    70 %     num_i1={num_i1};num_j1={num_j1};num_i2={num_i2};num_j2={num_j2};
    71 %     RootPath={Series.RootPath};
    72 %     RootFile={Series.RootFile};
    73 %     SubDir={Series.SubDir};
    74 %     FileExt={Series.FileExt};
    75 %     NomType={Series.NomType};
    76 % else
    77 %     RootPath=Series.RootPath;
    78 %     RootFile=Series.RootFile;
    79 %     SubDir=Series.SubDir;
    80 %     NomType=Series.NomType;
    81 %     FileExt=Series.FileExt;
    82 % end   
    8372    RootPath=Param.InputTable(:,1);
    8473    RootFile=Param.InputTable(:,3);
     
    10392    end
    10493end
     94
    10595
    10696%% Number of input series: this function  accepts two input file series at most (then it operates on the difference of fields)
     
    162152        elseif isempty(hget_field)
    163153           filename=...
    164                  name_generator(fullfile(RootPath{1},RootFile{1}),num_i1{1}(1),num_j1{1}(1),FileExt{1},NomType{1},1,num_i2{1}(1),num_j2{1}(1),SubDir{1});
     154                 name_generator(fullfile(RootPath{1},RootFile{1}),i1_series{1}(1),j1_series{1}(1),FileExt{1},NomType{1},1,i2_series{1}(1),num_j2{1}(1),SubDir{1});
    165155           get_field(filename);
    166156           return
     
    258248    end   
    259249end
    260 if size(time,2) < num_i2{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file'
     250if size(time,2) < i2_series{1}(end) || size(time,3) < num_j2{1}(end)% ime array absent or too short in ImaDoc xml file'
    261251    time=[];
    262252end
     
    276266    pathdir=fullfile(RootPath{1},subdir_result);% full subdirectory name, including path
    277267    if NbSlice==1% keep track of the first and lsat indices of the input files
    278         NomTypeOut=nomtype2pair(NomType{1},num_i2{end}(end)-num_i1{1}(1),num_j2{end}(end)-num_j1{1}(1));
    279         fileresult{1}=name_generator(filebase_out,num_i1{1}(1),num_j1{1}(1),ext_out,NomTypeOut,1,num_i2{end}(end),num_j2{end}(end),subdir_result);
     268        %NomTypeOut=nomtype2pair(Param.InputTable{1,4},i2_series{end}(end)-i1_series{1}(1),j2_series{end}(end)-j1_series{1}(1));
     269        NomTypeOut='_1-2';
     270%         RootPath,SubDir,RootFile,FileExt,NomType,i1,i2,j1,j2)
     271        fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i1_series{1}(1),[],[],[]);
     272%         fileresult{1}=name_generator(filebase_out,i1_series{1}(1),j1_series{1}(1),ext_out,NomTypeOut,1,i2_series{end}(end),j2_series{end}(end),subdir_result);
    280273        testexist=exist(fileresult{1},'file');
    281274    else % simplified indexing with i_slice for multiple slices
    282275        testexist=0;
    283276        for i_slice=1:NbSlice
    284             fileresult{i_slice}=name_generator(filebase_out,i_slice,[],ext_out,'_1',1,i_slice,[],subdir_result);
     277            fileresult{1}=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},ext_out,NomTypeOut,i_slice,[],[],[]);
     278            %fileresult{i_slice}=name_generator(filebase_out,i_slice,[],ext_out,'_1',1,i_slice,[],subdir_result);
    285279            if exist(fileresult{i_slice},'file')
    286280                testexist=1;
     
    307301
    308302%% coordinate transform or other user defined transform
    309 transform_fct=[];%default
    310 if isfield(Series,'transform_fct')
    311     transform_fct=Param.transform_fct;
     303transform_fct='';%default
     304if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'transform_fct')
     305    transform_fct=Param.FieldTransform.transform_fct;
    312306end
    313307
    314308%% main loop
    315 siz=size(num_i1{1});
     309siz=size(i1_series{1});
    316310nbfield2=siz(1); %nb of consecutive fields at each level(burst
    317311nbfield=siz(1)*siz(2);
     
    328322    % averaging loop
    329323    for index=1:nbfield*nbfield2
    330         stopstate=get(hseries.RUN,'BusyAction');
    331         if isequal(stopstate,'queue') % enable STOP command
    332             update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))
     324 %       stopstate=get(hseries.RUN,'BusyAction');
     325 %       if isequal(stopstate,'queue') % enable STOP command
     326         %   update_waitbar(hseries.waitbar,WaitbarPos,index/(nbfield*nbfield2))
    333327            ifile=indselect(index);
    334328            % reading input file(s)
    335329            for iview=1:nbview
    336                 [filename]=...
    337                     name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),num_j2{iview}(ifile),SubDir{iview});
    338                 if ~isequal(FileType{iview},'netcdf')
     330%                 [filename]=...
     331%                     name_generator(filebase{iview},num_i1{iview}(ifile),num_j1{iview}(ifile),FileExt{iview},NomType{iview},1,num_i2{iview}(ifile),j2_series{iview}(ifile),SubDir{iview});
     332                    filename=filecell{iview,index};
     333                    if ~isequal(FileType{iview},'netcdf')
    339334                    Data{iview}.ListVarName={'A'};
    340335                    Data{iview}.AName='image';
    341336                    switch FileType{iview}
    342337                        case 'movie'
    343                             A=read(MovieObject{iview},num_i1{iview}(ifile));
     338                            A=read(MovieObject{iview},i1_series{iview}(ifile));
    344339                        case 'avi'
    345                             mov=aviread(filename,num_i1{iview}(ifile));
     340                            mov=aviread(filename,i1_series{iview}(ifile));
    346341                            A=frame2im(mov(1));
    347342                        case 'vol'
    348343                            A=imread(filename);
    349344                        case 'multimage'
    350                             A=imread(filename,num_i1{iview}(ifile));
     345                            A=imread(filename,i1_series{iview}(ifile));
    351346                        case 'image'
    352347                            A=imread(filename);
     
    381376            if ~isempty(transform_fct)
    382377                if ~isempty(NbSlice_calib)
    383                     Data{iview}.ZIndex=mod(num_i1{iview}(ifile)-1,NbSlice_calib{1})+1;%Zindex for phys transform
     378                    Data{iview}.ZIndex=mod(i1_series{iview}(ifile)-1,NbSlice_calib{1})+1;%Zindex for phys transform
    384379                end
    385380                if nbview==2
     
    435430                end
    436431            end
    437         end
     432%         end
    438433    end
    439434    %end averaging loop
     
    455450        end
    456451    else  % time from ImaDoc prevails
    457         DataMean.Time=time(1,num_i1{1}(1),num_j1{1}(1));
    458         DataMean.Time_end=time(end,num_i1{end}(end),num_j1{end}(end));
     452        DataMean.Time=time(1,i1_series{1}(1),j1_series{1}(1));
     453        DataMean.Time_end=time(end,i1_series{end}(end),j1_series{end}(end));
    459454    end
    460455   
     
    468463        display([fileresult{i_slice} ' written']);
    469464    else %case of netcdf input file , determine global attributes
     465        if isempty(strcmp('Conventions',DataMean.ListGlobalAttribute))
     466            DataMean.ListGlobalAttribute=['Conventions' DataMean.ListGlobalAttribute];
     467        end
     468        DataMean.Conventions='uvmat';
    470469        DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {Param.Action}];
    471470        ActionKey='Action';
     
    473472            ActionKey=[ActionKey '_1'];
    474473        end
    475         eval(['DataMean.' ActionKey '=Param.Action;'])
     474        DataMean.(ActionKey)=Param.Action;
    476475        DataMean.ListGlobalAttribute=[DataMean.ListGlobalAttribute {ActionKey}];
    477476        if isfield(DataMean,'Time')
Note: See TracChangeset for help on using the changeset viewer.