Ignore:
Timestamp:
May 29, 2014, 6:17:00 PM (10 years ago)
Author:
sommeria
Message:
 
File:
1 edited

Legend:

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

    r780 r781  
    44if isstruct(Param) && isequal(Param.Action.RUN,0)
    55    ParamOut.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default)
    6     ParamOut.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
     6    ParamOut.WholeIndexRange='on';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default)
    77    ParamOut.NbSlice='off'; %nbre of slices ('off' by default)
    88    ParamOut.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
     
    1212    ParamOut.ProjObject='off';%can use projection object(option 'off'/'on',
    1313    ParamOut.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
    14     ParamOut.OutputDirExt='.p_formed_1';%set the output dir extension
     14    index=msgbox_uvmat('INPUT_TXT','index of the series to process (1 to 5)');%choose the i index of the dat files
     15    ParamOut.OutputDirExt=['.p_formed_' index];%set the output dir extension
     16    hseries=findobj(allchild(0),'Tag','series');
     17    hhseries=guidata(hseries);
     18    set(hhseries.num_last_i,'String',index)
     19    set(hhseries.num_first_i,'String',index)
    1520    ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
    1621      %check the input files
     
    2934
    3035ParamOut=[]; %default output
     36%% read input parameters from an xml file if input is a file name (batch mode)
     37checkrun=1;
     38if ischar(Param)
     39    Param=xml2struct(Param);% read Param as input file (batch case)
     40    checkrun=0;
     41end
    3142hseries=findobj(allchild(0),'Tag','series');
    3243RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series
     
    8495% close all
    8596% read_data=1;
    86 affichage=1;
     97affichage=0;
    8798% soustraction=0;
    88 
    89 % test_fin_fichier=1;
    90 pas_fichier=1;
    91 numero_tir_fin_old=1;
    9299
    93100%%%%%% Prepare output
    94101load (fullfile(RootPath,SubDir,[RootFile '.mat']))
    95 Data.ListVarName={'Coord_x','Coord_z','Pressure'};
    96 Data.VarDimName={'Coord_x','Coord_z',{'Coord_z','Coord_x'}};
    97 Data.Coord_x=5*(nbvoie_reception-0.5)/numel(nbvoie_reception); % totql length of e
    98 Data.Coord_z=(1:A)/133 ;% to check from input parameter ....
     102Data.ListGlobalAttribute={'CoordUnit'}; %%TODO: add also time, how to get it  ?????
     103Data.CoordUnit='pixel';
     104Data.ListVarName={'AX','AY','A'};
     105Data.VarDimName={'AX','AY',{'AY','AX'}};
     106%Data.Coord_x=5*(nbvoie_reception-0.5)/numel(nbvoie_reception); % totql length of e
     107Data.AX=1:65;
     108%Data.Coord_z=(1:A)/133 ;% to check from input parameter ....
     109Data.AY=1:332;
    99110%%%%%%
    100111%
     
    104115%name='test';%%%%%%%%%%%%%%%%%
    105116%         number=2;
    106 number=1; %subsequence index (from 1 to 5)
    107 OutputDirExt=['.p_formed_' num2str(number)]; %TODO: loop on 'number' from 1 to 5
    108 numero_tir_fin_old=1;
    109 pas_fichier=20;% nbre of successive shoots to read (to account for computer memory limit)
    110 Nmoy=20;  %%%%% value 20  FOR TEST : to shift to VALUE 8000 set by the .mat file
     117number=str2num(Param.OutputDirExt(11:end));%extract the subsequence index (from 1 to 5)
     118numero_tir_fin_old=1%%%%%%% =0 ?????
     119pas_fichier=20;%  %20;% nbre of successive shots to read (to account for computer memory limit)
     120Nmoy=800;  %%%%% value 20  FOR TEST : to shift to VALUE 8000 set by the .mat file
    111121
    112122test_fin_fichier=1;% test to stop input file reading
    113123while test_fin_fichier>0
    114124    numero_tir_debut=1;
    115     numero_tir_fin=numero_tir_debut+pas_fichier;
     125    numero_tir_fin=numero_tir_fin_old+pas_fichier-1;
    116126   
    117127    %  eval(['load ' directory '\' name '.mat'])
     
    123133    for ii=1:length(nbvoie_reception)%=64
    124134        %eval(['fid=fopen(''E:\ManipLGITLecoeur\' directory '\' name '_' num2str(number) '_' num2str(nbvoie_reception(ii)) '.dat'',''r'');']);
    125         filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,number,[],ii);
     135        filename=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,number,[],ii); % input file name
    126136        fid=fopen(filename);
    127137        toto=zeros(Nsequence*A*numero_tir_fin+31,1);% Nsequence=1
    128         toto=fread(fid,numero_tir_fin*A*Nsequence+31,'int16','ieee-le') ;
     138        toto=fread(fid,numero_tir_fin*A*Nsequence+31,'int16','ieee-le') ;% why shift by 31 ?????
    129139        toto=double(bitxor(uint16(toto),uint16(2048)));
    130140        toto(1:31)=[];toto(numero_tir_fin*A*Nsequence)=mean(toto);
     
    136146    end
    137147   
    138     matrice_finale(:,:,numero_tir_debut:numero_tir_fin_old)=[];
    139     numero_tir_fin=numero_tir_fin-1;
    140     matrice_finale=reshape(filtfilt(BB,AA,matrice_finale(:,:)),size(matrice_finale));
     148   % matrice_finale(:,:,numero_tir_debut:numero_tir_fin_old)=[];%%%%%%% first field removed (when numero_tir_fin_old=1) ?????
     149     matrice_finale(:,:,numero_tir_debut:numero_tir_fin_old-1)=[];%%%%%%%
     150  %  numero_tir_fin=numero_tir_fin-1;  ?????
     151    matrice_finale=reshape(filtfilt(BB,AA,matrice_finale(:,:)),size(matrice_finale));% low pass filtered input signal,along first (time) index?
    141152   
    142153    % if soustraction==1
     
    149160   
    150161    %%%%%%%%%%%%%%Imagerie
    151     fe=rsf*1e6;%acquisition frequency
     162    fe=rsf*1e6;% sampling frequency for receptor (in Hz)
    152163    cc=1475;%speed of sound
    153164    hanning_window=25;
     
    176187    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    177188    for kk=1:size(matrice_finale,3)
    178         kk
    179         tir=kk;
    180         signal=squeeze(matrice_finale(interval,:,tir));
    181         tata_fft=zeros(size(signal,1),size(signal,2));
    182         tata_fft=fft(signal,[],1);
    183        
    184         if kk==1
    185            
     189        disp(kk)
     190        signal=squeeze(matrice_finale(interval,:,kk));
     191        tata_fft=fft(signal,[],1);%FFT of the time signal size=(2650,64)     
     192        if kk==1           
    186193            matrice_freq_mean=mean(abs(fft(signal,[],1)),2);
    187194            X=[freq1*1e6 freq2*1e6];
     
    193200       
    194201        for ii=1:length(image_r)
    195             [ii kk]
    196202            for jj=1:length(image_z)
    197203               
     
    250256    %%%%%%% TO ADAPT
    251257    for iii=1:size(image_fin,3)
    252         Data.Pressure=image_fin(:,:,iii);
     258        Data.A=image_fin(:,:,iii);% time lapse decreasesas z coordinate increases.
    253259        FileIndex=numero_tir_fin - pas_fichier+iii;%%%%%%TO CHECK!!!!!
    254260        %%%%%%%%%%
    255261        %eval(['save analyse_' name '_' num2str(number) '_' num2str(numero_tir_fin_old) '_' num2str(numero_tir_fin) '.mat'])
    256         OutputDir=[Param.OutputSubDir OutputDirExt];% subdirectory for output files
    257         OutputFile=fullfile_uvmat(OutputDir,'','signal','.nc','_00001',FileIndex);
     262        OutputFile=fullfile_uvmat(RootPath,OutputDir,'signal','.nc','_00001',FileIndex);
    258263        error=struct2nc(OutputFile,Data);%save result file
    259264        if isempty(error)
     
    263268        end
    264269    end
    265     numero_tir_fin_old=numero_tir_fin+1;
    266     if (numero_tir_fin_old+pas_fichier)>Nmoy
     270    numero_tir_fin_old=numero_tir_fin+1% first index for next bloc reading
     271     if (numero_tir_fin_old+pas_fichier-1)>Nmoy
    267272    test_fin_fichier=-1;
    268273    end
Note: See TracChangeset for help on using the changeset viewer.