Changeset 609


Ignore:
Timestamp:
Apr 9, 2013, 8:20:00 PM (12 years ago)
Author:
sommeria
Message:

various bugs corrected after tests with Windows OS.

Location:
trunk/src
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_file_series.m

    r599 r609  
    55% OUTPUT:
    66% RootFile: root file detected in fileinput, possibly modified for movies (indexing is then done on image view, not file)
    7 % i1_series(ref_i+1, ref_j+1,pair),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
     7% i1_series(pair,ref_j+1, ref_i+1),i2_series,j1_series,j2_series: set of indices (i1,i2,j1,j2) sorted by ref index ref_i, ref_j, and pairindex in case of multiple pairs with the same ref
    88%  (ref_i+1 is used to deal with the image index zero sometimes used)
    99% NomType: nomenclature type corrected after checking the first file (problem of 0 before the number string)
     
    244244if isfield(FileInfo,'NumberOfFrames') && FileInfo.NumberOfFrames >1
    245245    if isempty(i1_series)
    246         i1_series=(1:FileInfo.NumberOfFrames)';
     246        i1_series=zeros(FileInfo.NumberOfFrames+1,2);% first column =0
     247        i1_series(:,2)=(0:FileInfo.NumberOfFrames)'; % second column=frame index -1
    247248        i1_input=1;
    248249        NomType='*';
    249250    else
    250         i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames);
     251        i1_series=i1_series(:,2)*ones(0,FileInfo.NumberOfFrames);
    251252        i1_series=[i1_series(:,1) i1_series];
    252253        j1_series=ones(size(i1_series,1),1)*(0:FileInfo.NumberOfFrames);
  • trunk/src/plot_field.m

    r582 r609  
    282282    VarName=FieldData.ListVarName{VarIndex(ivar)};
    283283    VarValue=FieldData.(VarName);
    284     if iscolumn(VarValue)
     284    if isvector(VarValue')
    285285        VarValue=VarValue';% put the different values on a line
    286286    end
  • trunk/src/read_multimadoc.m

    r537 r609  
    44%
    55% OUTPUT:
    6 %
     6% XmlData: cell array of structure representing the contents of the xml files
     7% NbSlice_calib: nbre of slices detected in the geometric calibration data
     8% mtrix of times
     9% errormsg: error message, ='' if reading OK
    710%
    811% INPUT:
    9 %
     12% RootPath,SubDir,RootFile,FileExt: cell arrays characterizing the input file series
     13% i1_series,i2_series,j1_series,j2_series: cell arrays of file index
     14% arrays, as given by the fct uvmat/get_file_series
     15%
    1016function [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
    1117errormsg='';
  • trunk/src/series.m

    r606 r609  
    6767
    6868%% initial settings
    69 drawnow
    70 set(hObject,'Units','pixels')
     69set(0,'Unit','points')
     70ScreenSize=get(0,'ScreenSize');%size of the current screen
     71Width=750;% prefered width of the GUI in points (1/72 inch)
     72Height=520;
     73%adjust to screen size (reduced by a min margin)
     74RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
     75if RescaleFactor>1
     76    %RescaleFactor=RescaleFactor/2+1/2; %reduce the rescale factor to provide an increased margin for a big screen
     77    RescaleFactor=min(RescaleFactor,1);
     78end
     79Width=Width*RescaleFactor;
     80Height=Height*RescaleFactor;
     81LeftX=80*RescaleFactor;%position of the left fig side, in pixels (put to the left side, with some margin)
     82LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
     83set(hObject,'Units','points')
     84set(hObject,'Position',[LeftX LowY Width Height])
    7185set(handles.PairString,'ColumnName',{'pairs'})
    7286set(handles.PairString,'ColumnEditable',false)
     
    7892if ~exist('Param','var')
    7993    Param=[]; %default
    80 end
    81 
    82 %% default list of functions in the mebu ActionName
     94end 
     95
     96%% list of builtin functions in the mebu ActionName
    8397ActionList={'check_data_files';'aver_stat';'time_series';'merge_proj'};% WARNING: fits with nb_builtin_ACTION=4 in ActionName_callback
     98NbBuiltinAction=numel(ActionList);
    8499[path_series,name,ext]=fileparts(which('series'));% path to the GUI series
    85100path_series_fct=fullfile(path_series,'series');%path of the functions in subdirectroy 'series'
    86 %path_bin=fullfile(path_series,'bin');%path of the binary functions (compiled)
    87 ActionPathList=regexprep(ActionList,'^.+$',path_series_fct);% set path=path_series to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string)
    88 ActionPathList=[ActionPathList ActionPathList];% set path to .sh commands for compiled functions
    89 ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh)
     101ActionExtList={'.m';'.sh'};% default choice of extensions (Matlab fct .m or compiled version .sh
     102ActionPathList=cell(NbBuiltinAction,numel(ActionExtList));%initiate the cell matrix of Action fct paths
     103ActionPathList(:)={path_series_fct}; %set the default path to series fcts to all list members
    90104RunModeList={'local';'background'};% default choice of extensions (Matlab fct .m or compiled version .sh)
    91105[s,w]=system('oarstat');% look for cluster system 'oar'
     
    99113set(handles.RunMode,'String',RunModeList)
    100114
    101 %% default list of functions in the mebu TransformName
     115%% list of builtin transform functions in the mebu TransformName
    102116TransformList={'';'sub_field';'phys';'phys_polar'};% WARNING: must fit with the corresponding menu in uvmat and nb_builtin_transform=4 in  TransformName_callback
     117NbBuiltinTransform=numel(TransformList);
    103118path_transform_fct=fullfile(path_series,'transform_field');
    104 TransformPathList=regexprep(TransformList,'^.+$',path_transform_fct);% set path=path_transform_fct to each function in the list ('^.+$'=any non empty nbre of char form beginning to end of char string)
    105 
    106 %% load the personal file uvmat_perso.mat
     119TransformPathList=cell(NbBuiltinTransform,1);%initiate the cell matrix of Action fct paths
     120TransformPathList(:)={path_transform_fct}; %set the default path to series fcts to all list members
     121
     122%% get the user defined functions stored in the personal file uvmat_perso.mat
    107123dir_perso=prefdir;
    108124profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     
    131147
    132148%% selection of the input Action fct
    133 ActionCheckExist=false(size(ActionList));
    134 for ilist=1:numel(ActionList)
     149ActionCheckExist=true(size(ActionList));%initiate the check of the path to the listed action fct
     150for ilist=NbBuiltinAction+1:numel(ActionList)%check  the validity of the path of the user defined Action fct
    135151    ActionCheckExist(ilist)=exist(fullfile(ActionPathList{ilist},[ActionList{ilist} '.m']),'file');
    136152end
    137 ActionPathList=ActionPathList(ActionCheckExist,:);
     153ActionPathList=ActionPathList(ActionCheckExist,:);% suppress the menu options which are not valid anymore
    138154ActionList=ActionList(ActionCheckExist);
    139155set(handles.ActionName,'String',[ActionList;{'more...'}])
     
    152168
    153169%% selection of the input transform fct
    154 TransformCheckExist=false(size(TransformList));
    155 TransformCheckExist(1)=1;%the first option is blank: no transform, always allowed
    156 for ilist=2:numel(TransformList)
     170TransformCheckExist=true(size(TransformList));
     171for ilist=NbBuiltinTransform+1:numel(TransformList)
    157172    TransformCheckExist(ilist)=exist(fullfile(TransformPathList{ilist},[TransformList{ilist} '.m']),'file');
    158173end
     
    260275%get the previous input file in the Input Table
    261276oldfile=''; %default
    262 InputTable=get(handles.InputTable,'Data');
    263 if isequal(InputTable(:,1),[{''};{''};{''};{''}])%open the personal file for empty previous input
     277SeriesData=get(handles.series,'UserData');
     278if isfield(SeriesData,'RefFile')
     279    oldfile=SeriesData.RefFile{1};
     280end
     281if ~exist(oldfile,'file')
    264282    dir_perso=prefdir;
    265283    profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
     
    270288        end
    271289    end
    272 else% select the previous file as the first line of the input table
    273     oldfile=fullfile(InputTable{1,1},InputTable{1,2},InputTable{1,3});
    274 end
    275 hfig=uigetfile_uvmat('file browser',fileparts(fileparts(oldfile)));
    276 uiwait(hfig);
    277 if ishandle(hfig) % stop if browser closed without selection
    278     fileinput=get(hfig,'UserData');% retrieve the input file selection
    279     delete(hfig)
    280     display_file_name(handles,fileinput,0)
     290end
     291fileinput=uigetfile_uvmat('file browser',oldfile);
     292if ~isempty(fileinput)
     293     display_file_name(handles,fileinput,0)
    281294end
    282295%
     
    481494% INPUT:
    482495% handles: handles of elements in the GUI
    483 % fielinput: input file name, including path
    484 % append =0 (refresh the Input table with the new file), ='append' append a new line in the table
     496% fileinput: input file name, including path
     497% iview: line index in the input table
    485498
    486499%% get the input root name, indices, file extension and nomenclature NomType
     
    542555ref_i=floor((i1+i2)/2);% reference image number corresponding to the file
    543556set(handles.num_ref_i,'String',num2str(ref_i));
    544 set(handles.num_ref_i,'UserData',[i1 i2])
     557% set(handles.num_ref_i,'UserData',[i1 i2])%store the indices for future opening
    545558if isempty(j1)
    546559    j1=1;
     
    551564ref_j=floor((j1+j2)/2);% reference image number corresponding to the file
    552565set(handles.num_ref_j,'String',num2str(ref_j));
    553 set(handles.num_ref_j,'UserData',[j1 j2])
     566% set(handles.num_ref_j,'UserData',[j1 j2]);%store the indices for future opening
    554567
    555568%% update the list of recent files in the menubar and save it for future opening
     
    571584    save (profil_perso,'MenuFile','-V6'); %store the file names for future opening of uvmat
    572585end
     586% save the opened file to initiate future opening
     587SeriesData=get(handles.series,'UserData');
     588SeriesData.RefFile{iview}=fileinput;
     589set(handles.series,'UserData',SeriesData)
    573590
    574591set(handles.InputTable,'BackgroundColor',[1 1 1])
     
    595612%% display the min and max indices for the file series
    596613if size(i1_series,2)==2 && min(min(i1_series(:,1,:)))==0
    597     MinIndex_j=1;
     614    MinIndex_j=1;% index j set to 1 by default
    598615    MaxIndex_j=1;
    599616    MinIndex_i=find(i1_series(:,2,:), 1 )-1;
     
    602619    pair_max=squeeze(max(i1_series,[],1)); %max on pair index
    603620    j_max=max(pair_max,[],1);
    604     %i_sum=sum(sum(i1_series,2),1);%sum of i1_series on the last index
    605621    MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i
    606622    MinIndex_i=find(j_max, 1 )-1;% min ref index i
    607623    diff_i_max=diff(j_max);
    608     if isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
    609         set(handles.num_incr_i,'String',num2str(diff_i_max(1)))
     624    if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max)))
     625        set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default
    610626    end
    611627    i_max=max(pair_max,[],2);
     
    633649set(handles.MaxIndex,'Data',MaxIndex)%display the max indices in the table MaxIndex
    634650
    635 %% adjust the first and last indices if requested by the bounds
    636 first_i=str2num(get(handles.num_first_i,'String'));
    637 ref_i=str2num(get(handles.num_ref_i,'String'));
    638 ref_j=str2num(get(handles.num_ref_j,'String'));
     651%% adjust the first and last indices, only if requested by the bounds
     652% i index, compare input to min index i
     653first_i=str2num(get(handles.num_first_i,'String'));%retrieve previous first i
     654ref_i=str2num(get(handles.num_ref_i,'String'));%index i given by the input field
    639655if isempty(first_i)
    640     first_i=ref_i;
     656    first_i=ref_i;% first_i updated by the input value
    641657elseif first_i < MinIndex_i
    642     first_i=MinIndex_i;
     658    first_i=MinIndex_i; % first_i set to the min i index (restricted by oter input lines)
    643659elseif first_i >MaxIndex_i
    644     first_i=MinIndex_i;
    645 end
     660    first_i=MaxIndex_i;% first_i set to the max i index (restricted by oter input lines)
     661end
     662% j index,  compare input to min index j
    646663first_j=str2num(get(handles.num_first_j,'String'));
     664ref_j=str2num(get(handles.num_ref_j,'String'));%index j given by the input field
    647665if isempty(first_j)
    648     first_j=ref_j;
     666    first_j=ref_j;% first_j updated by the input value
    649667elseif first_j<MinIndex_j
    650     first_j=MinIndex_j;
     668    first_j=MinIndex_j; % first_j set to the min j index (restricted by oter input lines)
    651669elseif first_j >MaxIndex_j
    652     first_j=MinIndex_j;
    653 end
     670    first_j=MaxIndex_j; % first_j set to the max j index (restricted by oter input lines)
     671end
     672% i index, compare input to max index i
    654673last_i=str2num(get(handles.num_last_i,'String'));
    655674if isempty(last_i)
     
    660679    last_i=first_i;
    661680end
    662 last_j=str2num(get(handles.num_first_j,'String'));
     681% j index, compare input to max index j
     682last_j=str2num(get(handles.num_last_j,'String'));
    663683if isempty(last_j)
    664684    last_j=ref_j;
    665685elseif last_j>MaxIndex_j
    666686    last_j=MaxIndex_j;
    667 elseif last_i<first_i
    668     last_i=first_i;
     687elseif last_j<first_j
     688    last_j=first_j;
    669689end
    670690set(handles.num_first_i,'String',num2str(first_i));
     
    677697FileBase=fullfile(InputTable{iview,1},InputTable{iview,3});
    678698time=[];%default
     699TimeSource='';
    679700% case of movies
    680701if strcmp(InputTable{iview,4},'*')
    681702    if ~isempty(VideoObject)
    682703        imainfo=get(VideoObject);
    683         time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)';
    684        % set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     704        time=zeros(imainfo.NumberOfFrames+1,2);
     705        time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     706        TimeSource='video';
     707       % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    685708        ColorType='truecolor';
    686709    elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
     
    698721end
    699722
    700 %%  read image documentation file  if found%%%%%%%%%%%%%%%%%%%%%%%%%%%
     723%%  read image documentation file  if found
    701724XmlData=[];
    702725NbSlice_calib={};
     
    710733        if isfield(XmlData,'Time')
    711734            time=XmlData.Time;
     735            TimeSource='xml';
    712736        end
    713737        if isfield(XmlData,'Camera')
     
    742766    if isempty(MinIndex_j)% only i index
    743767        if MinIndex_i>0
    744             TimeTable{iview,1}=time(MinIndex_i);
    745         end
    746         TimeTable{iview,2}=time(first_i);
    747         TimeTable{iview,3}=time(last_i);
    748         TimeTable{iview,4}=time(MaxIndex_i);
     768            TimeTable{iview,1}=time(MinIndex_i+1);
     769        end
     770        TimeTable{iview,2}=time(first_i+1);
     771        TimeTable{iview,3}=time(last_i+1);
     772        TimeTable{iview,4}=time(MaxIndex_i+1);
    749773    elseif ~isempty(time)
    750774        if MinIndex_i>0
    751775            TimeTable{iview,1}=time(MinIndex_i,MinIndex_j);
    752776        end
    753         if size(time)>=[last_i last_j]
    754             TimeTable{iview,2}=time(first_i,first_j);
    755             TimeTable{iview,3}=time(last_i,last_j);
    756         end
    757         if size(time)>=[MaxIndex_i MaxIndex_j];
    758             TimeTable{iview,4}=time(MaxIndex_i,MaxIndex_j);
     777        if size(time)>=[last_i+1 last_j+1]
     778            TimeTable{iview,2}=time(first_i+1,first_j+1);
     779            TimeTable{iview,3}=time(last_i+1,last_j+1);
     780        end
     781        if size(time)>=[MaxIndex_i+1 MaxIndex_j+1];
     782            TimeTable{iview,4}=time(MaxIndex_i+1,MaxIndex_j+1);
    759783        end
    760784    end
     
    787811%% update the series info in 'UserData'
    788812SeriesData=get(handles.series,'UserData');
    789 SeriesData.Ref_i{iview}=get(handles.num_ref_i,'UserData');
    790 SeriesData.Ref_j{iview}=get(handles.num_ref_j,'UserData');
    791813SeriesData.i1_series{iview}=i1_series;
    792814SeriesData.i2_series{iview}=i2_series;
     
    796818SeriesData.FileInfo{iview}=FileInfo;
    797819SeriesData.Time{iview}=time;
     820if ~isempty(TimeSource)
     821    SeriesData.TimeSource=TimeSource;
     822end
    798823if ~isempty(TimeUnit)
    799824    SeriesData.TimeUnit=TimeUnit;
     
    9921017    if size(SeriesData.Time{iview},1)>=i2(2)&&size(SeriesData.Time{iview},1)>=j2(2)
    9931018        if isempty(ref_j)
    994             time_first=(SeriesData.Time{iview}(i1(1))+SeriesData.Time{iview}(i2(1)))/2;
    995             time_last=(SeriesData.Time{iview}(i1(2))+SeriesData.Time{iview}(i2(2)))/2;
     1019            time_first=(SeriesData.Time{iview}(i1(1)+1)+SeriesData.Time{iview}(i2(1)+1))/2;
     1020            time_last=(SeriesData.Time{iview}(i1(2)+1)+SeriesData.Time{iview}(i2(2))+1)/2;
    9961021        else
    997             time_first=(SeriesData.Time{iview}(i1(1),j1(1))+SeriesData.Time{iview}(i2(1),j2(1)))/2;
    998             time_last=(SeriesData.Time{iview}(i1(2),j1(2))+SeriesData.Time{iview}(i2(2),j2(2)))/2;
     1022            time_first=(SeriesData.Time{iview}(i1(1)+1,j1(1)+1)+SeriesData.Time{iview}(i2(1)+1,j2(1)+1))/2;
     1023            time_last=(SeriesData.Time{iview}(i1(2)+1,j1(2)+1)+SeriesData.Time{iview}(i2(2)+1,j2(2)+1))/2;
    9991024        end
    10001025        TimeTable{iview,2}=time_first; %TODO: take into account pairs
     
    14291454
    14301455%% read index ranges
    1431 first_i=1;
    1432 last_i=1;
    1433 incr_i=1;
    1434 first_j=1;
    1435 last_j=1;
    1436 incr_j=1;
    1437 if isfield(Series.IndexRange,'first_i')
    1438     first_i=Series.IndexRange.first_i;
    1439     incr_i=Series.IndexRange.incr_i;
    1440     last_i=Series.IndexRange.last_i;
    1441 end
    1442 if isfield(Series.IndexRange,'first_j')
    1443     first_j=Series.IndexRange.first_j;
    1444     last_j=Series.IndexRange.last_j;
    1445     incr_j=Series.IndexRange.incr_j;
    1446 end
    1447 if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),...
    1448         set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return
     1456[first_i,incr_i,last_i,first_j,incr_j,last_j,errormsg]=get_index_range(Series.IndexRange);
     1457if ~isempty(errormsg)
     1458    msgbox_uvmat('ERROR',['series/Run_Callback/get_index_range' errormsg])
     1459    set(handles.RUN, 'Enable','On'),
     1460    set(handles.RUN,'BackgroundColor',[1 0 0])
     1461    return
    14491462else
    14501463    BlockLength=ceil(numel(first_i:incr_i:last_i)/NbProcess);
     
    14571470    switch StatusData.OutputFileMode
    14581471        case 'NbInput'
    1459             StatusData.NbOutputFile=numel(first_i,incr_i:last_i)*numel(first_j,incr_j:last_j);
     1472            StatusData.NbOutputFile=numel(first_i:incr_i:last_i)*numel(first_j:incr_j:last_j);
    14601473        case 'NbInput_i'
    1461             StatusData.NbOutputFile=numel(first_i,incr_i:last_i);
     1474            StatusData.NbOutputFile=numel(first_i:incr_i:last_i);
    14621475        case 'NbSlice'   
    14631476            StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String'));
     
    14791492            Series.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i);
    14801493        else
    1481             Series.IndexRange.first_i= first_i+iprocess-1;
     1494            Series.IndexRange.first_i= first_i+incr_i*(iprocess-1);
    14821495            Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice;
    14831496        end
  • trunk/src/series/aver_stat.m

    r605 r609  
    7373OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    7474   
    75 %% root input file(s) and type
     75%% root input file(s) name, type and index series
    7676RootPath=Param.InputTable(:,1);
    7777RootFile=Param.InputTable(:,3);
     
    8888% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    8989%%%%%%%%%%%%
    90 % NbSlice=1;%default
    91 % if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
    92 %     NbSlice=Param.IndexRange.NbSlice;
    93 % end
    9490nbview=numel(i1_series);%number of input file series (lines in InputTable)
    9591nbfield_j=size(i1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    9692nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    9793nbfield=nbfield_j*nbfield_i; %total number of fields
    98 %nbfield_i=floor(nbfield/NbSlice);%total number of  indexes in a slice (adjusted to an integer number of slices)
    99 %nbfield=nbfield_i*NbSlice; %total number of fields after adjustement
    100 
    101 %determine the file type on each line from the first input file
     94[first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
     95if ~isempty(errormsg),display(errormsg),return,end
     96
     97%% determine the file type on each line from the first input file
    10298ImageTypeOptions={'image','multimage','mmreader','video'};
    10399NcTypeOptions={'netcdf','civx','civdata'};
     
    150146    return
    151147end
    152 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
    153 
     148%NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
     149NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file
    154150
    155151%% Set field names and velocity types
     
    272268        %%%%%%%%%%%%   END MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
    273269    else
    274         display(errormsg)
     270        disp(errormsg)
    275271    end
    276272end
     
    303299end
    304300
    305 %writting the result file
    306 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),j1_series{1}(1),j1_series{1}(end));
     301%% writing the result file
     302OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,first_i,last_i,first_j,last_j);
    307303if CheckImage{1} %case of images
    308304    if isequal(FileInfo{1}.BitDepth,16)||(numel(FileInfo)==2 &&isequal(FileInfo{2}.BitDepth,16))
     
    313309        imwrite(DataOut.A,OutputFile,'BitDepth',8); % case of 16 bit images
    314310    end
    315     display([OutputFile ' written']);
     311    disp([OutputFile ' written']);
    316312else %case of netcdf input file , determine global attributes
    317313    errormsg=struct2nc(OutputFile,DataOut); %save result file
    318314    if isempty(errormsg)
    319         display([OutputFile ' written']);
    320     else
    321         msgbox_uvmat('ERROR',['error in writting result file: ' errormsg])
    322         display(errormsg)
     315        disp([OutputFile ' written']);
     316    else
     317        disp(['error in writting result file: ' errormsg])
    323318    end
    324319end  % end averaging  loop
  • trunk/src/series/civ_input.m

    r604 r609  
    8989FileType=SeriesData.FileType{1};
    9090FileInfo=SeriesData.FileInfo{1};
    91 Ref_i=SeriesData.Ref_i{1};
    92 Ref_j=SeriesData.Ref_j{1};
    93 FileInput=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomTypeInput,Ref_i(1),Ref_i(2),Ref_j(1),Ref_j(2));
     91FileInput=SeriesData.RefFile{1};
    9492
    9593%% case of netcdf file as input, get the processing stage and look for corresponding images
     
    226224    time=SeriesData.Time{1};
    227225    %transform .Time to a column vector if it is a line vector thenomenclature uses a single index: correct possible bug in xml
    228     if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector
    229         if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
    230             time=time';
    231             MaxIndex_i=MaxIndex_j;
    232             MaxIndex_j=1;
    233         end
    234     end
    235 end
    236 if isfield(SeriesData,'TimeUnit')
    237     TimeUnit=SeriesData.TimeUnit;
    238 end
     226%     if isequal(MaxIndex_i,1) && ~isequal(MaxIndex_j,1)% .Time is a line vector
     227%         if numel(nom_type_read)>=2 && isempty(regexp(nom_type_read(2:end),'\D','once'))
     228%             time=time';
     229%             MaxIndex_i=MaxIndex_j;
     230%             MaxIndex_j=1;
     231%         end
     232%     end
     233end
     234if isfield(Param.IndexRange,'TimeUnit')&&~isempty(Param.IndexRange.TimeUnit)
     235    TimeUnit=Param.IndexRange.TimeUnit;
     236end
     237if isfield(SeriesData,'TimeSource')
     238    set(handles.ImaDoc,'String',SeriesData.TimeSource)
     239end 
    239240if isfield(SeriesData,'GeometryCalib')
    240241    tsai=SeriesData.GeometryCalib;
     
    247248end
    248249% timing set by video input
    249 if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    250     set(handles.ListPairMode,'Value',1);
    251     dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
    252     if strcmp(NomTypeIma,'*')
    253         set(handles.ListPairMode,'String',{'series(Di)'})
    254         time=(dt*(0:MaxIndex_i-1))';%list of image times
    255     else
    256         set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
    257         time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
    258         enable_j(handles,'on')
    259     end
    260     TimeUnit='s';
    261     set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
    262 end
     250% if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
     251%     set(handles.ListPairMode,'Value',1);
     252%     dt=1/get(MovieObject,'FrameRate');%time interval between successive frames
     253%     if strcmp(NomTypeIma,'*')
     254%         set(handles.ListPairMode,'String',{'series(Di)'})
     255%         time=(dt*(0:MaxIndex_i-1))';%list of image times
     256%     else
     257%         set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}])
     258%         time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times
     259%         enable_j(handles,'on')
     260%     end
     261%     TimeUnit='s';
     262%     set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter
     263% end
    263264
    264265%% timing display
     
    274275else
    275276    set(handles.ImaDoc,'String',''); %xml file not used for timing
    276     %    time=(i1_series(:,1)+0:size(i1_series,3)-1);% time=index i
    277     %    time=time'*ones(1,size(i1_series,2),1); %makes a time matrix with the same time for all j indices
    278277    TimeUnit='frame';
    279278    time=ones(MaxIndex_j-MinIndex_j+1,1)*(MinIndex_i:MaxIndex_i);
    280279    time=time+0.001*(MinIndex_j:MaxIndex_j)'*ones(1,MaxIndex_i-MinIndex_i+1);
    281280end
    282 time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
    283 time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros
     281% time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices)
     282% time=[zeros(1,size(time,2)); time]; %insert a horizontal line of zeros
    284283CivInputData.Time=time;
    285284CivInputData.NomTypeIma=NomTypeIma;
    286285set(handles.civ_input,'UserData',CivInputData)
    287 %set(handles.ImaDoc,'UserData',time); %store the matrix of times
    288286set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms)
    289287set(handles.TimeUnit,'String',TimeUnit);
     
    292290set(handles.CoordUnit,'String',CoordUnit)
    293291set(handles.SearchRange,'UserData', pxcm_search);
    294 
    295 % set(handles.ImaExt,'String',ImaExt)
    296 % set(handles.NomType,'String',NomTypeIma)
    297292
    298293%% set the reference indices from the input file indices
     
    865860    mode=mode_list{mode_value};
    866861end
    867 displ_num=[];%default
     862% displ_num=[];%default
    868863ref_i=str2double(get(handles.ref_i,'String'));
    869864% last_i=str2num(get(handles.last_i,'String'));
     
    873868time=CivInputData.Time;
    874869siztime=size(CivInputData.Time);
    875 nbfield=siztime(2)-1;
    876 nbfield2=siztime(1)-1;
     870nbfield=siztime(1)-1;
     871nbfield2=siztime(2)-1;
    877872indchosen=1;  %%first pair selected by default
    878873%displ_num used to define the indices of the civ_input pairs
     
    916911    enable_j(handles, 'on')
    917912elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')
    918     index=1:200;
    919     displ_num(1:2,index)=zeros(2,200);
    920     displ_num(3,index)=-floor(index/2);
    921     displ_num(4,index)=ceil(index/2);
     913%     index=1:200;
     914%     displ_num(1:2,index)=zeros(2,200);
     915%     displ_num(3,index)=-floor(index/2);
     916%     displ_num(4,index)=ceil(index/2);
    922917    enable_i(handles, 'on')
    923918    if nbfield2 > 1
     
    942937    end
    943938end
    944 set(handles.ListPairCiv1,'UserData',displ_num);
     939%set(handles.ListPairCiv1,'UserData',displ_num);
    945940errormsg=find_netcpair_civ( handles,1);
    946941    if ~isempty(errormsg)
     
    978973    set(handles.ListPairCiv2,'Value',index_pair);
    979974end
     975
     976%update first_i and last_i according to the chosen image pairs
     977% mode_list=get(handles.ListPairMode,'String');
     978% mode_value=get(handles.ListPairMode,'Value');
     979% mode=mode_list{mode_value};
     980% if isequal(mode,'series(Di)')
     981%     first_i=str2double(get(handles.first_i,'String'));
     982%     last_i=str2double(get(handles.last_i,'String'));
     983%     incr_i=str2double(get(handles.incr_i,'String'));
     984%     num_i=first_i:incr_i:last_i;
     985%     lastfield=str2double(get(handles.nb_field,'String'));
     986%     if ~isnan(lastfield)
     987%         test_find=(num_i-floor(index_pair/2)*ones(size(num_i))>0)& ...
     988%             (num_i+ceil(index_pair/2)*ones(size(num_i))<=lastfield);
     989%         num_i=num_i(test_find);
     990%     end
     991%     set(handles.first_i,'String',num2str(num_i(1)));
     992%     set(handles.last_i,'String',num2str(num_i(end)));
     993% elseif isequal(mode,'series(Dj)')
     994%     first_j=str2double(get(handles.first_j,'String'));
     995%     last_j=str2double(get(handles.last_j,'String'));
     996%     incr_j=str2double(get(handles.incr_j,'String'));
     997%     num_j=first_j:incr_j:last_j;
     998%     lastfield2=str2double(get(handles.nb_field2,'String'));
     999%     if ~isnan(lastfield2)
     1000%         test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
     1001%             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
     1002%         num_j=num_j(test_find);
     1003%     end
     1004%     set(handles.first_j,'String',num2str(num_j(1)));
     1005%     set(handles.last_j,'String',num2str(num_j(end)));
     1006% end
     1007
     1008%------------------------------------------------------------------------
     1009% --- Executes on selection change in ListPairCiv2.
     1010function ListPairCiv2_Callback(hObject, eventdata, handles)
     1011%------------------------------------------------------------------------
     1012index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu
    9801013
    9811014%update first_i and last_i according to the chosen image pairs
     
    10121045
    10131046%------------------------------------------------------------------------
    1014 % --- Executes on selection change in ListPairCiv2.
    1015 function ListPairCiv2_Callback(hObject, eventdata, handles)
    1016 %------------------------------------------------------------------------
    1017 index_pair=get(handles.ListPairCiv2,'Value');%get the selected position index in the menu
    1018 
    1019 %update first_i and last_i according to the chosen image pairs
    1020 mode_list=get(handles.ListPairMode,'String');
    1021 mode_value=get(handles.ListPairMode,'Value');
    1022 mode=mode_list{mode_value};
    1023 if isequal(mode,'series(Di)')
    1024     first_i=str2double(get(handles.first_i,'String'));
    1025     last_i=str2double(get(handles.last_i,'String'));
    1026     incr_i=str2double(get(handles.incr_i,'String'));
    1027     num_i=first_i:incr_i:last_i;
    1028     lastfield=str2double(get(handles.nb_field,'String'));
    1029     if ~isnan(lastfield)
    1030         test_find=(num_i-floor(index_pair/2)*ones(size(num_i))>0)& ...
    1031             (num_i+ceil(index_pair/2)*ones(size(num_i))<=lastfield);
    1032         num_i=num_i(test_find);
    1033     end
    1034     set(handles.first_i,'String',num2str(num_i(1)));
    1035     set(handles.last_i,'String',num2str(num_i(end)));
    1036 elseif isequal(mode,'series(Dj)')
    1037     first_j=str2double(get(handles.first_j,'String'));
    1038     last_j=str2double(get(handles.last_j,'String'));
    1039     incr_j=str2double(get(handles.incr_j,'String'));
    1040     num_j=first_j:incr_j:last_j;
    1041     lastfield2=str2double(get(handles.nb_field2,'String'));
    1042     if ~isnan(lastfield2)
    1043         test_find=(num_j-floor(index_pair/2)*ones(size(num_j))>0)& ...
    1044             (num_j+ceil(index_pair/2)*ones(size(num_j))<=lastfield2);
    1045         num_j=num_j(test_find);
    1046     end
    1047     set(handles.first_j,'String',num2str(num_j(1)));
    1048     set(handles.last_j,'String',num2str(num_j(end)));
    1049 end
    1050 
    1051 %------------------------------------------------------------------------
    10521047function ref_i_Callback(hObject, eventdata, handles)
    10531048%------------------------------------------------------------------------
     
    11141109%% reads .nc subdirectoy and image numbers from the interface
    11151110SubDirImages=get(handles.Civ1_ImageA,'String');
     1111%TODO: determine
    11161112subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data
    11171113subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data
     
    11261122    ref_j=1;
    11271123end
    1128 time=get(handles.ImaDoc,'UserData');%get the set of times
     1124CivInputData=get(handles.civ_input,'UserData');
    11291125TimeUnit=get(handles.TimeUnit,'String');
     1126time=CivInputData.Time;
    11301127checkframe=strcmp(TimeUnit,'frame');
    1131 displ_num=get(handles.ListPairCiv1,'UserData');
     1128%displ_num=get(handles.ListPairCiv1,'UserData');
    11321129
    11331130%% eliminate the first pairs inconsistent with the position
    1134 if isempty(displ_num)
    1135     nbpair=0;
    1136 else
    1137     nbpair=length(displ_num(1,:));%nbre of displayed pairs
    1138     if  isequal(mode,'series(Di)')  %| isequal(mode,'st_series(Di)')
    1139         nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
    1140     elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
    1141         nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
    1142     end
    1143 end
    1144 nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
     1131% if isempty(displ_num)
     1132%     nbpair=0;
     1133% else
     1134%     nbpair=length(displ_num(1,:));%nbre of displayed pairs
     1135%     if  isequal(mode,'series(Di)')  %| isequal(mode,'st_series(Di)')
     1136%         nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index
     1137%     elseif  isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')
     1138%         nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index
     1139%     end
     1140% end
     1141% nbpair=min(200,nbpair);%limit the number of displayed pairs to 200
    11451142
    11461143%% case with no Civ1 operation, netcdf files need to exist for reading
    11471144displ_pair={''};
     1145nbpair=200;%default
    11481146select=ones(size(1:nbpair));%flag for displayed pairs =1 for display
    11491147testpair=0;
    11501148RootPath=get(handles.RootPath,'String');
    11511149RootFile=get(handles.Civ2_ImageB,'String');
     1150nbpair=200; %default
    11521151if index==1 % case civ1
    11531152    if ~get(handles.CheckCiv1,'Value') %
     
    12271226% in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices
    12281227% are relative to the reference indices ref_i and ref_j respectively.
     1228testpair=0; %TODO: check
    12291229if isequal(mode,'series(Di)')
    12301230    if testpair
  • trunk/src/series/civ_series.m

    r606 r609  
    5858    if ~exist(filecell{1,1},'file')
    5959        msgbox_uvmat('WARNING','the first input file does not exist')
     60    else
     61        FileType=get_file_type(filecell{1,1});
     62        if isempty(find(strcmp(FileType,{'civdata','image','multimage','mmreader','video'})));% =1 for images
     63            msgbox_uvmat('ERROR',['bad input file type for ' mfilename ': an image or civdata file is needed'])
     64        end
    6065    end
    6166    return
     
    8590    MinIndex=cell2mat(Param.IndexRange.MinIndex);
    8691    [filecell,i_series,tild,j_series]=get_file_series(Param);
     92    [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{1,1});
     93    if strcmp(FileType_A,'civdata')% a civdata file has been introduced as input.
     94         [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{2,1});
     95    end
    8796    [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=...
    8897        find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex,MaxIndex);
     
    118127   
    119128    NbField=numel(i1_series_Civ1);
    120     [FileType_A,FileInfo,MovieObject_A]=get_file_type(filecell{1,1});
     129
    121130    FileType_B=FileType_A;
    122131    MovieObject_B=MovieObject_A;
     
    143152
    144153%% get timing from the ImaDoc file or input video
    145 [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
     154XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt);
     155time=[];
     156if ~isempty(XmlFileName)
     157    XmlData=imadoc2struct(XmlFileName);
     158        if isfield(XmlData,'Time')
     159            time=XmlData.Time;
     160            TimeSource='xml';
     161        end
     162        if isfield(XmlData,'Camera')
     163            if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)
     164                NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform
     165                if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
     166                    msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
     167                end
     168            end
     169            if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)
     170                TimeUnit=XmlData.Camera.TimeUnit;
     171            end
     172        end
     173end
     174if strcmp(InputTable{iview,4},'*')
     175    if ~isempty(VideoObject)
     176        imainfo=get(VideoObject);
     177        time=zeros(imainfo.NumberOfFrames+1,2);
     178        time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     179        TimeSource='video';
     180       % set(han:dles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
     181        ColorType='truecolor';
     182    elseif ~isempty(imformats(regexprep(InputTable{iview,5},'^.',''))) || isequal(InputTable{iview,5},'.vol')%&& isequal(NomType,'*')% multi-frame image
     183        if ~isempty(InputTable{iview,2})
     184            imainfo=imfinfo(fullfile(InputTable{iview,1},InputTable{iview,2},[InputTable{iview,3} InputTable{iview,5}]));
     185        else
     186            imainfo=imfinfo([FileBase InputTable{iview,5}]);
     187        end
     188        ColorType=imainfo.ColorType;%='truecolor' for color images
     189        if length(imainfo) >1 %case of image with multiple frames
     190            nbfield=length(imainfo);
     191            nbfield_j=1;
     192        end
     193    end
     194end
     195
    146196%TODO: get time_A and time_B
    147 % case of movies TODO TODO TODO
     197
    148198if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader'))
    149199    set(handles.ListPairMode,'Value',1);
     
    161211    end
    162212    TimeUnit='s';
     213end
    163214%%%%% MAIN LOOP %%%%%%
    164215
  • trunk/src/series/time_series.m

    r606 r609  
    7575OutputDir=[Param.OutputSubDir Param.OutputDirExt];
    7676
    77 %% root input file(s) and type
     77%% root input file(s) name, type and index series
    7878RootPath=Param.InputTable(:,1);
    7979RootFile=Param.InputTable(:,3);
     
    9090% i1_series(iview,fileindex) expresses the same indices as a 1D array in file indices
    9191%%%%%%%%%%%%
    92 % NbSlice=1;%default
    93 % if isfield(Param.IndexRange,'NbSlice')&&~isempty(Param.IndexRange.NbSlice)
    94 %     NbSlice=Param.IndexRange.NbSlice;
    95 % end
    9692nbview=numel(i1_series);%number of input file series (lines in InputTable)
    9793nbfield_j=size(j1_series{1},1); %nb of fields for the j index (bursts or volume slices)
    9894nbfield_i=size(i1_series{1},2); %nb of fields for the i index
    9995nbfield=nbfield_j*nbfield_i; %total number of fields
    100 
    101 %determine the file type on each line from the first input file
     96[first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);
     97if ~isempty(errormsg),display(errormsg),return,end
     98
     99%% determine the file type on each line from the first input file
    102100ImageTypeOptions={'image','multimage','mmreader','video'};
    103101NcTypeOptions={'netcdf','civx','civdata'};
     
    151149    return
    152150end
    153 NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series
     151NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file
    154152
    155153%% Set field names and velocity types
     
    414412end
    415413
    416 %name of result file
    417 OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(1),i1_series{1}(end),j1_series{1}(1),j1_series{1}(end));
     414%% name of result file
     415OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,first_i,last_i,first_j,last_j);
    418416errormsg=struct2nc(OutputFile,DataOut); %save result file
    419417if isempty(errormsg)
     
    422420    displ_uvmat('ERROR',['error in Series/struct2nc: ' errormsg],checkrun)
    423421end
    424 
    425422
    426423%% plot the time series (the last one in case of multislices)
  • trunk/src/uigetfile_uvmat.m

    r606 r609  
    44%
    55% OUTPUT:
    6 % hfig: handles of the browser fig, the selected file name is obtained as File=get(hfig,'UserData')
     6% fileinput: detected file name, including path
    77%
    88% INPUT:
    9 % option: ='file browser': usual browser, 'series status': display advancement of a series calculation
     9% title: = displayed title, 'status': display advancement of a series calculation
    1010% InputDir: directory to browse at first display
    1111
    12 
    13 function hfig=uigetfile_uvmat(option,InputDir)
    14 if ~exist(InputDir,'dir')
    15     InputDir=pwd;
    16 end
    17 hfig=findobj(allchild(0),'name',option);
     12function fileinput=uigetfile_uvmat(title,InputName)
     13fileinput=''; %default file selection
     14if strcmp(title,'status')
     15    option='status';
     16else
     17    option='browser';
     18end
     19if exist(InputName,'file')||exist(InputName,'dir')
     20    [InputDir,InputFileName,Ext]=fileparts(InputName);
     21    InputFileName=[InputFileName Ext];
     22    if isdir(InputName)
     23        InputFileName=['+/' InputFileName];
     24    end
     25else
     26    InputDir=pwd;%look in the current work directory if the input file does not exist
     27    InputFileName='';
     28end
     29hfig=findobj(allchild(0),'tag',option);
    1830if isempty(hfig)
     31    set(0,'Unit','points')
    1932    ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
    20     hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Position',[ScreenSize(3)-600 ScreenSize(4)-640 560 600],'DeleteFcn',@stop_status,'UserData',InputDir);
    21     uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @(src,event)view_file(option,src,event),'tag','list','FontSize',12);
    22     uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,'String',InputDir,'FontSize',12,'FontWeight','bold');
    23     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'String','Close','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@stop_status);
    24     uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.1 0.01 0.2 0.07],'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@refresh_GUI);
     33    Width=350;% fig width in points (1/72 inch)
     34    Height=min(0.8*ScreenSize(4),500);
     35    Left=ScreenSize(3)- Width-40; %right edge close to the right, with margin=40
     36    Bottom=ScreenSize(4)-Height-40; %put fig at top right
     37    hfig=figure('name',option,'tag',option,'MenuBar','none','NumberTitle','off','Unit','points','Position',[Left,Bottom,Width,Height],'UserData',InputDir);
     38    uicontrol('Style','listbox','Units','normalized', 'Position',[0.05 0.09 0.9 0.71], 'Callback', @(src,event)view_file(option,src,event),'tag','list',...
     39        'FontUnits','points','FontSize',12);
     40    uicontrol('Style','edit','Units','normalized', 'Position', [0.05 0.87 0.9 0.1],'tag','titlebox','Max',2,...
     41        'String',InputDir,'FontUnits','points','FontSize',12,'FontWeight','bold');
     42    uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.7 0.01 0.2 0.07],'Callback',@(src,event)close(option,src,event),...
     43        'String','Close','FontWeight','bold','FontUnits','points','FontSize',12);
     44    uicontrol('Style','pushbutton','Tag','refresh','Units','normalized','Position', [0.1 0.01 0.2 0.07],'Callback',@refresh_GUI,...
     45        'String','Refresh','FontWeight','bold','FontUnits','points','FontSize',12);
    2546    %set(hrefresh,'UserData',StatusData)
    26     if strcmp(option,'series status') %put a run advancement display
     47    if strcmp(option,'status') %put a run advancement display
     48        set(hfig,'DeleteFcn',@stop_status)
    2749        uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.81 0.01 0.05],'BackgroundColor',[1 0 0],'tag','waitbar');
    2850        uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]);
    29     else  %put a title
    30         uicontrol('Style','text','Units','normalized', 'Position', [0.05 0.81 0.9 0.03],'String','select an input file:',...
    31             'FontSize',14,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
    32         uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.01 0.2 0.07],'String','Home','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir);
     51    else  %put a title and additional pushbuttons
     52        uicontrol('Style','text','Units','normalized', 'Position', [0.15 0.81 0.8 0.03],...
     53            'String',title,'FontUnits','points','FontSize',12,'FontWeight','bold','ForegroundColor','blue','HorizontalAlignment','left');
     54        uicontrol('Style','pushbutton','Tag','backward','Units','normalized','Position',[0.05 0.8 0.1 0.07],...
     55            'String','<--','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@backward);
     56        uicontrol('Style','pushbutton','Units','normalized', 'Position', [0.4 0.01 0.2 0.07],...
     57            'String','Home','FontWeight','bold','FontUnits','points','FontSize',12,'Callback',@home_dir);
    3358    end
    3459    drawnow
    3560end
    36 refresh_GUI(hfig)
    37    
    38 %------------------------------------------------------------------------   
    39 % --- launched by selecting a file on the list
     61refresh_GUI(findobj(hfig,'Tag','refresh'),InputFileName) 
     62if ~strcmp(option,'status') 
     63    uiwait(hfig)
     64end
     65fileinput=get(hfig,'UserData');% retrieve the input file selection
     66delete(hfig)
     67
     68%------------------------------------------------------------------------   
     69% --- launched by selecting an item on the file list
    4070function view_file(option,hObject,event)
    4171%------------------------------------------------------------------------
    4272list=get(hObject,'String');
    4373index=get(hObject,'Value');
    44 hfig=get(hObject,'parent');
    45 DirName=get(get(hObject,'parent'),'UserData');
    46 SelectName=regexprep(list{index},'^/','');% remove the / used to mark dir
    47 if strcmp(SelectName,'..')
     74hfig=get(hObject,'parent');%handle of the fig
     75DirName=get(hfig,'UserData');
     76SelectName=regexprep(list{index},'^\+/','');% remove the +/ used to mark dir
     77if strcmp(SelectName,'..')% the upward dir option has been selected
    4878    FullSelectName=fileparts(DirName);
    4979else
    50 %ind_dot=regexp(SelectName,'\.\.\.');
    51 % if ~isempty(ind_dot)
    52 %     SelectName=SelectName(1:ind_dot-1);
    53 % end
    54 FullSelectName=fullfile(DirName,SelectName);
     80    %ind_dot=regexp(SelectName,'\.\.\.');
     81    % if ~isempty(ind_dot)
     82    %     SelectName=SelectName(1:ind_dot-1);
     83    % end
     84    FullSelectName=fullfile(DirName,SelectName);
    5585end
    5686if exist(FullSelectName,'dir')% a directory has been selected
     
    6595%         FullSelectName=fileparts(fileparts(FullSelectName));
    6696%     end
     97    hbackward=findobj(hfig,'Tag','backward');
     98    set(hbackward,'UserData',DirName); %store the current dir for future backward action
    6799    ListFiles=list_files(FullSelectName);
    68100    set(hObject,'Value',1)
     
    82114        %uvmat(FullSelectName);
    83115        switch option
    84             case 'file browser'
     116            case 'browser'
    85117        hfig=get(hObject,'parent');
    86118        set(hfig,'UserData',FullSelectName);
    87119        uiresume(hfig)
    88             case 'series status'
     120            case 'status'
    89121           uvmat(FullSelectName);
    90122        end
    91     end
    92     set(gcbo,'Value',1)
     123        set(gcbo,'Value',1)
     124    end
    93125end
    94126
     
    96128% --- launched by selecting home
    97129function home_dir(hObject,event)
     130%------------------------------------------------------------------------
    98131DirName=pwd;
    99 
    100132ListFiles=list_files(DirName);% list the directory content
    101133hfig=get(hObject,'parent');
     
    108140
    109141%------------------------------------------------------------------------   
     142% --- launched by pressing the backward (<--) button
     143function backward(hObject,event)
     144%------------------------------------------------------------------------
     145PrevDir=get(hObject,'UserData');
     146if ~isempty(PrevDir)
     147hfig=get(hObject,'parent');
     148set(hfig,'UserData',PrevDir)
     149htitlebox=findobj(hfig,'tag','titlebox');  % display the new dir name
     150set(htitlebox,'String',PrevDir)
     151refresh_GUI(findobj(hfig,'Tag','refresh'))
     152end
     153
     154%------------------------------------------------------------------------
     155
     156%------------------------------------------------------------------------   
    110157% --- launched by refreshing the display figure
    111 function refresh_GUI(hfig,event)
    112 %------------------------------------------------------------------------
     158function refresh_GUI(hObject,InputFileName)
     159%------------------------------------------------------------------------
     160if ~exist('InputFileName','var')
     161    InputFileName='';
     162end
     163hfig=get(hObject,'parent');
    113164DirName=get(hfig,'UserData');
    114165ListFiles=list_files(DirName);% list the directory content
    115166hlist=findobj(hfig,'tag','list');% find the list object
    116167set(hlist,'String',ListFiles)
     168Value=[];
     169if ~isempty(InputFileName)
     170    Value=find(strcmp(InputFileName,ListFiles));
     171end
     172if isempty(Value)
     173    Value=1;
     174end
     175set(hlist,'Value',Value)
    117176return
    118177
     
    188247ListFiles=ListCells(1,:);%list of file names
    189248check_dir=cell2mat(ListCells(4,:));% check directories
    190 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','/$0');% put '/' in front of dir name display
     249ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display
    191250[tild,index_sort]=sort(check_dir,2,'descend');% sort
    192251ListFiles=ListFiles(index_sort);% list of names sorted by alaphabetical order and dir and file
    193 cell_remove=regexp(ListFiles,'^(-|\.|/\.)');% remove strings beginning by '/.',';' or '-'
    194 check_remove=cellfun('isempty',cell_remove);
    195 ListFiles=[{'/..'} ListFiles(check_remove)];
     252cell_remove=regexp(ListFiles,'^(-|\.|\+/\.)');% detect strings beginning by '-' ,'.' or '+/.'(dir beginning by . )
     253check_keep=cellfun('isempty', cell_remove);               
     254ListFiles=[{'+/..'} ListFiles(check_keep)];
    196255
    197256%-------------------------------------------------------------------------   
    198 % launched by deleting the status figure
    199 function stop_status(hObject, eventdata)
     257% launched by deleting the status figure (only used in mode series status')
     258function close(option,hObject, eventdata)
    200259%-------------------------------------------------------------------------
    201 hciv=findobj(allchild(0),'tag','series');
    202 hhciv=guidata(hciv);
    203 set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
    204 set(hhciv.status,'BackgroundColor',[0 1 0])
     260if strcmp(option,'status')
     261    hseries=findobj(allchild(0),'tag','series');
     262    hstatus=findobj(hfig,'Tag','status');
     263    set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ
     264    set(hhciv.status,'BackgroundColor',[0 1 0])
     265end
    205266delete(gcbf)
    206267
  • trunk/src/uvmat.m

    r606 r609  
    3232%          .OpenParam: structure containing parameters defined when uvmat is opened
    3333%                       .PosColorbar: position (1x4 vector)of the colorbar (relative to the fig uvmat)
    34 %                       .PosSetObject: position of set_object
    3534%                       .PosGeometryCalib: size of set_object
    3635%                       .NbBuiltin: nbre of functions always displayed in TransformName menu
     
    175174path_uvmat=fileparts(which('uvmat'));
    176175
    177 %% set the position of colorbar and ancillary GUIs:
    178 set(hObject,'Units','Normalized')
    179 movegui(hObject,'center')
     176%% set the position of the GUI, colorbar and ancillary GUIs:
     177set(hObject,'Units','pixels')%
     178set(0,'Units','pixels');
     179ScreenSize=get(0,'ScreenSize');%size of the current screen
     180Width=1050;
     181Height=700;
     182%adjust to screen size (reduced by a min margin)
     183RescaleFactor=min((ScreenSize(3)-80)/Width,(ScreenSize(4)-80)/Height);
     184if RescaleFactor>1
     185    RescaleFactor=RescaleFactor/2+1/2; %reduce the rescale factor to provide an increased margin for a big screen
     186end
     187Width=Width*RescaleFactor;
     188Height=Height*RescaleFactor;
     189LeftX=80*RescaleFactor;%position of the left fig side, in pixels (put to the left side, with some margin)
     190LowY=round(ScreenSize(4)/2-Height/2); % put at the middle height on the screen
     191set(hObject,'Position',[LeftX LowY Width Height])
     192
     193%set(hObject,'Units','Normalized')
     194
    180195%UvData.OpenParam.PosColorbar=[0.8450    0.0900    0.0190    0.3600];
    181196UvData.OpenParam.PosColorbar=[0.805 0.022 0.019 0.445];
    182 UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object
     197%UvData.OpenParam.PosSetObject=[-0.05 -0.03 0.3 0.7]; %position for set_object
    183198UvData.OpenParam.PosGeometryCalib=[0.95 -0.03 0.28 1 ];%position for geometry_calib (TO IMPROVE)
    184199% UvData.OpenParam.CalSize=[0.28 1];
     
    197212
    198213%% initialisation
    199 % set(handles.ListObject,'Value',1)% default: empty projection objectproj_field
    200 % set(handles.ListObject,'String',{''})
    201 % set(handles.ListObject_1,'Value',1)% default: empty projection objectproj_field
    202 % set(handles.ListObject_1,'String',{''})
    203214set(handles.FieldName,'Value',1)
    204215set(handles.FieldName,'string',{''})
     
    337348function MenuBrowse_Callback(hObject, eventdata, handles)
    338349[RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    339 oldfile=fullfile(RootPath,SubDir);
     350oldfile=[fullfile(RootPath,SubDir,RootFile) FileIndices FileExt];
    340351if isempty(oldfile) %loads the previously stored file name and set it as default in the file_input box
    341352    oldfile=get(handles.RootPath,'UserData');
    342353end
    343 hfig=uigetfile_uvmat('file browser',fileparts(oldfile));
    344 uiwait(hfig);
    345 if ishandle(hfig) % stop if browser closed without selection
    346     fileinput=get(hfig,'UserData');% retrieve the input file selection
    347     delete(hfig)
    348     % display the selected field and related information
     354fileinput=uigetfile_uvmat('select an input file:',oldfile);
     355if ~isempty(fileinput)
    349356    display_file_name(handles,fileinput)
    350357end
    351 
    352 %
    353 %
    354 %
    355 % [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',oldfile);
    356 % if ~ischar(FileName),return,end %abandon if the browser is cancelled
    357 % fileinput=[PathName FileName];%complete file name
    358358
    359359%% display the selected field and related information
     
    435435%------------------------------------------------------------------------
    436436RootPath=get(handles.RootPath,'String');
    437 [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);
    438 if ~ischar(FileName),return,end %abandon if the browser is cancelled
    439 fileinput_1=[PathName FileName];%complete file name
    440 
    441 % refresh the current displayed field
    442 set(handles.SubField,'Value',1)
    443 display_file_name(handles,fileinput_1,2)
    444 
    445 %update list of recent files in the menubar
    446 MenuFile_1=fileinput_1;
    447 MenuFile_2=get(handles.MenuFile_1,'Label');
    448 MenuFile_3=get(handles.MenuFile_2,'Label');
    449 MenuFile_4=get(handles.MenuFile_3,'Label');
    450 MenuFile_5=get(handles.MenuFile_4,'Label');
    451 set(handles.MenuFile_1,'Label',MenuFile_1)
    452 set(handles.MenuFile_2,'Label',MenuFile_2)
    453 set(handles.MenuFile_3,'Label',MenuFile_3)
    454 set(handles.MenuFile_4,'Label',MenuFile_4)
    455 set(handles.MenuFile_5,'Label',MenuFile_5)
    456 set(handles.MenuFile_1_1,'Label',MenuFile_1)
    457 set(handles.MenuFile_2_1,'Label',MenuFile_2)
    458 set(handles.MenuFile_3_1,'Label',MenuFile_3)
    459 set(handles.MenuFile_4_1,'Label',MenuFile_4)
    460 set(handles.MenuFile_5_1,'Label',MenuFile_5)
    461 % dir_perso=prefdir;
    462 % profil_perso=fullfile(dir_perso,'uvmat_perso.mat');
    463 % if exist(profil_perso,'file')
    464 %     save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-append'); %store the file names for future opening of uvmat
    465 % else
    466 %     txt=ver('MATLAB');
    467 %     Release=txt.Release;
    468 %     relnumb=str2double(Release(3:4));
    469 %     if relnumb >= 14
    470 %         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5','-V6'); %store the file names for future opening of uvmat
    471 %     else
    472 %         save (profil_perso,'MenuFile_1','MenuFile_2','MenuFile_3','MenuFile_4', 'MenuFile_5'); %store the file names for future opening of uvmat
    473 %     end
    474 % end
     437SubDir=get(handles.SubDir,'String');
     438fileinput_1=uigetfile_uvmat('select a second input file:',fullfile(RootPath,SubDir));
     439if ~isempty(fileinput_1)
     440    % [FileName, PathName] = uigetfile({'*.*','All Files(*.*)'},'Pick a file',RootPath);
     441    % if ~ischar(FileName),return,end %abandon if the browser is cancelled
     442    % fileinput_1=[PathName FileName];%complete file name
     443   
     444    % refresh the current displayed field
     445    set(handles.SubField,'Value',1)
     446    display_file_name(handles,fileinput_1,2)
     447   
     448    %update list of recent files in the menubar
     449    MenuFile_1=fileinput_1;
     450    MenuFile_2=get(handles.MenuFile_1,'Label');
     451    MenuFile_3=get(handles.MenuFile_2,'Label');
     452    MenuFile_4=get(handles.MenuFile_3,'Label');
     453    MenuFile_5=get(handles.MenuFile_4,'Label');
     454    set(handles.MenuFile_1,'Label',MenuFile_1)
     455    set(handles.MenuFile_2,'Label',MenuFile_2)
     456    set(handles.MenuFile_3,'Label',MenuFile_3)
     457    set(handles.MenuFile_4,'Label',MenuFile_4)
     458    set(handles.MenuFile_5,'Label',MenuFile_5)
     459    set(handles.MenuFile_1_1,'Label',MenuFile_1)
     460    set(handles.MenuFile_2_1,'Label',MenuFile_2)
     461    set(handles.MenuFile_3_1,'Label',MenuFile_3)
     462    set(handles.MenuFile_4_1,'Label',MenuFile_4)
     463    set(handles.MenuFile_5_1,'Label',MenuFile_5)
     464end
    475465
    476466% --------------------------------------------------------------------
     
    20031993num_j1=stra2num(get(handles.j1,'String'));
    20041994num_j2=stra2num(get(handles.j2,'String'));
    2005 [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);
     1995[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
     1996if isempty(j1_1)% case of movies, the index is not given by file index
     1997    j1_1=num_j1;
     1998end
    20061999
    20072000errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
     
    22042197            end 
    22052198         case 'multimage'
    2206             if ~strcmp(NomType_1,'*')
    2207                 frame_index_1=j1_1;%frame index for movies or multimage
     2199            if strcmp(NomType_1,'*')%frame index for movies or multimage
     2200                frame_index_1=i1_1;
    22082201            else
    2209                 frame_index_1=i1_1;
     2202                frame_index_1=j1_1;
    22102203            end   
    22112204        case 'vol' %TODO: update
     
    35093502    [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,
    35103503                                                      % associate the set_object interface handle to the plotting axes
    3511     set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject)
     3504    %set(hset_object,'Position',get(handles.uvmat,'Position')+UvData.OpenParam.PosSetObject)
    35123505    UvData.MouseAction='create_object';
    35133506else
     
    44024395    [PlotType,PlotParam]=plot_field(ProjData,hhview_field.PlotAxes,read_GUI(hview_field));%read plotting parameters on the GUI view_field);
    44034396    errormsg=fill_GUI(PlotParam,hview_field);
    4404                     for list={'Scalar','Vectors'}
    4405                     if ~isfield(PlotParamOut,list{1})
    4406                         set(hhview_field.(list{1}),'Visible','off')
    4407                     end
    4408                 end
     4397    for list={'Scalar','Vectors'}
     4398        if ~isfield(PlotParam,list{1})
     4399            set(hhview_field.(list{1}),'Visible','off')
     4400        end
     4401    end
    44094402    %write_plot_param(hhview_field,PlotParam); %update the display of plotting parameters for the current object
    44104403    haxes=findobj(hview_field,'tag','axes3');
Note: See TracChangeset for help on using the changeset viewer.