Array functions and settings#

The functions of the bartorch namespace. Shapes are C order, and an axis argument is an index into a tensor’s shape.

Fourier transforms#

fft

Fourier transform along axes, centred by default.

ifft

Inverse Fourier transform along axes: fft() with inverse=True.

fftshift

Move the zero frequency to the middle along axes, or back with inverse.

fftmod

Multiply by the alternating phase that centres an uncentred transform, along axes.

nufft

Non-uniform Fourier transform of an image to samples along traj.

nufft_adjoint

Adjoint of nufft(): samples along traj back to an image.

Wavelet transforms#

fwt

Forward multi-level discrete wavelet transform along axes.

iwt

Wavelet synthesis along axes: coefficients from fwt() back to samples.

Thresholding#

soft_thresh

Soft thresholding, x * max(1 - lamda / |x|, 0).

hard_thresh

Hard thresholding: keep x where |x| > lamda, zero elsewhere (-H).

Array utilities#

resize

Crop or zero-pad input to oshape.

flip

Reverse input along axes.

circshift

Cyclic shift along axes: element i moves to (i + shift) % n, as torch.roll.

conv

Cyclic convolution of input with kernel along axes, of the input's shape.

window

Multiply by a Hamming window along each of axes, or a Hann window (-H).

median_filter

Median over each window of length consecutive elements along axis (-m, -l).

moving_average

Mean over each window of length consecutive elements along axis (-a, -l).

normalize

Divide by the l2 norm over axes, or the l1 norm (-b), per index of the other axes.

mip

Maximum (or minimum, -m) intensity projection over axes, which are kept as size one.

unwrap

Unwrap the real part along axis: remove the jumps a period of 2 * bound puts in it.

casorati

Casorati matrix of the overlapping blocks of input.

rss

Root of the sum of squared magnitudes over axes.

Interpolation#

interpolate

Sample input at the voxel positions coord along axes.

warp

Pull input through a displacement field: out[p] = input(p + displacement[p]).

affine_transform

Resample input on an affinely mapped grid: out(u) = input(matrix @ [u, 1]).

fovshift

Shift the field of view of k-space data by a linear phase.

Registration#

register_affine

Affine transform that maps reference onto moved, by mutual information.

register_nonrigid

Displacement field from reference into moved, by greedy SyN or TV-L1 optical flow.

estimate_shift

Sub-voxel shift that moves b onto a, from the phase of their cross-spectrum.

Image-quality metrics#

nrmse

Normalized root mean square error ‖input - reference‖ / ‖reference‖.

mse

Mean squared error mean |input - reference|² over every element (--mse).

ssim

Mean structural similarity of the magnitudes (--ssim).

psnr

Peak signal-to-noise ratio of the magnitudes in decibels, averaged over images (--psnr).

roi_stat

Statistic of input over the region roi.

Coil kernels#

maps_to_kernels

Coil sensitivities as k-space kernels: the centre of each map's unitary spectrum.

kernels_to_maps

The maps a kernel bank stands for: zero-padded to spatial and transformed back.

Interoperability#

to_deepinv

A LinearOperator as a deepinv.physics.LinearPhysics.

Errors#

BartError

A BART command or operator failed; the message is BART's.

Runtime settings#

set_num_threads

Set the number of threads BART, its FFT and FINUFFT's host transforms use.

set_copy_inputs

Whether a command works on a private copy of each input, which is the default.

set_debug_level

Set BART's verbosity: 0 errors, 1 warnings, 2 info, 3 and up debug.

get_debug_level

CUDA#

cuda_available

Whether BART can run on a CUDA device: built with CUDA, and a device present.

set_cuda_streams

Set the number of CUDA streams BART runs on, 1 to 8.

use_cuda_memcache

Whether BART keeps freed device memory for its own reuse.

Build information#

bart_version

Version string of the embedded BART.

build_info

How the library was built: BART version, compiler, nested-function mode, CUDA.

backend_sources

The library serving each BLAS and LAPACK routine, and the FFT.