Index: trunk/src/series/civ_input.m
===================================================================
--- trunk/src/series/civ_input.m	(revision 1027)
+++ trunk/src/series/civ_input.m	(revision 1033)
@@ -80,5 +80,5 @@
     set(handles.num_CorrSmooth,'String',{'1';'2'})
     set(handles.CheckThreshold,'Visible','on')
-    set(handles.CheckDeformation,'Value',0)% desactivate (work in progress)
+    set(handles.CheckDeformation,'Value',0)% desactivate 
 end
 switch Param.Action.ActionName
@@ -95,8 +95,7 @@
 FileType='image';%fdefault
 FileInfo=[];
-if isfield(SeriesData,'FileType')&&isfield(SeriesData,'FileInfo')...
-        &&numel(SeriesData.FileType)>=1&&numel(SeriesData.FileInfo)>=1
-    FileType=SeriesData.FileType{1};%type of the first input file series
-    FileInfo=SeriesData.FileInfo{1};% info on the first input file series
+if isfield(SeriesData,'FileInfo')...
+    FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series
+    FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series
 else
     set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed 
@@ -109,7 +108,4 @@
 iview_image=1;%line # for the input images
 switch FileType
-    case {'image','image_DaVis','multimage','video','mmreader','cine_phantom','netcdf'}
-%         NomTypeImaA=NomTypeInput;
-%         iview_image=1;%line # for the input images
     case 'civdata'
         if ~strcmp(Param.Action.ActionName,'civ_series')
@@ -154,6 +150,8 @@
         return
     otherwise 
+        if ~strcmp(FieldType,'image')
         msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input')
         return
+        end
 end
 
@@ -308,11 +306,14 @@
     end
     if isfield(Param.ActionInput,'Civ2')
-       CheckDeformation_Callback(hObject, eventdata, handles)
-    end
-end
-       if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ListCompareMode')&&...
-               strcmp(Param.ActionInput.ListCompareMode,'displacement')
-            set(handles.PairIndices,'Visible','off')
-        end
+        CheckDeformation_Callback(hObject, eventdata, handles)
+    end
+end
+if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ListCompareMode')&&...
+        strcmp(Param.ActionInput.ListCompareMode,'displacement')
+    set(handles.PairIndices,'Visible','off')
+        set(handles.CheckRefFile,'Visible','on')
+else
+    set(handles.CheckRefFile,'Visible','off')
+end
 
 %% set the menu and default choice of civ pairs
@@ -370,5 +371,4 @@
 %% list the possible index pairs, depending on the option set in ListPairMode
 ListPairMode_Callback([], [], handles)
-%ListPairCiv1_Callback(hObject, eventdata, handles)
 
 %% set the GUI to modal: wait for OK to close
@@ -714,7 +714,5 @@
     mode_selected=mode_list{mode_value};
 end
-% displ_num=[];%default
 ref_i=str2double(get(handles.ref_i,'String'));
-% last_i=str2num(get(handles.last_i,'String'));
 CivInputData=get(handles.civ_input,'UserData');
 TimeUnit=get(handles.TimeUnit,'String');
@@ -725,10 +723,8 @@
 nbfield2=siztime(2)-1;
 %indchosen=1;  %%first pair selected by default
-%displ_num used to define the indices of the civ_input pairs
 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
 % are relative to the reference indices ref_i and ref_j respectively.
 if isequal(mode_selected,'pair j1-j2')
     dt=1;
-    displ='';
     index=0;
     numlist_a=[];
@@ -751,22 +747,8 @@
     end
     [dtsort,indsort]=sort(displ_dt);
-    if ~isempty(numlist_a)
-        displ_num(1,:)=numlist_a(indsort);
-        displ_num(2,:)=numlist_b(indsort);
-    end
-    displ_num(3,:)=0;
-    displ_num(4,:)=0;
     enable_j(handles, 'off')
 elseif isequal(mode_selected,'series(Dj)') %| isequal(mode,'st_series(Dj)')
-    index=1:200;
-    displ_num(1,index)=-floor(index/2);
-    displ_num(2,index)=ceil(index/2);
-    displ_num(3:4,index)=zeros(2,200);
     enable_j(handles, 'on')
 elseif isequal(mode_selected,'series(Di)') %| isequal(mode,'st_series(Di)')
-%     index=1:200;
-%     displ_num(1:2,index)=zeros(2,200);
-%     displ_num(3,index)=-floor(index/2);
-%     displ_num(4,index)=ceil(index/2);
     enable_i(handles, 'on')
     if nbfield2 > 1
@@ -776,8 +758,4 @@
     end
 elseif isequal(mode_selected,'displacement')%the pairs have the same indices
-    displ_num(1,1)=0;
-    displ_num(2,1)=0;
-    displ_num(3,1)=0;
-    displ_num(4,1)=0;
     if nbfield > 1 || nbfield==0
         enable_i(handles, 'on')
@@ -791,32 +769,21 @@
     end
 end
-%set(handles.ListPairCiv1,'UserData',displ_num);
 errormsg=find_netcpair_civ( handles,1);
-    if ~isempty(errormsg)
+if ~isempty(errormsg)
     msgbox_uvmat('ERROR',errormsg)
-    end
-% find_netcpair_civ2(handles)
-
+end
+
+%------------------------------------------------------------------------
 function enable_i(handles, state)
 set(handles.itext,'Visible',state)
-% set(handles.MinIndex_i,'Visible',state)
-% set(handles.last_i,'Visible',state)
-% set(handles.incr_i,'Visible',state)
 set(handles.MaxIndex_i,'Visible',state)
 set(handles.ref_i,'Visible',state)
 
