Changeset 477 for trunk/src


Ignore:
Timestamp:
Jun 26, 2012, 8:40:09 AM (13 years ago)
Author:
sommeria
Message:

various bugs repaired.

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/check_files.m

    r476 r477  
    8989    'read_GUI';... %read all parameters set by a GUI as a Matlab structure
    9090    'read_image';...%read .civ files (obsolete, but can be adapted to other text documentation files)
     91    'read_multimadoc';... %read a set of Imadoc files and compare their timing of different file series
    9192    'read_xls';...%read excel files containing the list of the experiments
    9293    'reinit';...% suppress the personal parameter file 'uvmat_perso.mat'
  • trunk/src/find_field_indices.m

    r411 r477  
    140140    for ilist=1:numel(ListRole)
    141141        eval(['VarType{icell}.' ListRole{ilist} '=ivar_' ListRole{ilist} ';'])
    142     end   
     142    end
    143143    if numel(ivar_coord_x)>1 || numel(ivar_coord_y)>1 || numel(ivar_coord_z)>1
    144144        errormsg='multiply defined coordinates  in the same cell';
  • trunk/src/plot_field.m

    r434 r477  
    463463       title_str=[title_str ext];
    464464    end
    465     if isfield(data,'Action')
     465    if isfield(data,'Action')&&isfield(data.Action,'ActionName')
    466466        if ~isequal(title_str,'')
    467467            title_str=[title_str ', '];
    468468        end
    469         title_str=[title_str data.Action];
     469        title_str=[title_str data.Action.ActionName];
    470470    end
    471471    htitle=title(title_str);
  • trunk/src/read_multimadoc.m

    r469 r477  
     1%'read_multimadoc': read a set of Imadoc files and compare their timing of different file series
     2%------------------------------------------------------------------------
     3% [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
     4%
     5% OUTPUT:
     6%
     7%
     8% INPUT:
     9%
    110function [XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series)
     11errormsg='';
    212nbview=numel(RootPath);
     13XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
    314NbSlice_calib=cell(1,nbview);
    415timecell=cell(1,nbview);
    5 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
    616for iview=1:nbview%Loop on views
    717    XmlFileName=find_imadoc(RootPath{iview},SubDir{iview},RootFile{iview},FileExt{iview});
  • trunk/src/series.m

    r476 r477  
    767767update_mode(handles,i1_series,i2_series,j1_series,j2_series,time)
    768768
    769 
    770 %% display the set of existing files as an image
    771 set(handles.waitbar_frame,'Units','pixels')
    772 pos=get(handles.waitbar_frame,'Position');
    773 xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
    774 yima=0.5:pos(4)-0.5;
    775 [XIma,YIma]=meshgrid(xima,yima);
    776 nb_i=size(i1_series,1);
    777 nb_j=size(i1_series,2);
    778 ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
    779 ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
    780 [Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
    781 CData=zeros([size(XIma) 3]);
    782 file_ima=double((i1_series(:,:,1)>0)');
    783 if numel(file_ima)>=2
    784 if size(file_ima,1)==1
    785     CLine=interp1(ind_i,file_ima,xima,'nearest');
    786     CData(:,:,2)=ones(size(yima'))*CLine;
    787 else
    788     CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
    789 end
    790 set(handles.waitbar_frame,'CData',CData)
    791 end
    792 set(handles.waitbar_frame,'Units','normalized')
    793 
    794 
    795769%% update the series info in 'UserData'
    796770SeriesData=get(handles.series,'UserData');
     
    812786end
    813787
     788%% display the set of existing files as an image
     789set(handles.FileStatus,'Units','pixels')
     790Position=get(handles.FileStatus,'Position');
     791set(handles.FileStatus,'Units','normalized')
     792xI=0.5:Position(3)-0.5;
     793nbview=numel(SeriesData.i1_series);
     794for iview=1:nbview
     795    index_min(iview)=min(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     796    index_max(iview)=max(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     797end
     798index_min=min(index_min);
     799index_max=max(index_max);
     800range_index=index_max-index_min+1;
     801scale_y=Position(4)/nbview;
     802scale_x=Position(3)/range_index;
     803x=(0.5:range_index-0.5)*Position(3)/range_index;
     804% y=(0.5:nbview-0.5)*Position(4)/nbview;
     805range_y=max(1,floor(Position(4)/nbview));
     806CData=zeros(nbview*range_y,Position(3));
     807for iview=1:nbview
     808    ind_y=1+(iview-1)*range_y:iview*range_y;
     809    LineData=zeros(1,range_index);
     810    x_index=find(SeriesData.i1_series{iview}(2:end,2:end,1)>0)-index_min+1;
     811    LineData(x_index)=1;
     812    LineData=interp1(x,LineData,xI,'nearest');
     813    CData(ind_y,:)=ones(size(ind_y'))*LineData;
     814end
     815CData=cat(3,zeros(size(CData)),CData,zeros(size(CData)));
     816set(handles.FileStatus,'CData',CData);
     817
     818%
     819%
     820% xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
     821% yima=0.5:pos(4)-0.5;
     822% [XIma,YIma]=meshgrid(xima,yima);
     823% nb_i=size(i1_series,1);
     824% nb_j=size(i1_series,2);
     825% ind_i=(0.5:nb_i-0.5)*pos(3)/nb_i;
     826% ind_j=(0.5:nb_j-0.5)*pos(4)/nb_j;
     827% [Ind_i,Ind_j]=meshgrid(ind_i,ind_j);
     828% CData=zeros([size(XIma) 3]);%black color
     829% file_ima=double((i1_series(:,:,1)>0)');
     830% if numel(file_ima)>=2
     831% if size(file_ima,1)==1
     832%     CLine=interp1(ind_i,file_ima,xima,'nearest');
     833%     CData(:,:,2)=ones(size(yima'))*CLine;
     834% else
     835%     CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
     836% end
     837% set(handles.FileStatus,'CData',CData)
     838% end
     839% set(handles.FileStatus,'Units','normalized')
     840
     841
    814842%% enable field and veltype menus, in accordance with the current action
    815843ActionName_Callback([],[], handles)
     
    829857    set(handles.PairString,'Visible','off')
    830858end
     859
     860%% set length of waitbar
     861displ_time(handles)
     862
    831863
    832864% %% set default options in menu 'Fields'%% TODO: check VelType
     
    9871019displ_time(handles);
    9881020
     1021
    9891022%------------------------------------------------------------------------
    9901023% ---- find the times corresponding to the first and last indices of a series
     
    9941027ref_i=[str2num(get(handles.num_first_i,'String')) str2num(get(handles.num_last_i,'String'))];
    9951028ref_j=[str2num(get(handles.num_first_j,'String')) str2num(get(handles.num_last_j,'String'))];
    996 % last_i=str2num(get(handles.num_last_i,'String'));
    997 % last_j=str2num(get(handles.num_last_j,'String'));
    9981029TimeTable=get(handles.TimeTable,'Data');
    9991030Pairs=get(handles.PairString,'Data');
     
    10401071set(handles.TimeTable,'Data',TimeTable)
    10411072
     1073%% set the waitbar position with respect to the min and max in the series
     1074% for iview=1:numel(SeriesData.i1_series)
     1075% [tild,index_min(iview)]=min(SeriesData.i1_series{iview}(SeriesData.i1_series{iview}>0));
     1076% [tild,index_max(iview)]=max(SeriesData.i1_series{iview}(SeriesData.i1_series{iview}>0));
     1077% end
     1078for iview=1:numel(SeriesData.i1_series)
     1079    index_min(iview)=min(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     1080    index_max(iview)=max(find(SeriesData.i1_series{iview}(2:end,2:end,1)>0));
     1081end
     1082[index_min,iview_min]=min(index_min);
     1083[index_max,iview_max]=min(index_max);
     1084index_first=(ref_i(1)-1)*(size(SeriesData.i1_series{iview_min},2)-1)+ref_j(1);
     1085index_last=(ref_i(2)-1)*(size(SeriesData.i1_series{iview_max},2)-1)+ref_j(2);
     1086range=index_max-index_min+1;
     1087coeff_min=(index_first-index_min)/range;
     1088coeff_max=(index_last-index_min+1)/range;
     1089Position=get(handles.Waitbar,'Position');
     1090Position_status=get(handles.FileStatus,'Position');
     1091Position(1)=coeff_min*Position_status(3)+Position_status(1);
     1092Position(3)=Position_status(3)*(coeff_max-coeff_min);
     1093set(handles.Waitbar,'Position',Position)
     1094update_waitbar(handles.Waitbar,0)
     1095
    10421096%------------------------------------------------------------------------
    10431097% --- Executes when selected cell(s) is changed in PairString.
     
    13351389            Series=h_fun(Series);% no background in the absence of output file
    13361390        else
    1337         % update the xml file after interactive input with the function
    1338         Series.Specific='?';
    1339         Series=h_fun(Series);
    1340         t=struct2xml(Series);
    1341         t=set(t,1,'name','Series');
    1342         save(t,filexml);
    1343         path_uvmat=fileparts(which('uvmat'));
    1344        
    1345         filename_bat=regexprep(filexml,'.xml$','.bat');
    1346         [fid,message]=fopen(filename_bat,'w');
    1347         if isequal(fid,-1)
    1348             msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
    1349             return
     1391            % update the xml file after interactive input with the function
     1392            Series.Specific='?';
     1393            Series=h_fun(Series);
     1394            t=struct2xml(Series);
     1395            t=set(t,1,'name','Series');
     1396            save(t,filexml);
     1397            path_uvmat=fileparts(which('uvmat'));
     1398           
     1399            filename_bat=regexprep(filexml,'.xml$','.bat');
     1400            [fid,message]=fopen(filename_bat,'w');
     1401            if isequal(fid,-1)
     1402                msgbox_uvmat('ERROR', ['creation of .bat file: ' message]);
     1403                return
     1404            end
     1405            path_fct=get(handles.ActionPath,'String');
     1406            filelog=regexprep(filexml,'.xml$','.log');
     1407            text_matlabscript=[...
     1408                '#!/bin/bash \n'...
     1409                '. /etc/sysprofile \n'...
     1410                'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
     1411                'addpath(''' path_uvmat '''); \n'...
     1412                'addpath(''' Series.Action.ActionPath '''); \n'...
     1413                '' Series.Action.ActionName  '( ''' filexml '''); \n'...
     1414                'exit \n'...
     1415                'END_MATLAB \n'];
     1416            fprintf(fid,text_matlabscript);
     1417            fclose(fid);
     1418            if isunix
     1419                system(['chmod +x ' filename_bat]);% set the file to executable
     1420                system(['. ' filename_bat ' &']);%execute fct
     1421            else
     1422                system(filename_bat);
     1423            end
    13501424        end
    1351         path_fct=get(handles.ActionPath,'String');
    1352         filelog=regexprep(filexml,'.xml$','.log');
    1353         text_matlabscript=[...
    1354             '#!/bin/bash \n'...
    1355             '. /etc/sysprofile \n'...
    1356             'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'...
    1357             'addpath(''' path_uvmat '''); \n'...
    1358             'addpath(''' Series.Action.ActionPath '''); \n'...
    1359             '' Series.Action.ActionName  '( ''' filexml '''); \n'...
    1360             'exit \n'...
    1361             'END_MATLAB \n'];
    1362         fprintf(fid,text_matlabscript);
    1363         fclose(fid);
    1364         if isunix
    1365             system(['chmod +x ' filename_bat]);% set the file to executable
    1366             system(['. ' filename_bat ' &']);%execute fct
    1367         else
    1368             system(filename_bat);
    1369         end
    1370         end
     1425        update_waitbar(handles.Waitbar,1); % put the waitbar to end position to indicate lounching is finished
    13711426end
    13721427
     
    16211676PathName=list_path{index_ACTION};%current recorded path
    16221677set(handles.ActionPath,'String',PathName); %show the path to the senlected function
     1678
     1679%reinitialise the waitbar
     1680update_waitbar(handles.Waitbar,0)
    16231681
    16241682%default setting for the visibility of the GUI elements
     
    21122170
    21132171%% display the set of existing files as an image
    2114 set(handles.waitbar_frame,'Units','pixels')
    2115 pos=get(handles.waitbar_frame,'Position');
     2172set(handles.Waitbar,'Units','pixels')
     2173pos=get(handles.Waitbar,'Position');
    21162174xima=0.5:pos(3)-0.5;% pixel positions on the image representing the existing file indices
    21172175yima=0.5:pos(4)-0.5;
     
    21312189    CData(:,:,2)=interp2(Ind_i,Ind_j,file_ima,XIma,YIma,'nearest');
    21322190end
    2133 set(handles.waitbar_frame,'CData',CData)
    2134 end
    2135 set(handles.waitbar_frame,'Units','normalized')
     2191set(handles.Waitbar,'CData',CData)
     2192end
     2193set(handles.Waitbar,'Units','normalized')
    21362194
    21372195%% enable field and veltype menus
  • trunk/src/set_object.m

    r445 r477  
    640640if ~isempty(answer)
    641641    t=struct2xml(Object);
     642    t=set(t,1,'name','ProjObject');
    642643    save(t,answer{1})
    643644end
  • trunk/src/update_waitbar.m

    r339 r477  
    33%INPUT:
    44% hwaitbar:  handles of the waitbar to update
    5 % bar_size: vector with 4 elements, representing the abscissa, ordinate, width, height of the waitbar relative to the GUI 
    65% advance_ratio: number between 0 and 1 representing the advancement of the calculation (loop index relative to the total length)
    76
    8 function update_waitbar(hwaitbar,bar_size,advance_ratio)
    9 % waitbarpos(1)=bar_size(1);
    10 % waitbarpos(3)=bar_size(3);
    11 % waitbarpos(4)=advance_ratio*bar_size(4);
    12 % waitbarpos(2)=bar_size(4)+bar_size(2)-waitbarpos(4);
    13 % set(hwaitbar,'Position',waitbarpos)
     7function update_waitbar(hwaitbar,advance_ratio)
     8
    149set(hwaitbar,'Units','pixels')
    15 pos=get(hwaitbar,'Position');
    16 CData=zeros([floor(pos(4)) floor(pos(3)) 3]);
    17 set(hwaitbar,'Units','normalized')
    18 CData(:,1:floor(advance_ratio*size(CData,2)),1:2)=1;
     10pos=get(hwaitbar,'Position');%read waitbar position in pixels
     11set(hwaitbar,'Units','normalized')%set back to normalize(the waitbar scales with the GUI)
     12CData=ones(floor(pos(4)),floor(pos(3)),3);
     13CData(:,:,3)=0 ;% initial color yellow (rgb=[1 1 0])
     14CData(:,1:floor(advance_ratio*size(CData,2)),2)=0; % advancement part in red (suppress the second color component green)
    1915set(hwaitbar,'CData',CData)
    2016drawnow
  • trunk/src/uvmat.m

    r476 r477  
    45434543
    45444544%read the file
    4545 data=xml2struct(fileinput);
    4546 
     4545[data,heading]=xml2struct(fileinput);
     4546if ~strcmp(heading,'ProjObject')
     4547    msgbox_uvmat('WARNING','The xml file does not have the heading ProjObject for projection objects')
     4548end
    45474549[tild,data.Name]=fileparts(FileName);% object name set as file name
    45484550ListObject=get(handles.ListObject,'String');
     
    45514553    set(handles.ListObject,'String',ListObject)
    45524554end
    4553 
    45544555IndexObj=length(ListObject);
    45554556
  • trunk/src/xml2struct.m

    r472 r477  
    4141    case 'cell'
    4242        out=[];%default
    43         if isequal(cellfun(@isnumeric,ss),ones(size(ss)))% if the all the cell content is  numeric
    44             out=cell2mat(ss);
    45         else
    46             for ilist=1:numel(ss)
     43        check_numeric=zeros(size(ss));
     44        for ilist=1:numel(ss)
     45            if ~isempty(str2num(ss{ilist}))
     46                out{ilist,1}=str2num(ss{ilist});
     47                check_numeric(ilist)=1;
     48            else
    4749                sep_ind=regexp(ss{ilist},'\s&\s');% check for separator ' & ' which indicates column separation in tables
    4850                if ~isempty(sep_ind)
     
    5658            end
    5759        end
    58 %         for ilist=1:numel(ss)
    59 %             if ~isempty(str2num(ss{ilist}))
    60 %             out(ilist,:)=str2num(ss{ilist});% convert to numeric
    61 %             end
    62 %         end
     60        if isequal(check_numeric,ones(size(ss)))
     61            out=cell2mat(out);
     62        end
    6363    otherwise
    6464        out=ss;
Note: See TracChangeset for help on using the changeset viewer.