Open-source pulse sequences  
Easily create and execute MR sequences
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ExternalSequence Class Reference

Data representing the entire MR sequence. More...

#include <ExternalSequence.h>

Public Types

typedef void(* PrintFunPtr) (const std::string &str)
 A pointer-type to the low-level print function.
 

Public Member Functions

 ExternalSequence ()
 Constructor.
 
 ~ExternalSequence ()
 Destructor.
 
bool load (std::string path)
 Load the sequence from file. More...
 
std::vector< double > GetDefinition (std::string key)
 Lookup the custom definition. More...
 
int GetNumberOfBlocks (void)
 Return number of sequence blocks.
 
SeqBlockGetBlock (int blockIndex)
 Construct a sequence block from the library events. More...
 
bool decodeBlock (SeqBlock *block)
 Decode a block by looking up indexed events. More...
 

Static Public Member Functions

static void print_msg (MessageType level, std::ostream &ss)
 Display an output message. More...
 
static void SetPrintFunction (PrintFunPtr fun)
 Set the output print function. More...
 

Private Member Functions

void buildFileIndex (std::ifstream &stream)
 Search the file stream for section headers e.g. [RF], [GRAD] etc. More...
 
void skipComments (std::ifstream &stream, char *buffer)
 Skip the comments and empty lines in the given input stream. More...
 
bool decompressShape (CompressedShape &encoded, float *shape)
 Decompress a run-length compressed shape. More...
 
bool checkBlockReferences (EventIDs &events)
 Check the IDs contains references to valid events in the library. More...
 
void checkGradient (SeqBlock &block)
 Check the shapes defining the arbitrary gradient events (if present) More...
 
void checkRF (SeqBlock &block)
 Check the shapes defining the RF event (if present) More...
 

Static Private Member Functions

static std::istream & getline (std::istream &stream, char *buffer, const int MAX_SIZE)
 Read a line from the input stream independent of line ending. More...
 
static void defaultPrint (const std::string &str)
 Print string to standard output (with newline character)
 

Private Attributes

std::map< std::string, int > m_fileIndex
 File location of sections, [RF], [ADC] etc.
 
std::vector< EventIDsm_blocks
 List of sequence blocks.
 
std::map< std::string, std::vector< double > > m_definitions
 Custom definitions provided through [DEFINITIONS] section)
 
std::map< int, RFEventm_rfLibrary
 Library of RF events.
 
std::map< int, GradEventm_gradLibrary
 Library of gradient events.
 
std::map< int, ADCEventm_adcLibrary
 Library of ADC readouts.
 
std::map< int, long > m_delayLibrary
 Library of delays.
 
std::map< int, CompressedShapem_shapeLibrary
 Library of compressed shapes.
 

Static Private Attributes

static const int MAX_LINE_SIZE = 256
 Maximum length of line.
 
static const char COMMENT_CHAR = '#'
 Character defining the start of a comment line.
 
static PrintFunPtr print_fun = &ExternalSequence::defaultPrint
 Pointer to output print function.
 

Detailed Description

Data representing the entire MR sequence.

This class defines an abstract sequence consisting of arbitrary blocks The basic structure of the sequence consists of three hierarchical levels:

  1. Block - list of integer indices pointing to simultaneous events for RF, gradients, ADC.
  2. Event - Basic event with one of the following types:
    • delay - Simple delay
    • RF - contains amplitude, frequency offset, and two indices pointing to basic shape for amp & phase
    • Trapezoid gradient - contains amplitude, ramp up, flat top, ramp down times
    • Arbitrary gradient - contains amplitude and index to basic shape
    • ADC readout - contains number of samples, dwell time, delay, frequency & phase offsets
  3. Shape - List of compressed samples defining a basic shape (arbitrary RF or gradient)
Author
Kelvin Layton kelvi.nosp@m.n.la.nosp@m.yton@.nosp@m.unik.nosp@m.linik.nosp@m.-fre.nosp@m.iburg.nosp@m..de
Date
May 2014
Examples:
parsemr.cpp.