+%------------------------------------------------------------------------
 function enable_j(handles, state)
 set(handles.jtext,'Visible',state)
-% set(handles.MinIndex_j,'Visible',state)
-% set(handles.last_j,'Visible',state)
-% set(handles.incr_j,'Visible',state)
 set(handles.MinIndex_j,'Visible',state)
 set(handles.MaxIndex_j,'Visible',state)
 set(handles.ref_j,'Visible',state)
-%hseries=findobj(allchild(0),'Tag','series');
-%hhseries=guidata(hseries);
-%series('enable_j',hhseries,state); %file input with xml reading  in uvmat, show the image in phys coordinates
-
-
 
 %------------------------------------------------------------------------
@@ -874,5 +841,4 @@
 errormsg='';
 CivInputData=get(handles.civ_input,'UserData');
-%browse=get(handles.RootPath,'UserData');
 compare_list=get(handles.ListCompareMode,'String');
 val=get(handles.ListCompareMode,'Value');
@@ -896,7 +862,4 @@
 menu_pair=get(handles.ListPairCiv2,'String');%previous menu of ListPairCiv1
 PairCiv2Init=menu_pair{get(handles.ListPairCiv2,'Value')};%previous choice of pair
-
-%% determine nom_type_nc, nomenclature type of the .nc files:
-%[nom_type_nc]=nomtype2pair(nom_type_ima,mode);
 
 %% reads .nc subdirectoy and image numbers from the interface
@@ -924,5 +887,4 @@
 nbpair=200;%default
 select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
-%nbpair=200; %default
 
 %% determine the menu display in .ListPairCiv1
@@ -991,8 +953,9 @@
         end
     case 'displacement'
-        displ_pair={'Di=Dj=0'};
-        displ_pair_dt={'Di=Dj=0'};
-end
-if index==1
+%         displ_pair={'Di=Dj=0'};
+%         displ_pair_dt={'Di=Dj=0'};
+        set(handles.PairIndices,'Visible','off')
+end
+if index==1 && ~strcmp(mode_selected,'displacement')
     set(handles.ListPairCiv1,'String',displ_pair_dt');
 end
@@ -1011,9 +974,7 @@
    set(handles.ListPairCiv1,'Value',1) 
 end
-% if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1))
-%     set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu
-% end
 
 %% determine the default selection in the pair menu for Civ2
+if ~strcmp(mode_selected,'displacement')
 if strcmp(get(handles.ListPairCiv2,'Visible'),'on')
     end_pair=regexp(PairCiv2Init,' :dt=');
@@ -1031,4 +992,5 @@
 end
 set(handles.ListPairCiv2,'String',displ_pair_dt');
+end
 set(gcf,'Pointer','arrow')% Indicate that the process is finished
 
@@ -2305,6 +2267,4 @@
 if ~isempty(filexml)
     Param=xml2struct(filexml);% read the input xml file as a Matlab structure
-
-   % Param.Action.RUN=0; %desactivate the input RUN=1
     if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange')
         msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''')
@@ -2326,21 +2286,40 @@
 end
 
+%------------------------------------------------------------------------
 % --- Executes on selection change in CheckCiv3.
+%------------------------------------------------------------------------
 function CheckCiv3_Callback(hObject, eventdata, handles)
 
+%------------------------------------------------------------------------
 % --- Executes on button press in CheckRefFile.
+%------------------------------------------------------------------------
 function CheckRefFile_Callback(hObject, eventdata, handles)
 
-    hseries=findobj(allchild(0),'Tag','series');
-    hhseries=guidata(hseries);
-    InputTable=get(hhseries.InputTable,'Data');
-    InputFile=fullfile(InputTable{1,1},InputTable{1,2},[InputTable{1,3} InputTable{1,5}]);
- % browse for a reference file for displacement
-    fileref= uigetfile_uvmat('pick a reference image file:',InputFile);
-        if ~isempty(fileref)
-    set(handles.RefFile,'String',fileref)
-    set(handles.ConfigSource,'String','NEW')
-    set(handles.ConfigSource,'BackgroundColor',[1 0 1])
-        end
+hseries=findobj(allchild(0),'Tag','series');
+hhseries=guidata(hseries);
+InputTable=get(hhseries.InputTable,'Data');
+i1=str2num(get(hhseries.num_first_i,'String'));
+j1=str2num(get(hhseries.num_first_j,'String'));
+InputFile=fullfile_uvmat(InputTable{1,1},InputTable{1,2},InputTable{1,3},InputTable{1,5},InputTable{1,4},i1,[],j1);
+% browse for a reference file for displacement
+fileref= uigetfile_uvmat('pick a reference image file:',InputFile);
+if ~isempty(fileref)
+    FileInfo=get_file_info(fileref);
+    CheckImage=strcmp(FileInfo.FieldType,'image');% =1 for images
+    if ~CheckImage
+        msgbox_uvmat('ERROR',['invalid file type input for reference image: ' FileInfo.FileType ' not an image'])
+    else
+        if isfield (FileInfo,'NumberOfFrames')&& FileInfo.NumberOfFrames>1
+            set(handles.num_OriginIndex,'Visible','on')
+            set(handles.OriginIndex_title,'Visible','on')
+        else
+            set(handles.num_OriginIndex,'Visible','off')
+            set(handles.OriginIndex_title,'Visible','off')
+        end
+        set(handles.RefFile,'String',fileref)
+        set(handles.ConfigSource,'String','NEW')
+        set(handles.ConfigSource,'BackgroundColor',[1 0 1])
+    end
+end
 
 %------------------------------------------------------------------------
