Doxygen Source Code Documentation
ge4_header.h File Reference
Go to the source code of this file.
Define Documentation
|
Definition at line 14 of file ge4_header.h. Referenced by set_params(). |
|
Definition at line 11 of file ge4_header.h. Referenced by process_ge4(), and set_params(). |
|
Definition at line 10 of file ge4_header.h. |
|
Definition at line 12 of file ge4_header.h. Referenced by process_ge4(), and set_params(). |
|
Definition at line 13 of file ge4_header.h. Referenced by process_ge4(), and set_params(). |
|
Definition at line 5 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 6 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 18 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 63 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 62 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 41 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 40 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 39 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 84 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 80 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 79 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 83 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 82 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 81 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 78 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 55 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 58 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 47 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 46 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 50 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 49 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 56 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 57 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 54 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 48 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 52 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 53 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 45 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 51 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 31 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 30 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 35 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 28 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 32 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 27 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 26 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 29 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 33 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 34 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 25 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 24 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 73 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 69 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 68 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 72 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 71 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 74 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 70 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 67 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 19 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Definition at line 20 of file ge4_header.h. Referenced by ge4_read_header(). |
|
Value: ( ind < 0 || (ind > (sizeof(str_list)/sizeof(char *))) ) ? \ "out-of-range" : str_list[ind] Definition at line 159 of file ge4_header.h. Referenced by idisp_ge4_series_header(). |
Function Documentation
|
Validate and read header data from a GEMS 4.x formatted file.
Definition at line 77 of file ge4_header.c. References ge4_study_t::age, ge4_series_t::center, ge4_study_t::date, ge4_image_t::echo_num, ge4_image_t::flip_angle, ge4_image_t::fNEX, ge4_series_t::fov, free, GE4_HEADER_LENGTH, GE4_IMAGE_SIZE, GE4_IMAGE_TITLE, GE4_L_IM_NUM, GE4_L_IM_TITLE, GE4_L_SER_PL_DESC, GE4_L_SER_SER_NUM, GE4_L_SER_TITLE, GE4_L_STDY_AGE, GE4_L_STDY_DATE, GE4_L_STDY_NUM, GE4_L_STDY_PAT_ID, GE4_L_STDY_PAT_NAME, GE4_L_STDY_TIME, GE4_L_STDY_TITLE, GE4_OFF_IMG_ECHO_NUM, GE4_OFF_IMG_FLIP_ANGLE, GE4_OFF_IMG_IM_LOCN, GE4_OFF_IMG_IM_NUM, GE4_OFF_IMG_IM_SPACING, GE4_OFF_IMG_IM_THICK, GE4_OFF_IMG_NEX_INT, GE4_OFF_IMG_NEX_REAL, GE4_OFF_IMG_NUM_ECHOS, GE4_OFF_IMG_TABLE_POSN, GE4_OFF_IMG_TE, GE4_OFF_IMG_TI, GE4_OFF_IMG_TITLE, GE4_OFF_IMG_TR, GE4_OFF_SER_CENTER, GE4_OFF_SER_FOV, GE4_OFF_SER_IM_MAT, GE4_OFF_SER_IM_MODE, GE4_OFF_SER_ORIENT, GE4_OFF_SER_PLANE_DESC, GE4_OFF_SER_PLANE_TYPE, GE4_OFF_SER_PULSE_SEQ, GE4_OFF_SER_SCAN_MAT_X, GE4_OFF_SER_SCAN_MAT_Y, GE4_OFF_SER_SERIES_NUM, GE4_OFF_SER_TITLE, GE4_OFF_STDY_AGE, GE4_OFF_STDY_DATE, GE4_OFF_STDY_NUM, GE4_OFF_STDY_PAT_ID, GE4_OFF_STDY_PAT_NAME, GE4_OFF_STDY_SEX, GE4_OFF_STDY_TIME, GE4_OFF_STDY_TITLE, GE4_SERIES_TITLE, GE4_STUDY_TITLE, ge4_validate_header(), ge4_header::im_bytes, ge4_header::im_h, ge4_image_t::im_loc, ge4_series_t::im_mat, ge4_series_t::im_mode, ge4_image_t::im_num, ge4_image_t::im_spacing, ge4_image_t::im_thickness, ge4_header::image, ge4_image_t::iNEX, malloc, ge4_study_t::num, ge4_image_t::num_echoes, ge4_series_t::orient, ge4_study_t::pat_id, ge4_study_t::pat_name, ge4_series_t::plane_desc, ge4_series_t::plane_type, ge4_series_t::pulse_seq, ge4_series_t::scan_mat_x, ge4_series_t::scan_mat_y, ge4_header::ser_h, ge4_series_t::series_num, ge4_study_t::sex, ge4_header::std_h, ge4_header::swap, swap_2_multi(), ge4_image_t::table_posn, ge4_image_t::te, THD_filesize(), ge4_image_t::ti, ge4_study_t::time, ge4_image_t::title, ge4_series_t::title, ge4_study_t::title, and ge4_image_t::tr. Referenced by mri_read_ge4(), and process_ge4().
00078 { 00079 ge4_image_t * ih; 00080 ge4_series_t * sh; 00081 ge4_study_t * st; 00082 FILE * fp; 00083 int file_len; 00084 int rres = 0; /* read result */ 00085 00086 if ( filename == NULL || H == NULL ) 00087 { 00088 fprintf( stderr, "** rg4h : bad params: %p, %p\n", filename, H ); 00089 return -1; 00090 } 00091 00092 file_len = THD_filesize( filename ); 00093 00094 /* file size must be fixed at 145408 bytes (142 KB) */ 00095 if ( file_len != (GE4_HEADER_LENGTH + GE4_IMAGE_SIZE) ) 00096 return 1; 00097 00098 /* clear structure */ 00099 memset( H, 0, sizeof(ge4_header) ); 00100 00101 if ( (fp = fopen( filename, "r" )) == NULL ) 00102 { 00103 fprintf( stderr, "ge4_read_header: failed to open '%s' for reading\n", 00104 filename); 00105 return -1; 00106 } 00107 00108 /* quickly scan and validate titles */ 00109 00110 sh = &H->ser_h; /* set helper pointer */ 00111 ih = &H->im_h; /* set helper pointer */ 00112 st = &H->std_h; /* set helper pointer */ 00113 00114 fseek( fp, GE4_OFF_STDY_TITLE, SEEK_SET ); 00115 rres |= (1 - fread( st->title, GE4_L_STDY_TITLE, 1, fp )); 00116 00117 fseek( fp, GE4_OFF_SER_TITLE, SEEK_SET ); 00118 rres |= (1 - fread( sh->title, GE4_L_SER_TITLE, 1, fp )); 00119 00120 fseek( fp, GE4_OFF_IMG_TITLE, SEEK_SET ); 00121 rres |= (1 - fread( ih->title, GE4_L_IM_TITLE, 1, fp )); 00122 00123 /* if read failure or bad title fields, we're outta' here */ 00124 if ( rres || 00125 strncmp( st->title, GE4_STUDY_TITLE, GE4_L_STDY_TITLE ) || 00126 strncmp( sh->title, GE4_SERIES_TITLE, GE4_L_SER_TITLE ) || 00127 strncmp( ih->title, GE4_IMAGE_TITLE, GE4_L_IM_TITLE ) 00128 ) 00129 return 1; 00130 00131 00132 /* study header fields */ 00133 00134 fseek( fp, GE4_OFF_STDY_NUM, SEEK_SET ); 00135 rres |= (1 - fread( st->num, GE4_L_STDY_NUM, 1, fp )); 00136 00137 fseek( fp, GE4_OFF_STDY_DATE, SEEK_SET ); 00138 rres |= (1 - fread( st->date, GE4_L_STDY_DATE, 1, fp )); 00139 00140 fseek( fp, GE4_OFF_STDY_TIME, SEEK_SET ); 00141 rres |= (1 - fread( st->time, GE4_L_STDY_TIME, 1, fp )); 00142 00143 fseek( fp, GE4_OFF_STDY_PAT_NAME, SEEK_SET ); 00144 rres |= (1 - fread( st->pat_name, GE4_L_STDY_PAT_NAME, 1, fp )); 00145 00146 fseek( fp, GE4_OFF_STDY_PAT_ID, SEEK_SET ); 00147 rres |= (1 - fread( st->pat_id, GE4_L_STDY_PAT_ID, 1, fp )); 00148 00149 fseek( fp, GE4_OFF_STDY_AGE, SEEK_SET ); 00150 rres |= (1 - fread( st->age, GE4_L_STDY_AGE, 1, fp )); 00151 00152 fseek( fp, GE4_OFF_STDY_SEX, SEEK_SET ); 00153 rres |= (1 - fread( &st->sex, 1, 1, fp )); 00154 00155 /* series header fields */ 00156 00157 fseek( fp, GE4_OFF_SER_SERIES_NUM, SEEK_SET ); 00158 rres |= (1 - fread( sh->series_num, GE4_L_SER_SER_NUM, 1, fp )); 00159 00160 fseek( fp, GE4_OFF_SER_PLANE_TYPE, SEEK_SET ); 00161 rres |= (1 - fread( &sh->plane_type, sizeof(sh->plane_type), 1, fp )); 00162 00163 fseek( fp, GE4_OFF_SER_PLANE_DESC, SEEK_SET ); 00164 rres |= (1 - fread( sh->plane_desc, GE4_L_SER_PL_DESC, 1, fp )); 00165 00166 fseek( fp, GE4_OFF_SER_IM_MODE, SEEK_SET ); 00167 rres |= (1 - fread( &sh->im_mode, sizeof(sh->im_mode), 1, fp )); 00168 00169 fseek( fp, GE4_OFF_SER_PULSE_SEQ, SEEK_SET ); 00170 rres |= (1 - fread( &sh->pulse_seq, sizeof(sh->pulse_seq), 1, fp )); 00171 00172 fseek( fp, GE4_OFF_SER_FOV, SEEK_SET ); 00173 rres |= (1 - fread( &sh->fov, sizeof(sh->fov), 1, fp )); 00174 00175 fseek( fp, GE4_OFF_SER_CENTER, SEEK_SET ); 00176 rres |= (1 - fread( sh->center, sizeof(sh->center), 1, fp )); 00177 00178 fseek( fp, GE4_OFF_SER_ORIENT, SEEK_SET ); 00179 rres |= (1 - fread( &sh->orient, sizeof(sh->orient), 1, fp )); 00180 00181 fseek( fp, GE4_OFF_SER_SCAN_MAT_X, SEEK_SET ); 00182 rres |= (1 - fread( &sh->scan_mat_x, sizeof(sh->scan_mat_x), 1, fp )); 00183 00184 fseek( fp, GE4_OFF_SER_SCAN_MAT_Y, SEEK_SET ); 00185 rres |= (1 - fread( &sh->scan_mat_y, sizeof(sh->scan_mat_y), 1, fp )); 00186 00187 fseek( fp, GE4_OFF_SER_IM_MAT, SEEK_SET ); 00188 rres |= (1 - fread( &sh->im_mat, sizeof(sh->im_mat), 1, fp )); 00189 00190 00191 /* image header fields */ 00192 00193 fseek( fp, GE4_OFF_IMG_IM_NUM, SEEK_SET ); 00194 rres |= (1 - fread( ih->im_num, GE4_L_IM_NUM, 1, fp )); 00195 00196 fseek( fp, GE4_OFF_IMG_IM_LOCN, SEEK_SET ); 00197 rres |= (1 - fread( &ih->im_loc, sizeof(ih->im_loc), 1, fp )); 00198 00199 fseek( fp, GE4_OFF_IMG_TABLE_POSN, SEEK_SET ); 00200 rres |= (1 - fread( &ih->table_posn, sizeof(ih->table_posn), 1, fp )); 00201 00202 fseek( fp, GE4_OFF_IMG_IM_THICK, SEEK_SET ); 00203 rres |= (1 - fread( &ih->im_thickness, sizeof(ih->im_thickness), 1, fp )); 00204 00205 fseek( fp, GE4_OFF_IMG_IM_SPACING, SEEK_SET ); 00206 rres |= (1 - fread( &ih->im_spacing, sizeof(ih->im_spacing), 1, fp )); 00207 00208 fseek( fp, GE4_OFF_IMG_TR, SEEK_SET ); 00209 rres |= (1 - fread( &ih->tr, sizeof(ih->tr), 1, fp )); 00210 00211 fseek( fp, GE4_OFF_IMG_TE, SEEK_SET ); 00212 rres |= (1 - fread( &ih->te, sizeof(ih->te), 1, fp )); 00213 00214 fseek( fp, GE4_OFF_IMG_TI, SEEK_SET ); 00215 rres |= (1 - fread( &ih->ti, sizeof(ih->ti), 1, fp )); 00216 00217 fseek( fp, GE4_OFF_IMG_NUM_ECHOS, SEEK_SET ); 00218 rres |= (1 - fread( &ih->num_echoes, sizeof(ih->num_echoes), 1, fp )); 00219 00220 fseek( fp, GE4_OFF_IMG_ECHO_NUM, SEEK_SET ); 00221 rres |= (1 - fread( &ih->echo_num, sizeof(ih->echo_num), 1, fp )); 00222 00223 fseek( fp, GE4_OFF_IMG_NEX_INT, SEEK_SET ); 00224 rres |= (1 - fread( &ih->iNEX, sizeof(ih->iNEX), 1, fp )); 00225 00226 fseek( fp, GE4_OFF_IMG_NEX_REAL, SEEK_SET ); 00227 rres |= (1 - fread( &ih->fNEX, sizeof(ih->fNEX), 1, fp )); 00228 00229 fseek( fp, GE4_OFF_IMG_FLIP_ANGLE, SEEK_SET ); 00230 rres |= (1 - fread( &ih->flip_angle, sizeof(ih->flip_angle), 1, fp )); 00231 00232 if ( rres ) 00233 { 00234 fprintf( stderr, "** failed to read ge4 header for '%s'\n", filename ); 00235 return -1; 00236 } 00237 00238 if ( ge4_validate_header( H ) ) 00239 return 1; 00240 00241 if ( get_image ) 00242 { 00243 if ( (H->image = (short *)malloc( GE4_IMAGE_SIZE )) == NULL ) 00244 { 00245 fprintf( stderr, "** failed to allocate %d bytes for image\n", 00246 GE4_IMAGE_SIZE ); 00247 return -1; 00248 } 00249 00250 fseek( fp, GE4_HEADER_LENGTH, SEEK_SET ); 00251 rres = fread( H->image, GE4_IMAGE_SIZE, 1, fp ); 00252 00253 if ( rres != 1 ) 00254 { 00255 fprintf( stderr, "** failed to read ge4 image for file '%s'\n", 00256 filename ); 00257 free( H->image ); 00258 return -1; 00259 } 00260 00261 H->im_bytes = GE4_IMAGE_SIZE; /* note it for "outsiders" */ 00262 00263 if ( H->swap ) 00264 swap_2_multi( H->image, GE4_IMAGE_SIZE/2 ); 00265 } 00266 00267 return 0; 00268 } |
|
|
Definition at line 285 of file ge4_header.c. References ge4_swap_all_bytes(), ge4_header::im_h, ge4_series_t::im_mode, ge4_series_t::plane_type, ge4_series_t::pulse_seq, and ge4_header::ser_h. Referenced by ge4_read_header().
00286 { 00287 ge4_series_t * s; 00288 ge4_image_t * im; 00289 00290 if ( h == NULL ) 00291 return -1; 00292 00293 s = &h->ser_h; 00294 im = &h->im_h; 00295 00296 /* note that titles have already been validated */ 00297 00298 if ( (s->plane_type < 0) || (s->plane_type > 4) || 00299 (s->im_mode < 0) || (s->im_mode > 4) || 00300 (s->pulse_seq < 0) || (s->pulse_seq > 25) ) 00301 { 00302 ge4_swap_all_bytes( h ); 00303 } 00304 00305 /* if these are still off, we are hosed... */ 00306 if ( (s->plane_type < 0) || (s->plane_type > 4) || 00307 (s->im_mode < 0) || (s->im_mode > 4) || 00308 (s->pulse_seq < 0) || (s->pulse_seq > 25) ) 00309 { 00310 return -1; 00311 } 00312 00313 return 0; 00314 } |
|
Definition at line 406 of file ge4_header.c. References ge4_image_t::echo_num, ge4_image_t::flip_angle, ge4_image_t::fNEX, ge4_image_t::im_loc, ge4_image_t::im_num, ge4_image_t::im_spacing, ge4_image_t::im_thickness, ge4_image_t::iNEX, ge4_image_t::num_echoes, ge4_image_t::table_posn, ge4_image_t::te, ge4_image_t::ti, ge4_image_t::title, and ge4_image_t::tr. Referenced by process_ge4().
00407 { 00408 if ( info ) 00409 fputs( info, stdout ); 00410 00411 if ( im == NULL ) 00412 { 00413 printf( "r_idisp_ge4_image_t: im == NULL" ); 00414 return -1; 00415 } 00416 00417 printf( " ge4_image_t at %p :\n" 00418 " title = %s\n" 00419 " im_num = %s\n" 00420 " im_loc = %.3f\n" 00421 " table_posn = %.3f\n" 00422 " im_thickness = %.3f\n" 00423 " im_spacing = %.3f\n" 00424 " tr (in ms) = %.3f\n" 00425 " te (in ms) = %.3f\n" 00426 " ti (in ms) = %.3f\n" 00427 " num_echoes = %d\n" 00428 " echo_num = %d\n" 00429 " iNEX = %d\n" 00430 " fNEX = %.3f\n" 00431 " flip_angle = %d\n", 00432 im, im->title, im->im_num, im->im_loc, im->table_posn, 00433 im->im_thickness, im->im_spacing, im->tr, im->te, im->ti, 00434 im->num_echoes, im->echo_num, im->iNEX, im->fNEX, im->flip_angle 00435 ); 00436 00437 return 0; 00438 } |
|
Definition at line 445 of file ge4_header.c. References ge4_series_t::center, ge4_series_t::fov, g_ge4_sl_im_modes, g_ge4_sl_orient, g_ge4_sl_pulse_seqs, GE4M_IND2STR, ge4_series_t::im_mat, ge4_series_t::im_mode, ge4_series_t::orient, ge4_series_t::plane_desc, ge4_series_t::plane_type, ge4_series_t::pulse_seq, ge4_series_t::scan_mat_x, ge4_series_t::scan_mat_y, ge4_series_t::series_num, and ge4_series_t::title. Referenced by process_ge4().
00446 { 00447 if ( info ) 00448 fputs( info, stdout ); 00449 00450 if ( s == NULL ) 00451 { 00452 printf( "r_idisp_ge4_series_t: s == NULL" ); 00453 return -1; 00454 } 00455 00456 printf( " ge4_series_t at %p :\n" 00457 " title = %s\n" 00458 " series_num = %s\n" 00459 " plane_type, plane_desc = %d, %s\n" 00460 " image_mode = %d (%s)\n" 00461 " pulse_seq = %d (%s)\n" 00462 " FOV (in mm) = %.3f\n" 00463 " center[0], c[1], c[2] = %.3f, %.3f, %.3f\n" 00464 " orient = %d (%s)\n" 00465 " scan_mat_x, scan_mat_y = %d, %d\n" 00466 " im_mat = %d\n", 00467 s, s->title, s->series_num, s->plane_type, s->plane_desc, 00468 s->im_mode, GE4M_IND2STR(s->im_mode, g_ge4_sl_im_modes), 00469 s->pulse_seq, GE4M_IND2STR(s->pulse_seq, g_ge4_sl_pulse_seqs), 00470 s->fov, s->center[0], s->center[1], s->center[2], 00471 s->orient, GE4M_IND2STR(s->orient,g_ge4_sl_orient), 00472 s->scan_mat_x, s->scan_mat_y, s->im_mat 00473 ); 00474 00475 return 0; 00476 } |
|
Definition at line 374 of file ge4_header.c. References ge4_study_t::age, ge4_study_t::date, ge4_study_t::num, ge4_study_t::pat_id, ge4_study_t::pat_name, ge4_study_t::sex, ge4_study_t::time, and ge4_study_t::title. Referenced by process_ge4().
00375 { 00376 if ( info ) 00377 fputs( info, stdout ); 00378 00379 if ( st == NULL ) 00380 { 00381 printf( "r_idisp_ge4_study_t: st == NULL" ); 00382 return -1; 00383 } 00384 00385 printf( " ge4_study_t at %p :\n" 00386 " title = %s\n" 00387 " num = %s\n" 00388 " date = %s\n" 00389 " time = %s\n" 00390 " pat_name = %s\n" 00391 " pat_id = %s\n" 00392 " age = %s\n" 00393 " sex = %c\n", 00394 st, st->title, st->num, st->date, st->time, 00395 st->pat_name, st->pat_id, st->age, st->sex 00396 ); 00397 00398 return 0; 00399 } |