UsTK : Ultrasound ToolKit  version 2.0.1 under development (2024-11-21)
usMHDSequenceReader Class Reference

#include <visp3/ustk_core/usMHDSequenceReader.h>

Public Member Functions

 usMHDSequenceReader ()
 
 ~usMHDSequenceReader ()
 
void acquire (usImageRF2D< short int > &image, uint64_t &timestamp)
 
void acquire (usImagePreScan2D< unsigned char > &image, uint64_t &timestamp)
 
void acquire (usImagePostScan2D< unsigned char > &image, uint64_t &timestamp)
 
void acquire (usImageRF3D< short int > &image, std::vector< uint64_t > &timestamp)
 
void acquire (usImagePreScan3D< unsigned char > &image, std::vector< uint64_t > &timestamp)
 
void acquire (usImagePostScan3D< unsigned char > &image, uint64_t &timestamp)
 
bool end ()
 
void getImage (unsigned int imageNumber, usImageRF2D< short int > &image, uint64_t &timestamp)
 
void getImage (unsigned int imageNumber, usImagePreScan2D< unsigned char > &image, uint64_t &timestamp)
 
void getImage (unsigned int imageNumber, usImagePostScan2D< unsigned char > &image, uint64_t &timestamp)
 
void getImage (unsigned int imageNumber, usImageRF3D< short int > &image, std::vector< uint64_t > &timestamp)
 
void getImage (unsigned int imageNumber, usImagePreScan3D< unsigned char > &image, std::vector< uint64_t > &timestamp)
 
void getImage (unsigned int imageNumber, usImagePostScan3D< unsigned char > &image, uint64_t &timestamp)
 
us::ImageType getImageType () const
 
int getImageNumber () const
 
uint64_t getNextTimeStamp ()
 
std::vector< uint64_t > getNextTimeStamps ()
 
int getTotalImageNumber () const
 
void setSequenceDirectory (const std::string sequenceDirectory)
 

Detailed Description

Reader for a sequence of images stored as mhd/raw files in a directory Image sequence files order have to respect alphabetical order in the directory, and be the same for corresponding mhd and raw files. For example : image1.mhd, image1.raw, image2.mhd, image2.raw, ... The directory must contain exactly the same number of images as the number of images contained in the sequence (1 mhd file and 1 raw file per image of the sequence).

Here is an example code of a basic use of this class:

#include <visp3/ustk_core/usMHDSequenceReader.h>
int main(int argc, char** argv)
{
std::string sequenceDirectory;
if(argc == 1) {
std::cout << "\nUsage: " << argv[0] << " [--input /path/to/mhd/sequence ] \n" << std::endl;
return 0;
}
for (unsigned int i=1; i<(unsigned int)argc; i++) {
if (std::string(argv[i]) == "--input") {
sequenceDirectory = std::string(argv[i+1]);
i = argc;
}
else {
std::cout << "\nUsage: " << argv[0] << " [--input /path/to/mhd/sequence ] \n" << std::endl;
return 0;
}
}
uint64_t timestamp;
reader.setSequenceDirectory(sequenceDirectory);
//reading loop
while ( !reader.end()) {
reader.acquire(image,timestamp);
std::cout << image;
std::cout << "timestamp : " << timestamp << std::endl;
}
return 0;
}
Reader for a sequence of images stored as mhd/raw files in a directory Image sequence files order hav...
void acquire(usImageRF2D< short int > &image, uint64_t &timestamp)
void setSequenceDirectory(const std::string sequenceDirectory)
Examples
tutorial-MHD-sequence-reader.cpp.

Definition at line 100 of file usMHDSequenceReader.h.

Constructor & Destructor Documentation

◆ usMHDSequenceReader()

usMHDSequenceReader::usMHDSequenceReader ( )

Constructor, initializes the member attribues.

Definition at line 6 of file usMHDSequenceReader.cpp.

◆ ~usMHDSequenceReader()

usMHDSequenceReader::~usMHDSequenceReader ( )

Destructor.

Definition at line 14 of file usMHDSequenceReader.cpp.

Member Function Documentation

◆ acquire() [1/6]

void usMHDSequenceReader::acquire ( usImagePostScan2D< unsigned char > &  image,
uint64_t &  timestamp 
)

◆ acquire() [2/6]

◆ acquire() [3/6]

void usMHDSequenceReader::acquire ( usImagePreScan2D< unsigned char > &  image,
uint64_t &  timestamp 
)

◆ acquire() [4/6]

void usMHDSequenceReader::acquire ( usImagePreScan3D< unsigned char > &  image,
std::vector< uint64_t > &  timestamp 
)

