function [data,drh,status]=sw06_readRec_shru(fid)
% -----------------------------------------------------------------------
%   sw06_readRec_shru
%
%        Reads a series of m-sequences (un-compressed) and header
%        from a datafile
%        at the current location. Make sure it is at
%        the beginning of a data record.   
%
%
%        Converts raw data to volts
%
%        Also returns header associated with that data record.
%
%       [DATA,DRH,STATUS] = sw06_readRec_shru(fid); 
% 
%  Remember:  File should be opened big endian for shru
%               fid = fopen(filename,'rb','ieee-be');
%
%
%  NOTE:  header for shru at the present is only 1008 bytes long
%   Don't know where data starts/ends...mmChanged.. in sample files only
%
%
%   SW06 shru data ONLY    
%			Newhall  2006
%-------------------------------------------------------------------------

channel = 1;   % only 1 channel on shru
 
  % ------------------------------------------
  %   some variables we have to know and set
  
  DEBUG=1;
 
  nch = 1;                        % one channel for shru
  sfreq = 2.5e6/256;              % 9765.625Hz
  spts = 625000;                  %  625000 for shru
  bytes_rec = 1250000;           % number of bytes in data record for SHRU
  % bytes_rec = nch * spts * 2;
  bytes_hdr = 1024;               % really a trailer
  total_b_rec = bytes_rec + bytes_hdr;
  nrecords = 128;
  
  status = 0;
  % ------------------------------------------
  
  % get  data record header 
  [drh, status] = sw06_getDRH_shru(fid);     % read header (trailer)
  if (status < 0)
      drh=[];data=[];
      fprintf('Error: End of file found during header read...\n');
      return;
  end
  
  % Get data record, all channels
  [all_data, count]=fread(fid,[nch,spts],'short'); % read 1 record of data
  if (count < 0)
      data = []; drh=[]; status=-1;
      fprintf('Error: End of file found during data read...\n');
      return;
  end
  
  % save only data to be returned.
  data = all_data(channel,:);
  
   %% from keith
   fixed_gain = 10^(26/20);    % linear - fixed gain is 10 for shark, 20 (26dB) for shru..
   ADC_halfscale = 2.5;  % ADC half scale volts (+/- half scale is ADC i/p range)
   ADC_maxvalue = 8192; % ADC maximum halfscale o/p value, half the 2's complement range
   norm_factor = ADC_halfscale/ADC_maxvalue/fixed_gain;
  
  % Now we clip off the last two bits as a gain (actually an exponent)
 
  data=data/4;
  mant=floor(data);
	% "floor" is required due to the nature of negative binary numbers
	gain=4*(data-floor(data));
	% exp=gain;
	gain=(2*(ones(length(channel),spts))).^(3*gain);
    
    data=data*norm_factor./gain;
    
    
% ------------------------------------------------------------------- 
 
