Changeset 781


Ignore:
Timestamp:
May 29, 2014, 6:17:00 PM (10 years ago)
Author:
sommeria
Message:
 
Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/get_file_type.m

    r771 r781  
    4040        FileInfo.FileType='xls';
    4141        FileType='xls';
     42    case '.dat'
     43        FileInfo.FileType='dat';
     44        FileType='dat';
    4245    otherwise
    4346        if ~isempty(FileExt)% exclude empty extension
  • trunk/src/plot_field.m

    r760 r781  
    9797%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    9898
    99 function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam,PosColorbar)
     99function [PlotType,PlotParamOut,haxes]= plot_field(Data,haxes,PlotParam)
    100100
    101101%% default input and output
     
    180180%% 2D plots
    181181if isempty(index_2D)
    182     plot_plane([],[],haxes,[],[]);%removes images or vector plots in the absence of 2D field plot
     182    plot_plane([],[],haxes,[]);%removes images or vector plots in the absence of 2D field plot
    183183else  %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);
    186186    AxeData.NbDim=2;
    187187    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);
    189189        AxeData.ZoomAxes=zoomaxes;
    190190    end
     
    573573
    574574%-------------------------------------------------------------------
    575 function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam,PosColorbar)
     575function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam)
    576576%-------------------------------------------------------------------
    577577PlotType='plane';
     
    589589
    590590hfig=get(haxes,'parent');%handle of the figure containing the plot axes
     591PosColorbar=[];
     592FigData=get(hfig,'UserData');
     593if isfield(FigData,'PosColorbar')
     594    PosColorbar=FigData.PosColorbar;
     595end
    591596hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
    592597hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
  • trunk/src/series.m

    r777 r781  
    15251525            return
    15261526        end
    1527                 [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder 
     1527        [success,msg] = fileattrib(DirXml,'+w','g','s');% allow writing access for the group of users, recursively in the folder
    15281528        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
    15311530        end
    15321531    end
  • trunk/src/series/beam_forming.m

    r780 r781  
    44if isstruct(Param) && isequal(Param.Action.RUN,0)
    55    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    6     ParamOut.WholeIndexRange='off';% 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)
    77    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
    88    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     
    1212    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
    1313    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)
    1520    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
    1621      %check the input files
     
    2934
    3035ParamOut=[]; %default output
     36%% read input parameters from an xml file if input is a file name (batch mode)
     37checkrun=1;
     38if ischar(Param)
     39    Param=xml2struct(Param);% read Param as input file (batch case)
     40    checkrun=0;
     41end
    3142hseries=findobj(allchild(0),'Tag','series');
    3243RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
     
    8495% close all
    8596% read_data=1;
    86 affichage=1;
     97affichage=0;
    8798% soustraction=0;
    88 
    89 % test_fin_fichier=1;
    90 pas_fichier=1;
    91 numero_tir_fin_old=1;
    9299
    93100%%%%%% Prepare output
    94101load (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 ....
     102Data.ListGlobalAttribute={'CoordUnit'}; %%TODO: add also time, how to get it  ?????
     103Data.CoordUnit='pixel';
     104Data.ListVarName={'AX','AY','A'};
     105Data.VarDimName={'AX','AY',{'AY','AX'}};
     106%Data.Coord_x=5*(nbvoie_reception-0.5)/numel(nbvoie_reception); % totql length of e
     107Data.AX=1:65;
     108%Data.Coord_z=(1:A)/133 ;% to check from input parameter ....
     109Data.AY=1:332;
    99110%%%%%%
    100111%
     
    104115%name='test';%%%%%%%%%%%%%%%%%
    105116%         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
     117number=str2num(Param.OutputDirExt(11:end));%extract the subsequence index (from 1 to 5)
     118numero_tir_fin_old=1%%%%%%% =0 ?????
     119pas_fichier=20;%  %20;% nbre of successive shots to read (to account for computer memory limit)
     120Nmoy=800;  %%%%% value 20  FOR TEST : to shift to VALUE 8000 set by the .mat file
    111121
    112122test_fin_fichier=1;% test to stop input file reading
    113123while test_fin_fichier>0
    114124    numero_tir_debut=1;
    115     numero_tir_fin=numero_tir_debut+pas_fichier;
     125    numero_tir_fin=numero_tir_fin_old+pas_fichier-1;
    116126   
    117127    %  eval(['load ' directory '\' name '.mat'])
     
    123133    for ii=1:length(nbvoie_reception)%=64
    124134        %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
    126136        fid=fopen(filename);
    127137        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 ?????
    129139        toto=double(bitxor(uint16(toto),uint16(2048)));
    130140        toto(1:31)=[];toto(numero_tir_fin*A*Nsequence)=mean(toto);
     
    136146    end
    137147   
    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?
    141152   
    142153    % if soustraction==1
     
    149160   
    150161    %%%%%%%%%%%%%%Imagerie
    151     fe=rsf*1e6;%acquisition frequency
     162    fe=rsf*1e6;% sampling frequency for receptor (in Hz)
    152163    cc=1475;%speed of sound
    153164    hanning_window=25;
     
    176187    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    177188    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           
    186193            matrice_freq_mean=mean(abs(fft(signal,[],1)),2);
    187194            X=[freq1*1e6 freq2*1e6];
     
    193200       
    194201        for ii=1:length(image_r)
    195             [ii kk]
    196202            for jj=1:length(image_z)
    197203               
     
    250256    %%%%%%% TO ADAPT
    251257    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.
    253259        FileIndex=numero_tir_fin - pas_fichier+iii;%%%%%%TO CHECK!!!!!
    254260        %%%%%%%%%%
    255261        %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);
    258263        error=struct2nc(OutputFile,Data);%save result file
    259264        if isempty(error)
     
    263268        end
    264269    end
    265     numero_tir_fin_old=numero_tir_fin+1;
    266     if (numero_tir_fin_old+pas_fichier)>Nmoy
     270    numero_tir_fin_old=numero_tir_fin+1% first index for next bloc reading
     271     if (numero_tir_fin_old+pas_fichier-1)>Nmoy
    267272    test_fin_fichier=-1;
    268273    end
  • trunk/src/series/civ_input.m

    r776 r781  
    9797NomTypeNc='';
    9898switch FileType
    99     case {'image','multimage','video','mmreader'}
     99    case {'image','multimage','video','mmreader','netcdf'}
    100100        NomTypeImaA=NomTypeInput;
    101101        iview_image=1;%line # for the input images
     
    134134        return
    135135    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')
    137137        return
    138138end
  • trunk/src/series/civ_series.m

    r774 r781  
    5757    Data.NbSlice='off'; %nbre of slices ('off' by default)
    5858    Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    59     Data.FieldName='off';% 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)
    6060    Data.FieldTransform = 'off';%can use a transform function
    6161    Data.ProjObject='off';%can use projection object(option 'off'/'on',
     
    221221        end
    222222        [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         
    223228        [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1));
     229        end
    224230        ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1));
    225231        if ~exist(ImageName_B,'file')
     
    228234        end
    229235        [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
    231243        NbField=numel(i1_series_Civ1);
    232244    elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1
     
    237249        end
    238250        [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(ImageName_A);
    239         [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_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));
    240252        ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1));
    241253        if ~exist(ImageName_B,'file')
     
    335347        try
    336348            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
    338356            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
    340364        catch ME
    341365            if ~isempty(ME.message)
     
    344368            end
    345369        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;
    348372        list_param=(fieldnames(Param.ActionInput.Civ1))';
    349373        Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before  each string in list_param
  • trunk/src/uvmat.m

    r778 r781  
    190190LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
    191191set(hObject,'Position',[LeftX LowY Width Height])
    192 UvData.OpenParam.PosColorbar=[0.80 0.02 0.018 0.445];
     192UvData.PosColorbar=[0.80 0.02 0.018 0.445];
    193193AxeData.LimEditBox=1; %initialise AxeData
    194194set(handles.PlotAxes,'UserData',AxeData)
     
    373373    set(handles.TableDisplay,'Position',pos_1)
    374374    % reset position of CheckTable
    375     set(handles.CheckTable,'Unit','pixels')
     375    set(handles.CheckTable,'Units','pixels')
    376376pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
    377377pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
     
    20772077% in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i)
    20782078errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    2079 
     2079ResizeFcn(handles.uvmat,[],handles)
    20802080if isempty(errormsg)
    20812081    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
     
    26482648        PlotParam{1}.Vectors.ColorCode= {'rgb'};
    26492649    end
    2650     PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
     2650    %PosColorbar{1}=UvData.OpenParam.PosColorbar;%prescribe the colorbar position on the uvmat interface
    26512651   
    26522652    %% second projection object (view_field display)
     
    26572657            haxes(2)=plot_handles{2}.PlotAxes;
    26582658            PlotParam{2}=read_GUI(view_field_handle);
    2659             PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
     2659            %PosColorbar{2}='*'; %TODO: deal with colorbar position on view_field
    26602660        end
    26612661    end
     
    27202720                view_field(ObjectData)
    27212721            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});
    27242723                if imap==1
    27252724                    errormsg=fill_GUI(PlotParamOut,handles.uvmat);
     
    27952794    CheckEditObject_Callback(handles.uvmat, [], handles)
    27962795end   
    2797 ResizeFcn(handles.uvmat,[],handles)
     2796%ResizeFcn(handles.uvmat,[],handles)
    27982797set(handles.uvmat,'Pointer',pointer)
    27992798
     
    42324231%------------------------------------------------------------------------
    42334232%get the image of the color display button 'VecColBar' in pixels
    4234 set(handles.VecColBar,'Unit','pixel');
     4233set(handles.VecColBar,'Units','pixel');
    42354234pos_vert=get(handles.VecColBar,'Position');
    4236 set(handles.VecColBar,'Unit','Normalized');
     4235set(handles.VecColBar,'Units','Normalized');
    42374236width=ceil(pos_vert(3));
    42384237height=ceil(pos_vert(4));
     
    46574656% --------------------------------------------------------------------
    46584657function MenuExportAxis_Callback(hObject, eventdata, handles)
     4658% --------------------------------------------------------------------   
    46594659ListFig=findobj(allchild(0),'Type','figure');
    46604660nb_option=0;
     
    47154715% --------------------------------------------------------------------
    47164716set(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
    47204718[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    47214719FileBase=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
     4722figure_movie=findobj(allchild(0),'name','figure_movie');
     4723
     4724if ~isempty(figure_movie)
     4725    delete(figure_movie)%delete existing figure_movie
     4726end
     4727figure_movie=figure;
     4728nbpix=[512 384];% resolution XVGA
     4729set(figure_movie,'name','figure_movie','Position',[1 1 nbpix])
     4730newaxes=copyobj(handles.PlotAxes,figure_movie);%new plotting axes in the new figure
     4731set(newaxes,'Tag','movieaxes')
     4732
     4733%% display time if defined in uvmat
     4734time_str=get(handles.TimeValue,'String');
     4735if ~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])
     4742end
     4743map=colormap(handles.PlotAxes);
     4744colormap(map);%transmit the current colormap to the zoom fig
     4745colorbar
     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
     4750Position=get(figure_movie,'Position');
     4751Position(2)=Position(2)+1.2*Position(4);
     4752Position(3)=1.5*Position(3);
     4753Position(4)=Position(4)/2;
     4754hfig=findobj(allchild(0),'Tag','set_movie');
     4755if ~isempty(hfig),delete(hfig), end; %delete existing version of the GUI
     4756hfig=figure('name','set_movie','tag','set_movie','MenuBar','none','NumberTitle','off','Units','pixels',...
     4757    'Position',Position);
     4758BackgroundColor=get(hfig,'Color');
     4759hh=0.14; % box height (relative)
     4760% first raw of the GUI
     4761uicontrol('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
     4763uicontrol('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
     4765uicontrol('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
     4767uicontrol('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
     4769uicontrol('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
     4771uicontrol('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
     4773uicontrol('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');
     4775uicontrol('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');
     4777uicontrol('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
     4779drawnow
     4780
     4781%------------------------------------------------------------------------
     4782% function called by pressing APPLY in the GUI  set_slices
     4783function set_movie_START_Callback(hObject,eventdata)
     4784%------------------------------------------------------------------------   
     4785%% read info from the GUI set_movie
     4786hset_movie=get(hObject,'parent');
     4787hMovieName=findobj(hset_movie,'Tag','MovieName');
     4788MovieName=get(hMovieName,'String');
     4789hFramePerSecond=findobj(hset_movie,'Tag','num_FramePerSecond');
     4790fps=str2double(get(hFramePerSecond,'String'));
     4791hFrameNumber=findobj(hset_movie,'Tag','num_FrameNumber');
     4792FrameNumber=str2double(get(hFrameNumber,'String'));% total nbre of frames
     4793
     4794%% create the movie file
     4795MovieDir=fileparts(MovieName);
     4796if ~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
     4806end
     4807if exist(MovieName,'file')
     4808    backup=MovieName;
    47334809    testexist=2;
    47344810    while testexist==2
     
    47364812        testexist=exist(backup,'file');     
    47374813    end
    4738     [success,message]=copyfile(aviname,backup);%make backup of the existing file
     4814    [success,message]=copyfile(MovieName,backup);%make backup of the existing file
    47394815    if isequal(success,1)
    4740         delete(aviname)%delete existing file
     4816        delete(MovieName)%delete existing file
    47414817    else
    47424818        msgbox_uvmat('ERROR',message)
     
    47454821end
    47464822%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)
     4823aviobj=avifile(MovieName,'Compression','None','fps',fps);
     4824
     4825%% get info from uvmat and adjust it
     4826huvmat=findobj(allchild(0),'Tag','uvmat');
     4827hhuvmat=guidata(huvmat);
     4828increment=str2num(get(hhuvmat.num_IndexIncrement,'String')); %get the field increment from uvmat
     4829set(hhuvmat.STOP,'Visible','on')
     4830set(hhuvmat.speed,'Visible','on')
     4831set(hhuvmat.speed_txt,'Visible','on')
     4832set(hhuvmat.Movie,'BusyAction','queue')
     4833set(hhuvmat.speed,'Value',1)
     4834figure_movie=findobj(allchild(0),'name','figure_movie');
     4835hhuvmat.PlotAxes=findobj(figure_movie,'Tag','movieaxes');% the axis in the new figure becomes the current main plotting axes
     4836for 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
    47844839            drawnow
    4785             time_str=get(handles.TimeValue,'String');
    4786             if ishandle(htitle)
    4787              set(htitle,'String',['t=' time_str])
    4788             end
    4789             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);
    47904845            aviobj=addframe(aviobj,mov);
    47914846    end
    47924847end
    47934848aviobj=close(aviobj);
    4794 % UvData=rmfield(UvData,'plotaxes');
    4795 % set(huvmat,'UserData',UvData);
    4796 msgbox_uvmat('CONFIRMATION',{['movie ' aviname ' created '];['with ' num2str(imax) ' frames']})
    4797 
     4849msgbox_uvmat('CONFIRMATION',{['movie ' MovieName ' created '];['with ' num2str(FrameNumber) ' frames']})
     4850
     4851
     4852%------------------------------------------------------------------------
     4853% function called by pressing APPLY in the GUI  set_slices
     4854function set_movie_Cancel_Callback(hObject,eventdata)
     4855%------------------------------------------------------------------------   
     4856delete(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'};
    47984865
    47994866%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    50775144
    50785145%% create the GUI set_slice
    5079 set(0,'Unit','points')
     5146set(0,'Units','points')
    50805147ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
    50815148Width=350;% fig width in points (1/72 inch)
     
    50855152hfig=findobj(allchild(0),'Tag','set_slice');
    50865153if ~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);
     5154hfig=figure('name','set_slices','tag','set_slice','MenuBar','none','NumberTitle','off','Units','pixels','Position',[Left,Bottom,Width,Height],'UserData',GeometryCalib);
    50885155BackgroundColor=get(hfig,'Color');
    50895156hh=0.14; % box height (relative)
     
    54825549        mask_dir=fileparts(answer);
    54835550        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 creation
     5551            [success,msg]=mkdir(mask_dir);
     5552            if success==0
     5553                msgbox_uvmat('ERROR',['cannot create ' mask_dir ': ' msg]);%error message for directory creation
    54875554                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
    54885559            end
    54895560        end
Note: See TracChangeset for help on using the changeset viewer.