Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

mrilib.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "mcw_malloc.h"
#include "debugtrace.h"
#include "Amalloc.h"
#include "coxplot.h"
#include "cdflib.h"
#include "mcw_glob.h"
#include "list_struct.h"
#include "thd_iochan.h"
#include "3ddata.h"
#include "thd_maker.h"
#include "editvol.h"
#include "cs.h"
#include "multivector.h"
#include "afni_environ.h"
#include "AFNI_label.h"

Go to the source code of this file.


Data Structures

struct  complex
struct  floatvec
struct  floatvecvec
struct  int_pair
struct  int_triple
struct  intvec
struct  MRI_2dalign_basis
union  MRI_DATA
struct  MRI_IMAGE
struct  MRI_IMARR
struct  rgba
struct  rgbyte
struct  SYM_irange

Defines

#define MRILIB_7D
#define COXEMAIL   "rwcox@nih.gov"
#define CLEAR_MRILIB_globals
#define PI   3.14159265358979323846
#define WAY_BIG   1.e+10
#define FLDIF(x, y)   ( fabs(x-y) > 1.e-4 * (fabs(x)+fabs(y)) )
#define MAX(a, b)   (((a)<(b)) ? (b) : (a))
#define MIN(a, b)   (((a)>(b)) ? (b) : (a))
#define LOAD_rgba(s, rr, gg, bb, aa)   ((s).r=(rr),(s).g=(gg),(s).b=(bb),(s).a=(bb))
#define UNLOAD_rgba(s, rr, gg, bb, aa)   ((rr)=(s).r,(gg)=(s).g,(bb)=(s).b,(aa)=(s).a)
#define BYTE_TO_ZONE(b)   (0.00392157*(b))
#define ZONE_TO_BYTE(z)   ((byte)(255.49*(z)))
#define MRI_KIND   MRI_TYPE ;
#define MRI_type   MRI_TYPE ;
#define MRI_kind   MRI_TYPE ;
#define MRI_rgbyte   MRI_rgb
#define LAST_MRI_TYPE   7
#define MRI_type_name   MRI_TYPE_name
#define MRI_TYPE_NAME(iimm)   MRI_TYPE_name[(iimm)->kind]
#define MRI_maxbyte   255
#define MRI_maxshort   32767
#define MRI_maxint   2147483647
#define SHORTIZE(xx)
#define BYTEIZE(xx)
#define MRI_IS_INT_TYPE(typ)   ((typ) < 3)
#define RGBZEQ(q)   ( (q).r==0 && (q).g==0 && (q).b==0 )
#define RGBZAS(q)   ( (q).r = (q).g = (q).b = 0 )
#define RGBYTE_TO_INT(rgb)   ( (rgb).r << 16 | (rgb).g << 8 | (rgb).b )
#define INT_TO_RGB(q)
#define USE_MRI_DELAY
#define INPUT_DELAY   1
#define BSWAP_DELAY   2
#define MRI_COPY_AUX(nn, oo)
#define MRI_IS_1D(iq)   ((iq)->ny == 1)
#define MRI_IS_2D(iq)   ((iq)->ny > 1 && (iq)->nz == 1)
#define MRI_IS_3D(iq)   ((iq)->nz > 1 && (iq)->nt == 1)
#define MRI_IS_4D(iq)   ((iq)->nt > 1 && (iq)->nu == 1)
#define MRI_DIMENSIONALITY(iq)
#define MRI_BYTE_PTR(iq)   ((iq)->im.byte_data)
#define MRI_SHORT_PTR(iq)   ((iq)->im.short_data)
#define MRI_INT_PTR(iq)   ((iq)->im.int_data)
#define MRI_FLOAT_PTR(iq)   ((iq)->im.float_data)
#define MRI_DOUBLE_PTR(iq)   ((iq)->im.double_data)
#define MRI_COMPLEX_PTR(iq)   ((iq)->im.complex_data)
#define MRI_RGB_PTR(iq)   ((iq)->im.rgb_data)
#define MRI_RGBA_PTR(iq)   ((iq)->im.rgba_data)
#define MRI_BYTE_2D(iq, ix, jy)   MRI_BYTE_PTR(iq)[(ix)+(jy)*(iq)->nx]
#define MRI_SHORT_2D(iq, ix, jy)   MRI_SHORT_PTR(iq)[(ix)+(jy)*(iq)->nx]
#define MRI_INT_2D(iq, ix, jy)   MRI_INT_PTR(iq)[(ix)+(jy)*(iq)->nx]
#define MRI_FLOAT_2D(iq, ix, jy)   MRI_FLOAT_PTR(iq)[(ix)+(jy)*(iq)->nx]
#define MRI_DOUBLE_2D(iq, ix, jy)   MRI_DOUBLE_PTR(iq)[(ix)+(jy)*(iq)->nx]
#define MRI_COMPLEX_2D(iq, ix, jy)   MRI_COMPLEX_PTR(iq)[(ix)+(jy)*(iq)->nx]
#define FLOAT_TO_BYTE(fff)   ( ((fff)<=0.0) ? (0) : ((fff)>=255.5) ? (255) : (byte)((fff)+0.49) )
#define SHORT_TO_BYTE(fff)   ( ((fff)<=0) ? (0) : ((fff)>=255) ? (255) : (byte)(fff) )
#define FLOAT_TO_SHORT(fff)   ((short)(fff))
#define IMAGE_IN_IMARR(name, nn)   ((name)->imarr[(nn)])
#define IMARR_SUBIMAGE   IMAGE_IN_IMARR
#define IMARR_SUBIM   IMAGE_IN_IMARR
#define IMARR_COUNT(name)   ((name)->num)
#define IMARR_LASTIM(name)   ((name)->imarr[(name)->num-1])
#define IMARR_FIRSTIM(name)   ((name)->imarr[0])
#define INC_IMARR   32
#define INIT_IMARR(name)
#define ADDTO_IMARR(name, imm)
#define FREE_IMARR(name)
#define DESTROY_IMARR(name)
#define TRUNCATE_IMARR(name, qq)
#define CMPLX(x, y)   ( MRI_cxa.r = (x) , MRI_cxa.i = (y) , MRI_cxa )
#define CADD(u, v)
#define CADDTO(u, v)   ( u.r += v.r , u.i += v.i )
#define CSUB(u, v)
#define CSUBFROM(u, v)   ( u.r -= v.r , u.i -= v.i )
#define CMULT(u, v)
#define CMULTBY(u, v)
#define CJMULT(u, v)
#define CJMULTBY(u, v)
#define CMADD(u, v, w)
#define CEXPIT(t)   ( MRI_cxc.r = cos(t) , MRI_cxc.i = sin(t) , MRI_cxc )
#define MEDIAN(a, b, c)
#define OSFSUM(p, q, r)   (0.70*(p)+0.15*((q)+(r)))
#define OSFILT(a, b, c)
#define TRUE   (1)
#define FALSE   (0)
#define MRI_BILINEAR   (1)
#define MRI_LINEAR   (1)
#define MRI_BICUBIC   (2)
#define MRI_CUBIC   (2)
#define MRI_FOURIER   (3)
#define MRI_NN   (0)
#define MRI_QUINTIC   (4)
#define MRI_HEPTIC   (5)
#define MRI_TSSHIFT   (6)
#define MRI_FOURIER_NOPAD   (66)
#define SQR(x)   ((x)*(x))
#define CSQR(z)   (SQR(z.r)+SQR(z.i))
#define CABS(z)   sqrt(CSQR(z))
#define CARG(z)   ( ((z).r!=0.0 || (z).i!=0.0) ? atan2((z).i,(z).r) : 0.0 )
#define CUNITIZE(z)   ( MRI_fla=CABS(z) , z.r=z.r/MRI_fla , z.i=z.i/MRI_fla )
#define WHOAMI
#define IMHEADER(f)
#define MRI_FATAL_ERROR   {fprintf(stderr,"in file: %s at line %d\n",__FILE__,__LINE__);EXIT(1);}
#define mri_clear_data_pointer(iq)   mri_fix_data_pointer(NULL,(iq))
#define mri_zero_image(iq)   memset(mri_data_pointer(iq),0,(iq)->nvox*(iq)->pixel_size)
#define mri_new_conforming(iq, kk)
#define mri_empty_conforming(iq, kk)
#define FILT_FFT_WRAPAROUND   1
#define ALIGN_DFSPACE_TYPE   1
#define ALIGN_DFTIME_TYPE   2
#define ALIGN_VERBOSE_CODE   1
#define ALIGN_NOITER_CODE   2
#define ALIGN_REGISTER_CODE   4
#define ALIGN_DETREND_CODE   8
#define ALIGN_DOBOTH_CODE   16
#define ALIGN_DEBUG_CODE   32
#define ALIGN_FREEUP_CODE   64
#define ALIGN_BILINEAR_CODE   128
#define ALIGN_FOURIER_CODE   256
#define MRI_ROT_0   1
#define MRI_ROT_90   2
#define MRI_ROT_180   4
#define MRI_ROT_270   8
#define MRI_FLMADD   128
#define LSB_FIRST   1
#define MSB_FIRST   2
#define NATIVE_ORDER   -1
#define REVERSE_ORDER(bord)   (3-(bord))
#define ORDER_LEN   9
#define LSB_FIRST_STRING   "LSB_FIRST"
#define MSB_FIRST_STRING   "MSB_FIRST"
#define NATIVE_STRING   "NATIVE_ORDER"
#define BYTE_ORDER_STRING(qq)
#define QG(x)   (0.5*erfc(x/1.414213562373095))
#define erfcinv(y)   (0.70710678*qginv(0.5*y))
#define normal_t2z(x)   (x)
#define KILL_floatvec(fv)
#define KILL_intvec(fv)
#define INLINE
#define RESTRICT
#define PRINT_VERSION(pp)   INFO_message("Program %s: AFNI version=%s",(pp),AFNI_VERSION_LABEL)
#define WROTE_DSET_MSG(dd, ss)   INFO_message("Output dataset %s {%s}",DSET_BRIKNAME(dd),(ss))
#define WROTE_DSET(dd)   INFO_message("Output dataset %s",DSET_BRIKNAME(dd))

Typedefs

typedef unsigned char byte
typedef enum MRI_TYPE MRI_TYPE
typedef complex complex
typedef rgbyte rgbyte
typedef MRI_DATA MRI_DATA
typedef MRI_IMAGE MRI_IMAGE
typedef MRI_IMARR MRI_IMARR

Enumerations

enum  MRI_TYPE {
  MRI_byte, MRI_short, MRI_int, MRI_float,
  MRI_double, MRI_complex, MRI_rgb, MRI_rgba
}

Functions

