- Timestamp:
- May 29, 2014, 6:17:00 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_file_type.m
r771 r781 40 40 FileInfo.FileType='xls'; 41 41 FileType='xls'; 42 case '.dat' 43 FileInfo.FileType='dat'; 44 FileType='dat'; 42 45 otherwise 43 46 if ~isempty(FileExt)% exclude empty extension -
trunk/src/plot_field.m
r760 r781 97 97 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 98 98 99 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam ,PosColorbar)99 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam) 100 100 101 101 %% default input and output … … 180 180 %% 2D plots 181 181 if isempty(index_2D) 182 plot_plane([],[],haxes,[] ,[]);%removes images or vector plots in the absence of 2D field plot182 plot_plane([],[],haxes,[]);%removes images or vector plots in the absence of 2D field plot 183 183 else %plot 2D field 184 if ~exist('PosColorbar','var'),PosColorbar=[];end;185 [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut ,PosColorbar);184 % if ~exist('PosColorbar','var'),PosColorbar=[];end; 185 [tild,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo(index_2D),haxes,PlotParamOut); 186 186 AxeData.NbDim=2; 187 187 if testzoomaxes && isempty(errormsg) 188 [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut ,PosColorbar);188 [zoomaxes,PlotParamOut,tild,errormsg]=plot_plane(Data,CellInfo(index_2D),zoomaxes,PlotParamOut); 189 189 AxeData.ZoomAxes=zoomaxes; 190 190 end … … 573 573 574 574 %------------------------------------------------------------------- 575 function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam ,PosColorbar)575 function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam) 576 576 %------------------------------------------------------------------- 577 577 PlotType='plane'; … … 589 589 590 590 hfig=get(haxes,'parent');%handle of the figure containing the plot axes 591 PosColorbar=[]; 592 FigData=get(hfig,'UserData'); 593 if isfield(FigData,'PosColorbar') 594 PosColorbar=FigData.PosColorbar; 595 end 591 596 hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes 592 597 hima=findobj(haxes,'Tag','ima');% search existing image in the current axes -
trunk/src/series.m
r777 r781 1525 1525 return 1526 1526 end 1527 [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder1527 [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder 1528 1528 if success==0 1529 msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg1});%error message for directory creation 1530 return 1529 msgbox_uvmat('WARNING',{['unable to set group write access to ' DirXml ':']; msg});%error message for directory creation 1531 1530 end 1532 1531 end -
trunk/src/series/beam_forming.m
r780 r781 4 4 if isstruct(Param) && isequal(Param.Action.RUN,0) 5 5 ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 6 ParamOut.WholeIndexRange='o ff';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)6 ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 7 7 ParamOut.NbSlice='off'; %nbre of slices ('off' by default) 8 8 ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) … … 12 12 ParamOut.ProjObject='off';%can use projection object(option 'off'/'on', 13 13 ParamOut.Mask='off';%can use mask option (option 'off'/'on', 'off' by default) 14 ParamOut.OutputDirExt='.p_formed_1';%set the output dir extension 14 index=msgbox_uvmat('INPUT_TXT','index of the series to process (1 to 5)');%choose the i index of the dat files 15 ParamOut.OutputDirExt=['.p_formed_' index];%set the output dir extension 16 hseries=findobj(allchild(0),'Tag','series'); 17 hhseries=guidata(hseries); 18 set(hhseries.num_last_i,'String',index) 19 set(hhseries.num_first_i,'String',index) 15 20 ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice 16 21 %check the input files … … 29 34 30 35 ParamOut=[]; %default output 36 %% read input parameters from an xml file if input is a file name (batch mode) 37 checkrun=1; 38 if ischar(Param) 39 Param=xml2struct(Param);% read Param as input file (batch case) 40 checkrun=0; 41 end 31 42 hseries=findobj(allchild(0),'Tag','series'); 32 43 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series … … 84 95 % close all 85 96 % read_data=1; 86 affichage= 1;97 affichage=0; 87 98 % soustraction=0; 88 89 % test_fin_fichier=1;90 pas_fichier=1;91 numero_tir_fin_old=1;92 99 93 100 %%%%%% Prepare output 94 101 load (fullfile(RootPath,SubDir,[RootFile '.mat'])) 95 Data.ListVarName={'Coord_x','Coord_z','Pressure'}; 96 Data.VarDimName={'Coord_x','Coord_z',{'Coord_z','Coord_x'}}; 97 Data.Coord_x=5*(nbvoie_reception-0.5)/numel(nbvoie_reception); % totql length of e 98 Data.Coord_z=(1:A)/133 ;% to check from input parameter .... 102 Data.ListGlobalAttribute={'CoordUnit'}; %%TODO: add also time, how to get it ????? 103 Data.CoordUnit='pixel'; 104 Data.ListVarName={'AX','AY','A'}; 105 Data.VarDimName={'AX','AY',{'AY','AX'}}; 106 %Data.Coord_x=5*(nbvoie_reception-0.5)/numel(nbvoie_reception); % totql length of e 107 Data.AX=1:65; 108 %Data.Coord_z=(1:A)/133 ;% to check from input parameter .... 109 Data.AY=1:332; 99 110 %%%%%% 100 111 % … … 104 115 %name='test';%%%%%%%%%%%%%%%%% 105 116 % number=2; 106 number=1; %subsequence index (from 1 to 5) 107 OutputDirExt=['.p_formed_' num2str(number)]; %TODO: loop on 'number' from 1 to 5 108 numero_tir_fin_old=1; 109 pas_fichier=20;% nbre of successive shoots to read (to account for computer memory limit) 110 Nmoy=20; %%%%% value 20 FOR TEST : to shift to VALUE 8000 set by the .mat file 117 number=str2num(Param.OutputDirExt(11:end));%extract the subsequence index (from 1 to 5) 118 numero_tir_fin_old=1%%%%%%% =0 ????? 119 pas_fichier=20;% %20;% nbre of successive shots to read (to account for computer memory limit) 120 Nmoy=800; %%%%% value 20 FOR TEST : to shift to VALUE 8000 set by the .mat file 111 121 112 122 test_fin_fichier=1;% test to stop input file reading 113 123 while test_fin_fichier>0 114 124 numero_tir_debut=1; 115 numero_tir_fin=numero_tir_ debut+pas_fichier;125 numero_tir_fin=numero_tir_fin_old+pas_fichier-1; 116 126 117 127 % eval(['load ' directory '\' name '.mat']) … … 123 133 for ii=1:length(nbvoie_reception)%=64 124 134 %eval(['fid=fopen(''E:\ManipLGITLecoeur\' directory '\' name '_' num2str(number) '_' num2str(nbvoie_reception(ii)) '.dat'',''r'');']); 125 filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,number,[],ii); 135 filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,number,[],ii); % input file name 126 136 fid=fopen(filename); 127 137 toto=zeros(Nsequence*A*numero_tir_fin+31,1);% Nsequence=1 128 toto=fread(fid,numero_tir_fin*A*Nsequence+31,'int16','ieee-le') ; 138 toto=fread(fid,numero_tir_fin*A*Nsequence+31,'int16','ieee-le') ;% why shift by 31 ????? 129 139 toto=double(bitxor(uint16(toto),uint16(2048))); 130 140 toto(1:31)=[];toto(numero_tir_fin*A*Nsequence)=mean(toto); … … 136 146 end 137 147 138 matrice_finale(:,:,numero_tir_debut:numero_tir_fin_old)=[]; 139 numero_tir_fin=numero_tir_fin-1; 140 matrice_finale=reshape(filtfilt(BB,AA,matrice_finale(:,:)),size(matrice_finale)); 148 % matrice_finale(:,:,numero_tir_debut:numero_tir_fin_old)=[];%%%%%%% first field removed (when numero_tir_fin_old=1) ????? 149 matrice_finale(:,:,numero_tir_debut:numero_tir_fin_old-1)=[];%%%%%%% 150 % numero_tir_fin=numero_tir_fin-1; ????? 151 matrice_finale=reshape(filtfilt(BB,AA,matrice_finale(:,:)),size(matrice_finale));% low pass filtered input signal,along first (time) index? 141 152 142 153 % if soustraction==1 … … 149 160 150 161 %%%%%%%%%%%%%%Imagerie 151 fe=rsf*1e6;% acquisition frequency162 fe=rsf*1e6;% sampling frequency for receptor (in Hz) 152 163 cc=1475;%speed of sound 153 164 hanning_window=25; … … 176 187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 177 188 for kk=1:size(matrice_finale,3) 178 kk 179 tir=kk; 180 signal=squeeze(matrice_finale(interval,:,tir)); 181 tata_fft=zeros(size(signal,1),size(signal,2)); 182 tata_fft=fft(signal,[],1); 183 184 if kk==1 185 189 disp(kk) 190 signal=squeeze(matrice_finale(interval,:,kk)); 191 tata_fft=fft(signal,[],1);%FFT of the time signal size=(2650,64) 192 if kk==1 186 193 matrice_freq_mean=mean(abs(fft(signal,[],1)),2); 187 194 X=[freq1*1e6 freq2*1e6]; … … 193 200 194 201 for ii=1:length(image_r) 195 [ii kk]196 202 for jj=1:length(image_z) 197 203 … … 250 256 %%%%%%% TO ADAPT 251 257 for iii=1:size(image_fin,3) 252 Data. Pressure=image_fin(:,:,iii);258 Data.A=image_fin(:,:,iii);% time lapse decreasesas z coordinate increases. 253 259 FileIndex=numero_tir_fin - pas_fichier+iii;%%%%%%TO CHECK!!!!! 254 260 %%%%%%%%%% 255 261 %eval(['save analyse_' name '_' num2str(number) '_' num2str(numero_tir_fin_old) '_' num2str(numero_tir_fin) '.mat']) 256 OutputDir=[Param.OutputSubDir OutputDirExt];% subdirectory for output files 257 OutputFile=fullfile_uvmat(OutputDir,'','signal','.nc','_00001',FileIndex); 262 OutputFile=fullfile_uvmat(RootPath,OutputDir,'signal','.nc','_00001',FileIndex); 258 263 error=struct2nc(OutputFile,Data);%save result file 259 264 if isempty(error) … … 263 268 end 264 269 end 265 numero_tir_fin_old=numero_tir_fin+1 ;266 if (numero_tir_fin_old+pas_fichier)>Nmoy270 numero_tir_fin_old=numero_tir_fin+1% first index for next bloc reading 271 if (numero_tir_fin_old+pas_fichier-1)>Nmoy 267 272 test_fin_fichier=-1; 268 273 end -
trunk/src/series/civ_input.m
r776 r781 97 97 NomTypeNc=''; 98 98 switch FileType 99 case {'image','multimage','video','mmreader' }99 case {'image','multimage','video','mmreader','netcdf'} 100 100 NomTypeImaA=NomTypeInput; 101 101 iview_image=1;%line # for the input images … … 134 134 return 135 135 otherwise 136 msgbox_uvmat('ERROR','civ_series needs images or civ data as input')136 msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input') 137 137 return 138 138 end -
trunk/src/series/civ_series.m
r774 r781 57 57 Data.NbSlice='off'; %nbre of slices ('off' by default) 58 58 Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two', 'off' by default) 59 Data.FieldName='o ff';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)59 Data.FieldName='on';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default) 60 60 Data.FieldTransform = 'off';%can use a transform function 61 61 Data.ProjObject='off';%can use projection object(option 'off'/'on', … … 221 221 end 222 222 [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(ImageName_A); 223 if strcmp(FileInfo_A.FileType,'netcdf') 224 FieldName_A=Param.InputFields.FieldName; 225 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 226 par_civ1.ImageA=DataIn.(FieldName_A); 227 else 223 228 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 229 end 224 230 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 225 231 if ~exist(ImageName_B,'file') … … 228 234 end 229 235 [FileType_B,FileInfo_B,VideoObject_B]=get_file_type(ImageName_B); 230 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 236 if strcmp(FileInfo_B.FileType,'netcdf') 237 FieldName_B=Param.InputFields.FieldName; 238 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 239 par_civ1.ImageB=DataIn.(FieldName_B); 240 else 241 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,Param.InputFields,FrameIndex_B_Civ1(1)); 242 end 231 243 NbField=numel(i1_series_Civ1); 232 244 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 … … 237 249 end 238 250 [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(ImageName_A); 239 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,File Type_A,VideoObject_A,FrameIndex_A_Civ2(1));251 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1)); 240 252 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1)); 241 253 if ~exist(ImageName_B,'file') … … 335 347 try 336 348 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 337 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 349 if strcmp(FileInfo_A.FileType,'netcdf') 350 FieldName_A=Param.InputFields.FieldName; 351 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 352 par_civ1.ImageA=DataIn.(FieldName_A); 353 else 354 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 355 end 338 356 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 339 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 357 if strcmp(FileInfo_B.FileType,'netcdf') 358 FieldName_B=Param.InputFields.FieldName; 359 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 360 par_civ1.ImageB=DataIn.(FieldName_B); 361 else 362 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 363 end 340 364 catch ME 341 365 if ~isempty(ME.message) … … 344 368 end 345 369 end 346 par_civ1.ImageWidth= FileInfo_A.Width;347 par_civ1.ImageHeight= FileInfo_A.Height;370 par_civ1.ImageWidth=size(par_civ1.ImageA,2);%FileInfo_A.Width; 371 par_civ1.ImageHeight=size(par_civ1.ImageA,1);%FileInfo_A.Height; 348 372 list_param=(fieldnames(Param.ActionInput.Civ1))'; 349 373 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param -
trunk/src/uvmat.m
r778 r781 190 190 LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen 191 191 set(hObject,'Position',[LeftX LowY Width Height]) 192 UvData. OpenParam.PosColorbar=[0.80 0.02 0.018 0.445];192 UvData.PosColorbar=[0.80 0.02 0.018 0.445]; 193 193 AxeData.LimEditBox=1; %initialise AxeData 194 194 set(handles.PlotAxes,'UserData',AxeData) … … 373 373 set(handles.TableDisplay,'Position',pos_1) 374 374 % reset position of CheckTable 375 set(handles.CheckTable,'Unit ','pixels')375 set(handles.CheckTable,'Units','pixels') 376 376 pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold 377 377 pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3); % set 'CheckHold' to the right of the fig … … 2077 2077 % in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i) 2078 2078 errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1); 2079 2079 ResizeFcn(handles.uvmat,[],handles) 2080 2080 if isempty(errormsg) 2081 2081 set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull … … 2648 2648 PlotParam{1}.Vectors.ColorCode= {'rgb'}; 2649 2649 end 2650 PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface2650 %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface 2651 2651 2652 2652 %% second projection object (view_field display) … … 2657 2657 haxes(2)=plot_handles{2}.PlotAxes; 2658 2658 PlotParam{2}=read_GUI(view_field_handle); 2659 PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field2659 %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field 2660 2660 end 2661 2661 end … … 2720 2720 view_field(ObjectData) 2721 2721 else 2722 % ObjectData.VarAttribute{5}.Role='scalar';TODO CORRECT 2723 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap},PosColorbar{imap}); 2722 [PlotType,PlotParamOut]=plot_field(ObjectData,haxes(imap),PlotParam{imap}); 2724 2723 if imap==1 2725 2724 errormsg=fill_GUI(PlotParamOut,handles.uvmat); … … 2795 2794 CheckEditObject_Callback(handles.uvmat, [], handles) 2796 2795 end 2797 ResizeFcn(handles.uvmat,[],handles)2796 %ResizeFcn(handles.uvmat,[],handles) 2798 2797 set(handles.uvmat,'Pointer',pointer) 2799 2798 … … 4232 4231 %------------------------------------------------------------------------ 4233 4232 %get the image of the color display button 'VecColBar' in pixels 4234 set(handles.VecColBar,'Unit ','pixel');4233 set(handles.VecColBar,'Units','pixel'); 4235 4234 pos_vert=get(handles.VecColBar,'Position'); 4236 set(handles.VecColBar,'Unit ','Normalized');4235 set(handles.VecColBar,'Units','Normalized'); 4237 4236 width=ceil(pos_vert(3)); 4238 4237 height=ceil(pos_vert(4)); … … 4657 4656 % -------------------------------------------------------------------- 4658 4657 function MenuExportAxis_Callback(hObject, eventdata, handles) 4658 % -------------------------------------------------------------------- 4659 4659 ListFig=findobj(allchild(0),'Type','figure'); 4660 4660 nb_option=0; … … 4715 4715 % -------------------------------------------------------------------- 4716 4716 set(handles.MenuExportMovie,'BusyAction','queue')% activate the button 4717 huvmat=get(handles.InputFileREFRESH,'parent'); 4718 % UvData=get(huvmat,'UserData'); 4719 %[xx,xx,FileBase]=read_file_boxes(handles); 4717 4720 4718 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 4721 4719 FileBase=fullfile(RootPath,RootFile); 4722 %read the current input file name 4723 prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'}; 4724 dlg_title = 'select properties of the output avi movie'; 4725 num_lines= 1; 4726 def = {[FileBase '_out.avi'];'10';'1';'[0.03 0.05 0.95 0.92]';'10'}; 4727 answer = inputdlg(prompt,dlg_title,num_lines,def,'on'); 4728 aviname=answer{1}; 4729 fps=str2double(answer{2}); 4730 % check for existing file with output name aviname 4731 if exist(aviname,'file') 4732 backup=aviname; 4720 4721 %% create a fig and axis for movies 4722 figure_movie=findobj(allchild(0),'name','figure_movie'); 4723 4724 if ~isempty(figure_movie) 4725 delete(figure_movie)%delete existing figure_movie 4726 end 4727 figure_movie=figure; 4728 nbpix=[512 384];% resolution XVGA 4729 set(figure_movie,'name','figure_movie','Position',[1 1 nbpix]) 4730 newaxes=copyobj(handles.PlotAxes,figure_movie);%new plotting axes in the new figure 4731 set(newaxes,'Tag','movieaxes') 4732 4733 %% display time if defined in uvmat 4734 time_str=get(handles.TimeValue,'String'); 4735 if ~isempty(time_str) 4736 htitle=get(newaxes,'Title'); 4737 % xlim=get(newaxes,'XLim'); 4738 % ylim=get(newaxes,'YLim'); 4739 % set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) 4740 4741 set(htitle,'String',['t=' time_str]) 4742 end 4743 map=colormap(handles.PlotAxes); 4744 colormap(map);%transmit the current colormap to the zoom fig 4745 colorbar 4746 4747 %% create the GUI set_movie 4748 %set(0,'Units','points') 4749 %ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 4750 Position=get(figure_movie,'Position'); 4751 Position(2)=Position(2)+1.2*Position(4); 4752 Position(3)=1.5*Position(3); 4753 Position(4)=Position(4)/2; 4754 hfig=findobj(allchild(0),'Tag','set_movie'); 4755 if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI 4756 hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',... 4757 'Position',Position); 4758 BackgroundColor=get(hfig,'Color'); 4759 hh=0.14; % box height (relative) 4760 % first raw of the GUI 4761 uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.95-hh/2 0.9 hh/2],'BackgroundColor',BackgroundColor,... 4762 'String','movie name:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 4763 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.95-1.5*hh 0.9 hh],'tag','MovieName','BackgroundColor',[1 1 1],... 4764 'String',fullfile(RootPath,[SubDir '.movie'], [RootFile '.avi']),'FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''MovieName'': name (with path) of the movie to create');%edit box 4765 uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.95-2.5*hh 0.45 hh/2],'BackgroundColor',BackgroundColor,... 4766 'String','frames per second:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 4767 uicontrol('Style','text','Units','normalized', 'Position', [0.55 0.95-2.5*hh 0.45 hh/2],'BackgroundColor',BackgroundColor,... 4768 'String','total nbre of frames:','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 4769 uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.95-3.5*hh 0.3 hh],'tag','num_FramePerSecond','BackgroundColor',[1 1 1],... 4770 'String','10','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_FramePerSecond'': nbre of frames per second');%edit box 4771 uicontrol('Style','edit','Units','normalized', 'Position', [0.65 0.95-3.5*hh 0.3 hh],'tag','num_FrameNumber','BackgroundColor',[1 1 1],... 4772 'String','10','FontUnits','points','FontSize',12,'FontWeight','bold','TooltipString','''num_FrameNumber'': total nbre of frames');%edit box 4773 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.05 0.15 0.25 hh],'BackgroundColor',[1 0 0],'String','START','Callback',@(hObject,eventdata)set_movie_START_Callback(hObject,eventdata),... 4774 'FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''APPLY'': apply the output to the current field series in uvmat'); 4775 uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.15 0.25 hh],'Callback',@(hObject,eventdata)set_movie_Cancel_Callback(hObject,eventdata),... 4776 'String','Cancel','FontWeight','bold','FontUnits','points','FontSize',12,'TooltipString','''Cancel'': quit GUI without action'); 4777 uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.05 0.9 hh/2],'BackgroundColor',BackgroundColor,... 4778 'String','will extract the result of ++> on uvmat: adjust figure_movie with its Matlab edit menu, then press ''START ''','FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','center');%title 4779 drawnow 4780 4781 %------------------------------------------------------------------------ 4782 % function called by pressing APPLY in the GUI set_slices 4783 function set_movie_START_Callback(hObject,eventdata) 4784 %------------------------------------------------------------------------ 4785 %% read info from the GUI set_movie 4786 hset_movie=get(hObject,'parent'); 4787 hMovieName=findobj(hset_movie,'Tag','MovieName'); 4788 MovieName=get(hMovieName,'String'); 4789 hFramePerSecond=findobj(hset_movie,'Tag','num_FramePerSecond'); 4790 fps=str2double(get(hFramePerSecond,'String')); 4791 hFrameNumber=findobj(hset_movie,'Tag','num_FrameNumber'); 4792 FrameNumber=str2double(get(hFrameNumber,'String'));% total nbre of frames 4793 4794 %% create the movie file 4795 MovieDir=fileparts(MovieName); 4796 if ~exist(MovieDir,'dir') 4797 [success,message]=mkdir(MovieDir); 4798 if ~isequal(success,1) 4799 msgbox_uvmat('ERROR',message) 4800 return 4801 end 4802 [success,message] = fileattrib(MovieDir,'+w','g','s');% allow writing access for the group of users, recursively in the folder 4803 if success==0 4804 msgbox_uvmat('WARNING',{['unable to set group write access to ' MovieDir ':']; message});%error message for directory creation 4805 end 4806 end 4807 if exist(MovieName,'file') 4808 backup=MovieName; 4733 4809 testexist=2; 4734 4810 while testexist==2 … … 4736 4812 testexist=exist(backup,'file'); 4737 4813 end 4738 [success,message]=copyfile( aviname,backup);%make backup of the existing file4814 [success,message]=copyfile(MovieName,backup);%make backup of the existing file 4739 4815 if isequal(success,1) 4740 delete( aviname)%delete existing file4816 delete(MovieName)%delete existing file 4741 4817 else 4742 4818 msgbox_uvmat('ERROR',message) … … 4745 4821 end 4746 4822 %create avi open 4747 aviobj=avifile(aviname,'Compression','None','fps',fps); 4748 4749 %display first view for tests 4750 newfig=figure; 4751 newaxes=copyobj(handles.PlotAxes,newfig);%new plotting axes in the new figure 4752 set(newaxes,'Tag','movieaxes') 4753 nbpix=[512 384]*str2double(answer{3}); 4754 set(gcf,'Position',[1 1 nbpix])% resolution XVGA 4755 set(newaxes,'Position',eval(answer{4})); 4756 map=colormap(handles.PlotAxes); 4757 colormap(map);%transmit the current colormap to the zoom fig 4758 msgbox_uvmat('INPUT_Y-N',{['adjust figure ' num2str(newfig) ' with its matlab edit menu '] ;... 4759 ['then press OK to get the avi movie as a copy of figure ' num2str(newfig) ' display']}); 4760 % UvData.plotaxes=newaxes;% the axis in the new figure becomes the current main plotting axes 4761 % set(huvmat,'UserData',UvData); 4762 increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d 4763 set(handles.STOP,'Visible','on') 4764 set(handles.speed,'Visible','on') 4765 set(handles.speed_txt,'Visible','on') 4766 set(handles.Movie,'BusyAction','queue') 4767 4768 %imin=str2double(get(handles.i1,'String')); 4769 imax=str2double(answer{5}); 4770 % if isfield(UvData,'Time') 4771 htitle=get(newaxes,'Title'); 4772 xlim=get(newaxes,'XLim'); 4773 ylim=get(newaxes,'YLim'); 4774 set(htitle,'Position',[xlim(2)+0.07*(xlim(2)-xlim(1)) ylim(2)-0.05*(ylim(2)-ylim(1)) 0]) 4775 time_str=get(handles.TimeValue,'String'); 4776 set(htitle,'String',['t=' time_str]) 4777 set(handles.speed,'Value',1) 4778 AxesPos=get(newaxes,'Position'); 4779 handles.PlotAxes=newaxes;% the axis in the new figure becomes the current main plotting axes 4780 for i=1:imax 4781 if get(handles.speed,'Value')~=0 && isequal(get(handles.MenuExportMovie,'BusyAction'),'queue') % enable STOP command 4782 runpm(hObject,eventdata,handles,increment)% run plus 4783 set(newaxes,'Position',AxesPos) 4823 aviobj=avifile(MovieName,'Compression','None','fps',fps); 4824 4825 %% get info from uvmat and adjust it 4826 huvmat=findobj(allchild(0),'Tag','uvmat'); 4827 hhuvmat=guidata(huvmat); 4828 increment=str2num(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat 4829 set(hhuvmat.STOP,'Visible','on') 4830 set(hhuvmat.speed,'Visible','on') 4831 set(hhuvmat.speed_txt,'Visible','on') 4832 set(hhuvmat.Movie,'BusyAction','queue') 4833 set(hhuvmat.speed,'Value',1) 4834 figure_movie=findobj(allchild(0),'name','figure_movie'); 4835 hhuvmat.PlotAxes=findobj(figure_movie,'Tag','movieaxes');% the axis in the new figure becomes the current main plotting axes 4836 for i=1:FrameNumber 4837 if get(hhuvmat.speed,'Value')~=0 && isequal(get(hhuvmat.MenuExportMovie,'BusyAction'),'queue') % enable STOP command 4838 runpm(hObject,eventdata,hhuvmat,increment)% run plus 4784 4839 drawnow 4785 time_str=get(h andles.TimeValue,'String');4786 if ishandle(htitle)4787 set(htitle,'String',['t=' time_str])4788 end4789 mov=getframe( newfig);4840 time_str=get(hhuvmat.TimeValue,'String'); 4841 htitle=get(hhuvmat.PlotAxes,'Title'); 4842 Title=get(htitle,'String'); 4843 set(htitle,'String',regexprep(Title,'t=\d+.\d*',['t=' time_str])) 4844 mov=getframe(figure_movie); 4790 4845 aviobj=addframe(aviobj,mov); 4791 4846 end 4792 4847 end 4793 4848 aviobj=close(aviobj); 4794 % UvData=rmfield(UvData,'plotaxes'); 4795 % set(huvmat,'UserData',UvData); 4796 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']}) 4797 4849 msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']}) 4850 4851 4852 %------------------------------------------------------------------------ 4853 % function called by pressing APPLY in the GUI set_slices 4854 function set_movie_Cancel_Callback(hObject,eventdata) 4855 %------------------------------------------------------------------------ 4856 delete(hObject) 4857 % 4858 % 4859 % 4860 % %read the current input file name 4861 % prompt = {'movie file name';'frames per second';'frame resolution (*[512x384] pixels)';'axis position relative to the frame';'total frame number (starting from the current uvmat display)'}; 4862 % dlg_title = 'select properties of the output avi movie'; 4863 % num_lines= 1; 4864 % def = {[FileBase '_out.avi'];'10';'1';'[0.05 0.07 0.9 0.9]';'10'}; 4798 4865 4799 4866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 5077 5144 5078 5145 %% create the GUI set_slice 5079 set(0,'Unit ','points')5146 set(0,'Units','points') 5080 5147 ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right 5081 5148 Width=350;% fig width in points (1/72 inch) … … 5085 5152 hfig=findobj(allchild(0),'Tag','set_slice'); 5086 5153 if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI 5087 hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Unit ','points','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib);5154 hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Units','pixels','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib); 5088 5155 BackgroundColor=get(hfig,'Color'); 5089 5156 hh=0.14; % box height (relative) … … 5482 5549 mask_dir=fileparts(answer); 5483 5550 if ~exist(mask_dir,'dir') 5484 [ xx,msg1]=mkdir(mask_dir);5485 if ~strcmp(msg1,'')5486 errormsg=['cannot create ' mask_dir ': ' msg1];%error message for directory creation5551 [success,msg]=mkdir(mask_dir); 5552 if success==0 5553 msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation 5487 5554 return 5555 end 5556 [success,msg] = fileattrib(mask_dir,'+w','g','s');% allow writing access for the group of users, recursively in the folder 5557 if success==0 5558 msgbox_uvmat('WARNING',{['unable to set group write access to ' mask_dir ':']; msg});%error message for directory creation 5488 5559 end 5489 5560 end
Note: See TracChangeset
for help on using the changeset viewer.