frame_timing_correct

PURPOSE ^

FRAME_TIMING_CORRECT: Corrects serially collected *.get data so that each

SYNOPSIS ^

function [c_data, stats]= frame_timing_correct(raw_data, method, fwd_model)

DESCRIPTION ^

 FRAME_TIMING_CORRECT: Corrects serially collected *.get data so that each
 frame appears to come from an instantaneous point in time.

 c_data = frame_timing_correct(filenames, framerates, method)
   raw_data     = input data
   method       = 'FFT' or 'linear' (interpolation method)
   c_data       = output data 208 x N_frames
   stats.change = change in output
   fwd_model    = fwd_model (currently ignored)

Corrects serially collected *.get data so that each frame appears 
to come from an instantaneous point in time.
outputs *_corrected.get & associated *_corrected.prl files
intended to be a standalone compilable file.

 ISSUES WITH CODE:
   - FFT method assumes wrap-around. This means the first and last several frames incorrect
   - Code creates its own data reader - should use eidors_readdata
   - Code should be able to parse the stim_meas patterns, not assume them

CITATION_REQUEST:
  AUTHOR: Rebecca Yerworth and Richard Bayford
  TITLE: The effect of serial data collection on the accuracy of
  electrical impedance tomography images
  JOURNAL: Physiological Measurement
  VOL: 34
  NUM: 6
  YEAR: 2013
  PAGE: 659-669
  LINK: http://iopscience.iop.org/0967-3334/34/6/659/pdf/0967-3334_34_6_659.pdf
  DOI: 10.1088/0967-3334/34/6/659
  PUBMED:  23719130
 
%
try
   citeme(serial_correction)
end

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  [c_data, stats]= frame_timing_correct(raw_data, method, fwd_model)
0002 % FRAME_TIMING_CORRECT: Corrects serially collected *.get data so that each
0003 % frame appears to come from an instantaneous point in time.
0004 %
0005 % c_data = frame_timing_correct(filenames, framerates, method)
0006 %   raw_data     = input data
0007 %   method       = 'FFT' or 'linear' (interpolation method)
0008 %   c_data       = output data 208 x N_frames
0009 %   stats.change = change in output
0010 %   fwd_model    = fwd_model (currently ignored)
0011 %
0012 %Corrects serially collected *.get data so that each frame appears
0013 %to come from an instantaneous point in time.
0014 %outputs *_corrected.get & associated *_corrected.prl files
0015 %intended to be a standalone compilable file.
0016 %
0017 % ISSUES WITH CODE:
0018 %   - FFT method assumes wrap-around. This means the first and last several frames incorrect
0019 %   - Code creates its own data reader - should use eidors_readdata
0020 %   - Code should be able to parse the stim_meas patterns, not assume them
0021 %
0022 %CITATION_REQUEST:
0023 %  AUTHOR: Rebecca Yerworth and Richard Bayford
0024 %  TITLE: The effect of serial data collection on the accuracy of
0025 %  electrical impedance tomography images
0026 %  JOURNAL: Physiological Measurement
0027 %  VOL: 34
0028 %  NUM: 6
0029 %  YEAR: 2013
0030 %  PAGE: 659-669
0031 %  LINK: http://iopscience.iop.org/0967-3334/34/6/659/pdf/0967-3334_34_6_659.pdf
0032 %  DOI: 10.1088/0967-3334/34/6/659
0033 %  PUBMED:  23719130
0034 %
0035 %%
0036 %try
0037  %   citeme(serial_correction)
0038 %end
0039 
0040 if nargin<=2
0041    method='fft'; % other choice is linear
0042 end
0043 if nargin>=3
0044    eidors_msg('frame_timing_correct: ignoring fwd_model',1);
0045 end
0046 
0047 %generate protocol
0048 %imdl.fwd_model.stimulation=mk_stim_patterns(16,1,[0,1],[0,1],{'no_meas_current'},1);
0049 %n_stim_pattern = size(imdl.fwd_model.stimulation,2);
0050 %n_meas_pattern = size(imdl.fwd_model.stimulation(1).meas_pattern,1);
0051 %prt_len = n_stim_pattern*n_meas_pattern;  %protocol lenght
0052 prt_len=208;
0053 prt_time=0:1/(prt_len):1-1/(prt_len); %subframe timings relative to frame length
0054 
0055     
0056 switch upper(method)
0057    case 'FFT'
0058         NFFT=size(raw_data,2);
0059         c_ave=zeros(prt_len,floor(NFFT/2));
0060         c_data=zeros(prt_len,NFFT);
0061         for e=1:prt_len % for each electrode combination
0062             Y = fft(raw_data(e,1:NFFT)',NFFT)/NFFT;
0063             a=angle(Y(2:floor(NFFT/2)))-2*pi*(1:NFFT/2-1)'*prt_time(e)/NFFT;
0064             c_ave(e,1)=Y(1); %Y_phase corrected
0065             c_ave(e,2:floor(NFFT/2))=2*(cos(a).*abs(Y(2:floor(NFFT/2)))+1i*sin(a).*abs(Y(2:floor(NFFT/2))));
0066             if isreal(raw_data)
0067                 c_data(e,:)=real(ifft(c_ave(e,:),NFFT))*NFFT;
0068             else
0069                 c_data(e,:)=(ifft(c_ave(e,:),NFFT))*NFFT;
0070             end
0071             c_ave=c_ave(:,1);
0072         end
0073    case 'LINEAR'
0074         %do linear interpolation
0075         c_data=zeros(prt_len,size(raw_data,2)-1);
0076         c_data(:,1)=raw_data(:,1); %first time frame not lag corrected.
0077         for t = 2:size(raw_data,2)
0078             c_data(:,t)=(raw_data(:,t-1)+(raw_data(:,t)-raw_data(:,t-1)).*(1-prt_time'));
0079         end
0080         c_ave=mean(c_data,2); %average frame
0081    otherwise 
0082       error('no interpolation method %s available',method)
0083 end
0084   
0085 
0086 stats.change = abs((c_data(1:208,:)-raw_data)./raw_data);

Generated on Fri 30-Dec-2022 19:44:54 by m2html © 2005