Changeset 113 for aedes_readfid.m


Ignore:
Timestamp:
Mar 18, 2010, 2:27:46 PM (9 years ago)
Author:
tjniskan
Message:
  • Iterating...

M aedes_readfid.m
M aedes_revision.m

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aedes_readfid.m

    r112 r113  
    908908  end
    909909else
    910   kspace = [];
     910  %kspace = [];
     911   kspace = zeros(hdr.FileHeader.np/2*hdr.FileHeader.ntraces,...
     912     hdr.FileHeader.nblocks,Dat.precision);
    911913end
    912914
     
    10591061  d=dir(fopen(file_fid));
    10601062  file_sz = d.bytes/1024/1024; % File size in MB
    1061   nBlocks = ceil(file_sz/500); % Read data in 500 MB blocks
     1063  if file_sz<500
     1064    nBlocks = 1;
     1065  else
     1066    nBlocks = ceil(file_sz/500); % Read data in 500 MB blocks
     1067  end
    10621068 
    10631069  % Initialize waitbar
     
    11131119  nVals = (nbheaders*28)/prec;
    11141120 
    1115  
    1116  
    1117   % Read the whole data including block headers etc...
    1118   kspace = fread(file_fid,inf,prec_str);
    1119   kspace=reshape(kspace,nVals+hdr.FileHeader.np*hdr.FileHeader.ntraces,[]);
    1120  
    1121   % Remove block headers from the data
    1122   kspace(1:nVals,:)=[];
    1123   %kspace=kspace(nVals+1:end,:);
    1124  
    1125   % Transform to complex values
    1126   kspace = reshape(kspace,hdr.FileHeader.np,...
    1127         hdr.FileHeader.ntraces,hdr.FileHeader.nblocks);
    1128  
    1129   % Do DC-correction if necessary
    1130   if ~Dat.DCcorrection || ( nt(1)>1 )
    1131     kspace=complex(kspace(1:2:end,:,:),kspace(2:2:end,:,:));
    1132   else
    1133     kspace=complex(kspace(1:2:end,:,:)-hdr.BlockHeaders.lvl,...
    1134       kspace(2:2:end,:,:)-hdr.BlockHeaders.tlt);
    1135   end
     1121  count = 1;
     1122  nbh = floor(nbheaders/nBlocks);
     1123  szh = nVals+hdr.FileHeader.np*hdr.FileHeader.ntraces;
     1124  for ii=1:nBlocks
     1125   
     1126    % Read the whole data including block headers etc...
     1127    if ii==nBlocks
     1128      tmp = fread(file_fid,inf,prec_str);
     1129    else
     1130      tmp = fread(file_fid,nbh*szh,prec_str);
     1131    end
     1132    tmp=reshape(tmp,nVals+hdr.FileHeader.np*hdr.FileHeader.ntraces,[]);
     1133    tmp(1:nVals,:)=[];
     1134   
     1135    if ii==nBlocks
     1136      inds = ((nBlocks-1)*nbh+1):size(kspace,2);
     1137    else
     1138      inds = ((nBlocks-1)*nbh+1):nBlocks*nbh;
     1139    end
     1140   
     1141    % Do DC-correction if necessary
     1142    if ~Dat.DCcorrection || ( nt(1)>1 )
     1143      kspace(:,inds)=complex(tmp(1:2:end,:,:),tmp(2:2:end,:,:));
     1144    else
     1145      kspace(:,inds)=complex(tmp(1:2:end,:,:)-hdr.BlockHeaders.lvl,...
     1146        tmp(2:2:end,:,:)-hdr.BlockHeaders.tlt);
     1147    end
     1148  end
     1149  clear tmp
     1150 
     1151  % Transform to 3D matrix
     1152  kspace = reshape(kspace,hdr.FileHeader.np/2,...
     1153    hdr.FileHeader.ntraces,hdr.FileHeader.nblocks);
     1154
     1155 
     1156%   % Read the whole data including block headers etc...
     1157%   kspace = fread(file_fid,inf,prec_str);
     1158%   kspace=reshape(kspace,nVals+hdr.FileHeader.np*hdr.FileHeader.ntraces,[]);
     1159%   
     1160%   % Remove block headers from the data
     1161%   kspace(1:nVals,:)=[];
     1162%   %kspace=kspace(nVals+1:end,:);
     1163%   
     1164%   % Transform to complex values
     1165%   kspace = reshape(kspace,hdr.FileHeader.np,...
     1166%       hdr.FileHeader.ntraces,hdr.FileHeader.nblocks);
     1167%   
     1168%   % Do DC-correction if necessary
     1169%   if ~Dat.DCcorrection || ( nt(1)>1 )
     1170%     kspace=complex(kspace(1:2:end,:,:),kspace(2:2:end,:,:));
     1171%   else
     1172%     kspace=complex(kspace(1:2:end,:,:)-hdr.BlockHeaders.lvl,...
     1173%       kspace(2:2:end,:,:)-hdr.BlockHeaders.tlt);
     1174%   end
    11361175 
    11371176  %% Store and order k-space values
     
    12991338    for ii=1:nBlocks
    13001339      fprintf(1,repmat('\b',1,bsl));
    1301       fprintf(1,['Processing block...%0',lnumstr,'d/%0',lnumstr,'d'],ii,nBlocks);
     1340      fprintf(1,['%0',lnumstr,'d/%0',lnumstr,'d'],ii,nBlocks);
    13021341      tmp_data = [];
    13031342      for kk=1:nRcv
     
    13111350      end
    13121351      if ii==1
    1313         data = sqrt(sum(tmp_data.*conj(tmp_data),5));
     1352        data(:,:,:,1:size(tmp_data,4)) = sqrt(sum(tmp_data.*conj(tmp_data),5));
    13141353      elseif ii==nBlocks
    13151354        data(:,:,:,((ii-1)*blksz+1):(nVols+1)) = sqrt(sum(tmp_data(:,:,:,2:end,:).*conj(tmp_data(:,:,:,2:end,:)),5));
Note: See TracChangeset for help on using the changeset viewer.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008