Changeset 153 for vnmr_recon/epi_recon.m
 Timestamp:
 Jan 20, 2011, 2:17:49 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

vnmr_recon/epi_recon.m
r152 r153 44 44 45 45 46 data = abs(fftshift(fftshift(fft(fft(kspace,[],1),[],2),1),2)); 47 data = permute(data,[2 1 3 4]); 48 data = flipdim(flipdim(data,1),2); 49 data(:,:,:,1) = []; % Remove reference image 50 46 51 % =================================== 47 52 % Reconstruct VNMRj and EPIP sequences … … 77 82 ns = procpar.ns; 78 83 79 % Phase sampling84 80 85 if isEPIP 81 nv = procpar.nphase; 82 83 % Read sampling 84 np = procpar.nread/2; 86 nv = procpar.nphase; % Phase sampling 87 np = procpar.nread/2; % Read sampling 85 88 else 86 89 nv = procpar.nv; … … 89 92 90 93 % Get orientation 91 orient = procpar.orient{1} 94 orient = procpar.orient{1}; 92 95 93 96 % Remove navigators 94 97 if nNav~=0 95 98 nav_data = kspace(1:(np*nNav),:); 96 kspace(1:(np*nNav),:)=[];99 %kspace(1:(np*nNav),:)=[]; 97 100 else 98 101 nav_data = []; … … 100 103 101 104 if Dat.EPIPhasedArrayData 102 data = zeros(nv,np,ns,nVols,nRcv ,'single');105 data = zeros(nv,np,ns,nVols,nRcvrs,'single'); 103 106 else 104 107 data = zeros(nv,np,ns,nVols,'single'); … … 106 109 107 110 % Reshape kspace and detach reference images 108 if isEPIP 109 kspace = reshape(kspace,np,nv,nRcvrs,ns,nVols+nRef); 110 else 111 kspace = reshape(kspace,np,nv,nRcvrs,ns,nVols+nRef); 112 end 111 kspace = reshape(kspace,np,nv+nNav,ns,nRcvrs,nVols+nRef); 113 112 114 113 % Flip even kspace lines 115 if ~Dat.FastDataRead 116 for tt=2:2:size(kspace,2) 117 kspace(:,tt,:,:,:) = flipdim(kspace(:,tt,:,:,:),1); 118 end 119 else 120 kspace(:,2:2:end,:,:,:) = flipdim(kspace(:,2:2:end,:,:,:),1); 121 end 122 ref_data = kspace(:,:,:,:,1:nRef); 123 kspace(:,:,:,:,1:nRef)=[]; 114 % if ~Dat.FastDataRead 115 % for tt=2+nNav:2:size(kspace,2) 116 % kspace(:,tt,:,:,:) = flipdim(kspace(:,tt,:,:,:),1); 117 % end 118 % else 119 % for tt=2+nNav:2:size(kspace,2) 120 % kspace(:,tt,:,:,:) = flipdim(kspace(:,tt,:,:,:),1); 121 % end 122 % %kspace(:,2+nNav:2:end,:,:,:) = flipdim(kspace(:,2+nNav:2:end,:,:,:),1); 123 % end 124 ref_data = kspace(:,nNav+1:end,:,:,1:nRef); 125 ref_data(:,2:2:end,:,:,:) = flipdim(ref_data(:,2:2:end,:,:,:),1); 126 %kspace(:,:,:,:,1:nRef)=[]; 124 127 125 128 % Calculate phase corrections for all receivers … … 128 131 for ii=1:nRcvrs 129 132 if nRef==1 130 ref_im = ref_data(:,:, ii,:,1);133 ref_im = ref_data(:,:,:,ii,1); 131 134 phase1 = exp(sqrt(1)*angle(fft(ref_im,[],1))); 132 135 rev_phase = 1; 133 phase_e(:,:, ii,:,:) = phase1;136 phase_e(:,:,:,ii,:) = phase1; 134 137 elseif nRef==3 135 138 ref1_ind = find(procpar.image==0,1); 136 ref1 = ref_data(:,:, ii,:,ref1_ind);139 ref1 = ref_data(:,:,:,ii,ref1_ind); 137 140 phase1 = exp(sqrt(1)*angle(fft(ref1,[],1))); 138 141 139 142 ref2_ind = find(procpar.image==2,1); 140 ref2 = flipdim(ref_data(:,:, ii,:,ref2_ind),1);143 ref2 = flipdim(ref_data(:,:,:,ii,ref2_ind),1); 141 144 phase2 = exp(sqrt(1)*angle(fft(ref2,[],1))); 142 145 143 146 im1_ind = find(procpar.image==1,1); 144 im1 = flipdim(ref_data(:,:, ii,:,im1_ind),1);147 im1 = flipdim(ref_data(:,:,:,ii,im1_ind),1); 145 148 146 rev_phase(:,:, ii,:,:) = fft(im1,[],1).*phase2;147 phase_e(:,:, ii,:,:) = phase1;149 rev_phase(:,:,:,ii,:) = fft(im1,[],1).*phase2; 150 phase_e(:,:,:,ii,:) = phase1; 148 151 end 149 152 end … … 164 167 tmp_data = []; 165 168 if ii==nBlocks 166 vol_inds = (ii1)*blksz+1 :nVols;169 vol_inds = (ii1)*blksz+1+nRef:nVols+nRef; 167 170 else 168 vol_inds = (ii1)*blksz+1:ii*blksz; 169 end 170 tmp_kspace = kspace(:,:,:,:,vol_inds); 171 171 vol_inds = (ii1)*blksz+1+nRef:ii*blksz+nRef; 172 end 173 tmp_kspace = kspace(:,nNav+1:end,:,:,vol_inds); 174 175 % Flip even lines 176 tmp_kspace(:,2:2:end,:,:,:) = flipdim(tmp_kspace(:,2:2:end,:,:,:),1); 177 172 178 for kk=1:nRcvrs 173 179 if nRef==3 174 180 for tt=1:length(vol_inds) 175 tmp_kspace(:,:, kk,:,tt) = ifft(rev_phase(:,:,kk,:,:)+fft(kspace(:,:,kk,:,vol_inds(tt)),[],1).*phase_e(:,:,kk,:,:));181 tmp_kspace(:,:,:,kk,tt) = ifft(rev_phase(:,:,:,kk,:)+fft(tmp_kspace(:,:,:,kk,tt),[],1).*phase_e(:,:,:,kk,:)); 176 182 end 177 183 else 178 184 for tt=1:length(vol_inds) 179 tmp_kspace(:,:, kk,:,tt) = ifft(fft(kspace(:,:,kk,:,vol_inds(tt)),[],1).*phase_e(:,:,kk,:,:));185 tmp_kspace(:,:,:,kk,tt) = ifft(fft(tmp_kspace(:,:,:,kk,tt),[],1).*phase_e(:,:,:,kk,:)); 180 186 end 181 187 end … … 186 192 if Dat.EPIPhasedArrayData 187 193 data_block = abs(tmp_data); 188 data_block = permute(data_block,[1 2 4 5 3]);189 194 % Permute to correct orientation 190 195 if strcmpi(orient,'trans90') 191 data_block = permute(data_block,[2 1 3 4 5]); 196 data_block = permute(data_block,[2 1 3 5 4]); 197 data_block = flipdim(data_block,2); 198 else 199 data_block = permute(data_block,[1 2 3 5 4]); 192 200 end 193 data(:,:,:, vol_inds,:) = data_block;201 data(:,:,:,:,vol_indsnRef) = data_block; 194 202 else 195 data_block = sqrt(sum(tmp_data.*conj(tmp_data), 3));203 data_block = sqrt(sum(tmp_data.*conj(tmp_data),4)); 196 204 % Permute to correct orientation 197 205 if strcmpi(orient,'trans90') 198 data_block = permute(data_block,[2 1 3 4 5]); 206 data_block = permute(data_block,[2 1 3 5 4]); 207 data_block = flipdim(data_block,2); 199 208 end 200 data(:,:,:,vol_inds ) = squeeze(data_block);209 data(:,:,:,vol_indsnRef) = squeeze(data_block); 201 210 end 202 211 203 212 end 204 213 fprintf(1,'\n') 205 206 214 end 207 215
Note: See TracChangeset
for help on using the changeset viewer.