The Convert Library

 

This library enable sliceOmatic to read all the supported image formats.

 

The library also provide a few functions to access the data contained in the structure.  Most of these functions are only used internally by sliceOmatic, but a few may be useful to you:

 

 

 

Tomo_Image_Pixel_Get

 

Get a pointer to the desired pixel.  This function does not attempt to "reformat" the pixel data.

 

Tomo_Image_Pixel_Get_Int

 

Get and set the GLI value of the desired pixel.  These function will reformat the pixel value according to the original pixel format.

 

Tomo_Image_Pixel_Set_Int

 

 

Tomo_Image_Pixel_Get_Tag

 

Get and set the tag value of the desired pixel.

 

Tomo_Image_Pixel_Set_Tag

 

 

Tomo_Image_Get_Str_Format

 

Return information about the images in a character string.

 

Tomo_Image_Get_Str_Image_Type

 

 

Tomo_Image_Get_Str_Modality

 

 

Since, one of the element of the SliceO_File class is the "Tomo_Image" structure, we will present the content of this structure here:

 

 

typedef          struct          Tomo_Image {

 

          // --- sliceOmatic flags ---

          unsigned int          UID ;          // slice unique id (generate by the lib)

          unsigned int          chksum ;          // Check sum of the image data

          unsigned int          flag ;          // image flags

          unsigned char          lock;          // used for multi-thread access

          unsigned char          NEMA_transfert;          // only for NEMA images

          unsigned int          NEMA_offset;          // only for NEMA images

          char          *DICOM_type ;          // from 0008,0008 tag

          DICOM_Root          *DICOM_root ;          // Information needed for DICOM parsing

          DICOM_List          *DICOM_org ;          // We keep the DICOM attributes from the file

                              // if the input file is NEMA.

          DICOM_List          *DICOM_table ;          // from the IOD definition in the DICOM Tables

          DICOM_List          *DICOM_out ;          // Created from the file, the IOD and the header

 

          Code_Seq          tomovision ;          // (0040,A170)

 

          // --- image location and converter info ---

          unsigned short          format ;          // IGB, NEMA, SIGNA_3x...

          unsigned short          modality ;          // CT, MRI, PHOTO, SPECT...

          unsigned short          scan_type ;          // axial, scout ...

          unsigned char          source ;          // 1:file, 2:char stream

 

          unsigned short          x, y, z, t ;          // image resolution

          void          *data ;          // image pixel data

          unsigned char          *data_tag ;          // segmented image pixel data

          void          *icon ;          // icon (64x64) pixel data

 

          // --- image can be either from a stream or a file ---

          // if the image is a file, input = name of the file,

          // path, name and ext are details of this name.

          // if the image is a stream, input is a pointer to this

          // stream and path, name and ext are NULL.

 

          // --- file location ---

          int          index ;          // if multiple images in a file

          char          *path ;

          char          *name ;

          char          *ext ;

          char          *input ;          // complete file name or data stream

          char          *file_data ;          // file name for data file (if diff)

          char          *file_TAG ;          // file name for TAG file

 

          unsigned int          file_header ;          // size of header

          unsigned int          ima_header ;          // size of header for each image

          unsigned int          file_size ;          // size of file

          long          ima_offset ;          // beginning of pixel data in file

          long          *ima_offset_vect ;          // beginning of pixel data in file

                              // if non-contiguous multi-slice

          unsigned int          memory_used ;

 

          Image_G1          g1 ;

          Image_G2          g2 ;

          Image_G3          g3 ;

          Image_G4          g4 ;

 

          // --- hooks for user structures and flags ---

          unsigned char          user_flag_0 ;

          unsigned char          user_flag_1 ;

          unsigned char          user_flag_2 ;

          unsigned char          user_flag_3 ;

          unsigned char          user_flag_4 ;

          void          *user_0 ;

          void          *user_1 ;

          void          *user_2 ;

          void          *user_3 ;

          void          *user_4 ;

          void          *user_5 ;

          void          *user_6 ;

          void          *user_7 ;

          void          *user_8 ;

          void          *user_9 ;

 

} Tomo_Image ;

 

 

 

// ===========================================================================

// =========================== Image information =============================

// ===========================================================================

