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  

2tocx.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002    Major portions of this software are copyrighted by the Medical College
00003    of Wisconsin, 1994-2000, and are released under the Gnu General Public
00004    License, Version 2.  See the file README.Copyright for details.
00005 ******************************************************************************/
00006 
00007 #include "mrilib.h"
00008 
00009 int main( int argc , char * argv[] )
00010 {
00011    int nx,ny,ii,npix ;
00012    MRI_IMAGE * im1 , * im2 , * flim , * cxim ;
00013    float * a1 , * a2 ;
00014    complex * cxar ;
00015 
00016    if( argc < 4 ){
00017       printf("Usage: 2tocx im1 im2 cxim\n") ;
00018       exit(0) ;
00019    }
00020 
00021    im1 = mri_read( argv[1] ) ;
00022    im2 = mri_read( argv[2] ) ;
00023    if( im1 == NULL || im2 == NULL ) exit(1) ;
00024 
00025    flim = mri_to_float(im1) ; mri_free(im1) ; im1 = flim ; a1 = MRI_FLOAT_PTR(im1) ;
00026    flim = mri_to_float(im2) ; mri_free(im2) ; im2 = flim ; a2 = MRI_FLOAT_PTR(im2) ;
00027 
00028    nx = im1->nx ; ny = im1->ny ; npix = nx*ny ;
00029 
00030    cxim = mri_new( nx , ny , MRI_complex ) ;
00031    cxar = MRI_COMPLEX_PTR(cxim) ;
00032 
00033    for( ii=0 ; ii < npix ; ii++ ){
00034       cxar[ii].r = a1[ii] ;
00035       cxar[ii].i = a2[ii] ;
00036    }
00037 
00038    mri_write( argv[3] , cxim ) ;
00039    exit(0) ;
00040 }
 

Powered by Plone

This site conforms to the following standards: