Changeset 609 for trunk/src/series.m


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

various bugs corrected after tests with Windows OS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.