Ignore:
Timestamp:
Jun 22, 2012, 3:45:50 PM (12 years ago)
Author:
sommeria
Message:

functions upadated in series

File:
1 edited

Legend:

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

    r464 r470  
    130130end
    131131
     132
    132133%% calibration data and timing: read the ImaDoc files
    133 mode=''; %default
    134 timecell={};
    135 itime=0;
    136 NbSlice_calib={};
    137 XmlData=cell(1,nbview);%initiate the structures containing the data from the xml file (calibration and timing)
    138 
    139 for iview=1:nbview%Loop on views
    140     SubDirBase=regexprep(SubDir{iview},'\..*','');%take the root part of SubDir, before the first dot '.'
    141     filexml=[fullfile(RootPath{iview},SubDirBase) '.xml'];%new convention: xml at the level of the image folder
    142     if ~exist(filexml,'file')
    143         filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.xml']; % old convention: xml inside the image folder
    144         if ~exist(filexml,'file')
    145             filexml=[fullfile(RootPath{iview},SubDir{iview},RootFile{iview}) '.civ']; % very old convention: .civ file
    146             if ~exist(filexml,'file')
    147                 filexml='';
    148             end
    149         end
    150     end
    151     if ~isempty(filexml)
    152         [XmlData{iview},error]=imadoc2struct(filexml);
    153     end
    154     if isfield(XmlData{iview},'Time')
    155         itime=itime+1;
    156         timecell{itime}=XmlData{iview}.Time;
    157     end
    158     if isfield(XmlData{iview},'GeometryCalib') && isfield(XmlData{iview}.GeometryCalib,'SliceCoord')
    159         NbSlice_calib{iview}=size(XmlData{iview}.GeometryCalib.SliceCoord,1);%nbre of slices for Zindex in phys transform
    160         if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})
    161             msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');
    162         end
    163     end
    164 end
    165 
    166 
    167 %% check coincidence in time for several input file series
    168 multitime=0;
    169 if isempty(timecell)
    170     time=[];
    171 elseif length(timecell)==1
    172     time=timecell{1};
    173 elseif length(timecell)>1
    174     multitime=1;
    175     for icell=1:length(timecell)
    176         if ~isequal(size(timecell{icell}),size(timecell{1}))
    177             msgbox_uvmat('WARNING','inconsistent time array dimensions in ImaDoc fields, the time for the first series is used')
    178             time=timecell{1};
    179             multitime=0;
    180             break
    181         end
    182     end
    183 end
    184 if multitime
    185     for icell=1:length(timecell)
    186         time(icell,:,:)=timecell{icell};
    187     end
     134[XmlData,NbSlice_calib,time,errormsg]=read_multimadoc(RootPath,SubDir,RootFile,FileExt,i1_series,i2_series,j1_series,j2_series);
     135if size(time,1)>1
    188136    diff_time=max(max(diff(time)));
    189137    if diff_time>0
     
    191139    end   
    192140end
    193 if size(time,2) < i2_series{1}(end) ||( ~isempty(j2_series{1}) && size(time,3) < j2_series{1}(end))% time array absent or too short in ImaDoc xml file'
    194     time=[];
    195 end
     141
    196142
    197143%% coordinate transform or other user defined transform
     
    266212    %%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    267213    for index=index_slice
     214 
    268215        if checkrun
    269216            update_waitbar(hseries.waitbar_frame,WaitbarPos,index/(nbfield))
     
    285232            timeread(iview)=0;
    286233            if isfield(Data{iview},'Time')
    287                     timeread(iview)=Field{iview}.Time;
     234                    timeread(iview)=Data{iview}.Time;
    288235                    nbtime=nbtime+1;
    289236                end
     
    317264            return
    318265        end
    319              % time of the merged field:
    320         time_i=0;%default
    321         if isempty(time)% time from ImaDoc prevails
    322             time_i=sum(timeread)/nbtime;
    323         else
    324             time_i=(time(i1,j1)+time(i2,j2))/2; %TODO: upgrade
    325         end
     266       
     267        % time of the merged field:
     268        if ~isempty(time)% time defined from ImaDoc
     269            timeread=time(:,index);
     270        end
     271        timeread=mean(timeread);
     272       
    326273        % generating the name of the merged field
    327274        i1=i1_series{iview}(index);
     
    342289        end
    343290        OutputFile=fullfile_uvmat(RootPath{1},Param.OutputSubDir,RootFile{1},FileExtOut,NomType{1},i1,i2,j1,j2);
    344        
    345         % time of the merged field:
    346         time_i=0;%default
    347         if isempty(time)% time from ImaDoc prevails
    348             time_i=sum(timeread)/nbtime;
    349         else
    350             % time_i=i1;
    351             time_i=(time(i1,j1)+time(i2,j2))/2; %TODO: upgrade
    352         end
    353291       
    354292        % recording the merged field
     
    405343                MergeData.dt=dt;
    406344            end
    407             MergeData.Time=time_i;
     345            MergeData.Time=timeread;
    408346            error=struct2nc(OutputFile,MergeData);%save result file
    409347            if isempty(error)
Note: See TracChangeset for help on using the changeset viewer.