Changeset 764 for trunk/src/uvmat.m


Ignore:
Timestamp:
May 2, 2014, 2:03:44 AM (10 years ago)
Author:
sommeria
Message:

improvement of movie-pair for uvmat and introduction of a separate window SetPair? in series.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r760 r764  
    610610%------------------------------------------------------------------------
    611611[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(get(handles.FileIndex,'String'));
    612 set(handles.i1,'String',num2str(i1));
     612set(handles.i1,'String',num2str(i1));%update the counters
    613613set(handles.i2,'String',num2str(i2));
    614614set(handles.j1,'String',num2str(j1));
     
    626626FileIndex=fullfile_uvmat('','','','',get(handles.NomType,'String'),i1,i2,j1,j2);
    627627set(handles.FileIndex,'String',FileIndex)
    628 % inputfilerefresh the current settings and inputfilerefresh the field view
     628% refresh the current settings and refresh the field view
    629629RootPath_Callback(hObject,eventdata,handles)
    630630
     
    12601260    case 1
    12611261        indices=fullfile_uvmat('','','','',NomType,stra2num(get(handles.i1,'String')),i2,j1,j2);
    1262         set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1262%        set(handles.i1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
    12631263    case 2
    12641264        indices=fullfile_uvmat('','','','',NomType,i1,stra2num(get(handles.i2,'String')),j1,j2);
    1265         set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1265%        set(handles.i2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
    12661266    case 3
    12671267        indices=fullfile_uvmat('','','','',NomType,i1,i2,stra2num(get(handles.j1,'String')),j2);
    1268         set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1268%        set(handles.j1,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
    12691269    case 4
    12701270        indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,stra2num(get(handles.j2,'String')));
    1271         set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1271%        set(handles.j2,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
    12721272end
    12731273set(handles.FileIndex,'String',indices)
    1274 set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
     1274%set(handles.FileIndex,'BackgroundColor',[0.7 0.7 0.7])% mark the edit box in grey, then RUN0 will mark it in white for confirmation
    12751275% update the second index if relevant
    12761276if strcmp(get(handles.FileIndex_1,'Visible'),'on')
     
    15181518    msgbox_uvmat('ERROR',errormsg);
    15191519end
    1520 set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back to red
    15211520
    15221521%------------------------------------------------------------------------
     
    15371536    msgbox_uvmat('ERROR',errormsg);
    15381537end
    1539 set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back to red
    15401538
    15411539%------------------------------------------------------------------------
     
    16191617%% check for movie pair status
    16201618movie_status=get(handles.movie_pair,'Value');
    1621 if isequal(movie_status,1)
     1619if movie_status
    16221620    STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
    16231621end
     
    16351633    j1=str2num(get(handles.j1,'String'));%case of indexed movie
    16361634end
     1635if movie_status% we read the second index from the edit box
     1636    i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
     1637    if strcmp(get(handles.j2,'Visible'),'on')
     1638    j2=str2num(get(handles.j2,'String'));%
     1639    end
     1640end
    16371641sub_value= get(handles.SubField,'Value');
    16381642if sub_value % a second input file has been entered
     
    16721676    end
    16731677   
    1674     % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
     1678% the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
    16751679else
    16761680    UvData=get(handles.uvmat,'UserData');
     
    18181822end
    18191823set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
     1824set(handles.runplus,'BackgroundColor',[1 0 0])
     1825set(handles.runmin,'BackgroundColor',[1 0 0])
    18201826
    18211827%% update the index counters if the index move is successfull
     1828
    18221829if isempty(errormsg)
    18231830    set(handles.i1,'String',num2stra(i1,NomType,1));
     
    18461853        if isempty(j2), set(handles.j2,'String',''); end
    18471854    end
    1848     set(handles.i1,'BackgroundColor',[1 1 1])
    1849     set(handles.i2,'BackgroundColor',[1 1 1])
    1850     set(handles.j1,'BackgroundColor',[1 1 1])
    1851     set(handles.j2,'BackgroundColor',[1 1 1])
    1852     set(handles.FileIndex,'BackgroundColor',[1 1 1])
    1853     set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
    18541855end
    18551856
     
    18621863if ~get(handles.movie_pair,'value')
    18631864    set(handles.movie_pair,'BusyAction','Cancel')%stop movie pair if button is 'off'
    1864     set(handles.i2,'String','')
    1865     set(handles.j2,'String','')
    1866     set(handles.Dt_txt,'String','')
     1865    set(handles.i2,'String','')% the second i index display is suppressed
     1866    set(handles.j2,'String','')% the second j index display is suppressed
     1867    set(handles.Dt_txt,'String','')% the time interval indication is suppressed
    18671868    return
    1868 else
    1869     set(handles.movie_pair,'BusyAction','queue')
    1870     set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
    1871 end
    1872 
    1873 %% initialisation
    1874 set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow
     1869end
     1870   
     1871%% check the input file indexing:
     1872[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     1873NomType=get(handles.NomType,'String');
     1874if ~isempty(find(regexp(NomType,'-')))
     1875    msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')
     1876    return
     1877end
     1878filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
     1879
     1880set(handles.movie_pair,'BusyAction','queue')%
     1881set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)
     1882set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
     1883set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
    18751884drawnow
    1876 list_fields=get(handles.FieldName,'String');% list menu fields
    1877 index_fields=get(handles.FieldName,'Value');% selected string index
    1878 FieldName=list_fields{index_fields}; % selected field
    1879 UvData=get(handles.uvmat,'UserData');
    1880 if isequal(FieldName,'image')
    1881     index=1;
    1882     [RootPath,SubDir,RootFile,FileIndices,Ext]=read_file_boxes(handles);
    1883     NomType=get(handles.NomType,'String');
    1884 else
    1885     list_fields=get(handles.FieldName_1,'String');% list menu fields
    1886     index_fields=get(handles.FieldName_1,'Value');% selected string index
    1887     FieldName=list_fields{index_fields}; % selected field
    1888     if isequal(FieldName,'image')
    1889         index=2;
    1890         [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line
    1891     else
    1892         msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
    1893         set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    1894         set(handles.movie_pair,'Value',0)
    1895         return
    1896     end
    1897 end
     1885% list_fields=get(handles.FieldName,'String');% list menu fields
     1886% index_fields=get(handles.FieldName,'Value');% selected string index
     1887% FieldName=list_fields{index_fields}; % selected field
     1888
     1889
     1890% if isequal(FieldName,'image')
     1891%     index=1;
     1892
     1893% else
     1894%     list_fields=get(handles.FieldName_1,'String');% list menu fields
     1895%     index_fields=get(handles.FieldName_1,'Value');% selected string index
     1896%     FieldName=list_fields{index_fields}; % selected field
     1897%     if isequal(FieldName,'image')
     1898%         index=2;
     1899%         [RootPath,SubDir,RootFile,FileIndex_1,Ext,NomType]=read_file_boxes_1(handles);% get info from the second input line
     1900%     else
     1901%         msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
     1902%         set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     1903%         set(handles.movie_pair,'Value',0)
     1904%         return
     1905%     end
     1906% end
    18981907num_i1=str2num(get(handles.i1,'String'));
    18991908num_j1=stra2num(get(handles.j1,'String'));
    19001909num_i2=str2num(get(handles.i2,'String'));
    19011910num_j2=stra2num(get(handles.j2,'String'));
     1911
     1912%% determine the name 'imaname_1' of the second file in the pair
    19021913imaname_1='';
    1903 if isempty(num_j2)
     1914if isempty(num_j2)% no second j index indicated
    19041915    if isempty(num_i2)
    19051916        if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
    1906             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1,[],num_j1+1);
     1917            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);
    19071918        end
    19081919        if exist(imaname_1,'file')
     
    19101921            set(handles.j2,'String',num2stra(num_j2,NomType));
    19111922        else
    1912             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i1+1,[],num_j1);
     1923            imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);
    19131924            if exist(imaname_1,'file')
    19141925                num_i2=num_i1+1;
     
    19341945    num_j2=num_j1;%repeat the index i1 by default
    19351946end
    1936 imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,Ext,NomType,num_i2,[],num_j2);
     1947imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);
    19371948if strcmp(NomType,'*')
    19381949    num_frame=num_i2;
     
    19461957      return
    19471958end
     1959
     1960%% display the first field in the pair (including possibly a background field from second line input filename_1)
     1961filename_1='';%default
     1962FileIndex_1='';
     1963if get(handles.SubField,'Value')
     1964    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
     1965    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
     1966end
     1967% num_i1=stra2num(get(handles.i1,'String'));
     1968% num_i2=stra2num(get(handles.i2,'String'));
     1969% num_j1=stra2num(get(handles.j1,'String'));
     1970% num_j2=stra2num(get(handles.j2,'String'));
     1971[tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
     1972if isempty(j1_1)% case of movies, the index is not given by file index
     1973    j1_1=num_j1;
     1974end
     1975
     1976errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
     1977
     1978if isempty(errormsg)
     1979    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
     1980else
     1981     msgbox_uvmat('ERROR',errormsg);
     1982     set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
     1983end
     1984UvData=get(handles.uvmat,'UserData');
     1985Field_a=UvData.Field;% movie on the field defined by the second input line
    19481986
    19491987%% display time interval for the image pair
     
    19601998end
    19611999
    1962 %% get the first image
    1963 %Field.AName='image';
    1964 if index==1
    1965     Field_a=UvData.Field;% movie on the second field
    1966 else
    1967     Field_a=UvData.Field_1;% movie on the first field
    1968 end
    1969 
    1970 %% read the second image
    1971 MovieObject=[];
    1972 if numel(UvData.MovieObject)>=index
    1973     MovieObject=UvData.MovieObject{index};
    1974 end
    1975 [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},MovieObject,num_frame);
    1976 
    1977 %px to phys or other transform on field
     2000%% read the second field
     2001if isempty(UvData.MovieObject)
     2002    [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{index},[],num_frame);
     2003else
     2004    [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileType{1},UvData.MovieObject{1},num_frame);
     2005end
     2006if ~isempty(errormsg)
     2007    msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])
     2008    return
     2009end
     2010
     2011%% apply phys or other transform on the two input fields
    19782012transform=get(handles.TransformPath,'UserData');
    19792013if  ~isempty(transform)
    1980     if isfield(UvData,'XmlData') && numel(UvData.XmlData)>=index %use geometry calib recorded from the ImaDoc xml file as first priority
    1981         if index==2
    1982         Field_a=transform(Field_a,UvData.XmlData{index});%the first field has been stored without transform
    1983         end
     2014    if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority
    19842015        if nargin(transform)>=2
    1985         Field_b=transform(Field_b,UvData.XmlData{index});
     2016            Field_b=transform(Field_b,UvData.XmlData{1});
    19862017        else
    1987           Field_b=transform(Field_b);
    1988         end
    1989     end
    1990 end
    1991 
    1992 % make movie until movie speed is set to 0 or STOP is activated
     2018            Field_b=transform(Field_b);
     2019        end
     2020    end
     2021end
     2022
     2023%% make movie until movie speed is set to 0 or STOP is activated
    19932024hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
    19942025set(handles.STOP,'Visible','on')
    19952026set(handles.speed,'Visible','on')
    19962027set(handles.speed_txt,'Visible','on')
    1997 set(handles.i2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
    1998 set(handles.j2,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
    1999 set(handles.FileIndex,'BackgroundColor',[1 1 1])% mark the edit box in white to indicate its use as input
    20002028while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command
    20012029    % read and plot the series of images in non erase mode
    2002     set(hima,'CData',Field_b.A);
     2030    set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
    20032031    pause(1.02-get(handles.speed,'Value'));% wait for next image
    20042032    set(hima,'CData',Field_a.A);
     
    20132041function REFRESH_Callback(hObject, eventdata, handles)
    20142042%------------------------------------------------------------------------
    2015 set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow
     2043set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the REFRESH button in yellow to indicate its activity
    20162044drawnow
    2017 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
     2045[RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);%read the features of the input file name (first line)
    20182046[tild,tild,tild,i1,i2,j1,j2]=fileparts_uvmat(FileIndex);% check back the indices used
    2019 if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
    2020 if isempty(j2), set(handles.j2,'String',''); end
    2021 filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];
    2022 filename_1='';%default
     2047if isempty(i2), set(handles.i2,'String',''); end % suppress the second i index display if not used
     2048if isempty(j2), set(handles.j2,'String',''); end % suppress the second j index display if not used
     2049filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
     2050filename_1='';%default second file name
    20232051FileIndex_1='';
    2024 if get(handles.SubField,'Value')
    2025     [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    2026     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
     2052if get(handles.SubField,'Value')% if a second file is introduced
     2053    [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);%read the features of the input file name (second line)
     2054    filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1]; %build the input file name (second line)
    20272055end
    20282056num_i1=stra2num(get(handles.i1,'String'));
     
    20342062    j1_1=num_j1;
    20352063end
    2036 
     2064% in case of movies the index is set by edit boxes i1 or j1 (case of movies indexed by index i)
    20372065errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    20382066
    2039 if ~isempty(errormsg)
    2040       msgbox_uvmat('ERROR',errormsg);
    2041       set(handles.InputFileREFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
    2042 else
    2043     set(handles.i1,'BackgroundColor',[1 1 1])
    2044     set(handles.i2,'BackgroundColor',[1 1 1])
    2045     set(handles.j1,'BackgroundColor',[1 1 1])
    2046     set(handles.j2,'BackgroundColor',[1 1 1])
    2047     set(handles.FileIndex,'BackgroundColor',[1 1 1])
    2048     set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 
     2067if isempty(errormsg)
    20492068    set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
    2050 end   
     2069else
     2070     msgbox_uvmat('ERROR',errormsg);
     2071     set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
     2072end
    20512073
    20522074%------------------------------------------------------------------------
     
    35543576        msgbox_uvmat('ERROR',errormsg);
    35553577    else
    3556         set(handles.i1,'BackgroundColor',[1 1 1])
    3557         set(handles.i2,'BackgroundColor',[1 1 1])
    3558         set(handles.j1,'BackgroundColor',[1 1 1])
    3559         set(handles.j2,'BackgroundColor',[1 1 1])
    3560         set(handles.FileIndex,'BackgroundColor',[1 1 1])
    3561         set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
     3578%         set(handles.i1,'BackgroundColor',[1 1 1])
     3579%         set(handles.i2,'BackgroundColor',[1 1 1])
     3580%         set(handles.j1,'BackgroundColor',[1 1 1])
     3581%         set(handles.j2,'BackgroundColor',[1 1 1])
     3582%         set(handles.FileIndex,'BackgroundColor',[1 1 1])
     3583%         set(handles.FileIndex_1,'BackgroundColor',[1 1 1])
    35623584    end
    35633585    set(handles.InputFileREFRESH,'BackgroundColor',[1 0 0])
     
    42354257[tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
    42364258errormsg=fill_GUI(PlotParamOut,handles.uvmat);
    4237 if ~isempty(errormsg)
     4259if isempty(errormsg)
     4260    set(handles.REFRESH,'BackgroundColor',[1 0 0]);% operation finished, back to red color
     4261else
    42384262    msgbox_uvmat('ERROR',errormsg)
    4239     return
    4240 end
    4241 set(handles.REFRESH,'BackgroundColor',[1 0 0]);
     4263    set(handles.REFRESH,'BackgroundColor',[1 0 1]);% magenta color: graph still needs to be updated
     4264end
     4265
    42424266
    42434267%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.