void mri_input_delay (MRI_IMAGE *)
void mri_purge_delay (MRI_IMAGE *)
void mri_add_fname_delay (char *, MRI_IMAGE *)
MRI_IMARRmri_read_file_delay (char *)
MRI_IMARRmri_read_3D_delay (char *)
int mri_equal (MRI_IMAGE *, MRI_IMAGE *)
MRI_IMARRmri_read_analyze75 (char *)
MRI_IMARRmri_read_siemens (char *)
MRI_IMARRmri_read3D_analyze75 (char *)
MRI_IMAGEmri_read_stuff (char *)
void mri_inflate_pbm (MRI_IMAGE *)
void mri_add_name (char *, MRI_IMAGE *)
MRI_IMAGE ** mri_stat_seq (MRI_IMAGE *)
MRI_IMAGEmri_edit_image (float pthr, float power, MRI_IMAGE *im)
MRI_IMARRmri_read_mpeg (char *)
int mri_isgray (MRI_IMAGE *)
int mri_imcount_mpeg (char *)
void cfft (int, int, float *, float *)
void cfft2d (int, int, int, float *, float *)
void csfft_cox (int, int, complex *)
void csfft_many (int, int, int, complex *)
int csfft_nextup (int)
int csfft_nextup_one35 (int)
int csfft_nextup_even (int)
void csfft_scale_inverse (int)
void csfft_use_fftw (int)
void mri_fftshift (MRI_IMAGE *, float, float, float, int)
void * mri_data_pointer (MRI_IMAGE *)
void mri_free (MRI_IMAGE *)
void mri_fix_data_pointer (void *, MRI_IMAGE *)
char * mri_dicom_header (char *)
void mri_dicom_pxlarr (off_t *, unsigned int *)
void mri_dicom_noname (int)
void mri_dicom_nohex (int)
void mri_dicom_setvm (int)
void mri_dicom_seterr (int)
MRI_IMARRmri_read_dicom (char *)
int mri_imcount_dicom (char *)
char * mri_dicom_sexinfo (void)
int mri_possibly_dicom (char *)
MRI_IMAGEmri_zeropad_3D (int, int, int, int, int, int, MRI_IMAGE *)
MRI_IMAGEmri_zeropad_2D (int, int, int, int, MRI_IMAGE *)
double mri_max (MRI_IMAGE *)
double mri_min (MRI_IMAGE *)
double mri_maxabs (MRI_IMAGE *)
MRI_IMAGEmri_cut_2D (MRI_IMAGE *, int, int, int, int)
MRI_IMAGEmri_cut_3D (MRI_IMAGE *, int, int, int, int, int, int)
void upsample_7 (int, int, float *, float *)
void upsample_1 (int, int, float *, float *)
MRI_IMAGEmri_dup2D (int, MRI_IMAGE *)
void mri_dup2D_mode (int)
void mri_move_guts (MRI_IMAGE *, MRI_IMAGE *)
MRI_IMAGEmri_copy (MRI_IMAGE *)
MRI_IMAGEmri_expand_2D (int, MRI_IMAGE *)
MRI_IMAGEmri_new (int, int, MRI_TYPE)
MRI_IMAGEmri_read (char *)
MRI_IMAGEmri_read_ge4 (char *)
int mri_write (char *, MRI_IMAGE *)
int mri_write_pnm (char *, MRI_IMAGE *)
int mri_write_jpg (char *, MRI_IMAGE *)
int mri_write_7D (char *, MRI_IMAGE *)
int mri_datum_size (MRI_TYPE typ)
MRI_IMAGEmri_read_ascii (char *)
MRI_IMAGEmri_read_ascii_ragged (char *, float)
int mri_write_ascii (char *, MRI_IMAGE *)
int mri_write_raw (char *, MRI_IMAGE *)
void mri_write_analyze (char *, MRI_IMAGE *)
MRI_IMAGEmri_read_1D (char *)
int mri_write_1D (char *, MRI_IMAGE *)
MRI_IMAGEmri_1D_fromstring (char *)
int setup_mri_write_angif (void)
int mri_write_angif (char *, MRI_IMARR *)
MRI_IMAGEmri_colorsetup (int, int, int, int)
MRI_IMAGEmri_new_vol (int, int, int, MRI_TYPE)
MRI_IMAGEmri_new_vol_empty (int, int, int, MRI_TYPE)
MRI_IMAGEmri_new_7D_generic (int nx, int ny, int nz, int nt, int nu, int nv, int nw, MRI_TYPE kind, int make_space)
MRI_IMARRmri_read_3D (char *)
MRI_IMARRmri_read_3A (char *)
MRI_IMARRmri_read_file (char *)
int mri_imcount (char *)
MRI_IMARRmri_read_many_files (int nf, char *fn[])
MRI_IMARRmri_read_ppm3 (char *fname)
MRI_IMAGEmri_read_ppm (char *fname)
void mri_read_ppm_header (char *, int *, int *)
MRI_IMAGEmri_read_just_one (char *fname)
MRI_IMAGEmri_read_nsize (char *fname)
MRI_IMARRmri_read_many_nsize (int nf, char *fn[])
void init_MCW_sizes (void)
char * imsized_fname (char *fname)
long mri_filesize (char *pathname)
char * my_strdup (char *str)
void mri_overlay_2D (MRI_IMAGE *, MRI_IMAGE *, int, int)
void mri_swapbytes (MRI_IMAGE *)
void swap_twobytes (int n, void *ar)
void swap_fourbytes (int n, void *ar)
void swap_eightbytes (int n, void *ar)
MRI_IMAGEmri_to_float (MRI_IMAGE *)
MRI_IMAGEmri_to_short (double, MRI_IMAGE *)
MRI_IMAGEmri_to_short_scl (double, double, MRI_IMAGE *)
MRI_IMAGEmri_to_short_sclip (double, double, int, int, MRI_IMAGE *)
MRI_IMAGEmri_to_complex (MRI_IMAGE *)
MRI_IMAGEmri_to_byte (MRI_IMAGE *)
MRI_IMAGEmri_to_byte_scl (double, double, MRI_IMAGE *)
MRI_IMAGEmri_to_rgb (MRI_IMAGE *)
MRI_IMAGEmri_3to_rgb (MRI_IMAGE *, MRI_IMAGE *, MRI_IMAGE *)
MRI_IMARRmri_rgb_to_3float (MRI_IMAGE *)
MRI_IMARRmri_rgb_to_3byte (MRI_IMAGE *)
MRI_IMAGEmri_sharpen_rgb (float, MRI_IMAGE *)
MRI_IMAGEmri_flatten_rgb (MRI_IMAGE *)
void mri_invert_inplace (MRI_IMAGE *)
MRI_IMAGEmri_to_rgba (MRI_IMAGE *)
MRI_IMAGEmri_pair_to_complex (MRI_IMAGE *, MRI_IMAGE *)
MRI_IMARRmri_complex_to_pair (MRI_IMAGE *)
MRI_IMAGEmri_to_complex_ext (MRI_IMAGE *, int, int, int)
MRI_IMAGEmri_scale_to_float (float, MRI_IMAGE *)
void mri_threshold (double, double, MRI_IMAGE *, MRI_IMAGE *)
MRI_IMAGEmri_mult_to_float (float *, MRI_IMAGE *)
MRI_IMAGEmri_scalize (MRI_IMAGE *, int, float *)
MRI_IMAGEmri_multiply_complex (int, MRI_IMAGE *, MRI_IMAGE *)
MRI_IMAGEmri_complex_phase (MRI_IMAGE *)
MRI_IMAGEmri_to_mri (int, MRI_IMAGE *)
MRI_IMAGEmri_to_mri_scl (int, double, MRI_IMAGE *)
MRI_IMAGEmri_complex_abs (MRI_IMAGE *)
void mri_fft_complex (int, float, MRI_IMAGE *)
float * mri_setup_taper (int, float)
MRI_IMAGEmri_warp (MRI_IMAGE *, int, int, int, void func(float, float, float *, float *))
MRI_IMAGEmri_warp_bicubic (MRI_IMAGE *, int, int, void func(float, float, float *, float *))
MRI_IMAGEmri_warp_bilinear (MRI_IMAGE *, int, int, void func(float, float, float *, float *))
MRI_IMAGEmri_resize (MRI_IMAGE *, int, int)
MRI_IMAGEmri_resize_NN (MRI_IMAGE *, int, int)
MRI_IMAGEmri_squareaspect (MRI_IMAGE *)
MRI_IMAGEmri_rotate (MRI_IMAGE *, float, float, float, float)
MRI_IMAGEmri_rotate_bilinear (MRI_IMAGE *, float, float, float, float)
MRI_IMAGEmri_rota (MRI_IMAGE *, float, float, float)
MRI_IMAGEmri_rota_bilinear (MRI_IMAGE *, float, float, float)
MRI_IMAGEmri_rota_shear (MRI_IMAGE *, float, float, float)
MRI_IMAGEmri_rota_variable (int, MRI_IMAGE *, float, float, float)
MRI_IMAGEmri_aff2d_byte (MRI_IMAGE *, int, float, float, float, float)
MRI_IMAGEmri_aff2d_rgb (MRI_IMAGE *, int, float, float, float, float)
void mri_scale_inplace (float, MRI_IMAGE *)
void ft_shift2 (int, int, float, float *, float, float *)
MRI_IMAGEmri_float_func (int, int, float, float, float, float, float(*func)(float, float))
void mri_histogram (MRI_IMAGE *, float, float, int, int, int h[])
void mri_histobyte (MRI_IMAGE *, int *)
void mri_histoshort_all (MRI_IMAGE *, int *)
void mri_histoshort_nonneg (MRI_IMAGE *, int *)
void mri_percents (MRI_IMAGE *, int nper, float per[])
MRI_IMAGEmri_flatten (MRI_IMAGE *)
float mri_quantile (MRI_IMAGE *im, float alpha)
void qsort_short (int, short *)
void qsort_float (int, float *)
void qsort_pair (int, float *, int *)
void qsort_int (int, int *)
void isort_short (int, short *)
void isort_float (int, float *)
void isort_pair (int, float *, int *)
MRI_IMAGEmri_nsize (MRI_IMAGE *)
float * mri_lsqfit (MRI_IMAGE *fitim, MRI_IMARR *refim, MRI_IMAGE *)
double * mri_startup_lsqfit (MRI_IMARR *, MRI_IMAGE *)
float * mri_delayed_lsqfit (MRI_IMAGE *, MRI_IMARR *, double *)
float * lsqfit (int, float *, float *, int, float *ref[])
double * startup_lsqfit (int, float *, int, float *ref[])
float * delayed_lsqfit (int, float *, int, float *ref[], double *)
MRI_IMAGEmri_sobel (int, int, MRI_IMAGE *)
MRI_IMAGEmri_sharpen (float, int, MRI_IMAGE *)
MRI_IMAGEmri_transpose (MRI_IMAGE *)
MRI_IMAGEmri_filt_fft (MRI_IMAGE *im, float, int, int, int)
MRI_IMAGEmri_medianfilter (MRI_IMAGE *, float, byte *, int)
MRI_IMAGEmri_cat2D (int, int, int, void *, MRI_IMARR *)
MRI_IMARRmri_uncat2D (int, int, MRI_IMAGE *im)
MRI_IMAGEmri_shift_1D (MRI_IMAGE *im, float shift)
MRI_IMARRmri_align_dfspace (MRI_IMAGE *, MRI_IMAGE *, MRI_IMARR *, int, float *, float *, float *)
MRI_IMARRmri_align_dftime (MRI_IMAGE *, MRI_IMAGE *, MRI_IMARR *, int, float *, float *, float *)
void mri_align_params (int, float, float, float, float, float, float)
void mri_align_method (int, int, int)
void mri_get_cmass_2D (MRI_IMAGE *, float *, float *)
void mri_get_cmass_3D (MRI_IMAGE *, float *, float *, float *)
void mri_2dalign_params (int, float, float, float, float, float, float)
void mri_2dalign_method (int, int, int)
MRI_2dalign_basismri_2dalign_setup (MRI_IMAGE *, MRI_IMAGE *)
MRI_IMAGEmri_2dalign_one (MRI_2dalign_basis *, MRI_IMAGE *, float *, float *, float *)
MRI_IMARRmri_2dalign_many (MRI_IMAGE *, MRI_IMAGE *, MRI_IMARR *, float *, float *, float *)
void mri_2dalign_cleanup (MRI_2dalign_basis *)
MRI_IMAGEmri_flippo (int rot, int mirror, MRI_IMAGE *im)
MRI_IMAGEmri_flip3D (int, int, int, MRI_IMAGE *inim)
int mri_short_order (void)
int mri_int_order (void)
void mri_swap2 (int, short *)
void mri_swap4 (int, int *)
void mri_drawline (MRI_IMAGE *im, int x0, int y0, int x1, int y1, byte r, byte g, byte b)
void mri_drawfilledrectangle (MRI_IMAGE *im, int x, int y, int width, int height, byte r, byte g, byte b)
void mri_drawemptyrectangle (MRI_IMAGE *im, int x, int y, int width, int height, byte r, byte g, byte b)
void mri_drawtext (MRI_IMAGE *im, int x, int y, int height, int angle, char *s, byte r, byte g, byte b)
void mri_draw_opacity (float)
void set_memplot_RGB_box (int xbot, int ybot, int xtop, int ytop)
void memplot_to_RGB_sef (MRI_IMAGE *im, MEM_plotdata *mp, int start, int end, int freee)
double lnbeta (double, double)
double incbeta (double, double, double, double)
double incbeta_inverse (double, double, double, double)
double qginv (double)
double qg (double)
double log10qg (double)
double student_t2p (double, double)
double student_p2t (double, double)
double student_t2z (double, double)
double correl_t2p (double, double, double, double)
double correl_t2z (double, double, double, double)
double correl_p2t (double, double, double, double)
double studave_t2p (double, double, double)
double studave_t2z (double, double, double)
double studave_p2t (double, double, double)
double fstat_p2t (double, double, double)
double fstat_t2p (double, double, double)
double fstat_t2z (double, double, double)
double normal_t2p (double zz)
double normal_p2t (double qq)
double chisq_t2p (double xx, double dof)
double chisq_t2z (double xx, double dof)
double chisq_p2t (double qq, double dof)
double beta_t2p (double xx, double aa, double bb)
double beta_t2z (double xx, double aa, double bb)
double beta_p2t (double qq, double aa, double bb)
double binomial_t2p (double ss, double ntrial, double ptrial)
double binomial_t2z (double ss, double ntrial, double ptrial)
double binomial_p2t (double qq, double ntrial, double ptrial)
double gamma_t2p (double xx, double sh, double sc)
double gamma_t2z (double xx, double sh, double sc)
double gamma_p2t (double qq, double sh, double sc)
double poisson_t2p (double xx, double lambda)
double poisson_t2z (double xx, double lambda)
double poisson_p2t (double qq, double lambda)
floatvecvecSYM_expand_ranges (int nlast, int nrang, SYM_irange *rang, char *str)
MRI_IMAGETHD_average_timeseries (MCW_cluster_array *, THD_3dim_dataset *)
MRI_IMAGETHD_average_one_timeseries (MCW_cluster *, THD_3dim_dataset *)
MRI_IMAGEmri_warp3D_cubic (MRI_IMAGE *, int, int, int, void func(float, float, float, float *, float *, float *))
MRI_IMAGEmri_warp3D_linear (MRI_IMAGE *, int, int, int, void func(float, float, float, float *, float *, float *))
MRI_IMAGEmri_warp3D_NN (MRI_IMAGE *, int, int, int, void func(float, float, float, float *, float *, float *))
MRI_IMAGEmri_warp3D (MRI_IMAGE *, int, int, int, void func(float, float, float, float *, float *, float *))
void mri_warp3D_method (int)
void mri_warp3D_zerout (int)
void mri_warp3D_set_womask (MRI_IMAGE *)
MRI_IMAGEmri_warp3D_quintic (MRI_IMAGE *, int, int, int, void func(float, float, float, float *, float *, float *))
MRI_IMAGEmri_warp3D_affine (MRI_IMAGE *, THD_vecmat)
MRI_IMAGEmri_warp3D_resize (MRI_IMAGE *, int, int, int)
double mri_entropy16 (MRI_IMAGE *)
double mri_entropy8 (MRI_IMAGE *)

Variables

char MRILIB_orients []
float MRILIB_zoff
float MRILIB_tr
float MRILIB_xoff
float MRILIB_yoff
int use_MRILIB_zoff
int use_MRILIB_xoff
int use_MRILIB_yoff
int use_MRILIB_xcos
int use_MRILIB_ycos
int use_MRILIB_zcos
float MRILIB_xcos [3]
float MRILIB_ycos [3]
float MRILIB_zcos [3]
int use_MRILIB_slicespacing
float MRILIB_slicespacing
char * MRI_TYPE_name [8]
float MRI_TYPE_maxval [7]
rgbyte tEMp_rgbyte_aAa
float MRI_fla
complex MRI_cxa
complex MRI_cxb
complex MRI_cxc
int MRI_mm

Define Documentation

#define ADDTO_IMARR name,
imm   
 

Value:

do{ int nn , iq ;                                                                    \
       if( (name)->num == (name)->nall ){                                               \
          nn = (name)->nall = 1.1*(name)->nall + INC_IMARR ;                            \
          (name)->imarr = (MRI_IMAGE **)realloc( (name)->imarr,sizeof(MRI_IMAGE *)*nn );              \
          for( iq=(name)->num ; iq < (name)->nall ; iq++ ) (name)->imarr[iq] = NULL ; } \
       nn = (name)->num ; ((name)->num)++ ;                                             \
       (name)->imarr[nn] = (imm) ; break ; } while(0)
Add one MRI_IMAGE to the MRI_IMARR struct.

Definition at line 391 of file mrilib.h.

Referenced by AFNI_add_timeseries(), AFNI_read_inputs(), AFNI_rescan_timeseries_CB(), AIVVV_imseq_addto(), AIVVV_imseq_popup(), drive_MCW_grapher(), dset_to_mri(), DSETN_func(), DT_read_opts(), EDIT_add_bricklist(), evolve_bitvector_array(), IMREG_main(), init_bitvector_array(), ISQ_getimage(), ISQ_make_montage(), ISQ_record_addim(), main(), mri_2dalign_many(), mri_2dalign_setup(), mri_3dalign_many(), mri_3dalign_setup(), mri_align_dfspace(), mri_complex_to_pair(), mri_lsqfit(), mri_read3D_analyze75(), mri_read_3A(), mri_read_3D(), mri_read_3D_delay(), mri_read_analyze75(), mri_read_dicom(), mri_read_file(), mri_read_file_delay(), mri_read_many_files(), mri_read_many_nsize(), mri_read_mpeg(), mri_read_ppm3(), mri_read_siemens(), mri_rgb_to_3byte(), mri_rgb_to_3float(), mri_rgba_composite_two(), mri_rgba_composite_VA(), mri_uncat2D(), PH_redraw(), plot_graphs(), PLUTO_imseq_addto(), PLUTO_imseq_popim(), PLUTO_imseq_popup(), RCREND_draw_CB(), REG_command_line(), REND_draw_CB(), RT_process_data(), SNAP_store_image(), THD_extract_many_series(), THD_get_all_timeseries(), THD_get_many_timeseries(), and THD_init_datablock_brick().

#define ALIGN_BILINEAR_CODE   128
 

Definition at line 841 of file mrilib.h.

Referenced by get_line_opt().

#define ALIGN_DEBUG_CODE   32
 

Definition at line 839 of file mrilib.h.

Referenced by get_line_opt(), mri_align_dfspace(), and REG_command_line().

#define ALIGN_DETREND_CODE   8
 

Definition at line 837 of file mrilib.h.

Referenced by REG_command_line().

#define ALIGN_DFSPACE_TYPE   1
 

Definition at line 831 of file mrilib.h.

Referenced by main(), and REG_command_line().

#define ALIGN_DFTIME_TYPE   2
 

Definition at line 832 of file mrilib.h.

Referenced by main(), and REG_command_line().

#define ALIGN_DOBOTH_CODE   16
 

Definition at line 838 of file mrilib.h.

Referenced by REG_command_line().

#define ALIGN_FOURIER_CODE   256
 

Definition at line 842 of file mrilib.h.

#define ALIGN_FREEUP_CODE   64
 

Definition at line 840 of file mrilib.h.

#define ALIGN_NOITER_CODE   2
 

Definition at line 835 of file mrilib.h.

Referenced by get_line_opt(), mri_align_dfspace(), and REG_command_line().

#define ALIGN_REGISTER_CODE   4
 

Definition at line 836 of file mrilib.h.

Referenced by get_line_opt(), IMREG_main(), main(), and mri_align_dfspace().

#define ALIGN_VERBOSE_CODE   1
 

Definition at line 834 of file mrilib.h.

Referenced by mri_align_dfspace(), and REG_command_line().

#define BSWAP_DELAY   2
 

Definition at line 224 of file mrilib.h.

#define BYTE_ORDER_STRING qq   
 

Value:

(  ((qq)==LSB_FIRST) ? LSB_FIRST_STRING \
                               : ((qq)==MSB_FIRST) ? MSB_FIRST_STRING \
                                                   : "Illegal Value" )

Definition at line 902 of file mrilib.h.

Referenced by RT_process_info(), and THD_datablock_from_atr().

#define BYTE_TO_ZONE b       (0.00392157*(b))
 

Scale a byte [0..255] to a float in [0..1).

Definition at line 98 of file mrilib.h.

#define BYTEIZE xx   
 

Value:

(  ((xx) <   0.0) ? (byte)0                     \
                      : ((xx) > 255.0) ? (byte)255 : (byte)rint(xx) )
Force a float into a byte.

Definition at line 153 of file mrilib.h.

Referenced by ISQ_process_mri(), main(), MASKAVE_main(), mri_to_byte(), mri_to_byte_scl(), mri_to_short_sclip(), SUMA_FormAfnidset(), THD_insert_series(), THD_load_datablock(), THD_makemask(), and thd_mask_from_brick().

#define CABS z       sqrt(CSQR(z))
 

Definition at line 520 of file mrilib.h.

Referenced by absfft_func(), cx_scramble(), EDIT_coerce_scale_type(), EDIT_coerce_type(), EDIT_one_dataset(), fft2D_func(), ISQ_process_mri(), main(), MAKER_4D_to_typed_fbuc(), MAKER_4D_to_typed_fim(), MAKER_4D_to_typed_fith(), mri_mult_to_float(), mri_scale_to_float(), mri_to_byte(), mri_to_byte_scl(), mri_to_float(), mri_to_short(), mri_to_short_sclip(), PLUTO_4D_to_nothing(), THD_extract_array(), THD_extract_float_brick(), THD_insert_series(), and THD_write_1D().

#define CADD u,
v   
 

Value:

( MRI_cxa.r = u.r + v.r , \
                    MRI_cxa.i = u.i + v.r , MRI_cxa )
Return complex u+v

Definition at line 434 of file mrilib.h.

#define CADDTO u,
v       ( u.r += v.r , u.i += v.i )
 

complex u += v

Definition at line 439 of file mrilib.h.

#define CARG z       ( ((z).r!=0.0 || (z).i!=0.0) ? atan2((z).i,(z).r) : 0.0 )
 

Definition at line 521 of file mrilib.h.

Referenced by cx_scramble(), and ISQ_process_mri().

#define CEXPIT      ( MRI_cxc.r = cos(t) , MRI_cxc.i = sin(t) , MRI_cxc )
 

Return complex exp(I*t)

Definition at line 476 of file mrilib.h.

Referenced by fft_shift2(), ft_shift2(), and main().

#define CJMULT u,
v   
 

Value:

( MRI_cxb.r = u.r * v.r + u.i * v.i , \
                      MRI_cxb.i = u.i * v.r - u.r * v.i , MRI_cxb )
Return complex u * conjg(v)

Definition at line 461 of file mrilib.h.

Referenced by FFT_2dchirpz(), and mri_multiply_complex().

#define CJMULTBY u,
v   
 

Value:

( MRI_fla = u.r * v.r + u.i * v.i , \
                        u.i     = u.i * v.r - u.r * v.i , u.r = MRI_fla )
complex u *= conjg(v)

Definition at line 466 of file mrilib.h.

#define CLEAR_MRILIB_globals
 

Value:

do{ MRILIB_orients[0]='\0';                              \
     MRILIB_zoff=MRILIB_xoff=MRILIB_yoff=MRILIB_tr=0.0;   \
     use_MRILIB_xoff=use_MRILIB_yoff=use_MRILIB_zoff=0;   \
     use_MRILIB_xcos=use_MRILIB_ycos=use_MRILIB_zcos=0;   \
     use_MRILIB_slicespacing=0;                           \
 } while(0)
Clear the MRILIB globals (which are designed to transmit info from image files to to3d.c).

Definition at line 36 of file mrilib.h.

Referenced by main(), and T3D_read_images().

#define CMADD u,
v,
w   
 

Value:

( w.r += u.r * v.r - u.i * v.i , \
                       w.i += u.r * v.i + u.i * v.r    )
complex w += u*v

Definition at line 471 of file mrilib.h.

#define CMPLX x,
y       ( MRI_cxa.r = (x) , MRI_cxa.i = (y) , MRI_cxa )
 

Return a complex from two floats.

Definition at line 430 of file mrilib.h.

Referenced by DRAW_into_dataset(), and main().

#define CMULT u,
v   
 

Value:

( MRI_cxb.r = u.r * v.r - u.i * v.i , \
                     MRI_cxb.i = u.r * v.i + u.i * v.r , MRI_cxb )
Return complex u*v

Definition at line 451 of file mrilib.h.

Referenced by FFT_2dchirpz(), fft_shift2(), ft_shift2(), and mri_multiply_complex().

#define CMULTBY u,
v   
 

Value:

( MRI_fla = u.r * v.r - u.i * v.i , \
                       u.i     = u.r * v.i + u.i * v.r , u.r = MRI_fla )