typedef          struct          Image_G1 {

 

          // --- all values are in: mm,mm,mm,sec ---

          Vect          org ;          // (0020,0032) origin of pixel 0,0 (lower left) (in patient space)

          Vect          fov ;          // field of view (in image space)

          Vect          inc ;          // (0028,0030) pixel increment (= fov/nb_pix) (in image space)

          Vect          dim ;          // pixel dimensions (can be != from inc) (in image space)

                              // dim.z give the image thickness (0018,0050)

 

          // --- by default, for 3D or 4D data set, the images are uniformly

          // spaced.  If they are not, the org_vect give the origin for

          // each slice in the data set (the "t" information is relative

          // to the "image_date") ---

          Vect          *org_vect ;

          Vect          *inc_vect ;

          Vect          *dim_vect ;

 

          // --- slice orientation (in patient system) ---

          unsigned char          axis_system ;          // 0: dicom, 1:GE ...

          Vect          dir_h ;          // (0020,0037) dir of horiz line (from lower left to lower right)

          Vect          dir_v ;          // (0020,0037) dir of vert line (from lower left to upper left)

          Vect          dir_d ;          // dir of "depth" = scanning = dir_h x dir_v

          float          pos_d ;          // (0018,2005) pos of slice in scanning dir (value

                              // along the parametric line to dir_d)

 

          Matrix          mat_2D_3D ;          // from pixel to 3D

          Matrix          mat_3D_2D ;          // from 3D to pixel

 

          // --- slice orientation (in scanner system) ---

          unsigned char          view_h ;          // (0020,0020) view direction left/right

          unsigned char          view_v ;          // (0020,0020) view direction bottom/top

 

          char          *study_ID ;          // (0020,0010)

          unsigned int          study_num ;          //   "    "

          unsigned int          series_num ;          // (0020,0011)

          unsigned int          acquisition_num;          // (0020,0012)

          unsigned int          image_num ;          //(0020,0013)

          char          *accession_num ;          // (0008,0050)

 

          unsigned short          total_series ;          // (0020,1000)

          unsigned short          total_image ;          // (0020,1002) tot num of images in series

          unsigned short          total_acquisition ;          // (0020,1004)

          unsigned short          num ;          // number of the image in this seq.

 

          unsigned short          temporal_num ;          // (0020,0100)

          unsigned short          temporal_total ;          // (0020,0105)

          float          temporal_res ;          // (0020,0100)

 

          float          frame_time ;          // (0018,1063)

          float          *frame_time_vector ;          // (0018,1065)

 

          TomoVision_Date          study_date ;          // (0008,0020)

          TomoVision_Time          study_time ;          // (0008,0030)

          TomoVision_Date          series_date ;          // (0008,0021)

          TomoVision_Time          series_time ;          // (0008,0031)

          TomoVision_Date          acquisition_date ;          // (0008,0022)

          TomoVision_Time          acquisition_time ;          // (0008,0032)

          TomoVision_Date          image_date ;          // (0008,0023)

          TomoVision_Time          image_time ;          // (0008,0033)

 

          char          *study_comment ;          // (0008,1030) also: description

          char          *series_comment ;          // (0008,103E) also: description

          char          *image_comment ;          // (0020,4000)

          char          *patient_comment ;          // (0010,4000)

 

}   Image_G1 ;

 

// ===========================================================================

// ========================== Pixel information ==============================

// ===========================================================================

