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  

mri_complex_arith.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

MRI_IMAGEmri_multiply_complex (int mode, MRI_IMAGE *f, MRI_IMAGE *g)
MRI_IMAGEmri_complex_phase (MRI_IMAGE *im)
MRI_IMAGEmri_complex_abs (MRI_IMAGE *im)

Function Documentation

MRI_IMAGE* mri_complex_abs MRI_IMAGE   im
 

Definition at line 82 of file mri_complex_arith.c.

References MRI_DATA::complex_data, CSQR, MRI_DATA::float_data, MRI_IMAGE::im, MRI_IMAGE::kind, MRI_COPY_AUX, MRI_FATAL_ERROR, mri_new_conforming, and MRI_IMAGE::nvox.

00083 {
00084    register int ii , npix ;
00085    MRI_IMAGE *newImg ;
00086 
00087    if( im->kind != MRI_complex ){
00088       fprintf( stderr , "mri_complex_abs illegal type!\n" ) ;
00089       MRI_FATAL_ERROR ;
00090    }
00091 
00092    npix = im->nvox ;
00093    newImg  = mri_new_conforming( im , MRI_float ) ;
00094    MRI_COPY_AUX( newImg , im ) ;
00095 
00096    for( ii=0 ; ii < npix ; ii++ )
00097       newImg->im.float_data[ii] = sqrt( CSQR( im->im.complex_data[ii] ) ) ;
00098 
00099    return newImg ;
00100 }

MRI_IMAGE* mri_complex_phase MRI_IMAGE   im
 

Definition at line 59 of file mri_complex_arith.c.

References MRI_DATA::complex_data, MRI_DATA::float_data, complex::i, MRI_IMAGE::im, MRI_IMAGE::kind, MRI_COPY_AUX, MRI_FATAL_ERROR, mri_new_conforming, MRI_IMAGE::nvox, and complex::r.

00060 {
00061    register int ii , npix ;
00062    MRI_IMAGE *newImg ;
00063 
00064    if( im->kind != MRI_complex ){
00065       fprintf( stderr , "mri_complex_phase illegal image type!\n" ) ;
00066       MRI_FATAL_ERROR ;
00067    }
00068 
00069    npix = im->nvox ;
00070    newImg  = mri_new_conforming( im , MRI_float ) ;
00071    MRI_COPY_AUX( newImg , im ) ;
00072 
00073    for( ii=0 ; ii < npix ; ii++ )
00074      newImg->im.float_data[ii] =
00075         atan2( im->im.complex_data[ii].i , im->im.complex_data[ii].r ) ;
00076 
00077    return newImg ;
00078 }

MRI_IMAGE* mri_multiply_complex int    mode,
MRI_IMAGE   f,
MRI_IMAGE   g
 

Definition at line 16 of file mri_complex_arith.c.

References CJMULT, CMULT, MRI_DATA::complex_data, MRI_IMAGE::im, MRI_IMAGE::kind, MRI_COPY_AUX, MRI_FATAL_ERROR, mri_new_conforming, and MRI_IMAGE::nvox.

00017 {
00018    register int ii , npix ;
00019    MRI_IMAGE *newImg ;
00020 
00021    if( f->nvox != g->nvox ){
00022       fprintf( stderr , "mri_multiply_complex shapes imcompatible!\n" ) ;
00023       MRI_FATAL_ERROR ;
00024    }
00025 
00026    if( f->kind != MRI_complex  ||  g->kind != MRI_complex ){
00027       fprintf( stderr , "mri_multiply_complex illegal image type!\n" ) ;
00028       MRI_FATAL_ERROR ;
00029    }
00030 
00031    newImg  = mri_new_conforming( f , MRI_complex ) ;
00032    npix = f->nvox ;
00033    MRI_COPY_AUX( newImg , f ) ;
00034 
00035    switch( mode ){
00036      case 0:
00037         for( ii=0 ; ii < npix ; ii++ ){
00038            newImg->im.complex_data[ii] =
00039             CMULT( f->im.complex_data[ii] , g->im.complex_data[ii] ) ;
00040         }
00041         break ;
00042 
00043       case 1:
00044          for( ii=0 ; ii < npix ; ii++ ){
00045             newImg->im.complex_data[ii] =
00046              CJMULT( f->im.complex_data[ii] , g->im.complex_data[ii] ) ;
00047          }
00048          break ;
00049 
00050       default:
00051          fprintf( stderr , "mri_multiply_complex illegal mode %d\n" , mode ) ;
00052          MRI_FATAL_ERROR ;
00053    }
00054    return newImg ;
00055 }
 

Powered by Plone

This site conforms to the following standards: