ncigt-fil
|
An FFT resource manager and associated functions. More...
Functions | |
int | fft1d (void *args) |
int | fft_mngr_alloc_2dfft (fil_fft_mngr *mngr, int M, int N, char direction) |
int | fft_mngr_alloc_fft (fil_fft_mngr *mngr, int N, char direction) |
int | fft_mngr_init (fil_fft_mngr *mngr) |
int | fft_mngr_quit (fil_fft_mngr *mngr) |
void | fft_t (short ncoils, short nf, short nz, short ny, short nx, char direction, fil_fft_mngr *mngr, short center, COMPLEX *data_in, COMPLEX *data_out) |
void | fftx (short ncoils, short Nf, int Nyz, short Nx, char dir, fil_fft_mngr *mngr, short center, COMPLEX *data) |
void | ffty (short ncoils, short nf, short nz, short ny, short nx, char direction, fil_fft_mngr *mngr, short center, COMPLEX *data) |
void | fftz (short ncoils, short nf, short nz, short ny, short nx, char direction, fil_fft_mngr *mngr, short center, COMPLEX *data_in, COMPLEX *data_out) |
int | fil_2dfft (fil_fft_mngr *mngr, int M, int N, COMPLEX *data, char dir) |
int | fil_fft (fil_fft_mngr *mngr, int N, COMPLEX *data, char dir, int unused) |
void | fil_fft_shift (COMPLEX *data, int Nx, int Ny) |
An FFT resource manager and associated functions.
This suite of functions provides a resource manager for Fast Fourier Transforms, in order to alleviate memory management bookkeeping.
The use of NC-IGT Fast Imaging Library (FIL) FFT manager facilitates reuse of scratch buffers needed by the FFT functions. Scratch buffers can be allocated at the start of a program, and used by multiple functions afterwards. Calling an FFT function with an initialized manager will create scratch space if there is none pre-allocated. Furthermore, if the FFT engine changes in the future, these fil_fft
calls will remain backwards compatible.
Usage:
#include "fil_fft.h" fil_fft_mngr mngr; COMPLEX *data; fft_mngr_init( &mngr ); data = (COMPLEX *) malloc( 256 * sizeof(COMPLEX) ); ... fil_fft( &mngr, 256, data, 'f', 1 ); ... fft_mngr_quit( &mngr );
Each manager allocates space for upto 512 different length-plus-f/b combinations. If your program needs more than 512 different FFTs, then use additional managers.
int fft1d | ( | void * | args | ) |
Computes a 1D FFT
To call this function, first declare a variable to hold the function arguments:
fft1d_args args;
Then, populate the variable,
args.direction = 'f'; // FFT direction: 'f' or 'b' args.data = in; // pointer to COMPLEX data to be transformed args.n = N; // length of data buffer args.buf = buf; // pointer to temporary COMPLEX buffer args.center = 0; // k-space center is in the middle of the data args.mngr = mngr; // a pointer to an FFT manager
Then call the function:
fft1d( (void *) &args );
This structure allows calls to fft1d
to be multi-threaded.
Inverse FFTs are scaled by the length of the data vector, so that a 'round trip' of and FFT followed by an IFFT will leave the data at the same amplitude.
args | a pointer to an fft1d_args variable |
int fft_mngr_alloc_2dfft | ( | fil_fft_mngr * | mngr, |
int | M, | ||
int | N, | ||
char | direction | ||
) |
Allocate an manager object for 2D FFTs.
mngr | an fil_fft manager |
M | length of dim 1 |
N | length of dim 2 |
direction | 'f':forward FFT :: 'b':inverse FFT |
int fft_mngr_alloc_fft | ( | fil_fft_mngr * | mngr, |
int | N, | ||
char | direction | ||
) |
Allocate an manager object for 1D FFTs.
mngr | an fil_fft manager |
N | length of requested fft |
direction | 'f':forward :: 'b':inverse |
int fft_mngr_init | ( | fil_fft_mngr * | mngr | ) |
Initialize the FFT manager.
The number of different FFT sizes needs to be declared before calling this initialization function.
Usage:
fil_fft_mngr mngr;
fft_mngr_init( &mngr );
mngr | a pointer to a FFT manager |
int fft_mngr_quit | ( | fil_fft_mngr * | mngr | ) |
Free all FFT-related memory allocations, and release the manager.
mngr | an FFT manager |
void fft_t | ( | short | ncoils, |
short | nf, | ||
short | nz, | ||
short | ny, | ||
short | nx, | ||
char | direction, | ||
fil_fft_mngr * | mngr, | ||
short | center, | ||
COMPLEX * | data_in, | ||
COMPLEX * | data_out | ||
) |
FFT from time to frequency, or vice-versa. The input is a dataset ordered (nx -x- ny -x- nz -x- nf -x- ncoils), and the FFT is performed only in the temporal frequency direction (2nd dimension).
ncoils | Number of coils. (dim 5) |
nf | Number of time frames. (dim 4) |
nz | Size along kz. (dim 3) |
ny | Size along ky. (dim 2) |
nx | Size along x or kx. (dim 1) |
direction | 'f' : forward FFT, or 'b' : inverse FFT |
mngr | a pointer to an FFT manager |
center | is center of k-space in the center of the data? set to 0 if DC is at 0, otherwise DC assumed to be at nf/2 |
data_in | Input data |
data_out | Output data. If it is the same as data_in, input data simply gets over-written. |
void fftx | ( | short | ncoils, |
short | Nf, | ||
int | Nyz, | ||
short | Nx, | ||
char | dir, | ||
fil_fft_mngr * | mngr, | ||
short | center, | ||
COMPLEX * | data | ||
) |
FFT along x or kx. The input is a data-set ordered ( Nx -x- (Ny*Nz) -x- Nf -x- ncoils ), and an FFT is performed only in the x/kx direction.
ncoils | number of coils |
Nf | size in the temporal frame direction. |
Nyz | size in the Nyz direction. |
Nx | size in the x/kx direction. |
dir | 'f' : forward FFT, or 'b' : inverse FFT |
mngr | a pointer to an FFT manager |
center | 0 if DC is at (0,0), otherwise DC assumed to be at (Nx/2,Nyz/2) |
data | Data to FFT. The input data gets overwritten by the output data. |
void ffty | ( | short | ncoils, |
short | nf, | ||
short | nz, | ||
short | ny, | ||
short | nx, | ||
char | direction, | ||
fil_fft_mngr * | mngr, | ||
short | center, | ||
COMPLEX * | data | ||
) |
FFT along y or ky. The input is a data-set ordered (nx -x- ny -x- nz -x- nf -x- ncoils), and an FFT is performed only in the y/ky direction.
ncoils | Number of coils. (dim 5) |
nf | Number of time frames. (dim 4) |
nz | Size along kz. (dim 3) |
ny | Size along ky. (dim 2) |
nx | Size along x or kx. (dim 1) |
direction | 'f' : forward FFT, or 'b' : inverse FFT |
mngr | a pointer to an FFT manager |
center | 0 if DC is at (0,0), otherwise DC assumed to be at (Nx/2,Ny/2) |
data | Data to FFT. The input data gets overwritten by the output data. |
void fftz | ( | short | ncoils, |
short | nf, | ||
short | nz, | ||
short | ny, | ||
short | nx, | ||
char | direction, | ||
fil_fft_mngr * | mngr, | ||
short | center, | ||
COMPLEX * | data_in, | ||
COMPLEX * | data_out | ||
) |
FFT along z or kz. The input is a data-set ordered as (nx -x- ny -x- nz -x- nf -x- ncoils), and an FFT is performed only in the z/kz direction.
ncoils | Number of coils. (dim 5) |
nf | Number of time frames. (dim 4) |
nz | Size along kz. (dim 3) |
ny | Size along ky. (dim 2) |
nx | Size along x or kx. (dim 1) |
direction | 'f' : forward FFT, or 'b' : inverse FFT |
mngr | a pointer to an FFT manager |
center | 0 if DC is at (0,0), otherwise DC assumed to be at (Nx/2,Ny/2) |
data_in | Input data |
data_out | Output data. If it is the same as data_in, input data simply gets over-written. |
int fil_2dfft | ( | fil_fft_mngr * | mngr, |
int | M, | ||
int | N, | ||
COMPLEX * | data, | ||
char | dir | ||
) |
Perform a 2D FFT on the data
.
Note: to match Matlab's "ifft2", the output must be scaled by 1/(M*N).
mngr | an FFT manager |
M | dim-1 length of the data set |
N | dim-2 length of the data set |
data | a pointer to the data buffer to transform |
dir | FFT direction forward "f" or backward "b" |
int fil_fft | ( | fil_fft_mngr * | mngr, |
int | N, | ||
COMPLEX * | data, | ||
char | dir, | ||
int | unused | ||
) |
Perform a 1D FFT on the data
.
Note: consistent with the underlying FFT engines used in this function, the inverse FFT (when dir = 'b';
) is not scaled to unity.
mngr | an FFT manager |
N | the length of the data set |
data | a pointer to the data buffer to transform |
dir | FFT direction forward 'f' or backward 'b' |
unused | (unused) |
void fil_fft_shift | ( | COMPLEX * | data, |
int | Nx, | ||
int | Ny | ||
) |
Perform an FFT shift on the data
, swapping the 1st/3rd and 2nd/4th quadrants of the data space.
data | pointer to the input data |
Nx | dim 1 of the data |
Ny | dim 2 of the data |