typedef          struct          Image_G2 {

 

          // --- pixel structure information ---

          unsigned char          pix_data_type ;          // BYTE,UBYTE... (see def)

          char          *pix_photometric;          // (0028,0004) RGB, MONO1, MONO2, YBR... (see def)

          char          *pix_units ;          // "Houdsfield", "mg/cl"...

          int          pix_fill ;          // (0028,0120) padding value

          unsigned short          pix_store ;          // (0028,0100) 8, 16, 24, 32 bits...

          unsigned short          pix_size ;          // (0028,0101) 8,12, 16 bits...

          unsigned char          pix_plane ;          // (0028,0002) 1, 3 (rgb) or 4 (rgba)

          unsigned char          pix_config ;          // (0028,0006) 0=rgbrgb..., 1=rrr...ggg...bbb...

          unsigned char          pix_sign ;          // (0028,0103) 0=unsigned, 1=signed

          unsigned char          pix_swap ;          // for gray images: 0=no swap 1=swap

                              // for RGB: 0:rgb 1:gbr

                              // for RGBA: 0:rgba 1:abgr 2=argb 3=bgra

          unsigned char          pix_high_bit ;          // (0028,0102) pos of high bit in word

          unsigned char          pix_sup_palette;          // (0008,9205) 1 CS Pixel Presentation

 

          float          pix_offset ;          // (0028,1052) re-scale info

          float          pix_scale ;          // (0028,1053)     "      "

          float          float_offset ;          // re-scale info for float values

          float          float_scale ;          //     "      "

          

          // NOTE: Palette information is only used for reading the images,

          //       once in memory (->data) the image is in RGB.

          unsigned short          palette_red_size ;          // (0028,1101) color palette

          unsigned short          palette_red_start ;

          unsigned short          palette_red_store ;

          unsigned short          palette_grn_size ;          // (0028,1102) color palette

          unsigned short          palette_grn_start ;

          unsigned short          palette_grn_store ;

          unsigned short          palette_blu_size ;          // (0028,1103) color palette

          unsigned short          palette_blu_start ;

          unsigned short          palette_blu_store ;

          unsigned short          *palette_red ;          // (0028,1201)

          unsigned short          *palette_grn ;          // (0028,1202)

          unsigned short          *palette_blu ;          // (0028,1203)

 

          unsigned short          *palette_seg_red ;          // (0028,1221)

          unsigned short           palette_seg_red_size ;          // in OW

          unsigned short          *palette_seg_grn ;          // (0028,1222)

          unsigned short           palette_seg_grn_size ;          // in OW

          unsigned short          *palette_seg_blu ;          // (0028,1223)

          unsigned short           palette_seg_blu_size ;          // in OW

 

          // --- min/max information ---

          int          head_min ;          // (0028,0106) min. val for the image pix from the header

          int          head_max ;          // (0028,0107) max. val for the image pix from the header

          int          head_window ;          // (0028,1051) window width

          int          head_level ;          // (0028,1050) window center

          int          real_min ;          // minimum val for the image pix

          int          real_max ;          // maximum val for the image pix

          float          float_min ;          // min value after scale & offset

          float          float_max ;

 

          int          series_min ;          // min. val for all images in series

          int          series_max ;          // max. val for all images in series

 

          char          compression ;          // compression flag

          void          *storage ;          // compression data structure

 

}   Image_G2 ;

 

// ===========================================================================

// ========================== Patient information ============================

// ===========================================================================

typedef          struct          Image_G3 {

          // --- image info from the header ---

          TomoVision_Name          patient_name ;          // (0010,0010)

          char          *patient_ID ;          // (0010,0020)

          char          *patient_other_ID ;          // (0010,1000)

          char          *patient_history ;          // (0010,21B0)

          char          *diagnostic ;          // (0008,1080)

          char          patient_sex ;          // (0010,0040)

          char          patient_pos_v ;          // (0018,5100) supine, prone, left, right

          char          patient_pos_d ;          // (0018,5100) head first, feet first

          char          *hospital_name ;          // (0008,0080)

          TomoVision_Name          physician_name ;          // (0008,1050)

          TomoVision_Name          radiologist_name ;          // (0008,1060)

          TomoVision_Name          referring_physician_name ;          // (0008,0090)

          char          *referring_physician_phone ;          // (0008,0092)

          TomoVision_Name          operator_name ;          // (0008,1070)

          char          *comments[MAX_COMMENTS] ;

 

          TomoVision_Date          patient_birth_date ;          // 0010,0030 (VR=DA)

          unsigned short          patient_age_year,  

                    patient_age_month,  

                    patient_age_day ;          // (0010,1010)

          float          patient_weight ;          // (0010,1030) in Kg

          float          patient_height ;          // (0010,1020) in m

          unsigned short          patient_heart_rate ;          // (0018,1088) in beat/min

 

}   Image_G3 ;

 

 

// ===========================================================================

// ==================== Scanner specific information =========================

// ===========================================================================

 