complex u *= v

Definition at line 456 of file mrilib.h.

#define COXEMAIL   "rwcox@nih.gov"
 

Definition at line 12 of file mrilib.h.

Referenced by DRAW_help_CB(), and ISQ_saver_CB().

#define CSQR z       (SQR(z.r)+SQR(z.i))
 

Definition at line 519 of file mrilib.h.

Referenced by autocorr(), main(), MCW_scale_to_max(), MCW_vol_amax(), mri_complex_abs(), mri_max(), mri_maxabs(), mri_min(), THD_get_brick_stats(), THD_load_datablock(), and ts_to_ftime().

#define CSUB u,
v   
 

Value:

( MRI_cxa.r = u.r - v.r , \
                    MRI_cxa.i = u.i - v.i , MRI_cxa )
Return complex u-v

Definition at line 442 of file mrilib.h.

#define CSUBFROM u,
v       ( u.r -= v.r , u.i -= v.i )
 

complex u -= v

Definition at line 447 of file mrilib.h.

#define CUNITIZE z       ( MRI_fla=CABS(z) , z.r=z.r/MRI_fla , z.i=z.i/MRI_fla )
 

complex z /= abs(z)

Definition at line 525 of file mrilib.h.

#define DESTROY_IMARR name   
 

Value:

do{ int nn ;                                                                 \
       if( (name) != NULL ){                                                    \
          for( nn=0 ; nn < (name)->num ; nn++ ) mri_free((name)->imarr[nn]) ;   \
          free((name)->imarr); free((name)); (name) = NULL; } break; } while(0)
Free the MRI_IMARR struct, including the images within.

Definition at line 408 of file mrilib.h.

Referenced by AFNI_fimmer_compute(), AIVVV_imseq_send_CB(), calculate_results(), cleanup_rtinp(), do_xrestore_stuff(), DSETN_func(), get_line_opt(), IMREG_main(), ISQ_free_alldata(), ISQ_getimage(), ISQ_make_montage(), ISQ_record_send_CB(), main(), mri_2dalign_cleanup(), mri_3dalign_cleanup(), mri_align_dfspace(), mri_read_just_one(), mri_read_mpeg(), mri_read_nsize(), mri_warp_bicubic(), plot_graphs(), PLUTO_imseq_popup(), PLUTO_imseq_send_CB(), RCREND_autocompute_CB(), RCREND_done_CB(), RCREND_draw_CB(), RCREND_read_exec_CB(), REND_autocompute_CB(), REND_done_CB(), REND_draw_CB(), REND_read_exec_CB(), SNAP_imseq_send_CB(), THD_delete_datablock(), THD_extract_many_series(), THD_get_all_timeseries(), THD_get_many_timeseries(), THD_init_datablock_brick(), THD_load_mpeg(), and THD_open_mpeg().

#define erfcinv y       (0.70710678*qginv(0.5*y))
 

Definition at line 962 of file mrilib.h.

#define FALSE   (0)
 

Definition at line 503 of file mrilib.h.

#define FILT_FFT_WRAPAROUND   1
 

Definition at line 818 of file mrilib.h.

Referenced by mri_2dalign_one(), mri_2dalign_setup(), mri_align_crao(), mri_align_dfspace(), and mri_filt_fft().

#define FLDIF x,
y       ( fabs(x-y) > 1.e-4 * (fabs(x)+fabs(y)) )
 

Are 2 floats significantly different?

Definition at line 63 of file mrilib.h.

Referenced by ISQ_make_image(), ISQ_make_montage(), and main().

#define FLOAT_TO_BYTE fff       ( ((fff)<=0.0) ? (0) : ((fff)>=255.5) ? (255) : (byte)((fff)+0.49) )
 

Definition at line 347 of file mrilib.h.

Referenced by EDIT_coerce_scale_type(), and EDIT_coerce_type().

#define FLOAT_TO_SHORT fff       ((short)(fff))
 

Definition at line 353 of file mrilib.h.

#define FREE_IMARR name   
 

Value:

do{ if( (name) != NULL ){                                                    \
          free((name)->imarr); free((name)); (name) = NULL; } break; } while(0)
Free the MRI_IMARR struct (but not the images within).

Definition at line 402 of file mrilib.h.

Referenced by AFNI_read_images(), AFNI_read_inputs(), AFNI_rescan_timeseries_CB(), avg_epochs(), drive_MCW_grapher(), DSETN_func(), main(), mri_affine_bicubic(), mri_dup2D(), mri_lsqfit(), mri_read_just_one(), mri_read_many_files(), mri_read_many_nsize(), mri_read_mpeg(), mri_read_siemens(), mri_rgba_composite_two(), mri_rgba_composite_VA(), mri_rota(), mri_rota_bilinear(), mri_rota_shear(), mri_shift2D_bilinear(), mri_warp3D_cubic(), mri_warp3D_linear(), mri_warp3D_NN(), mri_warp3D_quintic(), NUD_rotate(), PH_redraw(), PLUTO_imseq_popim(), REG_command_line(), RT_start_dataset(), T3D_read_images(), TFIM_getopts(), THD_delete_datablock(), and THD_get_many_timeseries().

#define IMAGE_IN_IMARR name,
nn       ((name)->imarr[(nn)])
 

Get the nn-th image from the image array "name".

Definition at line 367 of file mrilib.h.

Referenced by avg_epochs(), main(), mri_affine_bicubic(), mri_dup2D(), mri_read_just_one(), mri_read_many_nsize(), mri_read_nsize(), mri_rota(), mri_rota_bilinear(), mri_rota_shear(), mri_shift2D_bilinear(), and NUD_rotate().

#define IMARR_COUNT name       ((name)->num)
 

Get the number of images in the image array "name".

Definition at line 373 of file mrilib.h.

Referenced by AFNI_fimmer_pickort_CB(), AFNI_fimmer_pickref_CB(), AFNI_gra_send_CB(), AFNI_read_inputs(), AFNI_rescan_timeseries_CB(), AFNI_ts_in_library(), AIVVV_imseq_addto(), AIVVV_imseq_getim(), AIVVV_imseq_popup(), drive_MCW_grapher(), DSETN_func(), DT_read_opts(), evolve_bitvector_array(), get_line_opt(), GRA_doshift(), GRA_fim_CB(), GRA_opt_CB(), GRA_pick_xaxis_CB(), GRA_refstore_choose_CB(), GRA_refwrite_choose_CB(), ISQ_free_alldata(), ISQ_record_addim(), ISQ_record_getim(), ISQ_record_kill_CB(), ISQ_record_open(), ISQ_record_send_CB(), ISQ_record_update(), main(), mri_automask_imarr(), mri_read_dicom(), mri_read_mpeg(), mri_read_siemens(), mri_rgba_composite_array(), mri_write_angif(), plot_graphs(), PLUG_choose_timeseries_CB(), PLUG_finalize_timeseries_CB(), PLUTO_imseq_addto(), PLUTO_imseq_getim(), PLUTO_imseq_popup(), PLUTO_imseq_setim(), RCREND_accum_lab_CB(), RCREND_imseq_getim(), RCREND_open_imseq(), RCREND_update_imseq(), REND_imseq_getim(), REND_open_imseq(), REND_update_imseq(), RT_start_dataset(), SNAP_imseq_getim(), SNAP_store_image(), THD_get_all_timeseries(), THD_get_many_timeseries(), and THD_open_mpeg().

#define IMARR_FIRSTIM name       ((name)->imarr[0])
 

Definition at line 376 of file mrilib.h.

#define IMARR_LASTIM name       ((name)->imarr[(name)->num-1])
 

Definition at line 375 of file mrilib.h.

Referenced by SNAP_store_image().

#define IMARR_SUBIM   IMAGE_IN_IMARR
 

Definition at line 369 of file mrilib.h.

Referenced by AIVVV_imseq_addto(), calculate_results(), do_xrestore_stuff(), DSETN_func(), evolve_bitvector_array(), ISQ_getimage(), ISQ_record_addim(), ISQ_record_kill_CB(), main(), mri_read_dicom(), mri_read_file(), mri_read_mpeg(), mri_read_siemens(), mri_rgba_composite_array(), mri_warp3D_cubic(), mri_warp3D_linear(), mri_warp3D_NN(), mri_warp3D_quintic(), mri_warp_bicubic(), RCREND_accum_lab_CB(), THD_load_mpeg(), and THD_open_mpeg().

#define IMARR_SUBIMAGE   IMAGE_IN_IMARR
 

Definition at line 368 of file mrilib.h.

Referenced by AFNI_fimmer_compute(), AFNI_fimmer_pickort_CB(), AFNI_fimmer_pickref_CB(), AFNI_read_inputs(), AFNI_rescan_timeseries_CB(), AFNI_ts_in_library(), AIVVV_imseq_getim(), drive_MCW_grapher(), dset_to_mri(), DT_read_opts(), evolve_bitvector_array(), get_line_opt(), GRA_doshift(), GRA_pick_xaxis_CB(), GRA_refstore_choose_CB(), GRA_refwrite_choose_CB(), IMREG_main(), ISQ_make_montage(), ISQ_record_getim(), main(), MCW_choose_CB(), MCW_choose_timeseries(), mri_automask_imarr(), mri_cat2D(), mri_write_angif(), plot_graphs(), PLUG_finalize_timeseries_CB(), PLUTO_imseq_getim(), PLUTO_imseq_popup(), RCREND_imseq_getim(), RCREND_open_imseq(), RCREND_update_imseq(), REND_imseq_getim(), REND_open_imseq(), REND_update_imseq(), RT_start_dataset(), SNAP_imseq_getim(), and THD_extract_many_series().

#define IMHEADER  
 

Definition at line 537 of file mrilib.h.

#define INC_IMARR   32
 

Definition at line 378 of file mrilib.h.

#define INIT_IMARR name   
 

Value:

do{ int iq ; (name) = (MRI_IMARR *) malloc(sizeof(MRI_IMARR)) ;                 \
       (name)->num = 0 ; (name)->nall = INC_IMARR ;                                \
       (name)->imarr = (MRI_IMAGE **)malloc(sizeof(MRI_IMAGE *)*INC_IMARR) ;       \
       for( iq=(name)->num ; iq < (name)->nall ; iq++ ) (name)->imarr[iq] = NULL ; \
       break ; } while(0)
Initialize an MRI_IMARR struct.

Definition at line 382 of file mrilib.h.

Referenced by AFNI_read_inputs(), drive_MCW_grapher(), dset_to_mri(), DSETN_func(), DT_read_opts(), IMREG_main(), init_bitvector_array(), ISQ_getimage(), ISQ_make_montage(), ISQ_record_addim(), main(), mri_2dalign_many(), mri_2dalign_setup(), mri_3dalign_many(), mri_3dalign_setup(), mri_align_dfspace(), mri_complex_to_pair(), mri_lsqfit(), mri_read3D_analyze75(), mri_read_3A(), mri_read_3D(), mri_read_3D_delay(), mri_read_analyze75(), mri_read_dicom(), mri_read_file(), mri_read_file_delay(), mri_read_many_files(), mri_read_many_nsize(), mri_read_mpeg(), mri_read_ppm3(), mri_read_siemens(), mri_rgb_to_3byte(), mri_rgb_to_3float(), mri_rgba_composite_two(), mri_rgba_composite_VA(), mri_uncat2D(), PH_redraw(), plot_graphs(), PLUTO_imseq_popim(), PLUTO_imseq_popup(), RCREND_draw_CB(), REG_command_line(), REND_draw_CB(), RT_process_data(), SNAP_store_image(), THD_extract_many_series(), THD_get_all_timeseries(), THD_get_many_timeseries(), and THD_init_datablock_brick().

#define INLINE
 

Definition at line 1094 of file mrilib.h.

#define INPUT_DELAY   1
 

Definition at line 223 of file mrilib.h.

#define INT_TO_RGB q   
 

Value:

( tEMp_rgbyte_aAa.r = ((q) >> 16) & 0xff , \
                        tEMp_rgbyte_aAa.g = ((q) >>  8) & 0xff , \
                        tEMp_rgbyte_aAa.b = (q)         & 0xff , tEMp_rgbyte_aAa )
Convert one int to a RGB triple (rgbyte).

Definition at line 193 of file mrilib.h.

#define KILL_floatvec fv   
 

Value:

do{ if( (fv)->ar != NULL ) free((fv)->ar);   \
      free(fv);                                \
  } while(0)

Definition at line 1010 of file mrilib.h.

Referenced by decode_linebuf(), mri_read_ascii(), mri_read_ascii_ragged(), and SYM_expand_ranges().

#define KILL_intvec fv   
 

Value:

do{ if( (fv)->ar != NULL ) free((fv)->ar);   \
      free(fv);                                \
  } while(0)

Definition at line 1018 of file mrilib.h.

#define LAST_MRI_TYPE   7
 

The last MRI_TYPE yet defined.

Definition at line 118 of file mrilib.h.

#define LOAD_rgba s,
rr,
gg,
bb,
aa       ((s).r=(rr),(s).g=(gg),(s).b=(bb),(s).a=(bb))
 

Definition at line 93 of file mrilib.h.

#define LSB_FIRST   1
 

Definition at line 891 of file mrilib.h.

#define LSB_FIRST_STRING   "LSB_FIRST"
 

Definition at line 898 of file mrilib.h.

Referenced by main(), THD_datablock_from_atr(), THD_dataset_info(), THD_enviro_write_order(), THD_init_one_datablock(), and THD_write_datablock().

#define MAX a,
b       (((a)<(b)) ? (b) : (a))
 

Definition at line 68 of file mrilib.h.

#define MEDIAN a,
b,
c   
 

Value:

( MRI_mm = 4*((a)<(b)) + 2*((a)<(c)) + ((b)<(c)) , \
                        (MRI_mm==3||MRI_mm==4) ? (a) :                   \
                        (MRI_mm==7||MRI_mm==0) ? (b) : (c) )
Median of 3.

Definition at line 484 of file mrilib.h.

Referenced by main(), and median3_func().

#define MIN a,
b       (((a)>(b)) ? (b) : (a))
 

Definition at line 72 of file mrilib.h.

#define MRI_BICUBIC   (2)
 

Definition at line 508 of file mrilib.h.

Referenced by main(), mri_resize(), mri_rota_variable(), mri_warp(), REG_command_line(), and RT_registration_2D_setup().

#define MRI_BILINEAR   (1)
 

Definition at line 506 of file mrilib.h.

Referenced by main(), mri_resize(), mri_rota_variable(), mri_warp(), REG_command_line(), and RT_registration_2D_setup().

#define MRI_BYTE_2D iq,
ix,
jy       MRI_BYTE_PTR(iq)[(ix)+(jy)*(iq)->nx]
 

Definition at line 340 of file mrilib.h.

#define MRI_BYTE_PTR iq       ((iq)->im.byte_data)
 

Definition at line 331 of file mrilib.h.

#define mri_clear_data_pointer iq       mri_fix_data_pointer(NULL,(iq))
 

Set the data pointer in an MRI_IMAGE to NULL.

Definition at line 603 of file mrilib.h.

Referenced by AFNI_make_widgets(), BFIT_compute(), BFIT_main(), cleanup_rtinp(), CORREL_main(), IMREG_main(), main(), mri_purge_delay(), NUD_doall_CB(), NUD_update_base(), T3D_fix_dataset_dimen(), THD_autonudge(), THD_load_datablock(), THD_purge_datablock(), THD_purge_one_brick(), and THD_write_datablock().

#define MRI_COMPLEX_2D iq,
ix,
jy       MRI_COMPLEX_PTR(iq)[(ix)+(jy)*(iq)->nx]
 

Definition at line 345 of file mrilib.h.

#define MRI_COMPLEX_PTR iq       ((iq)->im.complex_data)
 

Definition at line 336 of file mrilib.h.

#define MRI_COPY_AUX nn,
oo   
 

Value:

( (nn)->dx = (oo)->dx , (nn)->dy = (oo)->dy , (nn)->dz = (oo)->dz , \
      (nn)->dt = (oo)->dt , (nn)->du = (oo)->du , (nn)->dv = (oo)->dv , \
      (nn)->dw = (oo)->dw ,                                             \
      (nn)->xo = (oo)->xo , (nn)->yo = (oo)->yo , (nn)->zo = (oo)->zo , \
      (nn)->to = (oo)->to , (nn)->uo = (oo)->uo , (nn)->vo = (oo)->vo , \
      (nn)->wo = (oo)->wo ,                                             \
      mri_add_name( (oo)->name , (nn) ) )

Definition at line 303 of file mrilib.h.

#define MRI_CUBIC   (2)
 

Definition at line 509 of file mrilib.h.

Referenced by main(), mri_3dalign_one(), mri_brainormalize(), mri_warp3D(), RT_registration_3D_setup(), SHIFT_set_method(), THD_rota_method(), and VL_command_line().

#define MRI_DIMENSIONALITY iq   
 

Value:

( ((iq)->ny == 1) ? 1 : ((iq)->nz == 1) ? 2 :     \
   ((iq)->nt == 1) ? 3 : ((iq)->nu == 1) ? 4 :     \
   ((iq)->nv == 1) ? 5 : ((iq)->nw == 1) ? 6 : 7 )
Return dimensionality of MRI_IMAGE

Definition at line 326 of file mrilib.h.

#define MRI_DOUBLE_2D iq,
ix,
jy       MRI_DOUBLE_PTR(iq)[(ix)+(jy)*(iq)->nx]
 

Definition at line 344 of file mrilib.h.

#define MRI_DOUBLE_PTR iq       ((iq)->im.double_data)
 

Definition at line 335 of file mrilib.h.

#define mri_empty_conforming iq,
kk   
 

Value:

mri_new_7D_generic( (iq)->nx, (iq)->ny, (iq)->nz , (iq)->nt ,    \
                       (iq)->nu, (iq)->nv, (iq)->nw , (kk) , FALSE )
Create new MRI_IMAGE of type kk, with same dimensions as iq, and with no data space allocated.

Definition at line 669 of file mrilib.h.

Referenced by EDIT_substitute_brick(), and main().

#define MRI_FATAL_ERROR   {fprintf(stderr,"in file: %s at line %d\n",__FILE__,__LINE__);EXIT(1);}
 

Definition at line 540 of file mrilib.h.

