Changeset 1018 for trunk


Ignore:
Timestamp:
Nov 3, 2017, 9:58:48 PM (6 years ago)
Author:
sommeria
Message:

extract_rdvision fixed

Location:
trunk/src/series
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/civ_input.m

    r1017 r1018  
    713713    if ischar(mode_list)
    714714        mode_list={mode_list};
    715     end
     715    end 
    716716    mode_value=get(handles.ListPairMode,'Value');
     717    if isempty(mode_value)
     718        mode_value=1;
     719    end
    717720    mode=mode_list{mode_value};
    718721end
     
    908911    mode_list=get(handles.ListPairMode,'String');
    909912    mode_value=get(handles.ListPairMode,'Value');
     913    if isempty(mode_value)
     914        mode_value=1;
     915    end
    910916    if isempty(mode_list)
    911917        return
     
    15591565        if strcmp(NomType,'_1')
    15601566           NbSlice=i1_series(1,2,end);
    1561            set(handles.NbSlice,'String',num2str(NbSlice))
     1567           set(handles.num_NbSlice,'String',num2str(NbSlice))
    15621568        end
    15631569        set(hObject,'UserData',filemask);%store for future use
  • trunk/src/series/extract_rdvision.m

    r991 r1018  
    200200    newxml=[newxml '.xml'];
    201201   
    202     %copyfile_modif(filexml,newxml); %copy the xml file in the upper folder
    203    
    204     %[XmlData,errormsg]=imadoc2struct(newxml);
    205 %     nbfield2=size(XmlData.Time,2)-1;
    206 %     if nbfield2>1
    207 %         NomTypeNew='_1_1';
    208 %     else
    209 %         NomTypeNew='_1';
    210 %     end
    211202    %% get the names of .seq and .sqb files
    212203    switch Param.InputTable{iview,5}
     
    214205            filename_seq=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.seq']);
    215206            filename_sqb=fullfile(RootPath,Param.InputTable{iview,2},[Param.InputTable{iview,3} '.sqb']);
     207           
    216208            logdir=[Param.OutputSubDir Param.OutputDirExt];
    217209            [success,errormsg] = copyfile(filename_seq,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.seq']); %copy the seq file in the upper folder
    218210            [success,errormsg] = copyfile(filename_sqb,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.sqb']); %copy the sqb file in the upper folder
     211            [success,errormsg] = copyfile(filexml,[fullfile(RootPath,logdir,Param.InputTable{iview,3}) '.xml']); %copy the original xml file in the upper folder
    219212        otherwise
    220213            errormsg='input file extension must be .seq or .sqb';
     
    240233        SeqData.binrepertoire=regexprep(SeqData.binrepertoire,'\','/');
    241234        [tild,SeqData.binrepertoire,DirExt]=fileparts(SeqData.binrepertoire);
    242         %SeqData.binrepertoire=[SeqData.binrepertoire DirExt];
    243235    end
    244236   
     
    271263    for ii=1: numel(m.Data)
    272264        timestamp(ii)=m.Data(ii).timestamp;
    273 %         j1=1;
    274 %         if ~isequal(nbfield2,1)
    275 %             j1=mod(ii-1,nbfield2)+1;
    276 %         end
    277 %         i1=floor((ii-1)/nbfield2)+1;
    278         %diff_time(i1,j1)= timestamp(ii)-XmlData.Time(i1+1,j1+1);
    279     end
    280     [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder
     265    end
     266    [nbfield1,nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder
    281267    [XmlData,errormsg]=imadoc2struct(newxml);% check reading of the new xml file
    282268    if ~isempty(errormsg)
     
    284270        return
    285271    end
    286     if ~isequal(size(XmlData.Time(2:end,2:end)),size(reshape(timestamp(1:end),nbfield2,[])'))
    287         disp(['size of record ' num2str(size(XmlData.Time(2:end,2:end))) ' does not fit with timestamp size ' num2str(size(reshape(timestamp(1:end),nbfield2,[])'))])
    288         return
    289     end
    290     difftime=XmlData.Time(2:end,2:end)-(reshape(timestamp(1:end),nbfield2,[]))';
     272    timestamp=timestamp(1:nbfield1*nbfield2);
     273    timestamp=reshape(timestamp,nbfield2,nbfield1);
     274    difftime=XmlData.Time(2:end,2:end)'-timestamp;
    291275    disp(['time from xml and timestamp differ by ' num2str(max(max(abs(difftime))))])
    292276    if max(abs(difftime))>0.01
     
    295279   
    296280        %% checking consistency with the xml file
    297     if ~isequal(SeqData.nb_frames,numel(timestamp))
    298         disp_uvmat('ERRROR',['inconsistent number of images ' num2str(SeqData.nb_frames) ' with respect to the xml file: ' num2str(numel(timestamp))] ,checkrun);
    299         return
    300     end   
     281%     if ~isequal(SeqData.nb_frames,numel(timestamp))
     282%         disp_uvmat('ERRROR',['inconsistent number of images ' num2str(SeqData.nb_frames) ' with respect to the xml file: ' num2str(numel(timestamp))] ,checkrun);
     283%         return
     284%     end   
    301285   
    302286    if nbfield2>1
     
    329313
    330314%% remove binary files if transfer OK
    331     if ~checkpreserve
    332         for iview=1:size(Param.InputTable,1)
    333          fullfile(RootPath,Param.InputTable{iview,2})
    334          source_dir=fullfile(RootPath,Param.InputTable{iview,2});
    335         [SUCCESS,MESSAGE]=rmdir(source_dir,'s')
    336         end
    337     end
     315%     if ~checkpreserve
     316%         for iview=1:size(Param.InputTable,1)
     317%          fullfile(RootPath,Param.InputTable{iview,2})
     318%          source_dir=fullfile(RootPath,Param.InputTable{iview,2});
     319%         [SUCCESS,MESSAGE]=rmdir(source_dir,'s')
     320%         end
     321%     end
    338322delete(fullfile(RootPath,'Running.xml'))%delete the  xml file to indicate that processing is finished
    339323
     
    451435
    452436
    453 function [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml)
     437function [nbfield1,nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml)
    454438msg='';
    455439t=xmltree(filexml);
    456440
    457 %% correct NbDtj
    458 uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj');
    459 uid_content=get(t,uid_NbDtj,'contents');
    460 t=set(t,uid_content,'value','1');% set NbDtj to 1 (correct error in the xml file)
    461 
    462 %% check Dtj
     441%% read Dtk and NbDtk
     442NbDtk=1; %default
     443Dtk=[]; % default
     444uid_Dtk=find(t,'ImaDoc/Camera/BurstTiming/Dtk');
     445uid_content_Dtk=get(t,uid_Dtk,'contents');
     446if ~isempty(uid_content_Dtk)
     447    Dtk=str2num(get(t,uid_content_Dtk,'value'));
     448    uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk');
     449    uid_content_NbDtk=get(t,uid_NbDtk,'contents');
     450    if ~isempty(uid_content_NbDtk)
     451    NbDtk=str2num(get(t,uid_content_NbDtk,'value'));
     452    end
     453end
     454
     455%% read Dti and NbDti
     456NbDti=1; %default
     457Dti=[]; % default
     458uid_Dti=find(t,'ImaDoc/Camera/BurstTiming/Dti');
     459uid_content_Dti=get(t,uid_Dti,'contents');
     460if ~isempty(uid_content_Dti)
     461    Dti=str2num(get(t,uid_content_Dti,'value'));
     462    uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti');
     463    uid_content_NbDti=get(t,uid_NbDti,'contents');
     464    if ~isempty(uid_content_NbDti)
     465    NbDti=str2num(get(t,uid_content_NbDti,'value'));
     466    end
     467end
     468
     469%% read Dtj and NbDtj
     470NbDtj=1; %default
     471Dtj=[]; % default
    463472uid_Dtj=find(t,'ImaDoc/Camera/BurstTiming/Dtj');
    464 uid_content=get(t,uid_Dtj,'contents');
    465 Dtjstring=get(t,uid_content,'value');
    466 if isempty(Dtjstring)
     473uid_content_Dtj=get(t,uid_Dtj,'contents');
     474if ~isempty(uid_content_Dtj)
     475    Dtj=str2num(get(t,uid_content_Dtj,'value'));
     476    uid_NbDtj=find(t,'ImaDoc/Camera/BurstTiming/NbDtj');
     477    uid_content_NbDtj=get(t,uid_NbDtj,'contents');
     478    if ~isempty(uid_content_NbDtj)
     479    NbDtj=str2num(get(t,uid_content_NbDtj,'value'));
     480    end
     481end
     482
     483%% correct NbDtj and NbDti (error from RDvision)
     484if NbDtj==numel(Dtj)% case of bursts
     485    NbDtj=1;
     486    uid_motor_nbslice=find(t,'ImaDoc/TranslationMotor/Nbslice');
     487    if ~isempty(uid_motor_nbslice)&& ~isempty(uid_Dtk)% case of multilevel
     488        NbSlice=str2num(get(t,get(t,uid_motor_nbslice,'contents'),'value'));
     489        NbDti=NbSlice-1;
     490    end
     491end
     492
     493if isempty(Dtj)% case of simple series
    467494    timestamp=timestamp';
    468     nbfield2=1;
     495    t=set(t,uid_content_NbDti,'value',num2str(numel(timestamp)-1));% correct NbDti in the xml file
    469496else
    470     Dtj=str2num(get(t,uid_content,'value'));
    471     nbfield2=numel(Dtj)+1;
     497    nbfieldi=(NbDti*numel(Dti)+1);
     498    nbfieldk=(NbDtk*numel(Dtk)+1);
     499    nbfield1=nbfieldi*nbfieldk;
     500    nbfield2=NbDtj*numel(Dtj)+1;
     501    NbFrames_xml=nbfield1*nbfield2;
     502   if NbFrames_xml<numel(timestamp)
     503       disp(['ERROR: size from xml ' num2str(NbFrame_xml) ' smaller than timestamp size ' num2str(numel(timestamp))])
     504       return
     505   end
     506   if NbFrames_xml>numel(timestamp)
     507       nbfield1=floor(numel(timestamp)/nbfield2);
     508       nbfieldk=floor(nbfield1/nbfieldi);
     509       nbfield1=nbfieldi*nbfieldk;
     510       NbDtk=nbfieldk-1;
     511       t=set(t,uid_content_NbDtk,'value',num2str(NbDtk));% correct NbDtk in the xml file (in practice numel(Dtk)=1;
     512       timestamp=timestamp(1:nbfield1*nbfield2);
     513       disp(['image record stopped before end: max index i= ' num2str(nbfield1)]);
     514       timestamp=reshape(timestamp,nbfield2,nbfield1);
     515   end
     516   % check Dtj with respect to timestamp
    472517    timestamp=(reshape(timestamp,nbfield2,[]))';
    473518    diff_Dtj=diff(timestamp(1,:))-Dtj;
     
    478523    end
    479524end
    480 %% correct NbDti
    481 NbDti=size(timestamp,1)-1; %default for series or burst
    482 uid_motor_nbslice=find(t,'ImaDoc/TranslationMotor/Nbslice');
    483 uid_NbDtk=find(t,'ImaDoc/Camera/BurstTiming/NbDtk');
    484 if ~isempty(uid_motor_nbslice)&& ~isempty(uid_NbDtk)
    485     uid_content=get(t,uid_motor_nbslice,'contents');
    486     NbSlice=str2num(get(t,uid_content,'value'));
    487     NbDti=NbSlice-1;
    488     uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti');
    489     uid_content=get(t,uid_NbDti,'contents');
    490     t=set(t,uid_content,'value',num2str(NbDti));
    491 end
    492525
    493526%% adjust Dti
    494 uid_Dti=find(t,'ImaDoc/Camera/BurstTiming/Dti');
    495 uid_content=get(t,uid_Dti,'contents');
    496 Dti=str2num(get(t,uid_content,'value'));
    497527Dti_stamp=(timestamp(1+NbDti,1)-timestamp(1,1))/NbDti;
     528t=set(t,uid_content_Dti,'value',num2str(Dti_stamp));%corret Dti
    498529if abs(Dti_stamp-Dti)>Dti/1000
    499530    disp([msg 'Dti from xml file corrected by ' num2str(Dti_stamp-Dti) ', ']);%'
     
    501532    disp('Dti OK')
    502533end
    503 t=set(t,uid_content,'value',num2str(Dti_stamp));
    504534
    505535%% adjust Dtk
    506 uid_Dtk=find(t,'ImaDoc/Camera/BurstTiming/Dtk');
    507536if ~isempty(uid_Dtk)
    508     uid_content_Dtk=get(t,uid_Dtk,'contents');
    509     Dtk=str2num(get(t,uid_content_Dtk,'value'));
    510     uid_content_NbDtk=get(t,uid_NbDtk,'contents');
    511     NbDtk=str2num(get(t,uid_content_NbDtk,'value'));
    512     Dtk_stamp=(timestamp(end-NbDti,1)-timestamp(1,1))/NbDtk;
     537    Dtk_stamp=(timestamp((NbDti+1)*NbDtk+1,1)-timestamp(1,1))/NbDtk;
     538    t=set(t,uid_content_Dtk,'value',num2str(Dtk_stamp));
    513539    if abs(Dtk_stamp-Dtk)>Dtk/1000
    514540        disp(['Dtk from xml file corrected by ' num2str(Dtk_stamp-Dtk)]);
     
    519545end
    520546
     547%% save the new xml file
    521548save(t,newxml)
    522549[success,errormsg] = fileattrib(newxml,'+w','g');% allow writing access for the group of users
Note: See TracChangeset for help on using the changeset viewer.