// --- Ultrasound calibration region ---

typedef          struct          Image_US_Calib {

          unsigned int          min_x ;          // (0018,6018) (VR=UL)

          unsigned int          min_y ;          // (0018,601A) (VR=UL)

          unsigned int          max_x ;          // (0018,601C) (VR=UL)

          unsigned int          max_y ;          // (0018,601E) (VR=UL)

          unsigned short          units_x ;          // (0018,6024) (VR=US)

          unsigned short          units_y ;          // (0018,6026) (VR=US)

          float          delta_x ;          // (0018,602C) (VR=FD)

          float          delta_y ;          // (0018,602E) (VR=FD)

          int          ref_pixel_x0 ;          // (0018,6020) (VR=SL)

          int          ref_pixel_y0 ;          // (0018,6022) (VR=SL)

          float          ref_val_x ;          // (0018,6028) (VR=FD)

          float          ref_val_y ;          // (0018,602A) (VR=FD)

          unsigned short          reg_spatial_format ;          // (0018,6012) (VR=US)

          unsigned short          reg_data_type ;          // (0018,6014) (VR=US)

          unsigned int          reg_flags ;          // (0018,6016) (VR=UL)

          unsigned int          transducer_freq ;          // (0018,6030) (VR=UL)

          unsigned int          pulse_rep_freq ;          // (0018,6032) (VR=UL)

} Image_US_Calib ;

 

 

 

// --- Ultrasound info ---

typedef          struct          Image_US {

          short          us_type ;          // (0008,0008) third argument

          short          us_modality ;          // (0008,0008) fourth argument

          float          freq ;          // in MHz (not used)

          float          rep_freq ;          // in Hz (only in Kretz)

          float          angle ;          // in deg. (not used)

          char          *acq_mode ;          // M-mode... (not used)

          char          *technique ;          // Angio... (only in Kretz)

          int          nb_region ;

          Image_US_Calib          *region ;

} Image_US ;

 

// --- CR info ---

typedef          struct          Image_CR {

          char          *plate_ID ;          // (0018,1004) (VR=LO)

          char          *radiation_setting ;          // (0018,1155) (VR=CS)

 

          char          *plate_type ;          // (0018,1260) (VR=CR)

          char          *phosphor_type ;          // (0018,1261) (VR=CR)

          char          *processing_desc ;          // (0018,1400) (VR=LO)

          char          *processing_code ;          // (0018,1401) (VR=LO)

 

          char          *cassette_orient ;          // (0018,1402) (VR=CS)

          char          *cassette_size ;          // (0018,1402) (VR=CS)

          float          exposure_on_plate ;          // (0018,1404) (VR=US)

          float          relat_xray_exposure ;          // (0018,1405) (VR=IS)

          float          sensitivity ;          // (0018,1400) (VR=DS)

} Image_CR ;

 

// --- CT info ---

typedef          struct          Image_CT {

} Image_CT ;

 

// --- MR info ---

typedef          struct          Image_MR {

//          char          *scanning_sequence ;          // (0018,0020) SE,IR,GR,EP,RM)

          char          *sequence_variant ;          // (0018,0021) SK,MTC,SS,TRSS,SP,MP,OSP,NONE)

          char          *acquisition_type ;          // (0018,0023) 2D,3D)

          char          *pulse_seq ;          // (0018,0024)

          char          *angio_flag ;          // (0018,0025)

 

          float          TR ;          // (0018,0080) Repetition time in msec

          float          TE ;          // (0018,0081) Echo time in msec

          float          TI ;          // (0018,0082) Inversion time in msec

          float          number_of_averages ;          // (0018,0083)

          float          imaging_freq ;          // (0018,0084) in MHz

          char          *imaging_nucleus ;          // (0018,0085)

          short          mr_type ;          // (0008,0008) third argument

          short          echo_number ;          // (0018,0086)

          float          field_strength ;          // (0018,0087) Magnetic Field Strenght (in Tesla)

          short          number_of_steps ;          // (0018,0089)

          short          echo_train_length ;          // (0018,0091)

          float          percent_sampling ;          // (0018,0093) (in %)

          float          pixel_bandwidth ;          // (0018,0095)

 

//?          float          trigger_time ;          // (0018,1060)

          char          *receiving_coil ;          // (0018,1250) none, head, body, surface...

          char          *transmitting_coil ;          // (0018,1251)

          int          acquisition_matrix[4] ;          // (0018,1310)

          char          *phase_encoding_dir ;          // (0018,1312)

          float          flip_angle ;          // (0018,1314)

} Image_MR ;

 

