[169] | 1 | %'aver_stat': calculate field average, used with series.fig |
---|
| 2 | %------------------------------------------------------------------------ |
---|
[374] | 3 | % function GUI_input=aver_stat(Param) |
---|
[169] | 4 | % |
---|
[447] | 5 | %%%%%%%%%%% GENERAL TO ALL SERIES ACTION FCTS %%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
[169] | 6 | %OUTPUT |
---|
| 7 | % GUI_input=list of options in the GUI series.fig needed for the function |
---|
| 8 | % |
---|
| 9 | %INPUT: |
---|
[447] | 10 | % In run mode, the input parameters are given as a Matlab structure Param copied from the GUI series. |
---|
| 11 | % In batch mode, Param is the name of the corresponding xml file containing the same information |
---|
| 12 | % In the absence of input (as activated when the current Action is selected |
---|
| 13 | % in series), the function ouput GUI_input set the activation of the needed GUI elements |
---|
[169] | 14 | % |
---|
[447] | 15 | % Param contains the elements:(use the menu bar command 'export/GUI config' in series to see the current structure Param) |
---|
| 16 | % .InputTable: cell of input file names, (several lines for multiple input) |
---|
| 17 | % each line decomposed as {RootPath,SubDir,Rootfile,NomType,Extension} |
---|
| 18 | % .OutputSubDir: name of the subdirectory for data outputs |
---|
| 19 | % .OutputDir: directory for data outputs, including path |
---|
| 20 | % .Action: .ActionName: name of the current activated function |
---|
| 21 | % .ActionPath: path of the current activated function |
---|
| 22 | % .IndexRange: set the file or frame indices on which the action must be performed |
---|
| 23 | % .FieldTransform: .TransformName: name of the selected transform function |
---|
| 24 | % .TransformPath: path of the selected transform function |
---|
| 25 | % .TransformHandle: corresponding function handle |
---|
| 26 | % .InputFields: sub structure describing the input fields withfields |
---|
| 27 | % .FieldName: name of the field |
---|
| 28 | % .VelType: velocity type |
---|
| 29 | % .FieldName_1: name of the second field in case of two input series |
---|
| 30 | % .VelType_1: velocity type of the second field in case of two input series |
---|
| 31 | % .ProjObject: %sub structure describing a projection object (read from ancillary GUI set_object) |
---|
| 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 33 | |
---|
[361] | 34 | function GUI_input=aver_stat(Param) |
---|
[447] | 35 | |
---|
| 36 | %% set the input elements needed on the GUI series when the action is selected in the menu ActionName |
---|
| 37 | if ~exist('Param','var') % case with no input parameter |
---|
| 38 | GUI_input={'NbViewMax';2;...% max nbre of input file series (default='' , no limitation) |
---|
| 39 | 'AllowInputSort';'off';...% allow alphabetic sorting of the list of input files (options 'off'/'on', 'off' by default) |
---|
[27] | 40 | 'NbSlice';'on'; ...%nbre of slices ('off' by default) |
---|
[447] | 41 | 'VelType';'two';...% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) |
---|
| 42 | 'FieldName';'two';...% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) |
---|
| 43 | 'FieldTransform'; 'on';...%can use a transform function |
---|
| 44 | 'ProjObject';'on';...%can use projection object(option 'off'/'on', |
---|
| 45 | 'Mask';'off';...%can use mask option (option 'off'/'on', 'off' by default) |
---|
| 46 | 'OutputDirExt';'.stat';...%set the output dir extension |
---|
[27] | 47 | ''}; |
---|
| 48 | return |
---|
| 49 | end |
---|
| 50 | |
---|
[447] | 51 | %%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% |
---|
| 52 | %% get input parameters, file names and indices |
---|
| 53 | % BATCH case: read the xml file for batch case |
---|
[449] | 54 | if ischar(Param) && ~isempty(find(regexp(Param,'.xml$'))) |
---|
[361] | 55 | Param=xml2struct(Param); |
---|
[442] | 56 | checkrun=0; |
---|
[447] | 57 | % RUN case: parameters introduced as the input structure Param |
---|
| 58 | else |
---|
[374] | 59 | hseries=guidata(Param.hseries);%handles of the GUI series |
---|
[447] | 60 | WaitbarPos=get(hseries.waitbar_frame,'Position');%position of the waitbar on the GUI series |
---|
| 61 | checkrun=1; % indicate the RUN option is used |
---|
[361] | 62 | end |
---|
[447] | 63 | % get the set of input file names (cell array filecell), and the lists of |
---|
| 64 | % input file or frame indices i1_series,i2_series,j1_series,j2_series |
---|
[374] | 65 | [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); |
---|
[447] | 66 | % filecell{iview,fileindex}: cell array representing the list of file names |
---|
| 67 | % iview: line in the table corresponding to a given file series |
---|
| 68 | % fileindex: file index within the file series, |
---|
| 69 | % 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 |
---|
| 70 | % i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices |
---|
| 71 | % set of frame indices used for movie or multimage input |
---|
| 72 | if ~isempty(j1_series) |
---|
| 73 | frame_index=j1_series; |
---|
| 74 | else |
---|
| 75 | frame_index=i1_series; |
---|
[41] | 76 | end |
---|
| 77 | |
---|
[447] | 78 | %% root input file(s) and type |
---|
| 79 | RootPath=Param.InputTable(:,1); |
---|
| 80 | RootFile=Param.InputTable(:,3); |
---|
| 81 | SubDir=Param.InputTable(:,2); |
---|
| 82 | NomType=Param.InputTable(:,4); |
---|
| 83 | FileExt=Param.InputTable(:,5); |
---|
[27] | 84 | |
---|
[447] | 85 | % numbers of slices and file indices |
---|
| 86 | NbSlice=1;%default |
---|
| 87 | if isfield(Param.IndexRange,'NbSlice') |
---|
| 88 | NbSlice=Param.IndexRange.NbSlice; |
---|
[27] | 89 | end |
---|
[447] | 90 | nbview=size(i1_series,1);%number of input file series (lines in InputTable) |
---|
| 91 | nbfield_j=size(i1_series,2); %nb of consecutive fields at each level(burst |
---|
| 92 | nbfield=nbfield_j*size(i1_series,3); %total number of files or frames |
---|
| 93 | nbfield_i=floor(nbfield/NbSlice);%total number of i indexes (adjusted to an integer number of slices) |
---|
| 94 | nbfield=nbfield_i*nbfield_j; %total number of fields after adjustement |
---|
[43] | 95 | |
---|
[447] | 96 | %determine the file type on each line from the first input file |
---|
| 97 | ImageTypeOptions={'image','multimage','mmreader','video'}; |
---|
| 98 | NcTypeOptions={'netcdf','civx','civdata'}; |
---|
[451] | 99 | |
---|
[27] | 100 | for iview=1:nbview |
---|
[451] | 101 | if ~exist(filecell{iview,1}','file') |
---|
| 102 | msgbox_uvmat('ERROR',['the first input file ' filecell{iview,1} ' does not exist']) |
---|
| 103 | return |
---|
| 104 | end |
---|
| 105 | [FileType{iview},FileInfo{iview},MovieObject{iview}]=get_file_type(filecell{iview,1}); |
---|
[447] | 106 | CheckImage{iview}=~isempty(find(strcmp(FileType{iview},ImageTypeOptions)));% =1 for images |
---|
| 107 | CheckNc{iview}=~isempty(find(strcmp(FileType{iview},NcTypeOptions)));% =1 for netcdf files |
---|
[27] | 108 | end |
---|
| 109 | |
---|
[451] | 110 | %% calibration data and timing: read the ImaDoc files |
---|
[27] | 111 | mode=''; %default |
---|
| 112 | timecell={}; |
---|
| 113 | itime=0; |
---|
| 114 | NbSlice_calib={}; |
---|
| 115 | for iview=1:nbview%Loop on views |
---|
| 116 | XmlData{iview}=[];%default |
---|
| 117 | filebase{iview}=fullfile(RootPath{iview},RootFile{iview}); |
---|
| 118 | if exist([filebase{iview} '.xml'],'file') |
---|
| 119 | [XmlData{iview},error]=imadoc2struct([filebase{iview} '.xml']); |
---|
| 120 | if isfield(XmlData{iview},'Time') |
---|
| 121 | itime=itime+1; |
---|
| 122 | timecell{itime}=XmlData{iview}.Time; |
---|
| 123 | end |
---|
| 124 | if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord') |
---|
| 125 | NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform |
---|
| 126 | if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) |
---|
| 127 | msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); |
---|
| 128 | end |
---|
| 129 | end |
---|
| 130 | elseif exist([filebase{iview} '.civ'],'file') |
---|
| 131 | [error,time,TimeUnit,mode,npx,npy,pxcmx,pxcmy]=read_imatext([filebase{iview} '.civ']); |
---|
| 132 | itime=itime+1; |
---|
| 133 | timecell{itime}=time; |
---|
| 134 | XmlData{iview}.Time=time; |
---|
| 135 | GeometryCalib.R=[pxcmx 0 0; 0 pxcmy 0;0 0 0]; |
---|
| 136 | GeometryCalib.Tx=0; |
---|
| 137 | GeometryCalib.Ty=0; |
---|
| 138 | GeometryCalib.Tz=1; |
---|
| 139 | GeometryCalib.dpx=1; |
---|
| 140 | GeometryCalib.dpy=1; |
---|
| 141 | GeometryCalib.sx=1; |
---|
| 142 | GeometryCalib.Cx=0; |
---|
| 143 | GeometryCalib.Cy=0; |
---|
| 144 | GeometryCalib.f=1; |
---|
| 145 | GeometryCalib.kappa1=0; |
---|
| 146 | GeometryCalib.CoordUnit='cm'; |
---|
| 147 | XmlData{iview}.GeometryCalib=GeometryCalib; |
---|
| 148 | if error==1 |
---|
| 149 | msgbox_uvmat('WARNING','inconsistent number of fields in the .civ file'); |
---|
| 150 | end |
---|
| 151 | end |
---|
| 152 | end |
---|
| 153 | |
---|
[392] | 154 | %% check coincidence in time for several input file series |
---|
[27] | 155 | multitime=0; |
---|
[55] | 156 | if isempty(timecell) |
---|
[27] | 157 | time=[]; |
---|
| 158 | elseif length(timecell)==1 |
---|
| 159 | time=timecell{1}; |
---|
| 160 | elseif length(timecell)>1 |
---|
| 161 | multitime=1; |
---|
| 162 | for icell=1:length(timecell) |
---|
| 163 | if ~isequal(size(timecell{icell}),size(timecell{1})) |
---|
| 164 | msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used') |
---|
| 165 | time=timecell{1}; |
---|
| 166 | multitime=0; |
---|
| 167 | break |
---|
| 168 | end |
---|
| 169 | end |
---|
| 170 | end |
---|
| 171 | if multitime |
---|
| 172 | for icell=1:length(timecell) |
---|
| 173 | time(icell,:,:)=timecell{icell}; |
---|
| 174 | end |
---|
| 175 | diff_time=max(max(diff(time))); |
---|
| 176 | if diff_time>0 |
---|
[447] | 177 | msgbox_uvmat('WARNING',['times of series differ by (max) ' num2str(diff_time)]) |
---|
[27] | 178 | end |
---|
| 179 | end |
---|
[447] | 180 | if size(time,2) < i2_series(1,end) || size(time,3) < j2_series(1,end)% time array absent or too short in ImaDoc xml file' |
---|
[27] | 181 | time=[]; |
---|
| 182 | end |
---|
| 183 | |
---|
[447] | 184 | %% coordinate transform or other user defined transform |
---|
| 185 | transform_fct='';%default |
---|
| 186 | if isfield(Param,'FieldTransform')&&isfield(Param.FieldTransform,'TransformHandle') |
---|
| 187 | transform_fct=Param.FieldTransform.TransformHandle; |
---|
[27] | 188 | end |
---|
[447] | 189 | %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% |
---|
| 190 | % EDIT FROM HERE |
---|
| 191 | |
---|
| 192 | %% check the validity of input file types |
---|
| 193 | if CheckImage{1} |
---|
| 194 | FileExtOut='.png'; % write result as .png images for image inputs |
---|
| 195 | elseif CheckNc{1} |
---|
| 196 | FileExtOut='.nc';% write result as .nc files for netcdf inputs |
---|
| 197 | else |
---|
| 198 | msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}]) |
---|
| 199 | return |
---|
| 200 | end |
---|
| 201 | if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) |
---|
| 202 | msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') |
---|
| 203 | return |
---|
| 204 | end |
---|
| 205 | NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series |
---|
| 206 | if NbSlice~=nbfield_j |
---|
| 207 | answer=msgbox_uvmat('INPUT_Y-N',['will not average slice by slice: for so cancel and set NbSlice= ' num2str(nbfield_j)]); |
---|
| 208 | if ~strcmp(answer,'Yes') |
---|
| 209 | return |
---|
[255] | 210 | end |
---|
[218] | 211 | end |
---|
[442] | 212 | |
---|
[447] | 213 | %% Set field names and velocity types |
---|
| 214 | InputFields{1}=[];%default (case of images) |
---|
| 215 | if isfield(Param,'InputFields') |
---|
| 216 | InputFields{1}=Param.InputFields; |
---|
| 217 | end |
---|
| 218 | if nbview==2 |
---|
| 219 | InputFields{2}=[];%default (case of images) |
---|
| 220 | if isfield(Param,'InputFields') |
---|
| 221 | InputFields{2}=Param.InputFields{1};%default |
---|
| 222 | if isfield(Param.InputFields,'FieldName_1') |
---|
| 223 | InputFields{2}.FieldName=Param.InputFields.FieldName_1; |
---|
| 224 | if isfield(Param.InputFields,'VelType_1') |
---|
| 225 | InputFields{2}.VelType=Param.InputFields.VelType_1; |
---|
| 226 | end |
---|
| 227 | end |
---|
[255] | 228 | end |
---|
| 229 | end |
---|
[447] | 230 | |
---|
| 231 | %% Initiate output fields |
---|
| 232 | %initiate the output structure as a copy of the first input one (reproduce fields) |
---|
| 233 | [DataOut,ParamOut,errormsg] = read_field(filecell{1,1},FileType{1},InputFields{1},1); |
---|
| 234 | if ~isempty(errormsg) |
---|
| 235 | msgbox_uvmat('ERROR',['error reading ' filecell{1,1} ': ' errormsg]) |
---|
[218] | 236 | return |
---|
| 237 | end |
---|
[447] | 238 | time_1=[]; |
---|
| 239 | if isfield(DataOut,'Time') |
---|
| 240 | time_1=DataOut.Time(1); |
---|
[41] | 241 | end |
---|
[447] | 242 | if CheckNc{iview} |
---|
| 243 | if isempty(strcmp('Conventions',DataOut.ListGlobalAttribute)) |
---|
| 244 | DataOut.ListGlobalAttribute=['Conventions' DataOut.ListGlobalAttribute]; |
---|
| 245 | end |
---|
| 246 | DataOut.Conventions='uvmat'; |
---|
| 247 | DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {Param.Action}]; |
---|
| 248 | ActionKey='Action'; |
---|
| 249 | while isfield(DataOut,ActionKey) |
---|
| 250 | ActionKey=[ActionKey '_1']; |
---|
| 251 | end |
---|
| 252 | DataOut.(ActionKey)=Param.Action; |
---|
| 253 | DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {ActionKey}]; |
---|
| 254 | if isfield(DataOut,'Time') |
---|
| 255 | DataOut.ListGlobalAttribute=[DataOut.ListGlobalAttribute {'Time','Time_end'}]; |
---|
| 256 | end |
---|
| 257 | end |
---|
[27] | 258 | |
---|
[447] | 259 | %% MAIN LOOP ON SLICES |
---|
| 260 | %%%%%%%%%%%%% STANDARD PART (DO NOT EDIT) %%%%%%%%%%%% |
---|
[27] | 261 | for i_slice=1:NbSlice |
---|
[447] | 262 | index_slice=i_slice:NbSlice:nbfield;% select file indices of the slice |
---|
[255] | 263 | nbfiles=0; |
---|
| 264 | nbmissing=0; |
---|
[447] | 265 | |
---|
| 266 | %initiate result fields |
---|
| 267 | for ivar=1:length(DataOut.ListVarName) |
---|
| 268 | DataOut.(DataOut.ListVarName{ivar})=0; % initialise all fields to zero |
---|
| 269 | end |
---|
| 270 | |
---|
| 271 | %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%% |
---|
| 272 | for index=index_slice |
---|
| 273 | if checkrun |
---|
| 274 | update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield)) |
---|
| 275 | stopstate=get(hseries.RUN,'BusyAction'); |
---|
| 276 | else |
---|
| 277 | stopstate='queue'; |
---|
| 278 | end |
---|
| 279 | |
---|
| 280 | %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%% |
---|
| 281 | for iview=1:nbview |
---|
[255] | 282 | % reading input file(s) |
---|
[447] | 283 | [Data{iview},ParamOut,errormsg] = read_field(filecell{iview,index},FileType{iview},InputFields{iview},frame_index(iview,index)); |
---|
| 284 | if ~isempty(errormsg) |
---|
| 285 | errormsg=['error of input reading: ' errormsg]; |
---|
| 286 | break |
---|
[255] | 287 | end |
---|
[447] | 288 | if ~isempty(NbSlice_calib) |
---|
| 289 | Data{iview}.ZIndex=mod(i1_series(iview,index)-1,NbSlice_calib{1})+1;%Zindex for phys transform |
---|
| 290 | end |
---|
| 291 | end |
---|
| 292 | Field=[]; % initiate the current input field structure |
---|
| 293 | %%%%%%%%%%%%%%%% end loop on views (input lines) %%%%%%%%%%%%%%%% |
---|
| 294 | %%%%%%%%%%%% END STANDARD PART %%%%%%%%%%%% |
---|
| 295 | % EDIT FROM HERE |
---|
| 296 | |
---|
| 297 | if isempty(errormsg) |
---|
[255] | 298 | % coordinate transform (or other user defined transform) |
---|
| 299 | if ~isempty(transform_fct) |
---|
[27] | 300 | if nbview==2 |
---|
[41] | 301 | [Data{1},Data{2}]=transform_fct(Data{1},XmlData{1},Data{2},XmlData{2}); |
---|
[27] | 302 | if isempty(Data{2}) |
---|
| 303 | Data(2)=[]; |
---|
| 304 | end |
---|
| 305 | else |
---|
[80] | 306 | Data{1}=transform_fct(Data{1},XmlData{1}); |
---|
[27] | 307 | end |
---|
[255] | 308 | end |
---|
| 309 | |
---|
| 310 | % field calculation (vort, div...) |
---|
[447] | 311 | if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civ') |
---|
| 312 | Data{1}=calc_field(InputFields{1}.FieldName,Data{1});%calculate field (vort..) |
---|
[27] | 313 | end |
---|
[255] | 314 | |
---|
| 315 | % field substration (for two input file series) |
---|
[27] | 316 | if length(Data)==2 |
---|
[447] | 317 | if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civ') |
---|
| 318 | Data{2}=calc_field(InputFields{2}.FieldName,Data{2});%calculate field (vort..) |
---|
| 319 | end |
---|
[27] | 320 | [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields |
---|
| 321 | if ~isempty(errormsg) |
---|
| 322 | msgbox_uvmat('ERROR',['error in aver_stat/sub_field:' errormsg]) |
---|
| 323 | return |
---|
| 324 | end |
---|
| 325 | else |
---|
| 326 | Field=Data{1}; |
---|
| 327 | end |
---|
[451] | 328 | |
---|
| 329 | %field projection on an object |
---|
[447] | 330 | if Param.CheckObject |
---|
[41] | 331 | [Field,errormsg]=proj_field(Field,ProjObject); |
---|
[255] | 332 | if ~isempty(errormsg) |
---|
[27] | 333 | msgbox_uvmat('ERROR',['error in aver_stat/proj_field:' errormsg]) |
---|
| 334 | return |
---|
| 335 | end |
---|
[255] | 336 | end |
---|
| 337 | nbfiles=nbfiles+1; |
---|
[447] | 338 | |
---|
| 339 | %%%%%%%%%%%% MAIN RUNNING OPERATIONS %%%%%%%%%%%% |
---|
| 340 | %update sum |
---|
| 341 | for ivar=1:length(Field.ListVarName) |
---|
| 342 | VarName=Field.ListVarName{ivar}; |
---|
| 343 | sizmean=size(DataOut.(VarName)); |
---|
| 344 | siz=size(Field.(VarName)); |
---|
| 345 | if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean) |
---|
| 346 | msgbox_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid']) |
---|
| 347 | return |
---|
| 348 | else |
---|
| 349 | DataOut.(VarName)=DataOut.(VarName)+ double(Field.(VarName)); % update the sum |
---|
[255] | 350 | end |
---|
| 351 | end |
---|
[447] | 352 | %%%%%%%%%%%% END MAIN RUNNING OPERATIONS %%%%%%%%%%%% |
---|
| 353 | else |
---|
| 354 | display(errormsg) |
---|
| 355 | end |
---|
[255] | 356 | end |
---|
[447] | 357 | %%%%%%%%%%%%%%%% end loop on field indices %%%%%%%%%%%%%%%% |
---|
| 358 | |
---|
[27] | 359 | for ivar=1:length(Field.ListVarName) |
---|
| 360 | VarName=Field.ListVarName{ivar}; |
---|
[447] | 361 | DataOut.(VarName)=DataOut.(VarName)/nbfiles; % normalize the mean |
---|
[27] | 362 | end |
---|
| 363 | if nbmissing~=0 |
---|
| 364 | msgbox_uvmat('WARNING',[num2str(nbmissing) ' input files are missing or skipted']) |
---|
| 365 | end |
---|
| 366 | if isempty(time) % time read from files prevails |
---|
| 367 | if isfield(Field,'Time') |
---|
| 368 | time_end=Field.Time(1);%last time read |
---|
| 369 | if ~isempty(time_1) |
---|
[447] | 370 | DataOut.Time=time_1; |
---|
| 371 | DataOut.Time_end=time_end; |
---|
[27] | 372 | end |
---|
| 373 | end |
---|
| 374 | else % time from ImaDoc prevails |
---|
[447] | 375 | DataOut.Time=time(1,i1_series(1,1),j1_series(1,1)); |
---|
| 376 | DataOut.Time_end=time(end,i1_series(end,end),j1_series(end,end)); |
---|
[27] | 377 | end |
---|
[255] | 378 | |
---|
[27] | 379 | %writing the result file |
---|
[447] | 380 | OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomTypeOut,i1_series(1,1),i1_series(1,end),i_slice,[]); |
---|
| 381 | if CheckImage{1} %case of images |
---|
| 382 | if isequal(FileInfo{1}.BitDepth,16)||(numel(FileInfo)==2 &&isequal(FileInfo{2}.BitDepth,16)) |
---|
| 383 | DataOut.A=uint16(DataOut.A); |
---|
| 384 | imwrite(DataOut.A,OutputFile,'BitDepth',16); % case of 16 bit images |
---|
[27] | 385 | else |
---|
[447] | 386 | DataOut.A=uint8(DataOut.A); |
---|
| 387 | imwrite(DataOut.A,OutputFile,'BitDepth',8); % case of 16 bit images |
---|
[27] | 388 | end |
---|
[447] | 389 | display([OutputFile ' written']); |
---|
[55] | 390 | else %case of netcdf input file , determine global attributes |
---|
[447] | 391 | errormsg=struct2nc(OutputFile,DataOut); %save result file |
---|
[27] | 392 | if isempty(errormsg) |
---|
[447] | 393 | display([OutputFile ' written']); |
---|
[27] | 394 | else |
---|
| 395 | msgbox_uvmat('ERROR',['error in writting result file: ' errormsg]) |
---|
| 396 | display(errormsg) |
---|
| 397 | end |
---|
[255] | 398 | end % end averaging loop |
---|
[447] | 399 | end |
---|
| 400 | %%%%%%%%%%%%%%%% end loop on slices %%%%%%%%%%%%%%%% |
---|
[255] | 401 | |
---|
[451] | 402 | %% open the result file with uvmat (in RUN mode) |
---|
| 403 | if checkrun |
---|
| 404 | hget_field=findobj(allchild(0),'name','get_field');%find the get_field... GUI |
---|
| 405 | delete(hget_field) |
---|
| 406 | uvmat(OutputFile)% open the last result file with uvmat |
---|
| 407 | end |
---|