Acquisition method for usImagePreScan3D : fills the output image with the next volume in the sequence.

Parameters
[out]imageThe usImagePreScan3D image acquired.
[out]timestampThe timestamps of the image (0 if not present in the sequence parameters). Every frame of the volume contains an associated timesamp. If the volume number in the sequence is odd, the timestamp vector is reversed : to fit the real conditions of the sweeping motor of a 3D probe (along + / - Z axis every new volume). First volume of a sequence is considered going along Z axis, and the second along -Z, etc...

Definition at line 253 of file usMHDSequenceReader.cpp.

References usImageIo::FORMAT_MHD, usImagePreScanSettings::getAxialResolution(), usImageIo::getHeaderFormat(), us::NOT_SET, us::PRESCAN_3D, usImagePreScan3D< Type >::resize(), usImagePreScanSettings::setAxialResolution(), usTransducerSettings::setDepth(), usMotorSettings::setFrameNumber(), usMotorSettings::setFramePitch(), usImagePreScanSettings::setImagePreScanSettings(), usMotorSettings::setMotorRadius(), usMotorSettings::setMotorSettings(), usMotorSettings::setMotorType(), usTransducerSettings::setSamplingFrequency(), usTransducerSettings::setScanLinePitch(), usTransducerSettings::setTransducerConvexity(), usTransducerSettings::setTransducerRadius(), and usTransducerSettings::setTransmitFrequency().

◆ acquire() [5/6]

void usMHDSequenceReader::acquire ( usImageRF2D< short int > &  image,
uint64_t &  timestamp 
)

◆ acquire() [6/6]

void usMHDSequenceReader::acquire ( usImageRF3D< short int > &  image,
std::vector< uint64_t > &  timestamp 
)

Acquisition method for usImageRF3D : fills the output image with the next volume in the sequence.

Parameters
[out]imageThe usImageRF3D image acquired.
[out]timestampThe timestamps of the image (0 if not present in the sequence parameters). Every frame of the volume contains an associated timesamp. If the volume number in the sequence is odd, the timestamp vector is reversed : to fit the real conditions of the sweeping motor of a 3D probe (along + / - Z axis every new volume). First volume of a sequence is considered going along Z axis, and the second along -Z, etc...

Definition at line 192 of file usMHDSequenceReader.cpp.

References usImageIo::FORMAT_MHD, usImagePreScanSettings::getAxialResolution(), usImageIo::getHeaderFormat(), us::NOT_SET, usImageRF3D< Type >::resize(), us::RF_3D, usImagePreScanSettings::setAxialResolution(), usTransducerSettings::setDepth(), usMotorSettings::setFrameNumber(), usMotorSettings::setFramePitch(), usImagePreScanSettings::setImagePreScanSettings(), usMotorSettings::setMotorRadius(), usMotorSettings::setMotorSettings(), usMotorSettings::setMotorType(), usTransducerSettings::setSamplingFrequency(), usTransducerSettings::setScanLinePitch(), usTransducerSettings::setTransducerConvexity(), usTransducerSettings::setTransducerRadius(), and usTransducerSettings::setTransmitFrequency().

◆ end()

bool usMHDSequenceReader::end ( )

Tells the used if the end of the sequence is reached.

Returns
True if the end of the sequence is reached.
Examples
tutorial-MHD-sequence-reader.cpp.

Definition at line 363 of file usMHDSequenceReader.cpp.

◆ getImage() [1/6]

void usMHDSequenceReader::getImage ( unsigned int  imageNumber,
usImagePostScan2D< unsigned char > &  image,
uint64_t &  timestamp 
)

Acquisition method for specific image in the sequence for usImagePostScan2D : fills the output image with the next volume in the sequence.

Parameters
[in]imageNumberImage number in sequence to acquire (from 0 to total image number - 1)
[out]imageThe usImagePostScan2D image acquired.
[out]timestampThe usImagePostScan2D timestamp (0 if not present in mhd file).

Definition at line 515 of file usMHDSequenceReader.cpp.

References usImageIo::FORMAT_MHD, usImageIo::getHeaderFormat(), us::NOT_SET, us::POSTSCAN_2D, usTransducerSettings::setDepth(), usTransducerSettings::setSamplingFrequency(), usTransducerSettings::setScanLinePitch(), usTransducerSettings::setTransducerConvexity(), usTransducerSettings::setTransducerRadius(), usTransducerSettings::setTransmitFrequency(), and usImagePostScan2D< Type >::setWidthResolution().

◆ getImage() [2/6]

void usMHDSequenceReader::getImage ( unsigned int  imageNumber,
usImagePostScan3D< unsigned char > &  image,
uint64_t &  timestamp 
)

◆ getImage() [3/6]

void usMHDSequenceReader::getImage ( unsigned int  imageNumber,
usImagePreScan2D< unsigned char > &  image,
uint64_t &  timestamp 
)

Acquisition method for specific image in the sequence for usImagePreScan2D : fills the output image with the next volume in the sequence.

Parameters
[in]imageNumberImage number in sequence to acquire (from 0 to total image number - 1)
[out]imageThe usImagePreScan2D image acquired.
[out]timestampThe usImagePreScan2D timestamp (0 if not present in mhd file).

Definition at line 466 of file usMHDSequenceReader.cpp.

References usImageIo::FORMAT_MHD, usImagePreScanSettings::getAxialResolution(), usImageIo::getHeaderFormat(), us::NOT_SET, us::PRESCAN_2D, usImagePreScan2D< Type >::resize(), usImagePreScanSettings::setAxialResolution(), usTransducerSettings::setDepth(), usImagePreScanSettings::setImagePreScanSettings(), usTransducerSettings::setSamplingFrequency(), usTransducerSettings::setScanLinePitch(), usTransducerSettings::setTransducerConvexity(), usTransducerSettings::setTransducerRadius(), and usTransducerSettings::setTransmitFrequency().

◆ getImage() [4/6]

void usMHDSequenceReader::getImage ( unsigned int  imageNumber,
usImagePreScan3D< unsigned char > &  image,
std::vector< uint64_t > &  timestamp 
)

◆ getImage() [5/6]

void usMHDSequenceReader::getImage ( unsigned int  imageNumber,
usImageRF2D< short int > &  image,
uint64_t &  timestamp 
)

Acquisition method for specific image in the sequence for usImageRF2D : fills the output image with the next volume in the sequence.

Parameters
[in]imageNumberImage number in sequence to acquire (from 0 to total image number - 1)
[out]imageThe usImageRF2D image acquired.
[out]timestampThe usImageRF2D timestamp (0 if not present in mhd file).

Definition at line 417 of file usMHDSequenceReader.cpp.

References usImageIo::FORMAT_MHD, usImagePreScanSettings::getAxialResolution(), usImageIo::getHeaderFormat(), us::NOT_SET, usImageRF2D< Type >::resize(), us::RF_2D, usImagePreScanSettings::setAxialResolution(), usTransducerSettings::setDepth(), usImagePreScanSettings::setImagePreScanSettings(), usTransducerSettings::setSamplingFrequency(), usTransducerSettings::setScanLinePitch(), usTransducerSettings::setTransducerConvexity(), usTransducerSettings::setTransducerRadius(), and usTransducerSettings::setTransmitFrequency().

◆ getImage() [6/6]

void usMHDSequenceReader::getImage ( unsigned int  imageNumber,
usImageRF3D< short int > &  image,
std::vector< uint64_t > &  timestamp 
)

◆ getImageNumber()

int usMHDSequenceReader::getImageNumber ( ) const

Returns the current image number, of last image acquired.

Returns
The image number (volume number for 3D sequences, frame number for 2D sequences).

Definition at line 402 of file usMHDSequenceReader.cpp.

◆ getImageType()

us::ImageType usMHDSequenceReader::getImageType ( ) const

Returns the current type of image acquired.

Returns
The image type of the sequence currently read.

Definition at line 369 of file usMHDSequenceReader.cpp.

◆ getNextTimeStamp()

uint64_t usMHDSequenceReader::getNextTimeStamp ( )

Returns the timestamp of next frame (use only for 2D sequence).

Returns
The timestamp of next frame.

Definition at line 375 of file usMHDSequenceReader.cpp.

◆ getNextTimeStamps()

std::vector< uint64_t > usMHDSequenceReader::getNextTimeStamps ( )

Returns the timestamps of next volume.

Returns
The timestamps of next volume.

Definition at line 387 of file usMHDSequenceReader.cpp.

◆ getTotalImageNumber()

int usMHDSequenceReader::getTotalImageNumber ( ) const

Returns the total image number in sequence.

Returns
The total image number (total volume number for 3D sequences, total frame number for 2D sequences).

Definition at line 408 of file usMHDSequenceReader.cpp.

◆ setSequenceDirectory()

void usMHDSequenceReader::setSequenceDirectory ( const std::string  sequenceDirectory)

Setter for the directory containing the mhd sequence to read. To call before calling acquire !

Parameters
sequenceDirectoryThe directory path.
Examples
tutorial-MHD-sequence-reader.cpp.

Definition at line 20 of file usMHDSequenceReader.cpp.