recon package

Module contents

This module includes many of the useful MRI reconstruction functions. At the moment it includes stuff like FFTs, sum of squares, registration, and interpolation.

Submodules

recon.bart module

recon.bart.bart(nargout, cmd, *args)

This is the python interface for the bart toolbox. If you want more information about individual bart functions, go for

bart [command] -h

Parameters
  • nargout (int) – The number of outputs you expect

  • cmd (str) – The bart command to put in (exclude ‘bart’)

  • *args (variable) – The inputs into bart, and this can vary

Returns

output – The output from bart

Return type

array_like

recon.fftc module

Centered FFTs

recon.fftc.fft2c(data)

Centered FFT in two dimensions (dim0, dim1). All other dimensions are left alone.

Parameters

data (array_like) – The input to the FFT, must be 2D

Returns

dim1 – Output from the FFT

Return type

array_like

recon.fftc.fftc(data, dim)

Centered FFT. User specifies the dimension of the transform.

Parameters
  • data (array_like) – The input to the FFT

  • dim (int) – The dimension to take the FFT

Returns

Result – The result of the FFT

Return type

array_like

recon.fftc.ifft2c(data)

Centered iFFT in two dimensions (dim0, dim1). All other dimensions are left alone.

Parameters

data (array_like) – The input to the iFFT, must be 2D

Returns

dim1 – Output from the iFFT

Return type

array_like

recon.fftc.ifftc(data, dim)

Centered iFFT. User specifies the dimension of the transform.

Parameters
  • data (array_like) – The input to the iFFT

  • dim (int) – The dimension to take the iFFT

Returns

Result – The result of the iFFT

Return type

array_like

recon.imtools module

These are some basic tools for image processing. This includes basic sinc interpolation, image cropping, zeropadding, and registration.

recon.imtools.add_rician(v, s)

r = ricernd(v, s) returns random sample(s) from the Rice (aka Rician) distribution with parameters v and s. (either v or s may be arrays, if both are, they must match in size)

R ~ Rice(v, s) if R = sqrt(X^2 + Y^2), where X ~ N(v*cos(a), s^2) and Y ~ N(v*sin(a), s^2) are independent normal distributions (any real a). Note that v and s are not the mean and standard deviation of R!

The size of Y is the common size of the input arguments. A scalar input functions as a constant matrix of the same size as the other inputs.

Parameters
  • v (array_like) – Array to add noise to

  • s (float) – The Rician noise parameter

Returns

imOut – Magnitude image with Rician noise

Return type

array_like

recon.imtools.crop(im, cropy, cropx)

Crops or pads image to the specified dimensions. This assums that the original is up to 4D (dim0, dim1, dim2, dim3) and crops in dim0 and dim1.

Parameters
  • im (array_like) – Array to be cropped. Can be up to 4D

  • cropy (int) – Extent of cropping in dim0

  • cropx (int) – Extent of cropping in dim1

Returns

im – Output image

Return type

array_like

recon.imtools.interpolate(im, cropy, cropx)

This is sinc interpolation (in Fourier domain) along the first two dimensions of an array.

Parameters
  • im (Input image) – Image to be interpolated. Can be complex or real and can have up to four dimensions

  • cropy (int) – The extent of interpolation in y (first dimension)

  • cropx (int) – The extent of interpolation in x (second dimension)

Returns

im – Interpolated array

Return type

array_like

recon.imtools.register_2D(data, regType='SyNRA', verbose=True)

This is a 2D registration for a stack of images using ANTs

Parameters
  • data (array_like) – A stack of 2D images in a 3D array, with registration occurring on third dimension

  • regType (str) – Description of ANTs registration

  • verbose (bool) – Verbose output

Returns

dataReg – Array of 2D images that have been registered

Return type

array_like

recon.imtools.register_2d_model(data, numPrecontrastBlood=5, numPrecontrastTissue=7, numProtonDensity=10, sliceCheck=4, frameCheck=31)

This function is a wrapper for the matlab implentation of 2D registration for 4D perfusion datasets. This relies on the physiological model to handle the contrast changes from frame to frame. It uses a spline deformable model on the backend.

Parameters
  • data (array_like) – Unregistered 4D data to be registered in the (y, x, t, z) format (while data is 4D, registration happens only in 2D)

  • numPrecontrastBlood (int) – Number of pre contrast blood images

  • numPrecontrastTissue (int) – Number of pre contrast tissue images

  • numProtonDensity (int) – Number of proton density images

Returns

dataReg – Registered data array (4D)

Return type

array_like

recon.imtools.register_3D(data, regType='SyNRA', verbose=True)

This is a 3D registration for a stack of images using ANTs

Parameters
  • data (array_like) – A stack of 3D images in a 4D array, with registration occurring on third dimension

  • regType (str) – Description of ANTs registration

  • verbose (bool) – Verbose output

Returns

dataReg – Array of 3D images that have been registered

Return type

array_like

recon.imtools.register_3d_model(data, numPrecontrastBlood=5, numPrecontrastTissue=7, numProtonDensity=10, sliceCheck=4, frameCheck=31)

This function is a wrapper for the matlab implentation of 3D registration for 4D perfusion datasets. This relies on the physiological model to handle the contrast changes from frame to frame. It uses a spline deformable model on the backend.

Parameters
  • data (array_like) – Unregistered 4D data to be registered in the (y, x, t, z) format

  • numPrecontrastBlood (int) – Number of pre contrast blood images

  • numPrecontrastTissue (int) – Number of pre contrast tissue images

  • numProtonDensity (int) – Number of proton density images

Returns

dataReg – Registered data array (4D)

Return type

array_like

recon.sos module

Sum of squares coil combination

recon.sos.sos(data, dim)

Sum-of-squares combination. User specificies the dimension of the combination.

recon.tempinterp module