Ignore:
Timestamp:
Jul 5, 2024, 9:00:14 AM (3 months ago)
Author:
sommeria
Message:

civ3 improved

File:
1 edited

Legend:

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

    r1152 r1153  
    140140
    141141        iview_image=2;%line # for the input images
    142     case 'civxdata'% case of  civx data,
    143         msgbox_uvmat('ERROR','old civX convention, use the GUI civ')
    144         return
    145142    otherwise
    146143        if ~strcmp(FieldType,'image')
     
    216213%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    217214if numel(time)>=2 % if there are at least two time values to define dt
    218     if size(time,1)<MaxIndex_i;
     215    if size(time,1)<MaxIndex_i
    219216        msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file');
    220217    elseif size(time,2)<MaxIndex_j
     
    252249    end
    253250else  %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed
    254 %     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
    255 %             ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
    256             for index = 1:min(ind_opening,5)
    257                 set(handles.(ListOptions{index}),'value',0)
    258                 fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file
    259             end
    260             if isempty(FileInfo)
    261             FileInfo.FileName='';
    262 end
    263             set(handles.ConfigSource,'String',FileInfo.FileName);
    264             set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
    265             for index = ind_opening+2:6
    266                 set(handles.(ListOptions{index}),'value',0)
    267             end
    268             checkrefresh=1;
    269 %     end
    270     if ind_opening>=3
     251    %     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
     252    %             ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
     253    for index = 1:min(ind_opening,5)
     254        set(handles.(ListOptions{index}),'value',0)
     255        fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file
     256    end
     257    if isempty(FileInfo)
     258        FileInfo.FileName='';
     259    end
     260    set(handles.ConfigSource,'String',FileInfo.FileName);
     261    if ind_opening<6
     262        for index = 1:ind_opening
     263            set(handles.(ListOptions{index}),'value',0)
     264        end
     265        for index = ind_opening+1:6
     266            set(handles.(ListOptions{index}),'value',1)
     267        end
     268        set(handles.CheckCiv3,'Visible','off')% make visible the switch 'iterate/repet' for Civ2.
     269        set(handles.CheckCiv3,'Value',0)% select'iterate/repet' by default
     270    else
     271        for index = 1:3
     272            set(handles.(ListOptions{index}),'value',0)
     273        end
     274        for index = 4:6
     275            set(handles.(ListOptions{index}),'value',1)
     276        end
    271277        set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
    272     else
    273         set(handles.CheckCiv3,'Visible','off')
    274     end
     278        set(handles.CheckCiv3,'Value',1)% select'iterate/repet' by default
     279    end
     280    checkrefresh=1;
     281    %     end
     282    % if ind_opening==6
     283    %     set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
     284    % else
     285    %     set(handles.CheckCiv3,'Visible','off')
     286    % end
    275287end
    276288
     
    10781090end
    10791091
    1080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1081 % Callbacks in the uipanel Fix1
    1082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1083 %------------------------------------------------------------------------
    1084 % % --- Executes on button press in CheckMask.
    1085 % function get_mask_fix1_Callback(hObject, eventdata, handles)
    1086 % %------------------------------------------------------------------------
    1087 % maskval=get(handles.CheckMask,'Value');
    1088 % if isequal(maskval,0)
    1089 %     set(handles.Mask,'String','')
    1090 % else
    1091 %     mask_displ='no mask'; %default
    1092 %     filebase=get(handles.RootPath,'String');
    1093 %     [nbslice, flag_mask]=get_mask(filebase,handles);
    1094 %     if isequal(flag_mask,1)
    1095 %         mask_displ=[num2str(nbslice) 'mask'];
    1096 %     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    1097 %         filebase_a=get(handles.RootFile_1,'String');
    1098 %         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    1099 %         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    1100 %             mask_displ='no mask';
    1101 %         end
    1102 %     end
    1103 %     if isequal(mask_displ,'no mask')
    1104 %         [FileName, PathName, filterindex] = uigetfile( ...
    1105 %             {'*.png', ' (*.png)';
    1106 %             '*.png',  '.png files '; ...
    1107 %             '*.*', 'All Files (*.*)'}, ...
    1108 %             'Pick a mask file *.png',filebase);
    1109 %         mask_displ=fullfile(PathName,FileName);
    1110 %         if ~exist(mask_displ,'file')
    1111 %             mask_displ='no mask';
    1112 %         end
    1113 %     end
    1114 %     if isequal(mask_displ,'no mask')
    1115 %         set(handles.CheckMask,'Value',0)
    1116 %         set(handles.CheckMask,'Value',0)
    1117 %         set(handles.CheckMask,'Value',0)
    1118 %     else
    1119 %         %set(handles.CheckMask,'Value',1)
    1120 %         set(handles.CheckMask,'Value',1)
    1121 %     end
    1122 %     set(handles.Mask,'String',mask_displ)
    1123 %     set(handles.Mask,'String',mask_displ)
    1124 %     set(handles.Mask,'String',mask_displ)
    1125 % end
    1126 
    1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1128 % Callbacks in the uipanel Civ2
    1129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1130 %------------------------------------------------------------------------
    1131 % --- Executes on button press in CheckMask: select box for mask option
    1132 function get_mask_civ2_Callback(hObject, eventdata, handles)
    1133 %------------------------------------------------------------------------
    1134 maskval=get(handles.CheckMask,'Value');
    1135 if isequal(maskval,0)
    1136     set(handles.Mask,'String','')
    1137 else
    1138     mask_displ='no mask'; %default
    1139     filebase=get(handles.RootPath,'String');
    1140     [nbslice, flag_mask]=get_mask(filebase,handles);
    1141     if isequal(flag_mask,1)
    1142         mask_displ=[num2str(nbslice) 'mask'];
    1143     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    1144         filebase_a=get(handles.RootFile_1,'String');
    1145         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    1146         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    1147             mask_displ='no mask';
    1148         end
    1149     end
    1150     if isequal(mask_displ,'no mask')
    1151         [FileName, PathName, filterindex] = uigetfile( ...
    1152             {'*.png', ' (*.png)';
    1153             '*.png',  '.png files '; ...
    1154             '*.*', 'All Files (*.*)'}, ...
    1155             'Pick a mask file *.png',filebase);
    1156         mask_displ=fullfile(PathName,FileName);
    1157         if ~exist(mask_displ,'file')
    1158             mask_displ='no mask';
    1159         end
    1160     end
    1161     if isequal(mask_displ,'no mask')
    1162         set(handles.CheckMask,'Value',0)
    1163         set(handles.CheckMask,'Value',0)
    1164     else
    1165         set(handles.CheckMask,'Value',1)
    1166     end
    1167     set(handles.Mask,'String',mask_displ)
    1168 end
    1169 
    1170 % %------------------------------------------------------------------------
    1171 % % --- Executes on button press in CheckMask.
    1172 % function get_mask_fix2_Callback(hObject, eventdata, handles)
    1173 % %------------------------------------------------------------------------
    1174 % maskval=get(handles.CheckMask,'Value');
    1175 % if isequal(maskval,0)
    1176 %     set(handles.Mask,'String','')
    1177 % else
    1178 %     mask_displ='no mask'; %default
    1179 %     filebase=get(handles.RootPath,'String');
    1180 %     [nbslice, flag_mask]=get_mask(filebase,handles);
    1181 %     if isequal(flag_mask,1)
    1182 %         mask_displ=[num2str(nbslice) 'mask'];
    1183 %     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    1184 %         filebase_a=get(handles.RootFile_1,'String');
    1185 %         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    1186 %         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    1187 %             mask_displ='no mask';
    1188 %         end
    1189 %     end
    1190 %     if isequal(mask_displ,'no mask')
    1191 %         [FileName, PathName, filterindex] = uigetfile( ...
    1192 %             {'*.png', ' (*.png)';
    1193 %             '*.png',  '.png files '; ...
    1194 %             '*.*', 'All Files (*.*)'}, ...
    1195 %             'Pick a mask file *.png',filebase);
    1196 %         mask_displ=fullfile(PathName,FileName);
    1197 %         if ~exist(mask_displ,'file')
    1198 %             mask_displ='no mask';
    1199 %         end
    1200 %     end
    1201 %     if isequal(mask_displ,'no mask')
    1202 %         set(handles.CheckMask,'Value',0)
    1203 %     end
    1204 %     set(handles.Mask,'String',mask_displ)
    1205 % end
    1206 
    1207 %------------------------------------------------------------------------
    1208 % --- function called to look for mask files
    1209 function [nbslice, flag_mask]=get_mask(filebase,handles)
    1210 %------------------------------------------------------------------------
    1211 %detect mask files, images with appropriate file base
    1212 %[filebase '_' xx 'mask'], xx=nbslice
    1213 %flag_mask=1 indicates detection
    1214 
    1215 flag_mask=0;%default
    1216 nbslice=1;
    1217 
    1218 % subdir=get(handles.Civ1_ImageB,'String');
    1219 [Path,Name]=fileparts(filebase);
    1220 if ~isdir(Path)
    1221     msgbox_uvmat('ERROR','no path for input files')
    1222     return
    1223 end
    1224 % currentdir=pwd;
    1225 % cd(Path);%move in the dir of the root name filebase
    1226 maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files
    1227 % cd(currentdir);%come back to the current working directory
    1228 if ~isempty(maskfiles)
    1229     %     msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
    1230     % else
    1231     flag_mask=1;
    1232     maskname=maskfiles(1).name;% take the first mask file in the list
    1233     [Path2,Name,ext]=fileparts(maskname);
    1234     Namedouble=double(Name);
    1235     val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
    1236     ind_mask=findstr('mask',Name);
    1237     i=ind_mask-1;
    1238     while val(i)==0 && i>0
    1239         i=i-1;
    1240     end
    1241     nbslice=str2double(Name(i+1:ind_mask-1));
    1242     if ~isnan(nbslice) && Name(i)=='_'
    1243         flag_mask=1;
    1244     else
    1245         msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2])
    1246         return
    1247         nbslice=1;
    1248     end
    1249 end
    1250 
    12511092%------------------------------------------------------------------------
    12521093% --- function called to look for grid files
     
    14191260function CheckMask_Callback(hObject, eventdata, handles)
    14201261%------------------------------------------------------------------------
    1421 value=get(hObject,'Value');
    14221262hparent=get(hObject,'parent');
    1423 parent_tag=get(hparent,'Tag');
    14241263hchildren=get(hparent,'children');
    14251264handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel
    1426 handle_NbSlice=findobj(hchildren,'tag','num_NbSlice');% look for the mask name box in the same panel
     1265% handle_NbSlice=findobj(hchildren,'tag','num_NbSlice');% look for the mask name box in the same panel
    14271266testmask=0;
    1428 if value
     1267if get(hObject,'Value')% if the checkbox is activated
    14291268    hseries=findobj(allchild(0),'Tag','series');
    14301269    hhseries=guidata(hseries);
    14311270    InputTable=get(hhseries.InputTable,'Data');
    1432     ind_A=1;% line index of the (first) image series
    1433     if strcmp(InputTable{1,5},'.nc');
    1434         ind_A=2;
    1435     end
    1436  % browse for a mask
    1437         filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
    1438         [FilePath,FileName,Ext]=fileparts(filemask);   
    1439         [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName,Ext]);
     1271    if strcmp(InputTable{1,5},'.nc')
     1272        ind_A=2;%case of nc file as input (for civ3), image in second line
     1273    else
     1274        ind_A=1;% line index of the (first) image series
     1275    end
     1276    % browse for a mask
     1277    filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
     1278    if ~isempty(filemask)
     1279        [FilePath,FileName,FileExt]=fileparts(filemask);
     1280        [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName FileExt]);
    14401281        if strcmp(NomType,'_1')
    1441            NbSlice=i1_series(1,2,end);
    1442            set(handles.num_NbSlice,'String',num2str(NbSlice))
     1282            NbSlice=i1_series(1,2,end);
     1283            set(handles.num_NbSlice,'String',num2str(NbSlice))
     1284        elseif ~strcmp(NomType,'*')
     1285            msgbox_uvmat('ERROR','multilevel masks must be labeled with a single index as _1,_2,...');
     1286            return
    14431287        end
    14441288        set(hObject,'UserData',filemask);%store for future use
    1445         if ~isempty(filemask)
    1446             testmask=1;
    1447         end
     1289        testmask=1;
     1290    end
    14481291end
    14491292if testmask
Note: See TracChangeset for help on using the changeset viewer.