Changeset 459 for trunk


Ignore:
Timestamp:
Jun 18, 2012, 9:23:41 AM (13 years ago)
Author:
sommeria
Message:

sub_background and time series set to the new standards

Location:
trunk/src/series
Files:
2 edited

Legend:

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

    r457 r459  
    5454
    5555   
    56 function GUI_config=sub_background (Param)
     56function ParamOut=sub_background (Param)
    5757
    5858%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
    5959if ~exist('Param','var') % case with no input parameter
    60     GUI_config={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation)
     60    ParamOut={'NbViewMax';1;...% max nbre of input file series (default='' , no limitation)
    6161        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
    6262        'WholeIndexRange';'on';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     
    7575%% select different modes,  RUN, parameter input, BATCH
    7676% BATCH  case: read the xml file for batch case
     77ParamOut=Param; %default output
    7778if ischar(Param)
    7879    if strcmp(Param,'input?')
    79         checkrun=1;% will inly search input parameters (preparation of BATCH mode)
     80        checkrun=1;% will search input parameters (preparation of BATCH mode)
    8081    else
    8182        Param=xml2struct(Param);
     
    206207        return
    207208    end
    208     GUI_config.CheckVolume=strcmp(answer{1},'Yes');
    209     GUI_config.SlidingSequenceSize=nbaver_ima;
    210     GUI_config.BrightnessRankThreshold=str2num(answer{3});
     209    ParamOut.Specific.CheckVolume=strcmp(answer{1},'Yes');
     210    ParamOut.Specific.SlidingSequenceSize=nbaver_ima;
     211    ParamOut.Specific.BrightnessRankThreshold=str2num(answer{3});
    211212   
    212213    % apply the image rescaling function 'level' (avoid the blinking effects of bright particles)
    213214    answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background');
    214     GUI_config.CheckLevelTransform=strcmp(answer,'Yes');
    215     if checkrun==2
     215    ParamOut.Specific.CheckLevelTransform=strcmp(answer,'Yes');
     216    if checkrun==1
    216217         return
    217218    end
    218219    %%%%%%%%%%%%%%%%%%%%%%  STOP HERE FOR PAMETER INPUT MODE  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    219220else
    220     GUI_config=Param.Specific;
    221     if isequal(GUI_config.CheckVolume,1)
     221    if isequal(Param.Specific.CheckVolume,1)
    222222        step=1;
    223223    else
    224224        step=nbfield_j;%case of bursts: the sliding background is shifted by the length of one burst
    225225    end
    226     nbaver_ima=GUI_config.SlidingSequenceSize;%number of images for the sliding background
     226    nbaver_ima=Param.Specific.SlidingSequenceSize;%number of images for the sliding background
    227227    nbaver=ceil(nbaver_ima/step);%number of bursts for the sliding background
    228228    if isequal(floor(nbaver/2),nbaver)
     
    237237
    238238% calculate absolute brightness rank
    239 rank=floor(GUI_config.BrightnessRankThreshold*nbaver_ima);
     239rank=floor(ParamOut.Specific.BrightnessRankThreshold*nbaver_ima);
    240240if rank==0
    241241    rank=1;%rank selected in the sorted image series
     
    341341       
    342342        %write result file
    343         if GUI_config.CheckLevelTransform
     343        if ParamOut.Specific.CheckLevelTransform
    344344            C=levels(Acor);
    345345            imwrite(C,newname,'BitDepth',8); % save the new image
     
    390390                    newname=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1);
    391391                    %write result file
    392                     if GUI_config.CheckLevelTransform
     392                    if ParamOut.Specific.CheckLevelTransform
    393393                        C=levels(Acor);
    394394                        imwrite(C,newname,'BitDepth',8); % save the new image
     
    425425       
    426426        %write result file
    427         if GUI_config.CheckLevelTransform
     427        if ParamOut.Specific.CheckLevelTransform
    428428            C=levels(Acor);
    429429            imwrite(C,newname,'BitDepth',8); % save the new image
  • trunk/src/series/time_series.m

    r457 r459  
    4848function ParamOut=time_series(Param)
    4949
    50 %% requests for the visibility of input windows in the GUI series  (activated directly by the selection in the menu ACTION)
    51 if ~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)
     50%% set the input elements needed on the GUI series when the action is selected in the menu ActionName
     51if ~exist('Param','var') % case with no input parameter
     52    ParamOut={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation)
     53        'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default)
     54        'WholeIndexRange';'off';...% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    5755        '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
     56        'VelType';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     57        'FieldName';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
     58        'FieldTransform'; 'on';...%can use a transform function
     59        'ProjObject';'on';...%can use projection object(option 'off'/'on',
     60        'Mask';'off';...%can use mask option   (option 'off'/'on', 'off' by default)
     61        'OutputDirExt';'.tseries';...%set the output dir extension
    6562               ''};
    66     return %exit the function
     63        return
    6764end
    6865
     
    242239end
    243240%%% TO UPDATE
    244 if isequal(FieldName,'get_field...')
     241if isequal(InputFields{1},'get_field...')
    245242    hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI
    246243    if numel(hget_field)>1
     
    291288    end
    292289end
    293 
    294 
    295 
    296 
    297 %% detect whether the two files are 'images' or 'netcdf'
    298 testcivx=0;
    299 % FileExt=get(hseries.FileExt,'String');
    300 if ~isequal(FieldName,{'get_field...'})
    301     testcivx=isequal(FileType{1},'netcdf');
    302 end
    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
    311290
    312291%% LOOP ON SLICES
     
    397376                        Field=Data{1};
    398377                    end
    399                     if test_object
    400                         [Field,errormsg]=proj_field(Field,ProjObject);
     378                    if Param.CheckObject
     379                        [Field,errormsg]=proj_field(Field,Param.ProjObject);
    401380                    end
    402381                end
     
    410389                        return
    411390                    end
    412                     RecordData=Field;%default
    413                     RecordData.NbDim=Field.NbDim+1; %add the time dimension for plots
     391                    DataOut=Field;%default
     392                    DataOut.NbDim=Field.NbDim+1; %add the time dimension for plots
    414393                    nbvar=length(Field.ListVarName);
    415394                    if nbvar==0
     
    428407                                if isequal(var_role,'warnflag')
    429408                                    testsum(ivar)=0;  % not recorded variable
    430                                     eval(['RecordData=rmfield(RecordData,''' Field.ListVarName{ivar} ''');']);%remove variable
     409                                    eval(['DataOut=rmfield(DataOut,''' Field.ListVarName{ivar} ''');']);%remove variable
    431410                                end
    432411                                if isequal(var_role,'coord_x')| isequal(var_role,'coord_y')|...
     
    447426                    for ivar=1:nbvar
    448427                        if testsum(ivar)==2
    449                             eval(['RecordData.' Field.ListVarName{ivar} '=[];'])
    450                         end
    451                     end
    452                     RecordData.ListVarName=[{'Time'} RecordData.ListVarName];
     428                            eval(['DataOut.' Field.ListVarName{ivar} '=[];'])
     429                        end
     430                    end
     431                    DataOut.ListVarName=[{'Time'} DataOut.ListVarName];
    453432                end
    454433               
     
    459438                    if testsum(ivar)==2% test for recorded variable
    460439                        if isempty(errormsg)
    461                             if isequal(ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode
     440                            if isequal(Param.ProjObject.ProjMode,'inside')% take the average in the domain for 'inside' mode
    462441                                if isempty(VarVal)
    463442                                    msgbox_uvmat('ERROR',['empty result at frame index ' num2str(i1_series{iview}(ifile))])
     
    467446                            end
    468447                            VarVal=shiftdim(VarVal,-1); %shift dimension
    469                             RecordData.(VarName)=cat(1,RecordData.(VarName),VarVal);%concanete the current field to the time series
     448                            DataOut.(VarName)=cat(1,DataOut.(VarName),VarVal);%concanete the current field to the time series
    470449                        else
    471                             RecordData.(VarName)=cat(1,RecordData.(VarName),0);% put each variable to 0 in case of input reading error
     450                            DataOut.(VarName)=cat(1,DataOut.(VarName),0);% put each variable to 0 in case of input reading error
    472451                        end
    473452                    elseif testsum(ivar)==1% variable representing fixed coordinates
    474                         eval(['VarInit=RecordData.' VarName ';']);
     453                        eval(['VarInit=DataOut.' VarName ';']);
    475454                        if isempty(errormsg) && ~isequal(VarVal,VarInit)
    476455                            msgbox_uvmat('ERROR',['time series requires constant coordinates ' VarName])
     
    483462                if isempty(time)% time read in ncfiles
    484463                    if isfield(Field,'Time')
    485                         RecordData.Time(filecounter,1)=Field.Time;
     464                        DataOut.Time(filecounter,1)=Field.Time;
    486465                    else
    487                         RecordData.Time(filecounter,1)=ifile;%default
     466                        DataOut.Time(filecounter,1)=ifile;%default
    488467                    end
    489468                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
     469                  %  DataOut.Time(filecounter,1)=time{1}(i1_series{1})(ifile),j1_series{1}(ifile))+time(end,i2_series{end}(ifile),j2_series{end}(ifile)))/2;
     470                  DataOut.Time(filecounter,1)=i1_series{1}(ifile);% TODO : generalise
    492471                end
    493472               
     
    503482   
    504483    %remove time for global attributes if exists
    505     Time_index=find(strcmp('Time',RecordData.ListGlobalAttribute));
     484    Time_index=find(strcmp('Time',DataOut.ListGlobalAttribute));
    506485    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
     486        DataOut.ListGlobalAttribute(Time_index)=[];
     487    end
     488    DataOut.Conventions='uvmat';
     489    for ivar=1:numel(DataOut.ListVarName)
     490        VarName=DataOut.ListVarName{ivar};
     491        eval(['DataOut.' VarName '=squeeze(DataOut.' VarName ');']) %remove singletons
    513492    end
    514493   
     
    517496        DimCell=Field.VarDimName(ivar);
    518497        if testsum(ivar)==2%variable used as time series
    519             RecordData.VarDimName{ivar}=[{'Time'} DimCell];
     498            DataOut.VarDimName{ivar}=[{'Time'} DimCell];
    520499        elseif testsum(ivar)==1
    521             RecordData.VarDimName{ivar}=DimCell;
     500            DataOut.VarDimName{ivar}=DimCell;
    522501        end
    523502    end
    524503    indexremove=find(~testsum);
    525504    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)=[];
     505        DataOut.ListVarName(1+indexremove)=[];
     506        DataOut.VarDimName(indexremove)=[];
     507        if isfield(DataOut,'Role') && ~isempty(DataOut.Role{1})%generaliser aus autres attributs
     508            DataOut.Role(1+indexremove)=[];
    530509        end
    531510    end
    532511   
    533512    %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)
     513    if isfield(DataOut,'VarAttribute')
     514        DataOut.VarAttribute=[{[]} DataOut.VarAttribute];
     515    end
     516    DataOut.VarDimName=[{'Time'} DataOut.VarDimName];
     517    DataOut.Action=Param.Action;%name of the processing programme
     518    test_time=diff(DataOut.Time)>0;% test that the readed time is increasing (not constant)
    540519    if ~test_time
    541         RecordData.Time=[1:filecounter];
     520        DataOut.Time=[1:filecounter];
    542521    end
    543522   
     
    548527   
    549528    %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
     529%     filemean=fullfile_uvmat(RootPath{1},subdir_result,RootFile{1},'.nc','_1',i1_series{1}(i_slice));
     530    OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),i_slice,[]);
     531    errormsg=struct2nc(OutputFile,DataOut); %save result file
    554532    if isempty(errormsg)
    555         display([filemean ' written'])
     533        display([OutputFile ' written'])
    556534    else
    557535        msgbox_uvmat('ERROR',['error in Series/struct2nc: ' errormsg])
     
    562540figure
    563541haxes=axes;
    564 plot_field(RecordData,haxes)
     542plot_field(DataOut,haxes)
    565543
    566544%% display the result file using the GUI get_field
     
    569547    delete(hget_field)
    570548end
    571 get_field(filemean,RecordData)
     549get_field(OutputFile,DataOut)
    572550   
    573 %------------------------------------------------------------------------
    574 % --- Executes on selection change in CoordType.
    575 function CoordType_Callback(hObject, eventdata, handles)
    576 %------------------------------------------------------------------------
    577 menu_str=get(handles.CoordType,'String');
    578 ind_coord=get(handles.CoordType,'Value');
    579 coord_option=menu_str{ind_coord};
    580 if 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   
    607 end
    608 ind_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 
     551
     552
Note: See TracChangeset for help on using the changeset viewer.