Doxygen Source Code Documentation
thd_writedset.c File Reference
#include "mrilib.h"#include "thd.h"#include "thd_niftiwrite.h"Go to the source code of this file.
Functions | |
| void | THD_use_3D_format (int uu) |
| void | THD_use_NIFTI_format (int uu) |
| Boolean | THD_write_3dim_dataset (char *new_sessname, char *new_prefixname, THD_3dim_dataset *dset, Boolean write_brick) |
Variables | |
| int | use_3D_format = 0 |
| int | use_NIFTI_format = 0 |
Function Documentation
|
|
Definition at line 14 of file thd_writedset.c. References use_3D_format. Referenced by main().
00014 { use_3D_format = uu; }
|
|
|
Definition at line 15 of file thd_writedset.c. References use_NIFTI_format.
00015 { use_NIFTI_format = uu; }
|
|
||||||||||||||||||||
|
This routine writes all the header data in the struct to the datablock attributes, then writes the dataset to disk. 29 Apr 1998: erase attributes that are unused, so that they won't be left over from a previous life 09 Mar 2005: attributes are now set in function THD_set_dataset_attributes() rather than here 06 Apr 2005: might go all NIFTI on you ------------------------------------------------------------------ Definition at line 30 of file thd_writedset.c. References THD_diskptr::brick_name, calloc, THD_3dim_dataset::dblk, niftiwr_opts_t::debug_level, THD_datablock::diskptr, DSET_DIRNAME, DSET_IS_1D, DSET_IS_3D, DSET_IS_ANALYZE, DSET_IS_CTFMRI, DSET_IS_CTFSAM, DSET_IS_MASTERED, DSET_IS_MINC, DSET_IS_TCAT, DSET_IS_VOLUMES, DSET_NY, DSET_NZ, DSET_PREFIX, ENTRY, free, niftiwr_opts_t::infile_name, ISVALID_3DIM_DATASET, ISVALID_DATABLOCK, ISVALID_DISKPTR, my_getenv(), THD_datablock::parent, RETURN, STRING_HAS_SUFFIX, THD_init_diskptr_names(), THD_set_dataset_attributes(), THD_write_1D(), THD_write_3D(), THD_write_datablock(), THD_write_nifti(), use_3D_format, use_NIFTI_format, and THD_3dim_dataset::view_type. Referenced by adwarp_refashion_dataset(), AFNI_fimmer_execute(), AFNI_marks_action_CB(), AFNI_marks_transform_CB(), AFNI_refashion_dataset(), DUP_main(), IMREG_main(), main(), output_results(), output_ts_array(), PLUTO_add_dset(), RT_tell_afni_one(), RT_worker(), T3D_save_file_CB(), THD_3dim_from_block(), write_3dtime(), write_afni_data(), write_afni_fict(), write_afni_fizt(), write_bucket(), write_bucket_data(), and write_ts_array().
00032 {
00033 THD_datablock *blk ;
00034 int ii ;
00035 char *ppp ; /* 06 Apr 2005 */
00036
00037 ENTRY("THD_write_3dim_dataset") ;
00038
00039 /*-- sanity checks --*/
00040
00041 if( ! ISVALID_3DIM_DATASET(dset) ||
00042 ! ISVALID_DATABLOCK(dset->dblk) ||
00043 ! ISVALID_DISKPTR(dset->dblk->diskptr) ) RETURN(False) ;
00044
00045 blk = dset->dblk ;
00046 blk->parent = (XtPointer)dset ; /* 05 Jul 2005 */
00047
00048 /* Can only write AFNI formatted datasets */
00049
00050 if( DSET_IS_MINC(dset) ) RETURN(False) ; /* 29 Oct 2001 */
00051 if( DSET_IS_MASTERED(dset) ) RETURN(False) ; /* 11 Jan 1999 */
00052 if( DSET_IS_ANALYZE(dset) ) RETURN(False) ; /* 27 Aug 2002 */
00053 if( DSET_IS_CTFMRI(dset) ) RETURN(False) ; /* 05 Dec 2002 */
00054 if( DSET_IS_CTFSAM(dset) ) RETURN(False) ; /* 05 Dec 2002 */
00055 if( DSET_IS_TCAT(dset) ) RETURN(False) ; /* 05 Aug 2004 */
00056
00057 if( DSET_IS_VOLUMES(dset) && write_brick ) RETURN(False) ; /* 20 Jun 2002 */
00058
00059 if( DSET_IS_1D(dset) ||
00060 ( DSET_NY(dset)==1 && DSET_NZ(dset)==1 ) ){ /* 04 Mar 2003 */
00061
00062 THD_write_1D( new_sessname , new_prefixname , dset ) ;
00063 RETURN(True) ;
00064 }
00065
00066 /*------------------------------*/
00067 /*----- change filenames? -----*/
00068
00069 THD_init_diskptr_names( blk->diskptr ,
00070 new_sessname , NULL , new_prefixname ,
00071 dset->view_type , True ) ;
00072
00073 /*----- 09 Mar 2005: set attribute structs in the datablock -----*/
00074
00075 THD_set_dataset_attributes( dset ) ;
00076
00077 /*------ 06 Apr 2005: write a NIFTI-1 dataset??? -----*/
00078
00079 ppp = DSET_PREFIX(dset) ;
00080 if( STRING_HAS_SUFFIX(ppp,".nii") ||
00081 STRING_HAS_SUFFIX(ppp,".nii.gz") || use_NIFTI_format ){
00082
00083 niftiwr_opts_t options ;
00084
00085 ii = strlen(DSET_DIRNAME(dset)) + strlen(ppp) + 16 ;
00086 options.infile_name = calloc(1,ii) ;
00087 strcpy(options.infile_name,DSET_DIRNAME(dset)) ;
00088 strcat(options.infile_name,ppp) ;
00089
00090 if( !STRING_HAS_SUFFIX(options.infile_name,".nii") &&
00091 !STRING_HAS_SUFFIX(options.infile_name,".nii.gz") )
00092 strcat(options.infile_name,".nii") ;
00093
00094 { /* set the nifti_io debug level 8 Apr 2005 [rickr] */
00095 char * ept = my_getenv("AFNI_NIFTI_DEBUG");
00096 if( ept != NULL ) options.debug_level = atoi(ept);
00097 else options.debug_level = 0 ;
00098 }
00099
00100 if( !write_brick ){
00101 fprintf(stderr,
00102 "** ERROR: can't write HEADER only for NIfTI-1 file: %s\n",
00103 options.infile_name ) ;
00104 ii = 0 ;
00105 } else {
00106 ii = THD_write_nifti(dset,options) ;
00107 strcpy( dset->dblk->diskptr->brick_name , options.infile_name ) ;
00108 }
00109
00110 free((void *)options.infile_name) ;
00111 RETURN( (Boolean)ii ) ;
00112 }
00113
00114 /*------ 21 Mar 2003: use the .3D format? -----*/
00115
00116 if( STRING_HAS_SUFFIX(ppp,".3D") || DSET_IS_3D(dset) || use_3D_format ){
00117 if( !write_brick ){
00118 fprintf(stderr,
00119 "** ERROR: can't write HEADER only for .3D file: %s\n",
00120 DSET_PREFIX(dset) ) ;
00121 RETURN(False) ;
00122 }
00123 THD_write_3D( NULL, NULL, dset ) ; RETURN(True) ;
00124 }
00125
00126 /*----- write datablock to disk in AFNI .HEAD/.BRIK format -----*/
00127
00128 RETURN( THD_write_datablock(blk,write_brick) ) ;
00129 }
|
Variable Documentation
|
|
Definition at line 11 of file thd_writedset.c. Referenced by THD_use_3D_format(), and THD_write_3dim_dataset(). |
|
|
Definition at line 12 of file thd_writedset.c. Referenced by THD_use_NIFTI_format(), and THD_write_3dim_dataset(). |