Referenced by mri_3to_rgb(), mri_complex_abs(), mri_complex_phase(), mri_fft_complex(), mri_mult_to_float(), mri_multiply_complex(), mri_new_7D_generic(), mri_resize(), mri_scale_to_float(), mri_to_byte(), mri_to_byte_scl(), mri_to_complex(), mri_to_float(), mri_to_short(), mri_to_short_sclip(), and mri_warp().

#define MRI_FLMADD   128
 

Definition at line 882 of file mrilib.h.

#define MRI_FLOAT_2D iq,
ix,
jy       MRI_FLOAT_PTR(iq)[(ix)+(jy)*(iq)->nx]
 

Definition at line 343 of file mrilib.h.

#define MRI_FLOAT_PTR iq       ((iq)->im.float_data)
 

Definition at line 334 of file mrilib.h.

#define MRI_FOURIER   (3)
 

Definition at line 510 of file mrilib.h.

Referenced by apply_xshear(), apply_yshear(), apply_zshear(), main(), mri_3dalign_one(), mri_rota_variable(), new_RT_input(), REG_command_line(), SHIFT_set_method(), THD_rota_method(), and VL_command_line().

#define MRI_FOURIER_NOPAD   (66)
 

Definition at line 516 of file mrilib.h.

Referenced by apply_xshear(), apply_yshear(), apply_zshear(), main(), and THD_rota_method().

#define MRI_HEPTIC   (5)
 

Definition at line 513 of file mrilib.h.

Referenced by main(), mri_3dalign_one(), new_RT_input(), RT_registration_2D_setup(), SHIFT_set_method(), THD_rota_method(), and VL_command_line().

#define MRI_INT_2D iq,
ix,
jy       MRI_INT_PTR(iq)[(ix)+(jy)*(iq)->nx]
 

Definition at line 342 of file mrilib.h.

#define MRI_INT_PTR iq       ((iq)->im.int_data)
 

Definition at line 333 of file mrilib.h.

#define MRI_IS_1D iq       ((iq)->ny == 1)
 

Check if MRI_IMAGE is 1D (ny=1)

Definition at line 314 of file mrilib.h.

#define MRI_IS_2D iq       ((iq)->ny > 1 && (iq)->nz == 1)
 

Check if MRI_IMAGE is 2D (nz=1)

Definition at line 317 of file mrilib.h.

#define MRI_IS_3D iq       ((iq)->nz > 1 && (iq)->nt == 1)
 

Check if MRI_IMAGE is 3D (nt=1)

Definition at line 320 of file mrilib.h.

#define MRI_IS_4D iq       ((iq)->nt > 1 && (iq)->nu == 1)
 

Check if MRI_IMAGE is 4D (nu=1)

Definition at line 323 of file mrilib.h.

#define MRI_IS_INT_TYPE typ       ((typ) < 3)
 

Determine if a MRI_TYPE is an integer type.

Definition at line 158 of file mrilib.h.

#define MRI_kind   MRI_TYPE ;
 

Definition at line 112 of file mrilib.h.

#define MRI_KIND   MRI_TYPE ;
 

Definition at line 110 of file mrilib.h.

#define MRI_LINEAR   (1)
 

Definition at line 507 of file mrilib.h.

Referenced by main(), mri_warp3D(), mri_warp3d_align_one(), mri_warp3D_align_setup(), NUD_rotate(), RT_registration_3D_setup(), SHIFT_set_method(), THD_rota_method(), and VL_command_line().

#define MRI_maxbyte   255
 

Max value of a byte.

Definition at line 131 of file mrilib.h.

#define MRI_maxint   2147483647
 

Max value of an int.

Definition at line 139 of file mrilib.h.

#define MRI_maxshort   32767
 

Max value of a short.

Definition at line 135 of file mrilib.h.

#define mri_new_conforming iq,
kk   
 

Value:

mri_new_7D_generic( (iq)->nx, (iq)->ny, (iq)->nz , (iq)->nt ,    \
                       (iq)->nu, (iq)->nv, (iq)->nw , (kk) , TRUE )
Create new MRI_IMAGE of type kk, with same dimensions as iq.

Definition at line 662 of file mrilib.h.

Referenced by AFNI_newfunc_overlay(), AFNI_ttatlas_overlay(), cx_scramble(), ISQ_getimage(), ISQ_index_to_rgb(), ISQ_overlay(), main(), MREN_rgb_to_colorbytes(), MREN_rgb_to_colorshorts(), mri_3dalign_setup(), mri_3to_rgb(), mri_automask_imarr(), mri_brainormalize(), mri_complex_abs(), mri_complex_phase(), mri_complex_to_pair(), mri_copy(), mri_flatten(), mri_flatten_rgb(), mri_medianfilter(), mri_mult_to_float(), mri_multiply_complex(), mri_pair_to_complex(), mri_quantize(), mri_rgb_to_3byte(), mri_rgb_to_3float(), mri_rgba_composite_array(), mri_scale_to_float(), mri_scalize(), mri_sharpen_rgb(), mri_to_byte(), mri_to_byte_scl(), mri_to_complex(), mri_to_float(), mri_to_rgb(), mri_to_rgba(), mri_to_short(), mri_to_short_sclip(), mri_warp3D_align_setup(), mri_watershedize(), RCREND_reload_dataset(), RCREND_reload_func_dset(), REND_reload_dataset(), REND_reload_func_dset(), THD_extract_float_brick(), THD_mean_brick(), THD_median_brick(), and THD_rms_brick().

#define MRI_NN   (0)
 

Definition at line 511 of file mrilib.h.

Referenced by apply_xshear(), apply_yshear(), apply_zshear(), main(), mri_brainormalize(), mri_warp3D(), NUD_rotate(), SHIFT_set_method(), THD_rota_byte_mode(), THD_rota_method(), and VL_command_line().

#define MRI_QUINTIC   (4)
 

Definition at line 512 of file mrilib.h.

Referenced by main(), mri_3dalign_one(), mri_warp3D(), RT_registration_2D_setup(), SHIFT_set_method(), THD_rota_method(), and VL_command_line().

#define MRI_RGB_PTR iq       ((iq)->im.rgb_data)
 

Definition at line 337 of file mrilib.h.

#define MRI_RGBA_PTR iq       ((iq)->im.rgba_data)
 

Definition at line 338 of file mrilib.h.

#define MRI_rgbyte   MRI_rgb
 

Definition at line 114 of file mrilib.h.

#define MRI_ROT_0   1
 

Definition at line 878 of file mrilib.h.

#define MRI_ROT_180   4
 

Definition at line 880 of file mrilib.h.

#define MRI_ROT_270   8
 

Definition at line 881 of file mrilib.h.

#define MRI_ROT_90   2
 

Definition at line 879 of file mrilib.h.

#define MRI_SHORT_2D iq,
ix,
jy       MRI_SHORT_PTR(iq)[(ix)+(jy)*(iq)->nx]
 

Definition at line 341 of file mrilib.h.

#define MRI_SHORT_PTR iq       ((iq)->im.short_data)
 

Definition at line 332 of file mrilib.h.

#define MRI_TSSHIFT   (6)
 

Definition at line 514 of file mrilib.h.

Referenced by apply_xshear(), apply_yshear(), apply_zshear(), SHIFT_set_method(), THD_rota_byte_mode(), and THD_rota_method().

#define MRI_type   MRI_TYPE ;
 

Definition at line 111 of file mrilib.h.

#define MRI_TYPE_NAME iimm       MRI_TYPE_name[(iimm)->kind]
 

Definition at line 127 of file mrilib.h.

Referenced by adwarp_refashion_dataset(), AFNI_func_overlay(), AFNI_refashion_dataset(), and mri_overlay_2D().

#define MRI_type_name   MRI_TYPE_name
 

Definition at line 125 of file mrilib.h.

Referenced by CALC_read_opts(), EDIT_one_dataset(), main(), and thd_mask_from_brick().

#define mri_zero_image iq       memset(mri_data_pointer(iq),0,(iq)->nvox*(iq)->pixel_size)
 

Set all pixels in MRI_IMAGE to zero.

Definition at line 607 of file mrilib.h.

Referenced by FD_brick_to_series().

#define MRILIB_7D
 

Definition at line 10 of file mrilib.h.

#define MSB_FIRST   2
 

Definition at line 892 of file mrilib.h.

#define MSB_FIRST_STRING   "MSB_FIRST"
 

Definition at line 899 of file mrilib.h.

Referenced by main(), THD_datablock_from_atr(), THD_dataset_info(), THD_enviro_write_order(), THD_init_one_datablock(), and THD_write_datablock().

#define NATIVE_ORDER   -1
 

Definition at line 893 of file mrilib.h.

#define NATIVE_STRING   "NATIVE_ORDER"
 

Definition at line 900 of file mrilib.h.

Referenced by main().

#define normal_t2z      (x)
 

Definition at line 982 of file mrilib.h.

Referenced by THD_stat_to_zscore().

#define ORDER_LEN   9
 

Definition at line 897 of file mrilib.h.

Referenced by THD_datablock_from_atr(), and THD_init_one_datablock().

#define OSFILT a,
b,
c   
 

Value:

( MRI_mm = 4*((a)<(b)) + 2*((a)<(c)) + ((b)<(c)) , \
                        (MRI_mm==3||MRI_mm==4) ? OSFSUM(a,b,c) :         \
                        (MRI_mm==7||MRI_mm==0) ? OSFSUM(b,a,c) : OSFSUM(c,a,b) )
Order-statistic filter of 3.

Definition at line 494 of file mrilib.h.

Referenced by AFNI_gra_send_CB(), and osfilt3_func().

#define OSFSUM p,
q,
r       (0.70*(p)+0.15*((q)+(r)))
 

Order-statistic filter of 3.

Definition at line 490 of file mrilib.h.

#define PI   3.14159265358979323846
 

Definition at line 53 of file mrilib.h.

#define PRINT_VERSION pp       INFO_message("Program %s: AFNI version=%s",(pp),AFNI_VERSION_LABEL)
 

Definition at line 1108 of file mrilib.h.

Referenced by get_options(), identify_software(), and main().

#define QG      (0.5*erfc(x/1.414213562373095))
 

Definition at line 960 of file mrilib.h.

#define RESTRICT
 

Definition at line 1101 of file mrilib.h.

#define REVERSE_ORDER bord       (3-(bord))
 

Definition at line 895 of file mrilib.h.

Referenced by main(), THD_open_analyze(), THD_open_ctfmri(), and THD_open_ctfsam().

#define RGBYTE_TO_INT rgb       ( (rgb).r << 16 | (rgb).g << 8 | (rgb).b )
 

Convert one RBG triple (rgbyte) to a single int.

Definition at line 189 of file mrilib.h.

#define RGBZAS q       ( (q).r = (q).g = (q).b = 0 )
 

Definition at line 182 of file mrilib.h.

Referenced by mri_edgize().

#define RGBZEQ q       ( (q).r==0 && (q).g==0 && (q).b==0 )
 

Definition at line 181 of file mrilib.h.

Referenced by mri_edgize().

#define SHORT_TO_BYTE fff       ( ((fff)<=0) ? (0) : ((fff)>=255) ? (255) : (byte)(fff) )
 

Definition at line 350 of file mrilib.h.

Referenced by EDIT_coerce_type().

#define SHORTIZE xx   
 

Value:

(  ((xx) < -32767.0) ? (short)-32767                    \
                      : ((xx) >  32767.0) ? (short) 32767 : (short)rint(xx) )
Force a float into a short.

Definition at line 148 of file mrilib.h.

Referenced by main(), MASKAVE_main(), mri_brainormalize(), mri_threshold(), mri_to_short(), mri_to_short_sclip(), SUMA_FormAfnidset(), THD_insert_series(), THD_load_datablock(), THD_makemask(), and thd_mask_from_brick().

#define SQR      ((x)*(x))
 

Definition at line 518 of file mrilib.h.

Referenced by BFIT_compute(), main(), MASKAVE_main(), mri_align_crao(), normalize_doublevector(), normalize_floatvector(), PCOR_get_mcor(), PCOR_get_pcor(), PCOR_get_pcor_and_coef(), report_evaluation(), and VOLREG_main().

#define TRUE   (1)
 

Definition at line 499 of file mrilib.h.

#define TRUNCATE_IMARR name,
qq   
 

Value:

do{ int nn ;                                                                 \
       if( (name) != NULL && qq < (name)->num ){                                \
          for( nn=qq ; nn < (name)->num ; nn++ ) mri_free((name)->imarr[nn]);   \
          (name)->num = qq ;                                                    \
       } } while(0)
Free all images at-and-after [qq] in the MRI_IMARR struct.

Definition at line 416 of file mrilib.h.

Referenced by evolve_bitvector_array(), and mri_read_dicom().

#define UNLOAD_rgba s,
rr,
gg,
bb,
aa       ((rr)=(s).r,(gg)=(s).g,(bb)=(s).b,(aa)=(s).a)
 

Definition at line 94 of file mrilib.h.

#define USE_MRI_DELAY
 

Mar 1996: Extended to images up to 7D; Not all routines work with images > 2D -- check top of file for "7D SAFE" comments *

Definition at line 221 of file mrilib.h.

#define WAY_BIG   1.e+10
 

A big number (anything over this is infinity).

Definition at line 58 of file mrilib.h.

#define WHOAMI
 

Definition at line 530 of file mrilib.h.

#define WROTE_DSET dd       INFO_message("Output dataset %s",DSET_BRIKNAME(dd))
 

Definition at line 1116 of file mrilib.h.

Referenced by main().

#define WROTE_DSET_MSG dd,
ss       INFO_message("Output dataset %s {%s}",DSET_BRIKNAME(dd),(ss))
 

Definition at line 1112 of file mrilib.h.

#define ZONE_TO_BYTE z       ((byte)(255.49*(z)))
 

Scale a float in [0..1] to a byte in [0..255].

Definition at line 102 of file mrilib.h.


Typedef Documentation

typedef unsigned char byte
 

The MRI_byte data type.

Definition at line 83 of file mrilib.h.

typedef struct complex complex
 

I suppose that the next C makes this pleonastic.

typedef union MRI_DATA MRI_DATA
 

A union type to hold all possible MRI_IMAGE types. This was created before I really understood how to use void *.

typedef struct MRI_IMAGE MRI_IMAGE
 

Stores one image (1D to 7D). Why 7D, you ask? Well, I originally only had 2D images here. When extending AFNI from 3D to 3D+time and buckets, I thought that I might use 4D images (x,y,z,t) as the basic element. Instead, I decided to use an array of 3D images (in a THD_datablock), but by then I'd extended this typedef to allow (x,y,z,t,u,v,w) dimensioned arrays. I don't think anyplace ever uses more than 3D images, though.

typedef struct MRI_IMARR MRI_IMARR
 

Array of MRI_IMAGE pointers.

typedef enum MRI_TYPE MRI_TYPE
 

Integer flags for different image types. Sometimes called the "datum".

typedef struct rgbyte rgbyte
 

Triple to hold RGB bytes.


Enumeration Type Documentation

enum MRI_TYPE
 

Integer flags for different image types. Sometimes called the "datum".

Enumeration values:
MRI_byte 
MRI_short 
MRI_int 
MRI_float 
MRI_double 
MRI_complex 
MRI_rgb 
MRI_rgba 

Definition at line 106 of file mrilib.h.


Function Documentation

double beta_p2t double    qq,
double    aa,
double    bb
 

Definition at line 612 of file mri_stats.c.

References a, cdfbet(), p, and q.

Referenced by BFIT_compute(), main(), process_sample(), and THD_pval_to_stat().

00613 {
00614    int which , status ;
00615    double p,q,x,y,a,b,bound ;
00616 
00617    if( qq <= 0.0      ) return 0.9999 ;
00618    if( qq >= 0.999999 ) return 0.0 ;
00619 
00620    which  = 2 ;
00621    p      = 1.0 - qq ;
00622    q      = qq ;
00623    x      = 0.0 ;
00624    y      = 1.0 ;
00625    a      = aa ;
00626    b      = bb ;
00627 
00628    cdfbet( &which , &p , &q , &x , &y , &a , &b ,  &status , &bound ) ;
00629 
00630    return x ;
00631 }

double beta_t2p double    xx,
double    aa,
double    bb
 

Definition at line 583 of file mri_stats.c.

References a, cdfbet(), p, and q.

Referenced by beta_t2z(), BFIT_compute(), BFIT_main(), and THD_stat_to_pval().

00584 {
00585    int which , status ;
00586    double p,q,x,y,a,b,bound ;
00587 
00588    which  = 1 ;
00589    p      = 0.0 ;
00590    q      = 0.0 ;
00591    x      = xx ;
00592    y      = 1.0 - xx ;
00593    a      = aa ;
00594    b      = bb ;
00595 
00596    cdfbet( &which , &p , &q , &x , &y , &a , &b ,  &status , &bound ) ;
00597 
00598    if( status == 0 ) return q ;
00599    else              return 1.0 ;
00600 }

double beta_t2z double    xx,
double    aa,
double    bb
 

Definition at line 605 of file mri_stats.c.

References beta_t2p(), and qginv().

Referenced by THD_stat_to_zscore().

00606 {
00607    double pp ;
00608    pp = 0.5 * beta_t2p( xx , aa , bb ) ;
00609    return qginv(pp) ;
00610 }

double binomial_p2t double    qq,
double    ntrial,
double    ptrial
 

Definition at line 668 of file mri_stats.c.

References cdfbin(), p, q, and xn.

Referenced by main(), and THD_pval_to_stat().

00669 {
00670    int which , status ;
00671    double p,q, s,xn,pr,ompr,bound ;
00672 
00673    if( qq <= 0.0      ) return 99.99 ;
00674    if( qq >= 0.999999 ) return 0.0 ;
00675 
00676    which  = 2 ;
00677    p      = 1.0 - qq ;
00678    q      = qq ;
00679    s      = 0.0 ;
00680    xn     = ntrial ;
00681    pr     = ptrial ;
00682    ompr   = 1.0 - ptrial ;
00683 
00684    cdfbin( &which , &p , &q , &s , &xn , &pr , &ompr , &status , &bound ) ;
00685 
00686    if( status == 0 ) return s ;
00687    else              return 0.0 ;
00688 }

double binomial_t2p double    ss,
double    ntrial,
double    ptrial
 

Definition at line 639 of file mri_stats.c.

References cdfbin(), p, q, and xn.

Referenced by binomial_t2z(), and THD_stat_to_pval().

00640 {
00641    int which , status ;
00642    double p,q, s,xn,pr,ompr,bound ;
00643 
00644    which  = 1 ;
00645    p      = 0.0 ;
00646    q      = 0.0 ;
00647    s      = ss ;
00648    xn     = ntrial ;
00649    pr     = ptrial ;
00650    ompr   = 1.0 - ptrial ;
00651 
00652    cdfbin( &which , &p , &q , &s , &xn , &pr , &ompr , &status , &bound ) ;
00653 
00654    if( status == 0 ) return q ;
00655    else              return 1.0 ;
00656 }

double binomial_t2z double    ss,
double    ntrial,
double    ptrial
 

Definition at line 661 of file mri_stats.c.

References binomial_t2p(), and qginv().

Referenced by THD_stat_to_zscore().

00662 {
00663    double pp ;
00664    pp = 0.5 * binomial_t2p( ss , ntrial , ptrial ) ;
00665    return qginv(pp) ;
00666 }

void cfft int   ,
int   ,
float *   ,
float *   
 

Definition at line 23 of file mri_cfft.c.

References c, i1, i2, and PI.

Referenced by cfft2d().

00025 {
00026 #define IDMAX  1024
00027 #define LIDMAX 10
00028    static int idold = -999 ;
00029    register int i0,i1,i2,i4,i5,m0, id = idim;
00030    float    f1,f3,f4,f5,al,co,si,md = mode;
00031    static   int    n,m[LIDMAX];
00032    static   float  f2,c[IDMAX/2],s[IDMAX/2];
00033 
00034    /**** preparations if id has changed since last call ****/
00035 
00036    if (idold != id) {
00037      idold = id ;
00038      /* check for power of 2 */
00039      for( i4=4 ; i4 <= IDMAX ; i4 *= 2 ){
00040         if( id == i4 )break ;
00041      }
00042      if( id != i4 ){
00043        fprintf(stderr,"\n In cfft : illegal idim=%d\n",idim);
00044        exit(1) ;
00045      }
00046      f2     = id;
00047      n      = log(f2)/log(2.) + .5;
00048      m[n-1] = 1;
00049      al     = 2.*PI/f2;
00050      co     = cos(al);
00051      si     = sin(al);
00052      c[0]   = 1.;
00053      s[0]   = 0.;
00054      for(i4 = 1; i4 < 512; i4++) {
00055        c[i4] = c[i4-1]*co - s[i4-1]*si;
00056        s[i4] = s[i4-1]*co + c[i4-1]*si;
00057      }
00058      for(i4 = n-1; i4 >= 1; i4--) m[i4-1] = m[i4]*2;
00059    }
00060 
00061    /**** Main loop starts here ****/
00062 
00063    for(i0 = 0; i0 < n; i0++) {
00064      i1 = 0;
00065      m0 = m[i0];
00066      for(i2 = 0; i2 < m[n-i0-1]; i2++) {
00067        f4 = c[i1];
00068        f5 = s[i1]*md;
00069          for(i4 = 2*m0*i2; i4 < m0*(2*i2+1); i4++) {
00070            f3 = xr[i4+m0]*f4 - xi[i4+m0]*f5;
00071            f1 = xi[i4+m0]*f4 + xr[i4+m0]*f5;
00072            xr[i4+m0] = xr[i4] - f3;
00073            xr[i4] += f3;
00074            xi[i4+m0] = xi[i4] - f1;
00075            xi[i4] += f1;
00076          }
00077         for(i4 = 1; i4 < n; i4++) {
00078            i5 = i4;
00079            if (i1 < m[i4]) goto i1_plus1;
00080            i1 -= m[i4];
00081          }
00082 i1_plus1: i1 += m[i5];
00083      }
00084    }
00085    i1 = 0;
00086    for(i4 = 0; i4 < id; i4++) {
00087      if (i1 > i4) {
00088        f3 = xr[i4];
00089        f1 = xi[i4];
00090        xr[i4] = xr[i1];
00091        xi[i4] = xi[i1];
00092        xr[i1] = f3;
00093        xi[i1] = f1;
00094      }
00095      for(i2 = 0; i2 < n; i2++) {
00096        i5 = i2;
00097        if (i1 < m[i2]) goto i1_plus2;
00098        i1 -= m[i2];
00099      }
00100 i1_plus2:   i1 += m[i5];
00101    }
00102 
00103    if (md > 0.) {
00104      f1 = 1./f2;
00105      for(i4 = 0; i4 < id; i4++) {
00106        xr[i4] *= f1;
00107        xi[i4] *= f1;
00108      }
00109    }
00110    return;
00111 }

void cfft2d int   ,
int   ,
int   ,
float *   ,
float *   
 

Definition at line 116 of file mri_cfft.c.

References cfft(), free, and malloc.

Referenced by mri_fft_complex().

00118 {
00119    float *rbuf , *ibuf ;
00120    register int ii , jj , jbase ;
00121 
00122    rbuf = (float *)malloc( ny * sizeof(float) ) ;
00123    ibuf = (float *)malloc( ny * sizeof(float) ) ;
00124    if( rbuf == NULL || ibuf == NULL ){
00125       fprintf(stderr,"malloc error in cfft2d\n") ;
00126       exit(1) ;
00127    }
00128 
00129    for( jj=0 ; jj < ny ; jj++ ){
00130       jbase = nx * jj ;
00131       cfft( mode , nx , &xr[jbase] , &xi[jbase] ) ;
00132    }
00133 
00134    for( ii=0 ; ii < nx ; ii++ ){
00135       for( jj=0 ; jj < ny ; jj++ ){
00136          rbuf[jj] = xr[ii + jj*nx] ;
00137          ibuf[jj] = xi[ii + jj*nx] ;
00138       }
00139       cfft( mode , ny , rbuf , ibuf ) ;
00140       for( jj=0 ; jj < ny ; jj++ ){
00141          xr[ii+jj*nx] = rbuf[jj] ;
00142          xi[ii+jj*nx] = ibuf[jj] ;
00143       }
00144    }
00145 
00146    free(rbuf) ; free(ibuf) ;
00147    return ;
00148 }

double chisq_p2t double    qq,
double    dof
 

Definition at line 554 of file mri_stats.c.

References cdfchi(), p, and q.

Referenced by THD_pval_to_stat().

00555 {
00556    int which , status ;
00557    double p,q,x,df,bound ;
00558 
00559    if( qq <= 0.0      ) return 999.9 ;
00560    if( qq >= 0.999999 ) return 0.0 ;
00561 
00562    which  = 2 ;
00563    p      = 1.0 - qq ;
00564    q      = qq ;
00565    x      = 0.0 ;
00566    df     = dof ;
00567 
00568    cdfchi( &which , &p , &q , &x , &df , &status , &bound ) ;
00569    return x ;
00570 }

double chisq_t2p double    xx,
double    dof
 

Definition at line 534 of file mri_stats.c.

References cdfchi(), p, and q.

Referenced by BFIT_compute(), chisq_t2z(), and THD_stat_to_pval().

00535 {
00536    int which , status ;
00537    double p,q,x,df,bound ;
00538 
00539    which  = 1 ;
00540    p      = 0.0 ;
00541    q      = 0.0 ;
00542    x      = xx ;
00543    df     = dof ;
00544 
00545    cdfchi( &which , &p , &q , &x , &df , &status , &bound ) ;
00546 
00547    if( status == 0 ) return q ;
00548    else              return 1.0 ;
00549 }

double chisq_t2z double    xx,
double    dof
 

Definition at line 572 of file mri_stats.c.

References chisq_t2p(), and qginv().

Referenced by THD_stat_to_zscore().

00573 {
00574    double pp ;
00575    pp = 0.5 * chisq_t2p( xx , dof ) ;
00576    return qginv(pp) ;
00577 }

double correl_p2t double   ,
double   ,
double   ,
double   
 

Definition at line 71 of file mri_stats.c.

References incbeta_inverse(), and lnbeta().

Referenced by THD_pval_to_stat().

00072 {
00073    double bb , binv , rho ;
00074 
00075    if( pp <= 0.0      ) return 0.999 ;
00076    if( pp >= 0.999999 ) return 0.0 ;
00077 
00078    if( nsam <= nfit+nort || nfit < 1.0 || nort < 1.0 ) return 0.0 ;
00079 
00080    bb   = lnbeta( 0.5*nfit , 0.5*(nsam-nfit-nort) ) ;
00081    binv = incbeta_inverse( pp, 0.5*(nsam-nfit-nort) , 0.5*nfit , bb ) ;
00082    rho  = sqrt(1.0-binv) ;
00083    return rho ;
00084 }

double correl_t2p double   ,
double   ,
double   ,
double   
 

Definition at line 86 of file mri_stats.c.

References incbeta(), and lnbeta().

Referenced by CORREL_main(), correl_t2z(), and THD_stat_to_pval().

00087 {
00088    double bb , xx , pp ;
00089 
00090    if( rho <= 0.0 ||
00091        nsam <= nfit+nort || nfit < 1.0 || nort < 1.0 ) return 1.0 ;
00092 
00093    if( rho >= 0.9999999 ) return 0.0 ;
00094 
00095    bb   = lnbeta( 0.5*nfit , 0.5*(nsam-nfit-nort) ) ;
00096    xx   = 1.0 - rho*rho ;
00097    pp   = incbeta( xx , 0.5*(nsam-nfit-nort) , 0.5*nfit , bb ) ;
00098    return pp ;
00099 }

double correl_t2z double   ,
double   ,
double   ,
double   
 

Definition at line 104 of file mri_stats.c.

References correl_t2p(), and qginv().

Referenced by THD_stat_to_zscore().

00105 {
00106    double pp , xx ;
00107    pp = 0.5 * correl_t2p( fabs(rho) , nsam , nfit , nort ) ;
00108    xx = qginv(pp) ;
00109    return ( (rho > 0) ? xx : -xx ) ;
00110 }

void csfft_cox int   ,
int   ,
complex  
 

Referenced by absfft_func(), autocorr(), csfft_many(), EDIT_blur_volume_3d(), fft2D_func(), fft_3dec(), fft_5dec(), fft_shift2(), filter(), ft_shift2(), main(), mri_fft2D(), mri_filt_fft(), POWER_main(), and ts_to_ftime().

void csfft_many int    mode,
int    idim,
int    nvec,
complex   xc
 

Main loop starts here *

Definition at line 355 of file csfft.c.

References csfft_cox(), csfft_trigconsts(), fft_3dec(), fft_5dec(), complex::i, i1, i2, nold, complex::r, and xc.

Referenced by main().

00356 {
00357    register unsigned int  m, n, i0, i1, i2, i3, k , iv ;
00358    register complex       *r0, *r1, *csp , *xcx;
00359    register float         co, si, f0, f1, f2, f3, f4;
00360 
00361    if( nvec == 1 ){ csfft_cox( mode , idim , xc ) ; return ; }
00362 
00363    if( idim % 3 == 0 ){                           /* Aug 1999 */
00364       for( m=0 ; m < nvec ; m++ )
00365          fft_3dec( mode , idim , xc + m*idim ) ;
00366       return ;
00367    } else if( idim % 5 == 0 ){
00368       for( m=0 ; m < nvec ; m++ )
00369          fft_5dec( mode , idim , xc + m*idim ) ;
00370       return ;
00371    }
00372 
00373    /** perhaps initialize **/
00374 
00375    if( nold != idim ) csfft_trigconsts( idim ) ;
00376 
00377    n   = idim;
00378    i2  = idim >> 1;
00379    i1  = 0;
00380    csp = (mode > 0) ? csplus : csminus ;  /* choose const array */
00381 
00382    for (i0=0; i0 < n; i0 ++) {
00383       if ( i1 > i0 ) {
00384          for( iv=0,xcx=xc ; iv < nvec ; iv++,xcx+=n ){
00385             r0    = xcx + i0; r1    = xcx + i1;
00386             f1    = r0->r;    f2    = r0->i;
00387             r0->r = r1->r;    r0->i = r1->i;
00388             r1->r = f1;       r1->i = f2;
00389          }
00390       }
00391       m = i2;
00392       while ( m && !(i1 < m) ) { i1 -= m; m >>= 1; }
00393      i1 += m;
00394    }
00395 
00396 #define I00
00397 #ifdef I00
00398 #  define I0BOT 1
00399 #else
00400 #  define I0BOT 0
00401 #endif
00402 
00403    m = 1;
00404    k = 0;
00405    while (n > m) {
00406       i3 = m << 1;
00407 
00408 #ifdef I00
00409       /* handle i0=0 case [co=1,si=0] in special code */
00410 
00411       for (i1=0; i1 < n; i1 += i3) {
00412          for( iv=0,r0=xc+i1 ; iv < nvec ; iv++,r0+=n ){
00413             r1    = r0 + m;
00414             f1    = r1->r ;   f3    = r1->i ;
00415             f2    = r0->r ;   f4    = r0->i ;
00416             r1->r = f2 - f1 ; r1->i = f4 - f3 ;
00417             r0->r = f2 + f1 ; r0->i = f4 + f3 ;
00418          }
00419       }
00420       k++;
00421 #endif
00422 
00423       for (i0=I0BOT; i0 < m; i0 ++) {
00424          co = (csp + k)->r; si = (csp + k)->i;
00425          for (i1=i0; i1 < n; i1 += i3) {
00426             for( iv=0,r0=xc+i1 ; iv < nvec ; iv++,r0+=n ){
00427                r1    = r0 + m;
00428 #if 1
00429                f1    = r1->r * co - r1->i * si ;
00430                f3    = r1->r * si + r1->i * co ;
00431 #else
00432                f1    = r1->r * co ; f2    = r1->i * si ;
00433                f3    = r1->r * si ; f4    = r1->i * co ;
00434                f1   -= f2 ;         f3   += f4 ;
00435 #endif
00436                f2    = r0->r ;   f4    = r0->i ;
00437                r1->r = f2 - f1 ; r1->i = f4 - f3 ;
00438                r0->r = f2 + f1 ; r0->i = f4 + f3 ;
00439             }
00440          }
00441          k++;
00442       }
00443       m = i3;
00444    }
00445    return ;
00446 }

int csfft_nextup int   
 

Referenced by absfft_func(), csfft_nextup_even(), csfft_nextup_one35(), and main().

int csfft_nextup_even int   
 

Definition at line 2247 of file csfft.c.

References csfft_nextup().

Referenced by apply_xshear(), apply_yshear(), and apply_zshear().

02248 {
02249    int jj = idim ;
02250    do{
02251       jj = csfft_nextup(jj) ;
02252       if( jj%2 == 1 ) jj++ ;
02253       else            return jj ;
02254    } while(1) ;
02255    return 0 ; /* cannot be reached */
02256 }

int csfft_nextup_one35 int   
 

Referenced by apply_xshear(), apply_yshear(), apply_zshear(), autocorr(), EDIT_blur_volume_3d(), fft2D_func(), filter(), main(), mri_fft2D(), POWER_main(), THD_dataset_tshift(), and ts_to_ftime().

void csfft_scale_inverse int   
 

Referenced by autocorr(), and main().

void csfft_use_fftw int   
 

Definition at line 28 of file csfft.c.

References use_fftw.

Referenced by main().

00028 { use_fftw = uf; return; }

float* delayed_lsqfit int    veclen,
float *    data,
int    nref,
float *    ref[],
double *    cc
 

------------------------------------------------------------------ Given the data from startup_lsqfit, finish the job. ------------------------------------------------------------------*

Definition at line 313 of file mri_lsqfit.c.

References free, malloc, and ref.

Referenced by LSQ_worker(), main(), and mri_delayed_lsqfit().

00315 {
00316    int    ii , jj ;
00317    float  *alpha = NULL ;
00318    double *rr = NULL ;
00319    register double sum ;
00320 
00321    if( nref < 1 || veclen < nref ||
00322        data == NULL || ref == NULL || cc == NULL ) return NULL ;
00323 
00324    /*** form RHS vector into rr ***/
00325 
00326    rr = DBLEVEC(nref) ; if( rr == NULL ) return NULL ;
00327 
00328    for( ii=0 ; ii < nref ; ii++ ){
00329       sum = 0.0 ;
00330       for( jj=0 ; jj < veclen ; jj++ ) sum += ref[ii][jj] * data[jj] ;
00331       rr[ii] = sum ;
00332    }
00333 
00334    /*** forward solve ***/
00335 
00336    for( ii=0 ; ii < nref ; ii++ ){
00337       sum = rr[ii] ;
00338       for( jj=0 ; jj < ii ; jj++ ) sum -= CC(ii,jj) * rr[jj] ;
00339       rr[ii] = sum / CC(ii,ii) ;
00340    }
00341 
00342    /*** backward solve ***/
00343 
00344    for( ii=nref-1 ; ii >= 0 ; ii-- ){
00345       sum = rr[ii] ;
00346       for( jj=ii+1 ; jj < nref ; jj++ ) sum -= CC(jj,ii) * rr[jj] ;
00347       rr[ii] = sum / CC(ii,ii) ;
00348    }
00349 
00350    /*** put result into alpha ***/
00351 
00352    alpha = (float *) malloc( sizeof(float) * nref ) ; if( alpha == NULL ) return NULL ;
00353    for( ii=0 ; ii < nref ; ii++ ) alpha[ii] = rr[ii] ;
00354 
00355    /*** cleanup and exit ***/
00356 
00357    free(rr) ;
00358    return alpha ;
00359 }

double fstat_p2t double   ,
double   ,
double   
 

Definition at line 169 of file mri_stats.c.

References cdff(), p, and q.

Referenced by THD_pval_to_stat().

00170 {
00171    int which , status ;
00172    double p , q , f , dfn , dfd , bound ;
00173 
00174    if( pp <= 0.0      ) return 999.99 ;
00175    if( pp >= 0.999999 ) return 0.0 ;
00176 
00177    which  = 2 ;
00178    p      = 1.0 - pp ;  /* 20 Jan 1999: p and q were switched! */
00179    q      = pp ;
00180    f      = 0.0 ;
00181    dfn    = dofnum ;
00182    dfd    = dofden ;
00183 
00184    cdff( &which , &p , &q , &f , &dfn , &dfd , &status , &bound ) ;
00185 
00186    if( status == 0 ) return f ;
00187    else              return 0.0 ;
00188 }

double fstat_t2p double   ,
double   ,
double   
 

Definition at line 1285 of file NLfit.c.

References cdff(), p, and q.

Referenced by fstat_t2z(), report_results(), and THD_stat_to_pval().

01286 {
01287    int which , status ;
01288    double p , q , f , dfn , dfd , bound ;
01289 
01290    which  = 1 ;
01291    p      = 0.0 ;
01292    q      = 0.0 ;
01293    f      = ff ;
01294    dfn    = dofnum ;
01295    dfd    = dofden ;
01296 
01297    cdff( &which , &p , &q , &f , &dfn , &dfd , &status , &bound ) ;
01298 
01299    if( status == 0 ) return q ;
01300    else              return 1.0 ;
01301 }

double fstat_t2z double   ,
double   ,
double   
 

Definition at line 211 of file mri_stats.c.

References fstat_t2p(), and qginv().

Referenced by THD_stat_to_zscore().

00212 {
00213    double pp ;
00214    pp = 0.5 * fstat_t2p( ff , dofnum , dofden ) ;
00215    return qginv(pp) ;
00216 }

void ft_shift2 int    n,
int    nup,
float    af,
float *    f,
float    ag,
float *    g
 

other initialization *

Definition at line 298 of file mri_affine.c.

References CEXPIT, CMULT, csfft_cox(), free, complex::i, malloc, and complex::r.

Referenced by ft_xshear(), and ft_yshear().

00299 {
00300    static int nupold=0 ;
00301    static complex * row=NULL , * cf=NULL , * cg=NULL ;
00302 
00303    int ii , nby2=nup/2 , n21=nby2+1 ;
00304    complex fac , gac ;
00305    float sf , sg , dk ;
00306 
00307    /* make new memory for row storage? */
00308 
00309    if( nup > nupold ){
00310       if( row != NULL ){ free(row) ; free(cf) ; free(cg) ; }
00311       row = (complex *) malloc( sizeof(complex) * nup ) ;
00312       cf  = (complex *) malloc( sizeof(complex) * n21 ) ;
00313       cg  = (complex *) malloc( sizeof(complex) * n21 ) ;
00314       nupold = nup ;
00315    }
00316 
00317    /* FFT the pair of rows */
00318 
00319    for( ii=0 ; ii < n   ; ii++ ){ row[ii].r = f[ii] ; row[ii].i = g[ii] ; }
00320    for(      ; ii < nup ; ii++ ){ row[ii].r = row[ii].i = 0.0 ; }
00321 
00322    csfft_cox( -1 , nup , row ) ;
00323 
00324    /* untangle FFT coefficients from row into cf,cg */
00325 
00326    cf[0].r = 2.0 * row[0].r ; cf[0].i = 0.0 ;  /* twice too big */
00327    cg[0].r = 2.0 * row[0].i ; cg[0].i = 0.0 ;
00328    for( ii=1 ; ii < nby2 ; ii++ ){
00329       cf[ii].r =  row[ii].r + row[nup-ii].r ;
00330       cf[ii].i =  row[ii].i - row[nup-ii].i ;
00331       cg[ii].r =  row[ii].i + row[nup-ii].i ;
00332       cg[ii].i = -row[ii].r + row[nup-ii].r ;
00333    }
00334    cf[nby2].r = 2.0 * row[nby2].r ; cf[nby2].i = 0.0 ;
00335    cg[nby2].r = 2.0 * row[nby2].i ; cg[nby2].i = 0.0 ;
00336 
00337    /* phase shift both rows (cf,cg) */
00338 
00339    dk = (2.0*PI) / nup ;
00340    sf = -af * dk ; sg = -ag * dk ;
00341    for( ii=1 ; ii <= nby2 ; ii++ ){
00342       fac = CEXPIT(ii*sf) ; cf[ii] = CMULT( fac , cf[ii] ) ;
00343       gac = CEXPIT(ii*sg) ; cg[ii] = CMULT( gac , cg[ii] ) ;
00344    }
00345    cf[nby2].i = 0.0 ; cg[nby2].i = 0.0 ;
00346 
00347    /* retangle the coefficients from 2 rows */
00348 
00349    row[0].r = cf[0].r ; row[0].i = cg[0].r ;
00350    for( ii=1 ; ii < nby2 ; ii++ ){
00351       row[ii].r     =  cf[ii].r - cg[ii].i ;
00352       row[ii].i     =  cf[ii].i + cg[ii].r ;
00353       row[nup-ii].r =  cf[ii].r + cg[ii].i ;
00354       row[nup-ii].i = -cf[ii].i + cg[ii].r ;
00355    }
00356    row[nby2].r = cf[nby2].r ;
00357    row[nby2].i = cg[nby2].r ;
00358 
00359    /* inverse FFT and store back in output arrays */
00360 
00361    csfft_cox( 1 , nup , row ) ;
00362 
00363    sf = 0.5 / nup ;              /* 0.5 to allow for twice too big above */
00364    for( ii=0 ; ii < n ; ii++ ){
00365       f[ii] = sf * row[ii].r ; g[ii] = sf * row[ii].i ;
00366    }
00367 
00368    return ;
00369 }

double gamma_p2t double    qq,
double    sh,
double    sc
 

Definition at line 722 of file mri_stats.c.

References cdfgam(), p, q, scale, and shape.

Referenced by THD_pval_to_stat().

00723 {
00724    int which , status ;
00725    double p,q, x,shape,scale,bound ;
00726 
00727    if( qq <= 0.0      ) return 999.9 ;
00728    if( qq >= 0.999999 ) return 0.0 ;
00729 
00730    which  = 2 ;
00731    p      = 1.0 - qq ;
00732    q      = qq ;
00733    x      = 0.0 ;
00734    shape  = sh ;
00735    scale  = sc ;
00736 
00737    cdfgam( &which , &p , &q , &x , &shape , &scale , &status , &bound ) ;
00738 
00739    return x ;
00740 }

double gamma_t2p double    xx,
double    sh,
double    sc
 

Definition at line 694 of file mri_stats.c.

References cdfgam(), p, q, scale, and shape.

Referenced by gamma_t2z(), and THD_stat_to_pval().

00695 {
00696    int which , status ;
00697    double p,q, x,shape,scale,bound ;
00698 
00699    which  = 1 ;
00700    p      = 0.0 ;
00701    q      = 0.0 ;
00702    x      = xx ;
00703    shape  = sh ;
00704    scale  = sc ;
00705 
00706    cdfgam( &which , &p , &q , &x , &shape , &scale , &status , &bound ) ;
00707 
00708    if( status == 0 ) return q ;
00709    else              return 1.0 ;
00710 }

double gamma_t2z double    xx,
double    sh,
double    sc
 

Definition at line 715 of file mri_stats.c.

References gamma_t2p(), and qginv().

Referenced by THD_stat_to_zscore().

00716 {
00717    double pp ;
00718    pp = 0.5 * gamma_t2p( xx , sh , sc ) ;
00719    return qginv(pp) ;
00720 }

char* imsized_fname char *    fname
 

Check if a filesize fits an MCW_IMSIZE setup.

Parameters:
fname  = Filename
Returns:
A new "filename" with 3D header attached if it fits. If not, return a copy of the filename. In any case the returned string should be free()-d when it is no longer needed.

Definition at line 1597 of file mri_read.c.

References EXIT, MCW_imsize::head, init_MCW_sizes(), malloc, MAX_MCW_IMSIZE, MCW_imsize_good, mri_filesize(), my_strdup(), and MCW_imsize::size.

Referenced by mri_imcount(), mri_read_file(), mri_read_file_delay(), and mri_read_just_one().

01598 {
01599    int num , lll ;
01600    long len ;
01601    char * new_name ;
01602 
01603    init_MCW_sizes() ;
01604    if( MCW_imsize_good == 0 ){
01605       new_name = my_strdup(fname) ;  /* nothing to fit */
01606       return new_name ;              /* --> return copy of old name */
01607    }
01608 
01609    len = mri_filesize( fname ) ;
01610    if( len <= 0 ){
01611       new_name = my_strdup(fname) ;  /* not an existing filename */
01612       return new_name ;              /* --> return copy of old name */
01613    }
01614 
01615    for( num=0 ; num < MAX_MCW_IMSIZE ; num++ ){     /* check each possibility */
01616 
01617       if( imsize[num].size <= 0 ) continue ;        /* skip to next one */
01618 
01619       if( imsize[num].head < 0 && len == imsize[num].size ){  /* fixed size fit */
01620 
01621          lll = strlen(fname) + strlen(imsize[num].prefix) + 4 ;
01622          new_name = (char *) malloc( sizeof(char) * lll ) ;
01623          if( new_name == NULL ){
01624             fprintf(stderr,"\n*** Can't malloc in imsized_fname! ***\a\n");
01625             EXIT(1) ;
01626          }
01627          sprintf( new_name , "%s%s" , imsize[num].prefix , fname ) ;
01628          return new_name ;
01629 
01630       } else if( (len-imsize[num].head) % imsize[num].size == 0 ){
01631          int count = (len-imsize[num].head) / imsize[num].size ;
01632 
01633          if( count < 1 ) continue ;  /* skip to next one */
01634 
01635          lll = strlen(fname) + strlen(imsize[num].prefix) + 32 ;
01636          new_name = (char *) malloc( sizeof(char) * lll ) ;
01637          if( new_name == NULL ){
01638             fprintf(stderr,"\n*** Can't malloc in imsized_fname! ***\a\n");
01639             EXIT(1) ;
01640          }
01641          sprintf( new_name , "%s%d:%s" , imsize[num].prefix , count , fname ) ;
01642          return new_name ;
01643       }
01644 
01645    }
01646 
01647    new_name = my_strdup(fname) ;  /* no fit --> return copy of old name */
01648    return new_name ;
01649 }

double incbeta double   ,
double   ,
double   ,
double   
 

Definition at line 237 of file p2t.c.

00238 {
00239    double betain , psq , cx , xx,pp,qq , term,ai , temp , rx ;
00240    int indx , ns ;
00241 
00242    if( p <= ZERO || q <= ZERO || x < ZERO || x > ONE ) return -1.0 ;
00243 
00244    if( x == ZERO ) return ZERO ;
00245    if( x == ONE  ) return ONE ;
00246 
00247    /**  change tail if necessary and determine s **/
00248 
00249    psq = p+q ;
00250    cx  = ONE-x ;
00251    if(  p < psq*x ){
00252       xx   = cx ;
00253       cx   = x ;
00254       pp   = q ;
00255       qq   = p ;
00256       indx = 1 ;
00257    } else {
00258       xx   = x ;
00259       pp   = p ;
00260       qq   = q ;
00261       indx = 0 ;
00262    }
00263 
00264    term   = ONE ;
00265    ai     = ONE ;
00266    betain = ONE ;
00267    ns     = qq + cx*psq ;
00268 
00269    /** use soper's reduction formulae **/
00270 
00271       rx = xx/cx ;
00272 
00273 lab3:
00274       temp = qq-ai ;
00275       if(ns == 0) rx = xx ;
00276 
00277 lab4:
00278       term   = term*temp*rx/(pp+ai) ;
00279       betain = betain+term ;
00280       temp   = fabs(term) ;
00281       if(temp <= ACU && temp <= ACU*betain) goto lab5 ;
00282 
00283       ai = ai+ONE ;
00284       ns = ns-1 ;
00285       if(ns >= 0) goto lab3 ;
00286       temp = psq ;
00287       psq  = psq+ONE ;
00288       goto lab4 ;
00289 
00290 lab5:
00291       betain = betain*exp(pp*log(xx)+(qq-ONE)*log(cx)-beta)/pp ;
00292       if(indx) betain=ONE-betain ;
00293 
00294    return betain ;
00295 }

double incbeta_inverse double   ,
double   ,
double   ,
double   
 

Definition at line 325 of file p2t.c.

00326 {
00327    int indx , iex ;
00328    double fpu , xinbta , a,pp,qq, r,y,t,s,h,w , acu ,
00329           yprev,prev,sq , g,adj,tx,xin ;
00330 
00331    fpu = pow(10.0,SAE) ;
00332 
00333    if( p <= ZERO || q <= ZERO || alpha < ZERO || alpha > ONE ) return -1.0 ;
00334 
00335    if( alpha == ZERO ) return ZERO ;
00336    if( alpha == ONE  ) return ONE ;
00337 
00338    /** change tail if necessary **/
00339 
00340    if( alpha > 0.5 ){
00341       a    = ONE-alpha ;
00342       pp   = q ;
00343       qq   = p ;
00344       indx = 1 ;
00345     } else {
00346       a    = alpha ;
00347       pp   = p ;
00348       qq   = q ;
00349       indx = 0 ;
00350    }
00351 
00352    /** calculate the initial approximation **/
00353 
00354 lab2:
00355      r = sqrt(-log(a*a)) ;
00356      y = r - (2.30753 + 0.27061*r) / (ONE+(0.99229+0.04481*r)*r) ;
00357      if(pp > ONE && qq > ONE) goto lab5 ;
00358 
00359      r = qq+qq ;
00360      t = ONE/(9.0*qq) ;
00361      t = r * pow( (ONE-t+y*sqrt(t)) , 3.0 ) ;
00362      if( t <= ZERO ) goto lab3 ;
00363 
00364      t = (FOUR*pp+r-TWO)/t ;
00365      if( t <= ONE ) goto lab4 ;
00366 
00367      xinbta = ONE-TWO/(t+ONE) ; goto lab6 ;
00368 
00369 lab3:
00370      xinbta = ONE-exp((log((ONE-a)*qq)+beta)/qq) ; goto lab6 ;
00371 
00372 lab4:
00373      xinbta = exp((log(a*pp)+beta)/pp) ; goto lab6 ;
00374 
00375 lab5:
00376      r = (y*y-THREE)/SIX ;
00377      s = ONE/(pp+pp-ONE) ;
00378      t = ONE/(qq+qq-ONE) ;
00379      h = TWO/(s+t) ;
00380      w = y*sqrt(h+r)/h-(t-s)*(r+FIVE/SIX-TWO/(THREE*h)) ;
00381      xinbta = pp/(pp+qq*exp(w+w)) ;
00382 
00383      /** solve for x by a modified newton-raphson method **/
00384 
00385 lab6:
00386     r     = ONE-pp ;
00387     t     = ONE-qq ;
00388     yprev = ZERO ;
00389     sq    = ONE ;
00390     prev  = ONE ;
00391     if(xinbta < 0.0001) xinbta = 0.0001 ;
00392     if(xinbta > 0.9999) xinbta = 0.9999 ;
00393 
00394 #if 0
00395     iex = -5.0 / (pp*pp) - 1.0/(a*a) - 13.0 ; if( iex < SAE ) iex = SAE ;
00396     acu = pow(10.0,iex) ;
00397 #else
00398     acu = fpu ;
00399 #endif
00400 
00401 lab7:
00402       y = incbeta( xinbta , pp,qq,beta ) ;
00403       if( y < ZERO ) return -1.0 ;
00404       xin = xinbta ;
00405       y = (y-a)*exp(beta+r*log(xin)+t*log(ONE-xin)) ;
00406       if(y*yprev <= ZERO) prev = MAX(sq, fpu) ;
00407       g = ONE ;
00408 
00409 lab9:
00410       adj = g*y ;
00411       sq = adj*adj ;
00412       if(sq >= prev) goto lab10 ;
00413       tx = xinbta-adj ;
00414       if(tx >= ZERO && tx <= ONE) goto lab11 ;
00415 
00416 lab10:
00417       g = g/THREE ; goto lab9 ;
00418 
00419 lab11:
00420       if(tx == ZERO  || tx == ONE ) goto lab10 ;
00421       if(prev <= acu || y*y <= acu || fabs(xinbta-tx) < fpu) goto lab12 ;
00422       xinbta = tx ;
00423       yprev = y ;
00424       goto lab7 ;
00425 
00426 lab12:
00427       xinbta = tx ;
00428       if (indx) xinbta = ONE-xinbta ;
00429 #if 0
00430 printf("alpha = %g  incbeta = %g\n",alpha, incbeta(xinbta,p,q,beta) );
00431 #endif
00432       return xinbta ;
00433 }

void init_MCW_sizes void   
 

Set up MCW_SIZE_# database for input.

This implements the facility for the user to define MCW_IMSIZE_1 (or AFNI_IMSIZE_1) et cetera, for pre-defining a relationship between a file size in bytes and a 3D: prefix. This function is only called once to setup the table.

Date:
07 Nov 95

Definition at line 1514 of file mri_read.c.

References EXIT, free, MCW_imsize::head, malloc, MAX_MCW_IMSIZE, MCW_imsize_good, my_getenv(), MCW_imsize::prefix, and MCW_imsize::size.

Referenced by imsized_fname().

01515 {
01516    int num , count ;
01517    char ename[32] ;
01518    char * str ;
01519 
01520    if( MCW_imsize_good >= 0 ) return ;
01521 
01522    MCW_imsize_good = 0 ;
01523 
01524    for( num=0 ; num < MAX_MCW_IMSIZE ; num++ ){ /* look for environment string */
01525 
01526       imsize[num].size = -1 ;
01527 
01528       /* try to find environment variable with the num-th name */
01529 
01530       sprintf( ename , "AFNI_IMSIZE_%d" , num+1 ) ;
01531       str = my_getenv( ename ) ;
01532 
01533       if( str == NULL ){
01534          sprintf( ename , "MCW_IMSIZE_%d" , num+1 ) ;
01535          str = my_getenv( ename ) ;
01536          if( str == NULL ) continue ;
01537       }
01538 
01539       imsize[num].prefix = (char *) malloc( sizeof(char) * strlen(str) ) ;
01540       if( imsize[num].prefix == NULL ){
01541          fprintf(stderr,"\n*** Can't malloc in init_MCW_sizes! ***\a\n");
01542          EXIT(1) ;
01543       }
01544 
01545       if( str[0] != '%' ){  /* e.g., 16096=3D:-1:0:64:64:1: */
01546 
01547          imsize[num].head = -1 ;
01548          count = sscanf( str , "%d=%s" , &(imsize[num].size) , imsize[num].prefix ) ;
01549          if( count != 2 || imsize[num].size < 2 || strlen(imsize[num].prefix) < 2 ){
01550             free( imsize[num].prefix ) ;
01551             fprintf(stderr,"bad environment %s = %s\n" ,
01552                     ename , str ) ;
01553          }
01554 
01555       } else {              /* e.g., %16096+0=3D:0:7904:64:64: */
01556 
01557          count = sscanf( str+1 , "%d+%d=%s" ,
01558                          &(imsize[num].size) , &(imsize[num].head) , imsize[num].prefix ) ;
01559 
01560          if( count != 3 || imsize[num].size < 2 ||
01561              imsize[num].head < 0 || strlen(imsize[num].prefix) < 2 ){
01562 
01563             free( imsize[num].prefix ) ;
01564             fprintf(stderr,"bad environment %s = %s\n" ,
01565                     ename , str ) ;
01566          }
01567       }
01568 
01569       MCW_imsize_good ++ ;
01570    }
01571 
01572    return ;
01573 }

void isort_float int   ,
float *   
 

Definition at line 250 of file mri_percents.c.

References a, and p.

Referenced by median21_box_func(), median9_box_func(), osfilt9_box_func(), qsort_float(), winsor21_box_func(), and winsor9_box_func().

00251 {
00252    register int  j , p ;  /* array indices */
00253    register float temp ;  /* a[j] holding place */
00254    register float * a = ar ;
00255 
00256    if( n < 2 || ar == NULL ) return ;
00257 
00258    for( j=1 ; j < n ; j++ ){
00259 
00260      if( a[j] < a[j-1] ){  /* out of order */
00261         p    = j ;
00262         temp = a[j] ;
00263         do{
00264           a[p] = a[p-1] ;       /* at this point, a[p-1] > temp, so move it up */
00265           p-- ;
00266         } while( p > 0 && temp < a[p-1] ) ;
00267         a[p] = temp ;           /* finally, put temp in its place */
00268      }
00269    }
00270    return ;
00271 }

void isort_pair int   ,
float *   ,
int *   
 

Definition at line 350 of file mri_percents.c.

References a, and p.

Referenced by qsort_pair().

00351 {
00352    register int  j , p ;  /* array indices */
00353    register float temp ;  /* a[j] holding place */
00354    register int  itemp ;
00355    register float * a = ar ;
00356    register int   *ia = iar ;
00357 
00358    if( n < 2 || ar == NULL || iar == NULL ) return ;
00359 
00360    for( j=1 ; j < n ; j++ ){
00361 
00362      if( a[j] < a[j-1] ){  /* out of order */
00363         p    = j ;
00364         temp = a[j] ; itemp = ia[j] ;
00365         do{
00366           a[p] = a[p-1] ; ia[p] = ia[p-1] ;
00367           p-- ;
00368         } while( p > 0 && temp < a[p-1] ) ;
00369         a[p] = temp ; ia[p] = itemp ;
00370      }
00371    }
00372    return ;
00373 }

void isort_short int   ,
short *   
 

Definition at line 50 of file mri_percents.c.

References a, and p.

Referenced by qsort_short().

00051 {
00052    register int  j , p ;  /* array indices */
00053    register short temp ;  /* a[j] holding place */
00054    register short * a = ar ;
00055 
00056    if( n < 2 || ar == NULL ) return ;
00057 
00058    for( j=1 ; j < n ; j++ ){
00059 
00060      if( a[j] < a[j-1] ){  /* out of order */
00061         p    = j ;
00062         temp = a[j] ;
00063         do{
00064           a[p] = a[p-1] ;       /* at this point, a[p-1] > temp, so move it up */
00065           p-- ;
00066         } while( p > 0 && temp < a[p-1] ) ;
00067         a[p] = temp ;           /* finally, put temp in its place */
00068      }
00069    }
00070    return ;
00071 }

double lnbeta double   ,
double   
 

if the math library doesn't have the log(gamma(x)) function (as on Linux, for example)

Definition at line 219 of file p2t.c.

00220 {
00221    return (lgamma(p) + lgamma(q) - lgamma(p+q)) ;
00222 }

double log10qg double   
 

Definition at line 445 of file mri_stats.c.

References qg(), and v.

Referenced by main().

00446 {
00447   double v = qg(x) ;
00448   if( v > 0.0 ) return log10(v) ;
00449   return -99.99 ;
00450 }

float* lsqfit int   ,
float *   ,
float *   ,
int   ,
float *    ref[]
 

Definition at line 122 of file mri_lsqfit.c.

References malloc, and ref.

Referenced by huber_func(), mri_lsqfit(), and THD_generic_detrend().

00124 {
00125    int    ii , jj , kk ;
00126    float  *alpha = NULL ;
00127    double *cc = NULL , *rr = NULL ;
00128    double sum ;
00129 
00130    /** macros will be used in routines below, as well! **/
00131 
00132 #define DBLEVEC(ll) (double *) malloc( sizeof(double) * (ll) )
00133 #define DISCARD(xx) if( xx != NULL ){free(xx); xx = NULL;}
00134 #define CLEANUP     {DISCARD(cc); DISCARD(rr);}
00135 
00136    if( nref < 1 || veclen < nref || data == NULL || ref == NULL ) return NULL ;
00137 
00138    /*** form RHS vector into rr ***/
00139 
00140    rr = DBLEVEC(nref) ;
00141    cc = DBLEVEC(nref*nref) ;
00142    if( rr == NULL || cc == NULL ){ CLEANUP ; return NULL ; }
00143 
00144    if( wt != NULL ){
00145       for( ii=0 ; ii < nref ; ii++ ){
00146          sum = 0.0 ;
00147          for( jj=0 ; jj < veclen ; jj++ ) sum += ref[ii][jj] * wt[jj] * data[jj] ;
00148          rr[ii] = sum ;
00149       }
00150    } else {
00151       for( ii=0 ; ii < nref ; ii++ ){
00152          sum = 0.0 ;
00153          for( jj=0 ; jj < veclen ; jj++ ) sum += ref[ii][jj] * data[jj] ;
00154          rr[ii] = sum ;
00155       }
00156    }
00157 
00158    /*** form coefficient matrix into cc */
00159 
00160 #define CC(i,j) cc[(i)+(j)*nref]
00161 
00162    if( wt != NULL ){
00163       for( jj=0 ; jj < nref ; jj++ ){
00164          for( ii=0 ; ii <= jj ; ii++ ){
00165             sum = 0.0 ;
00166             for( kk=0 ; kk < veclen ; kk++ ) sum += ref[ii][kk] * ref[jj][kk] * wt[kk] ;
00167             CC(ii,jj) = CC(jj,ii) = sum ;
00168          }
00169       }
00170    } else {
00171       for( jj=0 ; jj < nref ; jj++ ){
00172          for( ii=0 ; ii <= jj ; ii++ ){
00173             sum = 0.0 ;
00174             for( kk=0 ; kk < veclen ; kk++ ) sum += ref[ii][kk] * ref[jj][kk] ;
00175             CC(ii,jj) = CC(jj,ii) = sum ;
00176          }
00177       }
00178    }
00179 
00180    /*** Choleski decompose cc ***/
00181 
00182    for( ii=0 ; ii < nref ; ii++ ){
00183       for( jj=0 ; jj < ii ; jj++ ){
00184          sum = CC(ii,jj) ;
00185          for( kk=0 ; kk < jj ; kk++ ) sum -= CC(ii,kk) * CC(jj,kk) ;
00186          CC(ii,jj) = sum / CC(jj,jj) ;
00187       }
00188       sum = CC(ii,ii) ;
00189       for( kk=0 ; kk < ii ; kk++ ) sum -= CC(ii,kk) * CC(ii,kk) ;
00190       if( sum <= 0.0 ){ CLEANUP ; return NULL ; }
00191       CC(ii,ii) = sqrt(sum) ;
00192    }
00193 
00194    /*** forward solve ***/
00195 
00196    for( ii=0 ; ii < nref ; ii++ ){
00197       sum = rr[ii] ;
00198       for( jj=0 ; jj < ii ; jj++ ) sum -= CC(ii,jj) * rr[jj] ;
00199       rr[ii] = sum / CC(ii,ii) ;
00200    }
00201 
00202    /*** backward solve ***/
00203 
00204    for( ii=nref-1 ; ii >= 0 ; ii-- ){
00205       sum = rr[ii] ;
00206       for( jj=ii+1 ; jj < nref ; jj++ ) sum -= CC(jj,ii) * rr[jj] ;
00207       rr[ii] = sum / CC(ii,ii) ;
00208    }
00209 
00210    /*** put result into alpha ***/
00211 
00212    alpha = (float *) malloc( sizeof(float) * nref ) ;
00213    for( ii=0 ; ii < nref ; ii++ ) alpha[ii] = rr[ii] ;
00214 
00215    /*** cleanup and exit ***/
00216 
00217    CLEANUP ; return alpha ;
00218 }

void memplot_to_RGB_sef MRI_IMAGE   im,
MEM_plotdata   mp,
int    start,
int    end,
int    freee
 

Actually do the rendering of a memplot into an RGB image.

  • Plotting will start with line start and go to end-1.
  • If end <= start, will do from start to the last one in the plot.
  • To do all lines, set start=end=0.
  • "freee" controls whether the aspect ratio will be free to vary (!= 0), or will be fixed (==0).
  • 18 Sep 2001: adapted from X11 routines in coxplot/plot_x11.c
  • 23 Mar 2002: actually tested for the first time ----------------------------------------------------------------------------

Definition at line 41 of file mri_coxplot.c.

References MEM_plotdata::aspect, box_xbot, box_xtop, box_ybot, box_ytop, COL_TO_BBB, COL_TO_GGG, COL_TO_RRR, ENTRY, MRI_IMAGE::kind, MEMPLOT_COL, MEMPLOT_NLINE, MEMPLOT_TH, MEMPLOT_X1, MEMPLOT_X2, MEMPLOT_Y1, MEMPLOT_Y2, mp, mri_draw_opacity(), mri_drawfilledrectangle(), mri_drawline(), MRI_IMAGE::nx, MRI_IMAGE::ny, set_memplot_RGB_box(), skip, x2, y1, and ZO_TO_TFS.

Referenced by ISQ_save_jpeg(), ISQ_saver_CB(), and PLOT_matrix_gray().

00043 {
00044    byte rrr=0,ggg=0,bbb=0 ;
00045    int ii , nline , same ;
00046    float old_thick , old_color , new_color , new_thick ;
00047    float scal,xscal,yscal , xoff,yoff ;
00048    int x1,y1 , x2,y2 ;
00049    int skip ;
00050 
00051 ENTRY("memplot_to_RGB_sef") ;
00052 
00053    /*--- check for madness ---*/
00054 
00055    if( im == NULL || im->kind != MRI_rgb || mp == NULL ) EXRETURN ;
00056 
00057    if( start < 0 ) start = 0 ;
00058 
00059    nline = MEMPLOT_NLINE(mp) ;
00060    if( nline < 1 || start >= nline ) EXRETURN ;
00061 
00062    if( end <= start || end > nline ) end = nline ;
00063 
00064    /*--- compute scaling from memplot objective
00065          coordinates to RGB window coordinates  ---*/
00066 
00067    if( box_xbot >= box_xtop || box_ybot >= box_ytop ){
00068 
00069       xscal = im->nx / mp->aspect ; /* aspect = x-axis objective size */
00070       yscal = im->ny / 1.0 ;        /* 1.0    = y-axis objective size */
00071       xoff  = yoff = 0.499 ;
00072 
00073    } else {  /* scale to a given sub-box in the window */
00074 
00075       xscal = box_xtop - box_xbot ;
00076       yscal = box_ytop - box_ybot ;
00077       xoff  = box_xbot + 0.499    ;
00078       yoff  = box_ybot + 0.499    ;
00079    }
00080 
00081    if( !freee ){                           /* no aspect freedom ==> */
00082       if( yscal < xscal ) xscal = yscal ;  /* use smaller scaling   */
00083       else                yscal = xscal ;
00084    }
00085    scal = sqrt(fabs(xscal*yscal)) ;
00086 
00087    old_color = -1.0 ;            /* these don't occur naturally */
00088    old_thick = -THCODE_INVALID ;
00089 
00090    /*--- loop over lines, scale and plot ---*/
00091 
00092    mri_draw_opacity( 1.0 ) ;
00093 
00094    for( ii=start ; ii < end ; ii++ ){
00095 
00096       skip = 0 ;
00097 
00098       /* check if need to change color or thickness of line */
00099 
00100       new_color = MEMPLOT_COL(mp,ii) ;
00101       if( new_color != old_color ){
00102          float rr=COL_TO_RRR(new_color) ,
00103                gg=COL_TO_GGG(new_color) , bb=COL_TO_BBB(new_color) ;
00104 
00105 #if 0
00106 fprintf(stderr,"Changing color to %f %f %f\n",rr,gg,bb) ;
00107 #endif
00108 
00109          rrr = ZO_TO_TFS(rr) ; ggg = ZO_TO_TFS(gg) ; bbb = ZO_TO_TFS(bb) ;
00110          old_color = new_color ;
00111       }
00112 
00113       new_thick = MEMPLOT_TH(mp,ii) ;
00114       if( new_thick < 0.0 ){               /* special negative thickness codes */
00115          int thc = (int)(-new_thick) ;
00116          switch( thc ){
00117             case THCODE_RECT:{        /* rectangle */
00118                int xb,yb , xt,yt ;
00119                int w,h ;
00120                x1 = rint( xoff + xscal * MEMPLOT_X1(mp,ii)         ) ;
00121                x2 = rint( xoff + xscal * MEMPLOT_X2(mp,ii)         ) ;
00122                y1 = rint( yoff + yscal * (1.0 - MEMPLOT_Y1(mp,ii)) ) ;
00123                y2 = rint( yoff + yscal * (1.0 - MEMPLOT_Y2(mp,ii)) ) ;
00124                if( x1 < x2 ){ xb=x1; xt=x2; } else { xb=x2; xt=x1; }
00125                if( y1 < y2 ){ yb=y1; yt=y2; } else { yb=y2; yt=y1; }
00126                w = xt-xb+1 ; h = yt-yb+1 ;
00127                mri_drawfilledrectangle( im , xb,yb , w,h , rrr,ggg,bbb ) ;
00128                skip = 1 ;
00129             }
00130             break ;
00131 
00132             case THCODE_OPAC:{        /* opacity [22 Jul 2004] */
00133                mri_draw_opacity( MEMPLOT_X1(mp,ii) ) ;
00134                skip = 1 ;
00135             }
00136             break ;
00137          }
00138 
00139       } else if( new_thick != old_thick ){ /* normal case: change line thickness */
00140 
00141          old_thick = new_thick ;  /* thickness not used at this time */
00142 
00143       }
00144 
00145       /* scale coords to ints (also see zzphph.f) */
00146 
00147       if( !skip ){
00148         x1 = (int)( xoff + xscal * MEMPLOT_X1(mp,ii)         ) ;
00149         x2 = (int)( xoff + xscal * MEMPLOT_X2(mp,ii)         ) ;
00150         y1 = (int)( yoff + yscal * (1.0 - MEMPLOT_Y1(mp,ii)) ) ;
00151         y2 = (int)( yoff + yscal * (1.0 - MEMPLOT_Y2(mp,ii)) ) ;
00152 
00153         /* draw it */
00154 
00155         mri_drawline( im , x1,y1 , x2,y2 , rrr,ggg,bbb ) ;
00156       }
00157    }
00158 
00159    set_memplot_RGB_box(0,0,0,0) ; /* clear box */
00160    EXRETURN ;
00161 }

MRI_IMAGE* mri_1D_fromstring char *    str
 

Produce a 1D (float) image from a string of the form "20@1,10@0,5@1". -------------------------------------------------------------------------------

Definition at line 7 of file mri_fromstring.c.

References ENTRY, far, free, malloc, mri_fix_data_pointer(), mri_new_vol_empty(), NI_decode_string_list(), NI_delete_str_array, NI_str_array::num, realloc, RETURN, and NI_str_array::str.

Referenced by mri_read_1D(), and mri_read_ascii().

00008 {
00009    int ii,nnn,count , ntot=0 ;
00010    float *far , value ;
00011    NI_str_array *sar ;
00012    char sep ;
00013    MRI_IMAGE *flim ;
00014 
00015 ENTRY("mri_1D_fromstring") ;
00016 
00017    sar = NI_decode_string_list( str , ",;" ) ;
00018    if( sar == NULL ) RETURN(NULL) ;
00019    if( sar->num == 0 ){ NI_delete_str_array(sar); RETURN(NULL); }
00020 
00021    far = (float *) malloc(sizeof(float)) ;
00022    for( ii=0 ; ii < sar->num ; ii++ ){
00023 
00024      if( strstr(sar->str[ii],"@") != NULL ||    /* if has one of the    */
00025          strstr(sar->str[ii],"x") != NULL ||    /* allowed separator    */
00026          strstr(sar->str[ii],"X") != NULL ||    /* characters, then     */
00027          strstr(sar->str[ii],"*") != NULL   ){  /* scan for count@value */
00028 
00029         nnn = sscanf( sar->str[ii] , "%d%c%f" , &count , &sep , &value ) ;
00030         if( nnn != 3 || count < 1 ){ free(far); RETURN(NULL); }
00031 
00032      } else {                                 /* just scan for value */
00033         count = 1 ;
00034         nnn   = sscanf( sar->str[ii] , "%f" , &value ) ;
00035         if( nnn != 1 ){ free(far); RETURN(NULL); }
00036      }
00037 
00038      far = (float *) realloc( far , sizeof(float)*(ntot+count) ) ;
00039      for( nnn=0 ; nnn < count ; nnn++ ) far[nnn+ntot] = value ;
00040      ntot += count ;
00041 
00042    }
00043 
00044    NI_delete_str_array(sar) ;
00045    flim = mri_new_vol_empty( ntot,1,1 , MRI_float ) ;
00046    mri_fix_data_pointer( far , flim ) ;
00047    RETURN(flim) ;
00048 }

void mri_2dalign_cleanup MRI_2dalign_basis  
 

Definition at line 296 of file mri_2dalign.c.