Member Function Documentation

void ExternalSequence::buildFileIndex ( std::ifstream &  stream)
private

Search the file stream for section headers e.g. [RF], [GRAD] etc.

Searches forward in the stream for sections enclosed in square brackets and writes to index

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ExternalSequence::checkBlockReferences ( EventIDs events)
private

Check the IDs contains references to valid events in the library.

Parameters
eventsThe event IDs to check
Returns
true if event references are ok
See also
checkRF(), checkGradient()

+ Here is the caller graph for this function:

void ExternalSequence::checkGradient ( SeqBlock block)
private

Check the shapes defining the arbitrary gradient events (if present)

Check the decompressed amplitude of the given block is between [0 1].

Parameters
blockThe sequence block to check
See also
checkRF()

+ Here is the caller graph for this function:

void ExternalSequence::checkRF ( SeqBlock block)
private

Check the shapes defining the RF event (if present)

Check the decompressed RF amplitude of the given block is between [0 1] and the phase between [0 2pi].

Parameters
blockThe sequence block to check
See also
checkGradient()

+ Here is the caller graph for this function:

bool ExternalSequence::decodeBlock ( SeqBlock block)

Decode a block by looking up indexed events.

This involves assigning the block's event objects from the libraries as well as decompressing arbitrary RF and gradient shapes.

Returns
true if successful

+ Here is the call graph for this function:

bool ExternalSequence::decompressShape ( CompressedShape encoded,
float *  shape 
)
private

Decompress a run-length compressed shape.

Parameters
encodedCompressed shape structure
shapearray of floating-point values (must be preallocated!)

+ Here is the caller graph for this function:

SeqBlock * ExternalSequence::GetBlock ( int  blockIndex)

Construct a sequence block from the library events.

Events are loaded from the library. However, arbitrary waveforms are not decoded until decodeBlock() is called.

See also
decodeBlock()
Examples:
parsemr.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< double > ExternalSequence::GetDefinition ( std::string  key)
inline

Lookup the custom definition.

Search the list of user-specified definitions through the [DEFINITIONS] section. If the definition key is not found, an empty vector is returned.

Parameters
keythe definition name
Returns
a list of values (or empty vector)

+ Here is the caller graph for this function:

std::istream & ExternalSequence::getline ( std::istream &  stream,
char *  buffer,
const int  MAX_SIZE 
)
staticprivate

Read a line from the input stream independent of line ending.

Unlike istream::getline(), this function safely handles three different line endings:

  • Unix/OSX (\n)
  • Windows (\r\n)
  • Old Mac (\r)
Parameters
streamthe input file stream to read from
bufferthe output line buffer (null terminated)
MAX_SIZEmaximum size of the buffer

+ Here is the caller graph for this function:

bool ExternalSequence::load ( std::string  path)

Load the sequence from file.

Reads the sequence files into the class members, the sequence is stored in compressed format. The given path refer to either:

  1. A single file with all sequence definitions
  2. A directory containing a single file (e.g. external.seq)
  3. A directory containing three files (blocks.seq, events.seq, shapes.seq)
Parameters
pathlocation of file or directory
Examples:
parsemr.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ExternalSequence::print_msg ( MessageType  level,
std::ostream &  ss 
)
static

Display an output message.

Display a message only if the MSG_LEVEL is sufficiently high. This function calls the low-level output function, which can be overridden using SetPutMsgFunction().

Parameters
leveltype of message
ssstring stream containing the message

+ Here is the caller graph for this function:

void ExternalSequence::SetPrintFunction ( PrintFunPtr  fun)
inlinestatic

Set the output print function.

Set the low-level output function to be used for printing or logging messages. If no function is specified messages will be printed to cout

Parameters
funPointer to function
Examples:
parsemr.cpp.

+ Here is the caller graph for this function:

void ExternalSequence::skipComments ( std::ifstream &  stream,
char *  buffer 
)
private

Skip the comments and empty lines in the given input stream.

Parameters
streamthe input file stream to process
bufferreturn output buffer of next non-comment line

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: