Changeset 1149


Ignore:
Timestamp:
Jun 23, 2024, 10:00:16 PM (5 days ago)
Author:
sommeria
Message:

extract_rdvision improved by automatic production of the xml file from timestamps

Location:
trunk/src
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/imadoc2struct.m

    r1127 r1149  
    3737errormsg='';%default
    3838s=[];
    39 % s.Heading=[];%default
    40 % s.Time=[]; %default
    41 % s.TimeUnit=[]; %default
    42 % s.GeometryCalib=[];
    43 % tsai=[];%default
    4439
    4540%% opening the xml file
     
    7267        s.TimeUnit=s.Camera.TimeUnit;
    7368    end
     69    if ~isfield(s.Camera,'FirstFrameIndexI')
     70        s.Camera.FirstFrameIndexI=1; %first index assumed equl to 1 by default
     71    end
    7472    Timing=s.Camera.BurstTiming;
    7573    if ~iscell(Timing)
    7674        Timing={Timing};
    7775    end
     76
    7877    s.Time=[];
    7978    for k=1:length(Timing)
     
    126125        end
    127126    end
    128     if ~isfield(s.Camera,'FirstFrameIndexI')
    129         s.Camera.FirstFrameIndexI=1; %first index qssumed equl to 1 by default
    130     end
     127   
    131128    s.Time=[zeros(size(s.Time,1),1) s.Time]; %insert a vertical line of zeros (to deal with zero file indices)
    132129    if s.Camera.FirstFrameIndexI~=0
  • trunk/src/series/extract_multitif.m

    r1144 r1149  
    9191        first_j=[];% note that the function will propose to cover the whole range of indices
    9292    if isfield(Param.IndexRange,'MinIndex_j'); first_j=Param.IndexRange.MinIndex_j; end
    93 % %     last_j=[];
    94 % %     if isfield(Param.IndexRange,'MaxIndex_j'); last_j=Param.IndexRange.MaxIndex_j; end
    9593    PairString='';
    9694    if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end
  • trunk/src/series/extract_rdvision.m

    r1148 r1149  
    1616% in series), the function ouput paramOut set the activation of the needed GUI elements
    1717%
    18 % Param contains the elements:(use the menu bar command 'export/GUI config' in series to 
     18% Param contains the elements:(use the menu bar command 'export/GUI config' in series to
    1919% see the current structure Param)
    2020%    .InputTable: cell of input file names, (several lines for multiple input)
     
    2727%             .RUN =0 for GUI input, =1 for function activation
    2828%             .RunMode='local','background', 'cluster': type of function  extract_rdvision.muse
    29 %             
     29%
    3030%    .IndexRange: set the file or frame indices on which the action must be performed
    3131%    .FieldTransform: .TransformName: name of the selected transform function
     
    105105    % check the names of .seq and .sqb files
    106106    iview=1;
    107     switch Param.InputTable{iview,5}
    108         case {'.seq','.sqb'}
    109             filename_seq=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.seq']);
    110             filename_sqb=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.sqb']);
    111             if ~exist(filename_seq,'file')
    112                 msgbox_uvmat('ERROR',[filename_seq ' missing']);
    113             end
    114             if ~exist(filename_sqb,'file')
    115                 msgbox_uvmat('ERROR',[filename_sqb ' missing']);
    116             end
    117             filexml=[fullfile(RootPath,Param.InputTable{iview,2},Param.InputTable{iview,3}) '.xml'];%xml at the level of the image folder
    118             if ~exist(filexml,'file')
    119                 msgbox_uvmat('ERROR',[filexml ' missing: needed to get the image organisation and timing ']);
    120                 return
    121             end
    122             [XmlData,errormsg]=imadoc2struct(filexml);
    123             if ~isempty(errormsg)
    124                 msgbox_uvmat('ERROR',errormsg);
    125                 return
    126             end
    127             timexml=reshape(XmlData.Time(2:end,2:end)',1,[]);
    128         otherwise
    129             msgbox_uvmat('ERROR','bad input file : select .seq or .sqb for image extraction');
     107    if ~ismember(Param.InputTable{iview,5},{'.seq','.sqb'})
     108        msgbox_uvmat('ERROR','bad input file : select .seq or .sqb for image extraction');
     109        return
     110    end
     111    filename_seq=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.seq']);
     112    filename_sqb=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.sqb']);
     113    if ~exist(filename_seq,'file')
     114        msgbox_uvmat('ERROR',[filename_seq ' missing']);
     115        return
     116    end
     117    if ~exist(filename_sqb,'file')
     118        msgbox_uvmat('ERROR',[filename_sqb ' missing']);
     119        return
     120    end
     121    filexml=[fullfile(RootPath,Param.InputTable{iview,2},Param.InputTable{iview,3}) '.xml'];%xml at the level of the image folder
     122    if exist(filexml,'file')
     123        [XmlData,errormsg]=imadoc2struct(filexml);
     124        if ~isempty(errormsg)
     125            msgbox_uvmat('ERROR',errormsg);
    130126            return
    131     end
    132     % get data from .seq file
     127        end
     128        ParamOut.ActionInput.Createxml=false;
     129        %  filexml=uigetfile_uvmat('pick xml file for timing',fullfile(RootPath,Param.InputTable{iview,2}),'.xml');
     130        % msgbox_uvmat('ERROR',[filexml ' missing: needed to get the image organisation and timing ']);
     131    else
     132        if isfield(Param,'ActionInput') && isfield(Param.ActionInput,'BurstLength')
     133            BurstLength=num2str(Param.ActionInput.BurstLength);
     134        else
     135            BurstLength='1';%default for a simple image series
     136        end
     137         answer=msgbox_uvmat('INPUT_TXT',{['no xml file in ' Param.InputTable{iview,2}];' introduce the nbre of frames in a burst to create xml'},BurstLength);
     138        ParamOut.ActionInput.BurstLength=str2double(answer);
     139         % filexml=uigetfile_uvmat('pick xml file for timing',fullfile(RootPath,Param.InputTable{iview,2}),'.xml');
     140        % [XmlData,errormsg]=imadoc2struct(filexml);
     141        ParamOut.ActionInput.Createxml=true;
     142    end
     143
     144% get data from .seq file
    133145    s=ini2struct(filename_seq);
    134146    SeqData=s.sequenceSettings;
     
    140152        'uint32' [1 1] 'file_idx';...
    141153        'uint32' [1 1] 'garbage2' },'Repeat',SeqData.nb_frames);
    142    
     154    ParamOut.ActionInput.XmlData.SourceFolder=fileparts(m.Filename);
    143155        timestamp=zeros(1,numel(m.Data));
    144156        for ii=1: numel(m.Data)
    145157            timestamp(ii)=m.Data(ii).timestamp;
    146158        end
     159        if ParamOut.ActionInput.Createxml
     160            ParamOut.ActionInput.XmlData.Camera.BurstTiming=time2xmlburst(timestamp,ParamOut.ActionInput.BurstLength);
     161            Time=xmlburst2time(ParamOut.ActionInput.XmlData.Camera.BurstTiming);
     162        else
     163           Time=XmlData.Time;
     164        end
     165        timexml=reshape(Time(2:end,2:end)',1,[]);
    147166        if numel(timestamp)<= numel(timexml)
    148167            timexml=timexml(1:numel(timestamp));
    149         else
    150             msgbox_uvmat('ERROR','time sequence defined by the xml file too small')
     168        else 
     169            msgbox_uvmat('ERROR',['time sequence from the xml file = ' num2str(numel(timexml))  ' smaller than timestamp length ' num2str(numel(timestamp))])
    151170            return
    152171        end
     
    171190end
    172191disp(Param)
    173 checkrun=strcmp(Param.RunMode,'local')
     192checkrun=strcmp(Param.RunMode,'local');
    174193hseries=findobj(allchild(0),'Tag','series');
    175194RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
     
    232251   
    233252    %% get the names of .seq and .sqb files and save them to the log output folder .extract
    234     switch Param.InputTable{iview,5}
    235         case {'.seq','.sqb'}
     253    if ismember( Param.InputTable{iview,5}, {'.seq','.sqb'})
    236254            filename_seq=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.seq']);
    237255            filename_sqb=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.sqb']);
     
    253271                        disp(errormsg)
    254272                    end
    255                 else
    256                     disp(['error:' filexml ' missing']);
    257                     return
    258273                end
    259274            end
    260         otherwise
     275    else
    261276            errormsg='input file extension must be .seq or .sqb';
    262277    end
     
    282297        [tild,SeqData.binrepertoire,DirExt]=fileparts(SeqData.binrepertoire);
    283298    end
    284    
    285    
    286299   
    287300    %% reading the .sqb file
     
    307320%             end
    308321%             m.Data=data;
    309     %%%%%%%
    310         [XmlData,errormsg]=imadoc2struct(filexml);% check reading of the xml file
    311         if ~isempty(errormsg)
    312             disp(errormsg)
    313             return
    314         end
    315         [nbfield1,nbfield2]=size(XmlData.Time);
    316         nbfield1=nbfield1-1;nbfield2=nbfield2-1;
    317 
    318     timestamp=zeros(1,numel(m.Data));
    319     for ii=1: numel(m.Data)
    320         timestamp(ii)=m.Data(ii).timestamp;
    321     end
    322     if isequal(Param.IndexRange.first_i,1)
    323         %[nbfield1,nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder
    324         % [XmlData,errormsg]=imadoc2struct(newxml);% check reading of the new xml file
    325 
    326         if numel(timestamp)~=nbfield1*nbfield2
    327             disp('WARNING: total image number defined by the xml file differs from  the number of frames ')
    328         else
    329             timestamp=reshape(timestamp,nbfield2,nbfield1);
    330             difftime=XmlData.Time(2:end,2:end)'-timestamp;
    331             disp(['time from xml and timestamp differ by ' num2str(max(max(abs(difftime))))])
    332             if max(abs(difftime))>0.01
    333                 checkpreserve=1;% will not erase the initial files, possibility of error
    334             end
    335         end
     322%%%%%%%
     323if Param.ActionInput.Createxml
     324    nbfield2=Param.ActionInput.BurstLength;
     325else
     326    [XmlData,errormsg]=imadoc2struct(filexml);% check reading of the xml file
     327    if isempty(errormsg)
     328        nbfield2=size(XmlData.Time,2)-1;
     329    else
     330        disp(errormsg)
     331        return
     332    end
     333end
     334
     335
     336
     337% timestamp=zeros(1,numel(m.Data));
     338% for ii=1: numel(m.Data)
     339%     timestamp(ii)=m.Data(ii).timestamp;
     340% end
     341if isequal(Param.IndexRange.first_i,1)
     342    if Param.ActionInput.Createxml
     343        t=struct2xml(Param.ActionInput.XmlData);
     344        t=set(t,1,'name','ImaDoc');
     345        save(t,newxml)
     346    else
     347        [success,errormsg]=copyfile(filexml,newxml);
     348    end
     349    % [nbfield1,nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder
     350    % if numel(timestamp)~=nbfield1*nbfield2
     351    %     disp('WARNING: total image number defined by the xml file differs from  the number of frames ')
    336352    % else
    337        % [nbfield1,nbfield2,msg]=copyfile_modif(filexml,timestamp,'');
    338     end
    339     if nbfield2>1
    340         NomTypeNew='_1_1';
    341     else
    342         NomTypeNew='_1';
    343     end
    344 
    345     [BinList,errormsg]=binread_rdv_series(RootPath,SeqData,m.Data,nbfield2,NomTypeNew,Param.IndexRange.first_i,Param.IndexRange.last_i);
    346     if ~isempty(errormsg)
    347         disp_uvmat('ERROR',errormsg,checkrun)
    348         return
    349     end
    350 
    351 end
    352 
     353    %     timestamp=reshape(timestamp,nbfield2,nbfield1);
     354    %     difftime=XmlData.Time(2:end,2:end)'-timestamp;
     355    %     disp(['time from xml and timestamp differ by ' num2str(max(max(abs(difftime))))])
     356    %     if max(abs(difftime))>0.01
     357    %         checkpreserve=1;% will not erase the initial files, possibility of error
     358    %     end
     359    % end
     360end
     361if nbfield2>1
     362    NomTypeNew='_1_1';
     363else
     364    NomTypeNew='_1';
     365end
     366
     367[BinList,errormsg]=binread_rdv_series(RootPath,SeqData,m.Data,nbfield2,NomTypeNew,Param.IndexRange.first_i,Param.IndexRange.last_i);
     368if ~isempty(errormsg)
     369    disp_uvmat('ERROR',errormsg,checkrun)
     370    return
     371end
     372end
    353373%% remove binary files if transfer OK
    354374%     if ~checkpreserve
Note: See TracChangeset for help on using the changeset viewer.