References MRI_2dalign_basis::chol_fine_fitim, MRI_2dalign_basis::chol_fitim, DESTROY_IMARR, MRI_2dalign_basis::fine_fitim, MRI_2dalign_basis::fitim, and free.

Referenced by cleanup_rtinp(), mri_2dalign_many(), and RT_registration_2D_close().

00297 {
00298    if( basis == NULL ) return ;
00299 
00300    if( basis->fitim           != NULL ){ DESTROY_IMARR( basis->fitim ) ; }
00301    if( basis->chol_fitim      != NULL ){ free(basis->chol_fitim) ; }
00302 
00303    if( basis->fine_fitim      != NULL ){ DESTROY_IMARR( basis->fine_fitim ) ; }
00304    if( basis->chol_fine_fitim != NULL ){ free(basis->chol_fine_fitim) ; }
00305 
00306    free(basis) ; return ;
00307 }

MRI_IMARR* mri_2dalign_many MRI_IMAGE  ,
MRI_IMAGE  ,
MRI_IMARR  ,
float *   ,
float *   ,
float *   
 

Definition at line 274 of file mri_2dalign.c.

References ADDTO_IMARR, MRI_IMARR::imarr, INIT_IMARR, mri_2dalign_cleanup(), mri_2dalign_one(), mri_2dalign_setup(), and MRI_IMARR::num.

Referenced by main().

00276 {
00277    int kim ;
00278    MRI_IMAGE * tim ;
00279    MRI_IMARR * alim ;
00280    MRI_2dalign_basis * basis ;
00281 
00282    basis = mri_2dalign_setup( im , imwt ) ;
00283    if( basis == NULL ) return NULL ;
00284 
00285    INIT_IMARR( alim ) ;
00286 
00287    for( kim=0 ; kim < ims->num ; kim++ ){
00288       tim = mri_2dalign_one( basis , ims->imarr[kim] , dx+kim , dy+kim , phi+kim ) ;
00289       ADDTO_IMARR(alim,tim) ;
00290    }
00291 
00292    mri_2dalign_cleanup( basis ) ;
00293    return alim ;
00294 }

void mri_2dalign_method int   ,
int   ,
int   
 

Definition at line 66 of file mri_2dalign.c.

References almode_coarse, almode_fine, and almode_reg.

Referenced by RT_registration_2D_setup().

00067 {
00068    if( coarse > 0 ) almode_coarse = coarse ;
00069    if( fine   > 0 ) almode_fine   = fine   ;
00070    if( reg    > 0 ) almode_reg    = reg    ;
00071    return ;
00072 }

MRI_IMAGE* mri_2dalign_one MRI_2dalign_basis  ,
MRI_IMAGE  ,
float *   ,
float *   ,
float *   
 

Definition at line 189 of file mri_2dalign.c.

References MRI_2dalign_basis::chol_fine_fitim, MRI_2dalign_basis::chol_fitim, DFAC, dfilt_sigma, dxy_thresh, FILT_FFT_WRAPAROUND, fine_dxy_thresh, MRI_2dalign_basis::fine_fitim, fine_phi_thresh, fine_sigma, fit, MRI_2dalign_basis::fitim, free, max_iter, mri_delayed_lsqfit(), mri_filt_fft(), mri_free(), MRI_ROTA_COARSE, MRI_ROTA_FINE, MRI_ROTA_REG, mri_to_float(), MRI_IMAGE::nx, MRI_IMAGE::ny, and phi_thresh.

Referenced by mri_2dalign_many(), and RT_registration_2D_onevol().

00191 {
00192    MRI_IMARR * fitim ;
00193    double * chol_fitim=NULL ;
00194    MRI_IMARR * fine_fitim  =NULL ;
00195    double * chol_fine_fitim=NULL ;
00196 
00197    float * fit , *dfit ;
00198    int nx,ny , ii,jj , joff , iter , good ;
00199    int use_fine_fit = (fine_sigma > 0.0) ;
00200    MRI_IMAGE * im2 , * bim2 , * tim ;
00201 
00202    nx  = im->nx ; ny  = im->ny ;
00203 
00204    fitim           = basis->fitim ;
00205    chol_fitim      = basis->chol_fitim ;
00206    fine_fitim      = basis->fine_fitim ;
00207    chol_fine_fitim = basis->chol_fine_fitim ;
00208 
00209    /*-- register the image: coarsely --*/
00210 
00211       im2  = mri_to_float( im ) ;
00212       bim2 = mri_filt_fft( im2, dfilt_sigma, 0,0, FILT_FFT_WRAPAROUND ) ;
00213       fit  = mri_delayed_lsqfit( bim2 , fitim , chol_fitim ) ;
00214       mri_free( bim2 ) ;
00215 
00216       iter = 0 ;
00217       good = ( fabs(fit[1]) > dxy_thresh ||
00218                fabs(fit[2]) > dxy_thresh || fabs(fit[3]) > phi_thresh ) ;
00219 
00220       /*-- iterate coarse fit --*/
00221 
00222       while( good ){
00223          tim  = MRI_ROTA_COARSE( im2 , fit[1] , fit[2] , fit[3]*DFAC ) ;
00224          bim2 = mri_filt_fft( tim, dfilt_sigma, 0,0, FILT_FFT_WRAPAROUND ) ;
00225          dfit = mri_delayed_lsqfit( bim2 , fitim , chol_fitim ) ;
00226          mri_free( bim2 ) ; mri_free( tim ) ;
00227 
00228          fit[1] += dfit[1] ;
00229          fit[2] += dfit[2] ;
00230          fit[3] += dfit[3] ;
00231 
00232          good = (++iter < max_iter) &&
00233                   ( fabs(dfit[1]) > dxy_thresh ||
00234                     fabs(dfit[2]) > dxy_thresh || fabs(dfit[3]) > phi_thresh ) ;
00235 
00236          free(dfit) ; dfit = NULL ;
00237       } /* end while */
00238 
00239       /*-- perform fine adjustments  --*/
00240 
00241       if( use_fine_fit ){
00242          good = 1 ;
00243          while( good ){
00244             tim  = MRI_ROTA_FINE( im2 , fit[1] , fit[2] , fit[3]*DFAC ) ;
00245             bim2 = mri_filt_fft( tim, fine_sigma, 0,0, FILT_FFT_WRAPAROUND ) ;
00246             dfit = mri_delayed_lsqfit( bim2 , fine_fitim , chol_fine_fitim ) ;
00247             mri_free( bim2 ) ; mri_free( tim ) ;
00248 
00249             fit[1] += dfit[1] ;
00250             fit[2] += dfit[2] ;
00251             fit[3] += dfit[3] ;
00252 
00253             good = (++iter < max_iter) &&
00254                      ( fabs(dfit[1]) > fine_dxy_thresh ||
00255                        fabs(dfit[2]) > fine_dxy_thresh || fabs(dfit[3]) > fine_phi_thresh ) ;
00256 
00257             free(dfit) ; dfit = NULL ;
00258          } /* end while */
00259       }
00260 
00261       /*-- save final alignment parameters --*/
00262 
00263       if( dx != NULL ) *dx = fit[1] ;
00264       if( dy != NULL ) *dy = fit[2] ;
00265       if( phi!= NULL ) *phi= fit[3]*DFAC ;
00266 
00267    /*-- do the actual realignment --*/
00268 
00269    tim = MRI_ROTA_REG( im2 , fit[1],fit[2],fit[3]*DFAC ) ;
00270    mri_free( im2 ) ;
00271    return tim ;
00272 }

void mri_2dalign_params int   ,
float   ,
float   ,
float   ,
float   ,
float   ,
float   
 

Definition at line 41 of file mri_2dalign.c.

References DFILT_SIGMA, dfilt_sigma, DXY_THRESH, dxy_thresh, FINE_DXY_THRESH, fine_dxy_thresh, FINE_PHI_THRESH, fine_phi_thresh, fine_sigma, MAX_ITER, max_iter, PHI_THRESH, and phi_thresh.

Referenced by REG_command_line().

00044 {
00045    if( maxite > 0   ) max_iter    = maxite ; else max_iter    = MAX_ITER    ;
00046    if( sig    > 0.0 ) dfilt_sigma = sig    ; else dfilt_sigma = DFILT_SIGMA ;
00047    if( dxy    > 0.0 ) dxy_thresh  = dxy    ; else dxy_thresh  = DXY_THRESH  ;
00048    if( dph    > 0.0 ) phi_thresh  = dph    ; else phi_thresh  = PHI_THRESH  ;
00049 
00050    fine_sigma = fsig ;
00051    if( fdxy > 0.0 ) fine_dxy_thresh = fdxy ; else fine_dxy_thresh = FINE_DXY_THRESH ;
00052    if( fdph > 0.0 ) fine_phi_thresh = fdph ; else fine_phi_thresh = FINE_PHI_THRESH ;
00053 
00054    return ;
00055 }

MRI_2dalign_basis* mri_2dalign_setup MRI_IMAGE  ,
MRI_IMAGE  
 

Definition at line 85 of file mri_2dalign.c.

References ADDTO_IMARR, MRI_2dalign_basis::chol_fine_fitim, MRI_2dalign_basis::chol_fitim, DFAC, dfilt_sigma, FILT_FFT_WRAPAROUND, MRI_2dalign_basis::fine_fitim, fine_sigma, MRI_2dalign_basis::fitim, imbase, INIT_IMARR, malloc, mri_data_pointer(), mri_filt_fft(), MRI_FLOAT_PTR, mri_free(), MRI_IS_2D, mri_new(), mri_startup_lsqfit(), mri_to_float(), MRI_IMAGE::nx, and MRI_IMAGE::ny.

Referenced by mri_2dalign_many(), and RT_registration_2D_setup().

00086 {
00087    MRI_IMAGE * im1 , *bim,*xim,*yim,*tim , *bim2 , * im2 , *imww ;
00088    float *tar,*xar,*yar ;
00089    int nx,ny , ii,jj , joff ;
00090    int use_fine_fit = (fine_sigma > 0.0) ;
00091    float hnx,hny ;
00092 
00093    MRI_IMARR * fitim  =NULL;
00094    double * chol_fitim=NULL ;
00095    MRI_IMARR * fine_fitim  =NULL ;
00096    double * chol_fine_fitim=NULL ;
00097    MRI_2dalign_basis * bout = NULL ;
00098 
00099    if( ! MRI_IS_2D(imbase) ){
00100       fprintf(stderr,"\n*** mri_2dalign_setup: cannot use nD images!\a\n") ;
00101       return NULL ;
00102    }
00103 
00104    im1 = mri_to_float( imbase ) ;
00105    nx  = im1->nx ;  hnx = 0.5 * nx ;
00106    ny  = im1->ny ;  hny = 0.5 * ny ;
00107 
00108    bim = mri_filt_fft( im1, dfilt_sigma, 0, 0, FILT_FFT_WRAPAROUND ) ; /* smooth */
00109    xim = mri_filt_fft( im1, dfilt_sigma, 1, 0, FILT_FFT_WRAPAROUND ) ; /* d/dx */
00110    yim = mri_filt_fft( im1, dfilt_sigma, 0, 1, FILT_FFT_WRAPAROUND ) ; /* d/dy */
00111 
00112    tim = mri_new( nx , ny , MRI_float ) ;  /* x * d/dy - y * d/dx */
00113    tar = mri_data_pointer( tim ) ;         /* which is d/d(theta) */
00114    xar = mri_data_pointer( xim ) ;
00115    yar = mri_data_pointer( yim ) ;
00116    for( jj=0 ; jj < ny ; jj++ ){
00117       joff = jj * nx ;
00118       for( ii=0 ; ii < nx ; ii++ ){
00119          tar[ii+joff] = DFAC * (  (ii-hnx) * yar[ii+joff]
00120                                 - (jj-hny) * xar[ii+joff] ) ;
00121       }
00122    }
00123    INIT_IMARR ( fitim ) ;
00124    ADDTO_IMARR( fitim , bim ) ;
00125    ADDTO_IMARR( fitim , xim ) ;
00126    ADDTO_IMARR( fitim , yim ) ;
00127    ADDTO_IMARR( fitim , tim ) ;
00128 
00129    if( imwt == NULL ) imww = mri_to_float( bim ) ;  /* 28 Oct 1996 */
00130    else               imww = mri_to_float( imwt ) ;
00131 
00132    tar = MRI_FLOAT_PTR(imww) ;       
00133    for( ii=0 ; ii < nx*ny ; ii++ ) tar[ii] = fabs(tar[ii]) ;  /* 16 Nov 1998 */
00134 
00135    chol_fitim = mri_startup_lsqfit( fitim , imww ) ;
00136    mri_free(imww) ;
00137 
00138    if( use_fine_fit ){
00139      bim = mri_filt_fft( im1, fine_sigma, 0, 0, FILT_FFT_WRAPAROUND ) ; /* smooth */
00140      xim = mri_filt_fft( im1, fine_sigma, 1, 0, FILT_FFT_WRAPAROUND ) ; /* d/dx */
00141      yim = mri_filt_fft( im1, fine_sigma, 0, 1, FILT_FFT_WRAPAROUND ) ; /* d/dy */
00142 
00143      tim = mri_new( nx , ny , MRI_float ) ;  /* x * d/dy - y * d/dx */
00144      tar = mri_data_pointer( tim ) ;         /* which is d/d(theta) */
00145      xar = mri_data_pointer( xim ) ;
00146      yar = mri_data_pointer( yim ) ;
00147      for( jj=0 ; jj < ny ; jj++ ){
00148         joff = jj * nx ;
00149         for( ii=0 ; ii < nx ; ii++ ){
00150            tar[ii+joff] = DFAC * (  (ii-hnx) * yar[ii+joff]
00151                                   - (jj-hny) * xar[ii+joff] ) ;
00152         }
00153      }
00154      INIT_IMARR ( fine_fitim ) ;
00155      ADDTO_IMARR( fine_fitim , bim ) ;
00156      ADDTO_IMARR( fine_fitim , xim ) ;
00157      ADDTO_IMARR( fine_fitim , yim ) ;
00158      ADDTO_IMARR( fine_fitim , tim ) ;
00159 
00160      if( imwt == NULL ) imww = mri_to_float( bim ) ;  /* 03 Oct 1997 */
00161      else               imww = mri_to_float( imwt ) ;
00162 
00163      tar = MRI_FLOAT_PTR(imww) ;       
00164      for( ii=0 ; ii < nx*ny ; ii++ ) tar[ii] = fabs(tar[ii]) ;
00165 
00166      chol_fine_fitim = mri_startup_lsqfit( fine_fitim , imww ) ;
00167      mri_free(imww) ;
00168    }
00169 
00170    mri_free(im1) ;
00171 
00172    bout = (MRI_2dalign_basis *) malloc( sizeof(MRI_2dalign_basis) ) ;
00173    bout->fitim           = fitim ;
00174    bout->chol_fitim      = chol_fitim ;
00175    bout->fine_fitim      = fine_fitim ;
00176    bout->chol_fine_fitim = chol_fine_fitim ;
00177    return bout ;
00178 }

MRI_IMAGE* mri_3to_rgb MRI_IMAGE  ,
MRI_IMAGE  ,
MRI_IMAGE  
 

Definition at line 66 of file mri_to_rgb.c.

References ENTRY, MRI_IMAGE::kind, MRI_BYTE_PTR, MRI_COPY_AUX, MRI_FATAL_ERROR, MRI_FLOAT_PTR, mri_new_conforming, MRI_IMAGE::nvox, and RETURN.

Referenced by mri_dup2D(), mri_warp3D_cubic(), mri_warp3D_linear(), mri_warp3D_NN(), mri_warp3D_quintic(), mri_warp_bicubic(), and NUD_rotate().

00067 {
00068    MRI_IMAGE *newim ;
00069    register int ii , npix ;
00070    register byte * rgb ;
00071 
00072 ENTRY("mri_3to_rgb") ;
00073 
00074    if( rim == NULL || bim == NULL || gim == NULL ) RETURN( NULL );
00075 
00076    newim = mri_new_conforming( rim , MRI_rgb ) ; rgb = MRI_BYTE_PTR(newim) ;
00077    npix  = rim->nvox ;
00078 
00079    switch( rim->kind ){
00080 
00081       case MRI_byte:{
00082          byte * rr=MRI_BYTE_PTR(rim), * gg=MRI_BYTE_PTR(gim), * bb=MRI_BYTE_PTR(bim) ;
00083          for( ii=0 ; ii < npix ; ii++ ){
00084             rgb[3*ii  ] = rr[ii] ;
00085             rgb[3*ii+1] = gg[ii] ;
00086             rgb[3*ii+2] = bb[ii] ;
00087          }
00088       }
00089       break ;
00090 
00091       case MRI_float:{
00092          float * rr=MRI_FLOAT_PTR(rim), * gg=MRI_FLOAT_PTR(gim), * bb=MRI_FLOAT_PTR(bim) ;
00093          for( ii=0 ; ii < npix ; ii++ ){
00094             rgb[3*ii  ] = rr[ii] ;
00095             rgb[3*ii+1] = gg[ii] ;
00096             rgb[3*ii+2] = bb[ii] ;
00097          }
00098       }
00099       break ;
00100 
00101       default:
00102          fprintf(stderr,"mri_3to_rgb:  unrecognized image conversion %d\n",rim->kind) ;
00103          MRI_FATAL_ERROR ;
00104    }
00105 
00106    MRI_COPY_AUX(newim,rim) ;
00107    RETURN( newim );
00108 }

void mri_add_fname_delay char *   ,
MRI_IMAGE  
 

Definition at line 34 of file mri_add_name.c.

References ENTRY, MRI_IMAGE::fname, free, and malloc.

Referenced by mri_read_3D_delay().

00035 {
00036    int ll ;
00037 
00038 ENTRY("mri_add_fname_delay") ;
00039 
00040    if( im == NULL ) EXRETURN ;  /* 29 Mar 2002 */
00041 
00042    if( im->fname != NULL ){ free( im->fname ) ; im->fname = NULL ; }
00043 
00044    if( str == NULL ) EXRETURN ;
00045 
00046    ll = strlen(str) ; if( ll <= 0 ) EXRETURN ;
00047 
00048    im->fname = (char *) malloc( ll+1 ) ;
00049    strcpy( im->fname , str ) ;
00050    EXRETURN ;
00051 }

void mri_add_name char *   ,
MRI_IMAGE  
 

<