// --- NM (Nuclear Medecine)/(PET) info ---

typedef          struct          Image_NM {

          char          *image_type_3 ;          // (0008,0008) field #3

          char          *image_type_4 ;          // (0008,0008) field #4

          Code_Seq radiopharmaceutical ;          // (0018,0304)

          Code_Seq radionuclide ;          // (0018,0300)

          Code_Seq patient_orientation ;          // (0054,0410)

          Code_Seq patient_orientation_modif ;          // (0054,0412)

          Code_Seq patient_gantry_relationship ;          // (0054,0414)

          float          radiopharmaceutical_volume ;          // (0018,1071) (cc)

          TomoVision_Time          radiopharmaceutical_start ;          // (0018,1072)

          TomoVision_Time          radiopharmaceutical_stop ;          // (0018,1073)

          float          radionuclide_total_dose ;          // (0018,1074) in MBq (=mCi*37)

          float          radionuclide_half_life ;          // (0018,1075)

          float          radionuclide_positron_fraction ;          // (0018,1076)

          float          radionuclide_specific_activity ;          // (0018,1077)

          int          max_images ;                              // (0054,0081)

          int          total_count ;          // (0018,0070)

          char          *units ;          // (0054,1001)

          char          *counts_source ;          // (0054,1002)

          char          *series_type ;          // (0054,1000)

          int          nb_image_corrections ;

          char          **image_correction ;          // (0028,0051)

          int          nb_decay_corrections ;

          char          **decay_correction ;          // (0054,1102)

 

 

          unsigned short          *energy_window_vector ;          // (0054,0010)

          unsigned short          nb_energy_windows ;          // (0054,0011)

          float          *energy_window_lower_limit ;          // (0054,0014) note: in PET we do not have (0054,0011)

          float          *energy_window_upper_limit ;          // (0054,0015) note: in PET we do not have (0054,0011)

          char          **energy_window_name ;          // (0054,0018) note: in PET we do not have (0054,0011)

 

          unsigned short          *detector_vector ;          // (0054,0020)

          unsigned short          nb_detectors ;          // (0054,0021)

 

          unsigned short          *phase_vector ;          // (0054,0030)

          unsigned short          nb_phases ;          // (0054,0031)

          unsigned short          *nb_frame_in_phases ;          // (0054,0033)

          int          *phase_delay ;          // (0054,0036)

          int          *frame_duration ;          // (0018,1242) (also used in rotations (0054,0052))

          int          *phase_pause ;          // (0054,0038)

 

          unsigned short          *rotation_vector ;          // (0054,0050)

          unsigned short          nb_rotations ;          // (0054,0051)

          float          *start_angle ;          // (0054,0200)

          float          *scan_arc ;          // (0018,1143)

          float          *angular_step ;          // (0018,1144)

          float          *table_pos ;          // (0018,1131)

          float          *table_height ;          // (0018,1130)

          unsigned short          *nb_frame_in_rotation ;          // (0054,0053)

 

          // --- gating information ---

          unsigned short          *RR_interval_vector ;          // (0054,0060)

          unsigned short          nb_RR_intervals ;          // (0054,0061)

          int          *nominal_interval ;          // (0018,1062)

          float          *frame_time ;          // (0018,1063)

          int          *low_RR_value ;          // (0018,1081)

          int          *high_RR_value ;          // (0018,1082)

          int          *interval_acquired ;          // (0018,1083)

          int          *interval_rejected ;          // (0018,1084)

 

 

          unsigned short          *time_slot_vector ;          // (0054,0070)

          unsigned short          nb_time_slots ;          // (0054,0071)

          float          *time_slot_time ;          // (0054,0073)

 

          unsigned short          *slice_vector ;          // (0054,0080)

          unsigned short          nb_slices ;          // (0054,0081)

 

          unsigned short          *angular_view_vector ;          // (0054,0090)

 

          unsigned short          *time_slice_vector ;          // (0054,0100)

          unsigned short          nb_time_slices ;          // (0054,0101)

 

} Image_NM ;

 

