Changeset 1147 for trunk


Ignore:
Timestamp:
May 29, 2024, 7:08:52 PM (4 weeks ago)
Author:
sommeria
Message:

merge_proj repaired with multimask possibility

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series.m

    r1144 r1147  
    495495set(handles.InputTable,'Data',InputTable)
    496496browse_data(oldfile,'on','on'); % open the GUI browse_data to get select a campaign dir, experiment and device
    497 % NbLines=numel(OutPut.Experiment)*numel(OutPut.DataSeries);
    498 % icount=0;
    499 % for iexp=1:numel(OutPut.Experiment)
    500 %     for idevice=1:numel(OutPut.DataSeries)
    501 %         icount=icount+1;
    502 %         InputTable{icount,1}=fullfile(OutPut.Campaign,OutPut.Experiment{iexp});
    503 %         InputTable{icount,2}=OutPut.DataSeries{idevice};
    504 %         if isempty(InputTable{icount,3})
    505 %             if icount>1
    506 %             InputTable{icount,3}=InputTable{icount-1,3};
    507 %             else
    508 %                 InputTable{icount,3}='';
    509 %             end
    510 %         end
    511 %         if isempty(InputTable{icount,4})
    512 %             if icount>1
    513 %             InputTable{icount,4}=InputTable{icount-1,4};
    514 %             else
    515 %                 InputTable{icount,4}='';
    516 %             end
    517 %         end
    518 %                 if isempty(InputTable{icount,5})
    519 %             if icount>1
    520 %             InputTable{icount,5}=InputTable{icount-1,5};
    521 %             else
    522 %                 InputTable{icount,5}='';
    523 %             end
    524 %         end
    525 %     end
    526 % end
    527 % if size(InputTable,1)>icount
    528 %     InputTable(icount+1:size(InputTable,1),:)=[];
    529 % end
    530 %REFRESH_Callback(hObject, eventdata, handles)
    531 
    532 % --------------------------------------------------------------------
    533 % function MenuCampaign_Callback(hObject, eventdata, handles)
    534 % % --------------------------------------------------------------------
    535 %
    536 % OutPut=browse_data(get(hObject,'Label'),'on','on'); % open the GUI browse_data to get select a campaign dir, experiment and device
    537 % if ~isfield(OutPut,'Campaign')
    538 %     return
    539 % end
    540 % NbLines=numel(OutPut.Experiment)*numel(OutPut.DataSeries);
    541 % icount=0;
    542 % InputTable=get(handles.InputTable,'Data');
    543 % for iexp=1:numel(OutPut.Experiment)
    544 %     for idevice=1:numel(OutPut.DataSeries)
    545 %         icount=icount+1;
    546 %         InputTable{icount,1}=fullfile(OutPut.Campaign,OutPut.Experiment{iexp});
    547 %         InputTable{icount,2}=OutPut.DataSeries{idevice};
    548 %         if isempty(InputTable{icount,3})
    549 %             if icount>1
    550 %                 InputTable{icount,3}=InputTable{icount-1,3};
    551 %             else
    552 %                 InputTable{icount,3}='';
    553 %             end
    554 %         end
    555 %         if isempty(InputTable{icount,4})
    556 %             if icount>1
    557 %                 InputTable{icount,4}=InputTable{icount-1,4};
    558 %             else
    559 %                 InputTable{icount,4}='';
    560 %             end
    561 %         end
    562 %         if isempty(InputTable{icount,5})
    563 %             if icount>1
    564 %                 InputTable{icount,5}=InputTable{icount-1,5};
    565 %             else
    566 %                 InputTable{icount,5}='';
    567 %             end
    568 %         end
    569 %     end
    570 % end
    571 % if size(InputTable,1)>icount
    572 %     InputTable(icount+1:size(InputTable,1),:)=[];
    573 % end
    574 % set(handles.InputTable,'Data',InputTable)
    575 % REFRESH_Callback(hObject, eventdata, handles)
     497
    576498
    577499
     
    30572979                set(handles.FieldName,'Value',2) % set menu to 'velocity
    30582980        end
    3059 %         if ~strcmp(GetFieldData.FieldOption,'civdata...')
    3060 %             TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
    3061 %             switch TimeNameStr
    3062 %                 case 'file index'
    3063 %                     set(handles.TimeName,'String','');
    3064 %                 case 'attribute'
    3065 %                     set(handles.TimeName,'String',['att:' GetFieldData.Time.TimeName]);
    3066 %                 case 'variable'
    3067 %                     set(handles.TimeName,'String',['var:' GetFieldData.Time.TimeName])
    3068 %                     set(handles.NomType,'String','*')
    3069 %                     set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])% A VERIFIER !!!!!!
    3070 %                     set(handles.FileIndex,'String','')
    3071 %                     ParamIn.TimeVarName=GetFieldData.Time.TimeName;
    3072 %                 case 'matrix_index'
    3073 %                     set(handles.TimeName,'String',['dim:' GetFieldData.Time.TimeName]);
    3074 %                     set(handles.NomType,'String','*')
    3075 %                     set(handles.RootFile,'String',[get(handles.RootFile,'String') get(handles.FileIndex,'String')])
    3076 %                     set(handles.FileIndex,'String','')
    3077 %                     ParamIn.TimeDimName=GetFieldData.Time.TimeName;
    3078 %             end
    3079 %         end
    30802981        set(handles.FieldName_1,'Value',1)
    30812982        set(handles.FieldName_1,'String',[FieldList; {'add_field...'}]);
     
    32643165function CheckMask_Callback(hObject, eventdata, handles)
    32653166
     3167
    32663168if get(handles.CheckMask,'Value')
    3267     InputTable=get(handles.InputTable,'Data');
    3268     nbview=size(InputTable,1);
    3269     MaskTable=cell(nbview,1); % default
    3270     ListMask=cell(nbview,1); % default
    3271     MaskData=get(handles.MaskTable,'Data');
    3272     MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1); % complement if undefined lines
    3273     for iview=1:nbview
    3274         ListMask{iview,1}=num2str(iview);
    3275         RootPath=InputTable{iview,1};
    3276         if ~isempty(RootPath)
    3277             if isempty(MaskData{iview})
    3278                 SubDir=InputTable{iview,2};
    3279                 MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']); % take the root part of SubDir, before the first dot '.'
    3280                 if exist(MaskPath,'dir')
    3281                     ListStruct=dir(MaskPath); % look for a mask file
    3282                     ListCells=struct2cell(ListStruct); % transform dir struct to a cell arrray
    3283                     check_dir=cell2mat(ListCells(4,:)); % =1 for directories, =0 for files
    3284                     ListFiles=ListCells(1,:); % list of file and dri names
    3285                     ListFiles=ListFiles(~check_dir); % list of file names (excluding dir)
    3286                     mdetect=0;
    3287                     if ~isempty(ListFiles)
    3288                         for ifile=1:numel(ListFiles)
    3289                             [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0);
    3290                             if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
    3291                                 mdetect=1;
    3292                                 MaskName=ListFiles{ifile};
    3293                             end
    3294                             if ~strcmp(MaskFile{ifile},MaskFile{1})
    3295                                 mdetect=0; % cancel detection test in case of multiple masks, use the brower for selection
    3296                                 break
    3297                             end
    3298                         end
    3299                     end
    3300                     if mdetect==1
    3301                         MaskName=fullfile(MaskPath,'mask_1.png');
    3302                     else
    3303                         MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image');
    3304                     end
    3305                 else
    3306                     MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
    3307                 end
    3308                 MaskTable{iview,1}=MaskName ;
    3309                 ListMask{iview,1}=num2str(iview);
    3310             end
     3169    set(handles.DeleteMask,'Visible','on')
     3170    Param=read_GUI_series(handles); % displayed parameters
     3171    NbView=size(Param.InputTable,1);
     3172    MaskTable=cell(NbView,2);
     3173   
     3174    RootPath=Param.InputTable{1,1};
     3175    first_j=[];% note that the function will propose to cover the whole range of indices
     3176    if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end
     3177    last_j=[];
     3178    if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end
     3179    PairString='';
     3180    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
     3181    [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString);
     3182    %checkmask=zeros(NbView,1);
     3183    for iview=1:NbView
     3184        checkmask=0;
     3185        FirstFileName=fullfile_uvmat(Param.InputTable{iview,1},Param.InputTable{iview,2},Param.InputTable{iview,3},...
     3186            Param.InputTable{iview,5},Param.InputTable{iview,4},i1,i2,j1,j2);
     3187        Data=nc2struct(FirstFileName);
     3188        if isfield(Data,'Civ2_Mask')
     3189            MaskTable{iview,1}=Data.Civ2_Mask;
     3190            checkmask=1;
     3191        end
     3192        if ~checkmask
     3193            MaskTable{iview,1}=uigetfile_uvmat('select a mask file:',Param.InputTable{iview,1},'image');
     3194        end
     3195    end
     3196    for iview=1:NbView
     3197        [Path,Name]=fileparts(MaskTable{iview,1});
     3198        Name=regexprep(Name,'_\d+','');
     3199        maskfiles=dir(fullfile(Path,[Name '_*.png']));%look for mask files       
     3200        if ~isempty(maskfiles)
     3201            for ilist=1:numel(maskfiles)
     3202                r=regexp(maskfiles(ilist).name,'_(?<num1>\d+)','names');%look for burst pairs
     3203                index(ilist)=str2double(r.num1);
     3204            end
     3205            MaskTable{iview,2}=max(index);
    33113206        end
    33123207    end
    33133208    set(handles.MaskTable,'Data',MaskTable)
    3314     set(handles.MaskTable,'Visible','on')
    3315     set(handles.MaskBrowse,'Visible','on')
    3316     set(handles.ListMask,'Visible','on')
    3317     set(handles.ListMask,'String',ListMask)
    3318     set(handles.ListMask,'Value',1)
    3319 else
    3320     set(handles.MaskTable,'Visible','off')
    3321     set(handles.MaskBrowse,'Visible','off')
    3322     set(handles.ListMask,'Visible','off')
    3323 end
    3324 
    3325 %------------------------------------------------------------------------
    3326 % --- Executes on button press in MaskBrowse.
    3327 %------------------------------------------------------------------------
    3328 function MaskBrowse_Callback(hObject, eventdata, handles)
    3329 
    3330 InputTable=get(handles.InputTable,'Data');
    3331 iview=get(handles.ListMask,'Value');
    3332 RootPath=InputTable{iview,1};
    3333 MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
    3334 if ~isempty(MaskName)
    3335     MaskTable=get(handles.MaskTable,'Data');
    3336     MaskTable{iview,1}=MaskName ;
    3337     set(handles.MaskTable,'Data',MaskTable)
    3338 end
     3209    set(handles.CheckMask,'Value',0)
     3210end
     3211%       
     3212% if ~isempty(NewMask)
     3213%     if isempty(MaskList)
     3214%         MaskList={NewMask};
     3215%     else
     3216%     MaskList={MaskList;NewMask};
     3217%     end
     3218%     set(handles.Mask,'String',MaskList)
     3219% end
     3220% end
     3221% %     MaskTable=cell(nbview,1); % default
     3222% %     ListMask=cell(nbview,1); % default
     3223% %     MaskData=get(handles.MaskTable,'Data');
     3224% %     MaskData(size(MaskData,1):nbview,1)=cell(size(MaskData,1):nbview,1); % complement if undefined lines
     3225%     for iview=1:nbview
     3226%         ListMask{iview,1}=num2str(iview);
     3227%         RootPath=InputTable{iview,1};
     3228%         if ~isempty(RootPath)
     3229%             if isempty(MaskData{iview})
     3230%                 SubDir=InputTable{iview,2};
     3231%                 MaskPath=fullfile(RootPath,[regexprep(SubDir,'\..*','') '.mask']); % take the root part of SubDir, before the first dot '.'
     3232%                 if exist(MaskPath,'dir')
     3233%                     ListStruct=dir(MaskPath); % look for a mask file
     3234%                     ListCells=struct2cell(ListStruct); % transform dir struct to a cell arrray
     3235%                     check_dir=cell2mat(ListCells(4,:)); % =1 for directories, =0 for files
     3236%                     ListFiles=ListCells(1,:); % list of file and dri names
     3237%                     ListFiles=ListFiles(~check_dir); % list of file names (excluding dir)
     3238%                     mdetect=0;
     3239%                     if ~isempty(ListFiles)
     3240%                         for ifile=1:numel(ListFiles)
     3241%                             [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileType]=find_file_series(MaskPath,ListFiles{ifile},0);
     3242%                             if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series)
     3243%                                 mdetect=1;
     3244%                                 MaskName=ListFiles{ifile};
     3245%                             end
     3246%                             if ~strcmp(MaskFile{ifile},MaskFile{1})
     3247%                                 mdetect=0; % cancel detection test in case of multiple masks, use the brower for selection
     3248%                                 break
     3249%                             end
     3250%                         end
     3251%                     end
     3252%                     if mdetect==1
     3253%                         MaskName=fullfile(MaskPath,'mask_1.png');
     3254%                     else
     3255%                         MaskName=uigetfile_uvmat('select a mask file:',MaskPath,'image');
     3256%                     end
     3257%                 else
     3258%                     MaskName=uigetfile_uvmat('select a mask file:',RootPath,'image');
     3259%                 end
     3260%                 MaskTable{iview,1}=MaskName ;
     3261%                 ListMask{iview,1}=num2str(iview);
     3262%             end
     3263%         end
     3264%     end
     3265%     set(handles.MaskTable,'Data',MaskTable)
     3266%     set(handles.MaskTable,'Visible','on')
     3267%     set(handles.MaskBrowse,'Visible','on')
     3268%     set(handles.ListMask,'Visible','on')
     3269%     set(handles.ListMask,'String',ListMask)
     3270%     set(handles.ListMask,'Value',1)
     3271
     3272
    33393273
    33403274%------------------------------------------------------------------------
     
    35353469ColumnWidth=num2cell(ColumnWidth);
    35363470set(handles.InputTable,'ColumnWidth',ColumnWidth)
     3471
     3472%% MaskTable
     3473set(handles.MaskTable,'Unit','pixel')
     3474Pos=get(handles.MaskTable,'Position');
     3475set(handles.MaskTable,'Unit','normalized')
     3476ColumnWidth=round([0.9 0.1]*(Pos(3)-52));
     3477ColumnWidth=num2cell(ColumnWidth);
     3478set(handles.MaskTable,'ColumnWidth',ColumnWidth)
    35373479
    35383480%% MinIndex_j and MaxIndex_i
     
    40193961
    40203962
    4021 function Mask_Callback(hObject, eventdata, handles)
    4022 % hObject    handle to Mask (see GCBO)
    4023 % eventdata  reserved - to be defined in a future version of MATLAB
    4024 % handles    structure with handles and user data (see GUIDATA)
    4025 
    4026 % Hints: get(hObject,'String') returns contents of Mask as text
    4027 %        str2double(get(hObject,'String')) returns contents of Mask as a double
     3963% --- Executes on button press in DeleteMask.
     3964function DeleteMask_Callback(hObject, eventdata, handles)
     3965set(handles.MaskTable,'Data',{})
  • trunk/src/series/civ_input.m

    r1143 r1147  
    268268    end
    269269else  %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed
    270     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
    271             ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
     270%     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
     271%             ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
    272272            for index = 1:min(ind_opening,5)
    273273                set(handles.(ListOptions{index}),'value',0)
    274274                fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file
    275275            end
     276            if isempty(FileInfo)
     277            FileInfo.FileName='';
     278end
    276279            set(handles.ConfigSource,'String',FileInfo.FileName);
    277280            set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
     
    280283            end
    281284            checkrefresh=1;
    282     end
     285%     end
    283286    if ind_opening>=3
    284287        set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
  • trunk/src/series/civ_series.m

    r1146 r1147  
    5353    path_series=fileparts(which('series'));
    5454    addpath(fullfile(path_series,'series'))
     55
     56
    5557    Data=civ_input(Param);% introduce the civ parameters using the GUI civ_input
    5658    %Data=civ_input_App(Param);% introduce the civ parameters using the GUI civ_input
  • trunk/src/series/merge_proj.m

    r1137 r1147  
    232232end
    233233
    234 %% mask (TODO: case of multilevels)
    235 MaskData=cell(NbView,1);
    236 if Param.CheckMask
    237     if ischar(Param.MaskTable)% case of a single mask (char chain)
    238         Param.MaskTable={Param.MaskTable};
    239     end
    240     for iview=1:numel(Param.MaskTable)
    241         if exist(Param.MaskTable{iview},'file')
    242             [MaskData{iview},tild,errormsg] = read_field(Param.MaskTable{iview},'image');
    243             if ~isempty(transform_fct) && nargin(transform_fct)>=2
    244                 MaskData{iview}=transform_fct(MaskData{iview},XmlData{iview});
    245             end
    246         end
    247     end
    248 end
    249234
    250235%% Set field names and velocity types
     
    319304        %% transform the input field iview (e.g; phys) if requested (no transform involving two input fields at this stage)
    320305        if ~isempty(transform_fct)&& checksub==0
    321             checksub=nargin(transform_fct);
    322306            if nargin(transform_fct)>=2
    323307                Data{iview}=transform_fct(Data{iview},XmlData{iview});
     
    345329       
    346330        %% mask
    347         if Param.CheckMask && ~isempty(MaskData{iview})
    348              [Data{iview},errormsg]=mask_proj(Data{iview},MaskData{iview});
     331        if Param.CheckMask % introduce multilevel mask like for civ
     332            NbSlice=Param.MaskTable{iview,2};
     333            [RootPath_mask,SubDir_mask,RootFile_mask,i1_mask,i2_mask,j1_mask,j2_mask,Ext_mask]=fileparts_uvmat(Param.MaskTable{iview,1});
     334            i1_mask=mod(i1-1,NbSlice)+1;
     335            maskname=fullfile_uvmat(RootPath_mask,SubDir_mask,RootFile_mask,Ext_mask,'_1',i1_mask);
     336            if ~exist(maskname,'file')
     337                maskname=Param.MaskTable{iview,1};
     338            end
     339            [MaskData,~,errormsg] = read_field(maskname,'image');
     340            if ~isempty(transform_fct) && nargin(transform_fct)>=2
     341                MaskData=transform_fct(MaskData,XmlData{iview});
     342            end
     343            if  ~isempty(MaskData)
     344                [Data{iview},errormsg]=mask_proj(Data{iview},MaskData);
     345            end
    349346        end
    350347    end
Note: See TracChangeset for help on using the changeset viewer.