Changeset 109 for aedes_readfid.m


Ignore:
Timestamp:
Mar 15, 2010, 2:09:25 PM (9 years ago)
Author:
tjniskan
Message:
  • Added blocked processing of multireceiver EPI data for memory/speed

optimization.

M aedes_readfid.m
M aedes_revision.m

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aedes_readfid.m

    r108 r109  
    12721272
    12731273% Check the number of receivers (PI stuff)
    1274 if isfield(procpar,'rcvrs') && ~isempty(procpar.rcvrs)
     1274if isfield(procpar,'rcvrs') && ~isempty(procpar.rcvrs) && ...
     1275    length(procpar.rcvrs{1})>1
    12751276  % Multiple receivers used
    12761277  if isfield(procpar,'apptype') && strcmp(procpar.apptype{1},'imEPI')
     
    12791280    nRcv = length(find(procpar.rcvrs{1}=='y'));
    12801281    tmp_data = [];
    1281     kspace2 = [];
    12821282    nVols = size(kspace,3)/nRcv-1;
    12831283    data = zeros(procpar.nv,procpar.np/2,procpar.ns,nVols+1,'single');
    1284     lnum = length(num2str(nVols));
     1284    kssz=size(kspace);
     1285    blksz = 500; % Process EPI data in 500 volume blocks
     1286    nBlocks = ceil((size(kspace,3)/nRcv)/blksz);
     1287    lnum = length(num2str(nBlocks));
    12851288    lnumstr = num2str(lnum);
    12861289    bsl = lnum*2+1;
    1287     fprintf(1,['Processing volume...%0',lnumstr,'d/%0',lnumstr,'d'],1,nVols);
    1288     for kk=1:(size(kspace,3)/nRcv-1)
    1289       for ii=1:nRcv
    1290         tmp_kspace = l_ReconstructKspace(kspace(:,:,[ii kk*nRcv+ii]),procpar,Dat);
     1290    fprintf(1,'Processing data in blocks of %d volumes\n',blksz)
     1291    fprintf(1,['Processing block...%0',lnumstr,'d/%0',lnumstr,'d'],1,nBlocks);
     1292    for ii=1:nBlocks
     1293      for kk=1:nRcv
     1294        inds = [kk ((ii-1)*blksz*nRcv+kk):nRcv:min((nRcv*ii*blksz),kssz(3))];
     1295        if ii==1
     1296          % For first block, phase image is in inds twice
     1297          inds = inds(2:end);
     1298        end
     1299        tmp_kspace = l_ReconstructKspace(kspace(:,:,inds),procpar,Dat);
    12911300        tmp_data(:,:,:,:,ii) = fftshift(fftshift(fft(fft(tmp_kspace,[],1),[],2),1),2);
    1292        
    1293         %tmp_kspace = l_ReconstructKspace(kspace(:,:,ii:nRcv:end),procpar,Dat);
    1294         %kspace2(:,:,:,:,ii)=tmp_kspace;
    1295       end
    1296       if kk==1
    1297         data = sqrt(mean(tmp_data.*conj(tmp_data),5));
     1301      end
     1302      if ii==1
     1303        data = sqrt(sum(tmp_data.*conj(tmp_data),5));
     1304      elseif ii==nBlocks
     1305        data(:,:,:,((ii-1)*blksz+1):end) = sqrt(sum(tmp_data(:,:,:,2,:).*conj(tmp_data(:,:,:,2,:)),5));
    12981306      else
    1299         data(:,:,:,kk+1) = sqrt(mean(tmp_data(:,:,:,2,:).*conj(tmp_data(:,:,:,2,:)),5));
     1307        data(:,:,:,((ii-1)*blksz+1):(ii*blksz)) = sqrt(sum(tmp_data(:,:,:,2,:).*conj(tmp_data(:,:,:,2,:)),5));
    13001308      end
    13011309      fprintf(1,repmat('\b',1,bsl));
    1302       fprintf(1,['%0',lnumstr,'d/%0',lnumstr,'d'],kk,nVols);
     1310      fprintf(1,['%0',lnumstr,'d/%0',lnumstr,'d'],ii,nBlocks);
    13031311    end
    13041312    fprintf(1,'\n')
    1305     %kspace = kspace2;
    1306     %data = fftshift(fftshift(fft(fft(kspace,[],1),[],2),1),2);
    1307     %data = sqrt(mean(data.*conj(data),5));
    1308     %kspace2=[];
     1313   
     1314%     for kk=1:(size(kspace,3)/nRcv-1)
     1315%       for ii=1:nRcv
     1316%         tmp_kspace = l_ReconstructKspace(kspace(:,:,[ii kk*nRcv+ii]),procpar,Dat);
     1317%         tmp_data(:,:,:,:,ii) = fftshift(fftshift(fft(fft(tmp_kspace,[],1),[],2),1),2);
     1318%         
     1319%         %tmp_kspace = l_ReconstructKspace(kspace(:,:,ii:nRcv:end),procpar,Dat);
     1320%         %kspace2(:,:,:,:,ii)=tmp_kspace;
     1321%       end
     1322%       if kk==1
     1323%         data = sqrt(mean(tmp_data.*conj(tmp_data),5));
     1324%       else
     1325%         data(:,:,:,kk+1) = sqrt(mean(tmp_data(:,:,:,2,:).*conj(tmp_data(:,:,:,2,:)),5));
     1326%       end
     1327%       fprintf(1,repmat('\b',1,bsl));
     1328%       fprintf(1,['%0',lnumstr,'d/%0',lnumstr,'d'],kk,nVols);
     1329%     end
     1330%     fprintf(1,'\n')
     1331%     %kspace = kspace2;
     1332%     %data = fftshift(fftshift(fft(fft(kspace,[],1),[],2),1),2);
     1333%     %data = sqrt(mean(data.*conj(data),5));
     1334%     %kspace2=[];
    13091335   
    13101336    % Remove reference image if requested
Note: See TracChangeset for help on using the changeset viewer.

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