Changeset 176 for aedes_readbruker.m


Ignore:
Timestamp:
Sep 7, 2011, 3:28:59 PM (8 years ago)
Author:
tjniskan
Message:
  • EPI is now read into a 4D matrix from Bruker 2dseq files.
  • Some modifications to Bruker raw data reading. Still far from ready though...

M aedes_readbruker.m
M aedes_revision.m

File:
1 edited

Legend:

Unmodified
Added
Removed
  • aedes_readbruker.m

    r175 r176  
    5050%                                               % 4=return raw kspace
    5151%
     52%        'wbar'        : [ {'on'} | 'off' ]     % Show/hide waitbar
    5253%
    5354%
     
    7778DATA = [];
    7879isRawData = true;
     80Dat.showWbar = true;
    7981Dat.precision = 'double';
    8082
     
    114116                error(msg);
    115117        end
    116         [data,kspace,msg] = l_ReadDataFid(filename,hdr,Dat);
     118        [data,kspace,pe1_table,msg] = l_ReadDataFid(filename,hdr,Dat);
    117119        DATA.DataFormat = 'bruker_raw';
    118120else
     
    123125        [data,kspace,msg] = l_ReadData2dseq(filename,hdr,Dat);
    124126        DATA.DataFormat = 'bruker_reco';
     127        pe1_table = [];
    125128end
    126129if isempty(data)
     
    136139DATA.KSPACE = kspace;
    137140DATA.PROCPAR = [];
    138 DATA.PHASETABLE = [];
     141DATA.PHASETABLE = pe1_table;
    139142
    140143
     
    258261% Read raw Bruker data (fid files)
    259262%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    260 function [data,kspace,msg] = l_ReadDataFid(filename,hdr,Dat)
     263function [data,kspace,pe1_table,msg] = l_ReadDataFid(filename,hdr,Dat)
    261264
    262265data = [];
     
    309312
    310313% Reconstruct k-space
    311 [kspace,msg] = l_ReconstructKspace(kspace,hdr,Dat);
     314[kspace,pe1_table,msg] = l_ReconstructKspace(kspace,hdr,Dat);
    312315if isempty(kspace)
    313316        kspace = [];
     
    399402end
    400403
     404% Show waitbar
     405if Dat.showWbar
     406        wbh = aedes_calc_wait('Reading data from Bruker 2dseq file.');
     407end
     408
    401409% Read data
    402410if ~isDataComplex
     
    421429        end
    422430       
     431        % The length of RECO_transposition should be same as NI.
     432        NI = length(hdr.reco.RECO_transposition);
     433        if NI~=hdr.d3proc.IM_SIZ
     434                data = reshape(data,hdr.d3proc.IM_SIY,...
     435                        hdr.d3proc.IM_SIX,NI,[]);
     436        end
     437       
    423438else
    424439        % - Read complex data -----------------------------------
    425440        msg = 'Reading complex data from 2dseq has not been implemented yet.';
     441        if Dat.showWbar
     442                close(wbh);
     443        end
    426444        fclose(fid);
    427445        return
    428446end
    429447
    430 
     448% Close waitbar
     449if Dat.showWbar
     450        close(wbh);
     451end
    431452
    432453%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    433454% Reconstruct k-space
    434455%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    435 function [kspace,msg] = l_ReconstructKspace(kspace,hdr,Dat)
     456function [kspace,pe1_table,msg] = l_ReconstructKspace(kspace,hdr,Dat)
    436457
    437458msg = '';
     
    443464phase_factor = hdr.acqp.ACQ_phase_factor; % scans belonging to a single image
    444465nDims = hdr.acqp.ACQ_dim;
    445 im_size = hdr.acqp.ACQ_size;
     466im_size = hdr.acqp.ACQ_size;im_size(1)=im_size(1)/2;
    446467order = hdr.acqp.ACQ_obj_order;
    447468
    448469% Get phase table
    449 %pe_table = hdr.method.PVM_EncSteps1+(-min(hdr.method.PVM_EncSteps1(:))+1);
    450 [s,pe1_table] = sort(hdr.acqp.ACQ_spatial_phase_1);
     470usePeTable = true;
     471if isfield(hdr.acqp,'ACQ_spatial_phase_1')
     472        [s,pe1_table] = sort(hdr.acqp.ACQ_spatial_phase_1);
     473elseif isfield(hdr.method,'PVM_EncSteps1')
     474        pe1_table = hdr.method.PVM_EncSteps1+(-min(hdr.method.PVM_EncSteps1(:))+1);
     475else
     476        pe1_table = [];
     477        usePeTable = false;
     478end
    451479
    452480% Reshape data so that all echoes are in correct planes
    453 kspace = reshape(kspace,im_size(1)/2,...
    454         phase_factor,NI,length(pe1_table)/phase_factor,NR);
     481kspace = reshape(kspace,im_size(1),...
     482        phase_factor,NI,im_size(2)/phase_factor,NR);
    455483kspace = permute(kspace,[1 2 4 3 5]);
    456 kspace = reshape(kspace,im_size(1)/2,im_size(2),NI,NR);
     484kspace = reshape(kspace,im_size(1),im_size(2),NI,NR);
     485
     486% Handle EPI data
     487if strncmpi(hdr.acqp.PULPROG,'EPI',3)
     488        epi_matrix_size = hdr.method.PVM_Matrix;
     489        kspace = reshape(kspace,epi_matrix_size(1),epi_matrix_size(2),NSLICES,NR);
     490end
    457491
    458492% Sort echoes
    459 kspace = kspace(:,pe1_table,:,:);
     493if usePeTable
     494        kspace = kspace(:,pe1_table,:,:);
     495end
    460496
    461497% Sort object order
Note: See TracChangeset for help on using the changeset viewer.

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