Porta Data and Imaging

From WikiSonix
Jump to: navigation, search

Callbacks[edit]

Callbacks are method used for acquiring image data from Porta. As discussed on a previous documentation page, Porta has two callbacks, one for Raw Data, which is direct cine buffer data, and one for Display Data, which is a processed ultrasound image to be displayed to the end user.

For Raw Data, the function setRawDataCallback() should be setup, and monitored for newly found frames in the cine buffer. This is useful for collecting:

  • Pre-scan converted B mode frames and M mode lines
  • RF data (i.e. special research mode)
  • Raw color Doppler and pulsed wave Doppler RF data

For Display Data, the function setDisplayCallback() should be setup, and monitored for newly processed frames. This is useful for collecting:

  • Processed B mode images
  • Processed Color Doppler images
  • Spectrum data from M or Pulsed Wave modes

Real-time Handling[edit]

To acquire raw data, the following pseudo-code steps should be taken:

void main()
{
  porta->setRawDataCallback(rawCB)

  while(1)
  {
    // do something
  }
}

bool rawCB(void * data)
{
  memcpy(buffer, data)
  // notify main thread, get out of here quickly!
  postMessage(processingFn)
}

void processingFn()
{
  // run some algorithm on 'buffer'
}

To acquire display data, the following pseudo-code steps should be taken:

void main()
{
  porta->setDisplayCallback(dispCB)

  while(1)
  {
    // do something
  }
}

bool dispCB(void * prm)
{
  porta->getBwImage(0, buffer)
  (MyDisplay *)prm->draw()
}

void MyDisplay::draw()
{
  // apply any buffering techniques
  // post message to redraw window
}

Acquiring Data while Frozen[edit]

To acquire raw data while frozen, the following pseudo-code steps should be taken:

void onFreeze()
{
  count = porta->getFrameCount(0)
}

void onGetFrame(int frame)
{
  // enforce boundaries
  if (frame < 0 || frame >= count)
    return

  data = porta->getFrameAddress(0, frame)
  // process raw frame
  // ... do something with 'data'
}

To acquire display data while frozen, the following pseudo-code steps should be taken:

void onFreeze()
{
  count = porta->getFrameCount(0)
}

void onCineScroll(int frame)
{
  // enforce boundaries
  if (frame < 0 || frame >= count)
    return

  porta->processCineImage(0, frame)
  porta->getBwImage(0, buffer)
  // notify display to copy buffer, redraw, etc...  
}