// --- SC (Secondary Capture) info ---

typedef          struct          Image_SC {

          short          modality ;          // (0008,0060) (VR=CS)

          short          conversion_type ;          // (0008,0064) (VR=CS)

          char          *device_ID ;          // (0018,1010) (VR=LO)          Secondary Capture Device ID

          char          *manufacturer ;          // (0018,1016) (VR=LO)          Secondary Capture Device Manufacturer

          char          *model ;          // (0018,1018) (VR=LO)          Secondary Capture Device Model Name

          char          *software_version ;          // (0018,1019) (VR=LO)          Secondary Capture Device Software Version

          char          *image_format_acquired;          // (0018,1023) (VR=LO)          Digital Image Format Acquired

          TomoVision_Date          capture_date ;          // (0018,1012) (VR=DA)

          TomoVision_Time          capture_time ;          // (0018,1014) (VR=TI)

} Image_SC ;

 

 

typedef          struct          Image_G4 {

          char          *manufacturer ;          // (0008,0070)

          char          *model ;          // (0008,1090)

          char          *station ;          // (0008,1010)

          char          *serial_number ;          // (0018,1000)

          char          *software_version ;          // (0018,1020)

          char          *scan_protocol ;          // (0018,1030)

          float          table_pos ;          // (0018,1131) & (0020,1041)

          float          *table_pos_vect ;

          float          table_height ;          // (0018,1130)

          float          scan_time ;          // (0018,1150) & (0018,9073) in sec

          float          recons_diam ;          // (0018,1100) in mm (reconstruction diameter)

          char          *scan_options ;          // (0018,0022) (PER,RG,CG,PPG,FC,PFF,PFP,SP,FS)

          char          contrast_flag ;          // (0018,0010) 1:unknow contrast, 2:IV, 4:oral, 6:IV+oral

          char          *contrast_str ;

          char          *contrast_oral ;

          char          *contrast_IV ;

          float          contrast_vol ;          // (0018,1041) volume of diluted solution

          float          contrast_dose ;          // (0018,1044) volume of concentrated product

          TomoVision_Time          contrast_start ;          // (0018,1042) start time (in hours)

          TomoVision_Time          contrast_end ;          // (0018,1043) end time (in hours)

          char          *anatomical_location ;          // (0018,0015)

          char          *anatomical_reference ;          // (0020,1040)

          float          anatomical_pos ;          // (0020,1041)

          char          *scanning_sequence ;          // (0018,0020) SE,IR,GR,EP,RM)

          char          lossy_compression_flag ;          // (0028,2110)

          float          lossy_compression_ratio ;          // (0028,2112)

          char          *pixel_int_relationship;          // (0018,1040) (VR=CS)

 

          float          gantry_tilt ;          // (0018,1120) in deg

          float          gantry_swivel ;          // (0018,1121) in deg

          char          tube_rotation ;          // (0018,1140) 1:cw, 2:ccw

          char          *detector_motion ;          // (0054,0202) "STEP AND SHOOT"

          float          scan_diam ;          // (0018,0090) in mm (collection FOV)

          float          tube_voltage ;          // (0018,0060) in KV

          float          tube_current ;          // (0018,1151) in mAmp

          float          generator_power ;          // (0018,1170) in KW

          float          exposure ;          // (0018,1152) in mAs

          float          dist_source_detector ;          // (0018,1110)

          float          dist_source_patient ;          // (0018,1111)

          float          focal_spot ;          // (0018,1190) (VR=DS)

          char          *collimator_name ;          // (0018,1180) (VR=SH)

          char          *filter ;          // (0018,1160) (VR=SH)

          char          *convolution_kernel ;          // (0018,1210) (not used)

          char          *image_correction ;          // (0028,0051) (not used)

 

          // --- include all modalities info ---

          Image_US    us ;

          Image_CR    cr ;

          Image_CT    ct ;

          Image_MR    mr ;

          Image_NM    nm ;

          Image_SC    sc ;

 

} Image_G4  ;