SyncRecord

From KitwarePublic
Revision as of 13:49, 24 October 2013 by Matt.mccormick (talk | contribs) (Created page with "Andrei State, 2013-10-24 Streamlined access to CMC patient p14_f05 tracked ultrasound scans I am also attaching source code for two C++ classes SyncRecordManager and SyncRecord...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Andrei State, 2013-10-24

Streamlined access to CMC patient p14_f05 tracked ultrasound scans

I am also attaching source code for two C++ classes SyncRecordManager and SyncRecord. Those were developed on Win7 with VC++ 2010, but I tried to keep them general enough and I hope they will work under Linux as well. They only use standard C++ stream and template libraries, and no Microsoft-specific stuff. You can use them to conveniently access all the data in those records, for example in a program that converts this data into a .mha/.mhd format, or in your own program that might directly reconstruct an ultrasound volume from these files. InnerOptic recommends you use this interface since it allows us to modify the format and add more data to it if/when necessary. Below is some skeleton sample code that should get you started:

  1. include "SyncRecordManager.h"

SyncRecordManager srm;

srm.load( "reexported_tracking_data_f_Kitware_v2.txt" ); // metadata is now in memory; check whether return value is true

SyncRecord *s;

// sequential access to records while( s = srm.getNextRecord() ){

int t = s->getTimestamp(); // duration in msec since the start of InnerOptic's acquisition program (at acquisition time); // could be used to determine how much time had passed from one tracked image to the next.

double x_in_ruf[MAX_US_SCAN_CROP_POLYGON_PTS] , y_in_ruf[MAX_US_SCAN_CROP_POLYGON_PTS]; for( int i = 0 ; i < MAX_US_SCAN_CROP_POLYGON_PTS ; ++i ) s->getScanCropVertex_in_ruf( i, x_in_ruf[i], y_in_ruf[i] ); // check whether return value is true // polygonal outline of actual ultrasound pixel scan data, in drift-corrected raw ultrasound frame pixels (x going right, y down) // only the data within this polygon should be reconstructed and used for registration with pre-op imagery // currently this polygon is a trapeze whose parallel edges are aligned with the x axis of the ultrasound image

s->getTrackerFromRufMatrix( tracker_f_ruf.M ); // OpenGL-style orthogonal transformation matrix (translations are in elements 12, 13, 14) which premultiplies a vector in drift-corrected // raw ultrasound frame pixels (z_in_ruf set to 0, add homogeneous component 1) to a vector in tracker space (tabletop field generator) // InnerOptic has performed a manual, approximate, constant-time-offset synchronization of these tracking matrices with the ultrasound images

unsigned char *rgb_ruf_pixels = s->loadRawRgbPixels(); // points to 24-bit raw ultrasound frame pixels as described above; check for non-NULL return value // for now all ultrasound scan files are at 960x768 resolution, so this pointer currently points to 3*960*768 Bytes

s->unloadRawRgbPixels(); // in a 64-bit program you can keep thousands of images in memory, otherwise you should deallocate (which invalidates the pointer) }

srm.rewind(); // in case you want to start another sequential access pass

Make sure that you have the following files for patient p14_f05

reexported_tracking_data_f_Kitware_v2.txt ultrasound_0002389.ppm through ultrasound_0004207.ppm