SMILX  1.01
Classes | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
milx::File Class Reference

A general file IO class for reading writing images and models. More...

#include <milxFile.h>

Classes

struct  ThreadStruct
 Thread Struct for running IO classes in threads. More...
 

Public Member Functions

 File ()
 Standard constructor.
 
virtual ~File ()
 Standard Destructor.
 
template<class Type , unsigned int Dimension>
bool OpenImage (const string filename, typename itk::Image< Type, Dimension >::Pointer &data)
 Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc. More...
 
template<class Type , unsigned int Dimension>
bool OpenImage (const string filename, vtkSmartPointer< vtkImageData > &data)
 
template<class Type , unsigned int Dimension>
bool SaveImage (const string filename, typename itk::Image< Type, Dimension >::Pointer data)
 Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc. More...
 
template<class Type , unsigned int Dimension>
bool SaveImage (const string filename, vtkSmartPointer< vtkImageData > data)
 Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, INR etc. Overloaded for VTK input/output. More...
 

Static Public Member Functions

static bool CanReadImage (const std::string filename)
 Checks if the image can be read by supported libraries. More...
 
static bool ReadImageInformation (const std::string filename, std::string &pixeltype, std::string &componentType, size_t &dimensions)
 Reads just the header of an image file (without reading the image data), and writes the info into the arguments passed by reference such as type etc. More...
 
static std::vector< std::string > GetSupportedImageFileExtensions ()
 Determines the supported image file format as file extensions from internal libraries and returns a list of strings for each format. More...
 
template<class TImage >
static bool OpenImage (const std::string filename, typename itk::SmartPointer< TImage > &data)
 Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc. More...
 
template<class TImage >
static bool OpenImages (std::vector< std::string > &filenames, std::vector< typename itk::SmartPointer< TImage > > &images)
 Opens a number of images, which are any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc. More...
 
template<class TImage >
static bool SaveImage (const std::string filename, typename itk::SmartPointer< TImage > data, itk::ImageIOBase *io=NULL)
 Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc. More...
 
template<class TImage >
static bool SaveImages (std::vector< std::string > &filenames, const std::vector< typename itk::SmartPointer< TImage > > images)
 Saves a number of images, which are any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc. More...
 
static std::vector< std::string > GetDICOMSeriesUIDs (const std::string directoryPath, bool recursive=false)
 DICOM Related. More...
 
static std::vector< std::string > GetDICOMSeriesFilenames (const std::string directoryPath, const std::string seriesName, bool recursive=false)
 Returns the filenames for a given UID/Series name for a given directory. More...
 
template<class TImage >
static bool GetDICOMData (const std::string directoryPath, typename itk::SmartPointer< TImage > &data, itk::MetaDataDictionary &dict, std::string &seriesName, std::string &caseID, std::string &echoID, std::string &seriesID, std::string &acqID, std::string &instanceID, bool recursive=false)
 Opens a DICOM series and returns the image meta data read by ITK/GDCM, i.e. the DICOM tags from the header, as well as the image data. More...
 
template<class TImage >
static bool GetDICOMMetaData (const std::string directoryPath, itk::MetaDataDictionary &dict, std::string &seriesName, std::string &caseID, std::string &echoID, std::string &seriesID, std::string &acqID, std::string &instanceID, bool recursive=false)
 Opens a DICOM series and returns the image meta data read by ITK/GDCM, i.e. the DICOM tags from the header. More...
 
template<class TImage >
static bool GetDICOMTags (const std::string directoryPath, std::vector< std::pair< std::string, std::string > > &tags, std::string &seriesName, std::string &caseID, std::string &echoID, std::string &seriesID, std::string &acqID, std::string &instanceID, bool recursive=false)
 Opens a DICOM series and returns the DICOM tags read by ITK/GDCM, i.e. the DICOM tags from the header, as a list of string pairs. More...
 
template<class TImage >
static bool GetDICOMTags (const itk::MetaDataDictionary dictionary, std::vector< std::pair< std::string, std::string > > &tags)
 
template<class TImage >
static bool OpenDICOMSeries (const std::string directoryPath, typename itk::SmartPointer< TImage > &data, std::string &seriesName, std::string &caseID, std::string &echoID, std::string &seriesID, std::string &acqID, std::string &instanceID, bool recursive=false)
 Opens a DICOM series from the path given. Returns the image volume from the series read by ITK/GDCM. More...
 
template<class TImage >
static bool OpenDICOMSeriesAndTags (const std::string directoryPath, typename itk::SmartPointer< TImage > &data, std::vector< std::pair< std::string, std::string > > &tags, std::string &seriesName, std::string &caseID, std::string &echoID, std::string &seriesID, std::string &acqID, std::string &instanceID, bool recursive=false)
 
template<class TImage >
static bool OpenImage (const std::string filename, vtkSmartPointer< vtkImageData > &data)
 Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, INR etc. Overloaded for VTK input/output. More...
 
template<class TImage >
static bool SaveImage (const std::string filename, vtkSmartPointer< vtkImageData > &data)
 Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, INR etc. Overloaded for VTK input/output. More...
 
template<class TImage >
static itk::SmartPointer< TImage > ReadImageUsingITK (const std::string filename)
 Opens the image using the ITK file reader class. Returns NULL if failed and outputs the error to std error. More...
 
template<class TImage >
static bool WriteImageUsingITK (const std::string filename, itk::SmartPointer< TImage > data)
 Saves the image using the ITK file writer class. Returns NULL if failed and outputs the error to std error. More...
 
template<class TType >
static itk::SmartPointer< itk::Transform< TType > > OpenTransform (std::string filename)
 Opens an ITK transform file and returns. More...
 
static vtkMatrix4x4 * OpenITKTransform (std::string filename)
 Opens an ITK transform file and converts it to a VTK transform matrix. More...
 
static vtkMatrix4x4 * OpenVTKTransform (std::string filename)
 Opens a VTK transform file and converts it to a VTK transform matrix. More...
 
static void SaveITKTransform (std::string filename, const vtkMatrix4x4 *matrix)
 
static void SaveVTKTransform (std::string filename, const vtkMatrix4x4 *matrix)
 
static bool OpenModel (const std::string filename, vtkSmartPointer< vtkPolyData > &data)
 Opens a model file, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj). More...
 
static bool OpenModelCollection (std::vector< std::string > filenames, vtkSmartPointer< vtkPolyDataCollection > &collection)
 Opens model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) into a collection. More...
 
static bool SaveModel (const std::string filename, vtkSmartPointer< vtkPolyData > data, const bool binary=false)
 Saves a model as a file, which can be a VTK XML or Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk) or a Polygonal File (*.ply). More...
 
static bool SaveModelCollection (std::vector< std::string > filenames, vtkSmartPointer< vtkPolyDataCollection > collection, const bool binary=false)
 Saves model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) from a collection. More...
 
static bool SaveTransform (const std::string filename, vtkSmartPointer< vtkTransform > data, const bool ITK=false)
 Saves a transform file, which can be VTK .trsf or ITK from a collection. More...
 
static bool SaveTransformCollection (std::vector< std::string > filenames, vtkSmartPointer< vtkTransformCollection > collection, const bool ITK=false)
 Saves transform files, which can be VTK .trsf or ITK from a collection. More...
 
static bool OpenDelimitedText (const std::string filename, vtkSmartPointer< vtkTable > &data, const std::string delimiter=",")
 Opens ASCII Delimited text files such as CSV files. Data is loaded into the table. More...
 
static bool SaveDelimitedText (const std::string filename, const vtkSmartPointer< vtkTable > data, const std::string delimiter=",")
 Saves table as an ASCII Delimited text files such as a CSV file. More...
 
static bool SaveCamera (const std::string filename, const vtkSmartPointer< vtkCamera > camera)
 
static bool LoadCamera (const std::string filename, vtkSmartPointer< vtkCamera > &camera)
 
static std::string StringToLowerCase (std::string filename)
 Returns a lower case version of the string.
 
static std::string StripFileExtension (const std::string &filename)
 
static std::string ExtractFilename (const std::string &filename, char delimiter='/')
 Returns filename (with extension) with paths removed. More...
 
static std::string ExtractPath (const std::string &filename, char delimiter='/')
 Returns the path of the filename with the basename removed. More...
 
static std::string GetBaseName (const std::string &filename)
 
static std::string GetFileExtension (const std::string &filename)
 Returns the file extension (in lower case) of the given filename. More...
 
static bool Exists (const std::string filename)
 Returns true if the file already exists.
 
static void MakeDirectory (std::string name)
 Creates directory (using ITK) if none exists.
 
static bool OpenModel (const string filename, vtkSmartPointer< vtkPolyData > &data)
 
static bool OpenModelCollection (std::vector< string > filenames, vtkSmartPointer< vtkPolyDataCollection > &collection)
 Opens model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) into a collection. More...
 
static bool SaveModel (const string filename, vtkSmartPointer< vtkPolyData > data, const bool binary=false)
 
static bool SaveModelCollection (std::vector< string > filenames, vtkSmartPointer< vtkPolyDataCollection > collection)
 Saves model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) from a collection. More...
 
static string StringToLowerCase (string filename)
 
static string StripFileExtension (const string &filename)
 
static string ExtractFilename (const string &filename, char delimiter='/')
 
static string ExtractPath (const string &filename, char delimiter='/')
 
static string GetBaseName (const string &filename)
 
static string GetFileExtension (const string &filename)
 

Static Protected Member Functions

static ITK_THREAD_RETURN_TYPE ThreaderCallback (void *arg)
 

Detailed Description

A general file IO class for reading writing images and models.

Loading a model:

vtkSmartPointer<vtkPolyData> surface;
std::string name = getFilenameFromSomewhere();
if( !File::OpenModel(name, surface) ) //Error printed inside
return false;

Loading models:

std::vector<std::string> filenames = getFilenamesFromSomewhere();
vtkSmartPointer<vtkPolyDataCollection> collection;
if( !milx::File::OpenModelCollection(filenames, collection) ) //Error printed inside
exit(EXIT_FAILURE);

Definition at line 92 of file milxFile.h.

Member Function Documentation

◆ CanReadImage()

bool milx::File::CanReadImage ( const std::string  filename)
static

Checks if the image can be read by supported libraries.

Currently does ITK only.

Definition at line 104 of file milxFile.h.

◆ ExtractFilename()

milx::File::ExtractFilename ( const std::string &  filename,
char  delimiter = '/' 
)
inlinestatic

Returns filename (with extension) with paths removed.

e.g. "/foo/bar/baz.txt" –> "baz.txt"

Definition at line 442 of file milxFile.h.

◆ ExtractPath()

milx::File::ExtractPath ( const std::string &  filename,
char  delimiter = '/' 
)
inlinestatic

Returns the path of the filename with the basename removed.

"/foo/bar/baz.txt" –> "/foo/bar/"

Definition at line 452 of file milxFile.h.

◆ GetDICOMData()

template<class TImage >
bool milx::File::GetDICOMData ( const std::string  directoryPath,
typename itk::SmartPointer< TImage > &  data,
itk::MetaDataDictionary &  dict,
std::string &  seriesName,
std::string &  caseID,
std::string &  echoID,
std::string &  seriesID,
std::string &  acqID,
std::string &  instanceID,
bool  recursive = false 
)
static

Opens a DICOM series and returns the image meta data read by ITK/GDCM, i.e. the DICOM tags from the header, as well as the image data.

Only the series name and case ID is guaranteed to exist. Initialise other IDs to empty just in case they are not in the series and will remain unchanged.

You can get the UIDs via the GetDICOMSeriesUIDs() member, which is read from the filenames. This does not read the whole image data and is faster for a quick query.

Print info

Return Meta Data as dictionary

Return image data

Definition at line 659 of file milxFile.h.

◆ GetDICOMMetaData()

template<class TImage >
bool milx::File::GetDICOMMetaData ( const std::string  directoryPath,
itk::MetaDataDictionary &  dict,
std::string &  seriesName,
std::string &  caseID,
std::string &  echoID,
std::string &  seriesID,
std::string &  acqID,
std::string &  instanceID,
bool  recursive = false 
)
static

Opens a DICOM series and returns the image meta data read by ITK/GDCM, i.e. the DICOM tags from the header.

You can get the UIDs via the GetDICOMSeriesUIDs() member, which is read from the filenames. This does not read the whole image data and is faster for a quick query.

Definition at line 756 of file milxFile.h.

◆ GetDICOMSeriesFilenames()

std::vector< std::string > milx::File::GetDICOMSeriesFilenames ( const std::string  directoryPath,
const std::string  seriesName,
bool  recursive = false 
)
static

Returns the filenames for a given UID/Series name for a given directory.

This function simply returns only filenames and nothing is actually read as an image.

Returns an empty list if an error was encountered.

Definition at line 151 of file milxFile.cxx.

◆ GetDICOMSeriesUIDs()

std::vector< std::string > milx::File::GetDICOMSeriesUIDs ( const std::string  directoryPath,
bool  recursive = false 
)
static

DICOM Related.

Returns the list of UIDs for a given directory.

This is useful because directories may contain more than one dataset. Recursive allows for multiple datasets.

Returns an empty list if an error was encountered.

Definition at line 115 of file milxFile.cxx.

◆ GetDICOMTags()

template<class TImage >
bool milx::File::GetDICOMTags ( const std::string  directoryPath,
std::vector< std::pair< std::string, std::string > > &  tags,
std::string &  seriesName,
std::string &  caseID,
std::string &  echoID,
std::string &  seriesID,
std::string &  acqID,
std::string &  instanceID,
bool  recursive = false 
)
static

Opens a DICOM series and returns the DICOM tags read by ITK/GDCM, i.e. the DICOM tags from the header, as a list of string pairs.

You can get the UIDs via the GetDICOMSeriesUIDs() member and the meta data via GetDICOMMetaData(), which are read from the filenames.

Definition at line 767 of file milxFile.h.

◆ GetFileExtension()

milx::File::GetFileExtension ( const std::string &  filename)
inlinestatic

Returns the file extension (in lower case) of the given filename.

This uses the last occurance of the period to get the right most substring.

Definition at line 472 of file milxFile.h.

◆ GetSupportedImageFileExtensions()

std::vector< std::string > milx::File::GetSupportedImageFileExtensions ( )
static

Determines the supported image file format as file extensions from internal libraries and returns a list of strings for each format.

Currently does ITK only.

Definition at line 96 of file milxFile.cxx.

◆ OpenDelimitedText()

bool milx::File::OpenDelimitedText ( const std::string  filename,
vtkSmartPointer< vtkTable > &  data,
const std::string  delimiter = "," 
)
static

Opens ASCII Delimited text files such as CSV files. Data is loaded into the table.

Returns true if successful.

Definition at line 738 of file milxFile.cxx.

◆ OpenDICOMSeries()

template<class TImage >
bool milx::File::OpenDICOMSeries ( const std::string  directoryPath,
typename itk::SmartPointer< TImage > &  data,
std::string &  seriesName,
std::string &  caseID,
std::string &  echoID,
std::string &  seriesID,
std::string &  acqID,
std::string &  instanceID,
bool  recursive = false 
)
static

Opens a DICOM series from the path given. Returns the image volume from the series read by ITK/GDCM.

You can get the UIDs via the GetDICOMSeriesUIDs() member, which is read from the filenames. The DICOM tags are read and seriesName and caseID is replaced with DICOM tag values. Only the series name and case ID is guaranteed to exist. Initialise other IDs to empty just in case they are not in the series and will remain unchanged.

Returns true if successful. Image is also NOT flipped for VTK.

Definition at line 820 of file milxFile.h.

◆ OpenImage() [1/4]

template<class Type , unsigned int Dimension>
bool milx::File::OpenImage ( const string  filename,
typename itk::Image< Type, Dimension >::Pointer &  data 
)

Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc.

Returns true if successful. data is allocated within this member, so pass a NULL pointer. Image is also NOT flipped, consider using overloaded OpenImage() with VTK image data which is flipped.

Internal structure used for passing image data into the threading library

Definition at line 126 of file milxFile_Threaded.h.

◆ OpenImage() [2/4]

template<class TImage >
bool milx::File::OpenImage ( const std::string  filename,
typename itk::SmartPointer< TImage > &  data 
)
static

Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc.

Returns true if successful. data is allocated within this member, so pass a NULL pointer. Image is also NOT flipped, consider using overloaded OpenImage() with VTK image data which is flipped.

Definition at line 509 of file milxFile.h.

◆ OpenImage() [3/4]

template<class Type , unsigned int Dimension>
bool milx::File::OpenImage ( const string  filename,
vtkSmartPointer< vtkImageData > &  data 
)

Export to VTK

< ITK to VTK image

Flip - ITK and VTK do not have the same orientation

Definition at line 326 of file milxFile_Threaded.h.

◆ OpenImage() [4/4]

template<class TImage >
milx::File::OpenImage ( const std::string  filename,
vtkSmartPointer< vtkImageData > &  data 
)
static

Opens an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, INR etc. Overloaded for VTK input/output.

ITK Reader is used and then transparently converted to a VTK image. Returns true if successful. Image is also flipped since the ITK reader orientation is different to VTK images.

Export to VTK

< ITK to VTK image

Flip - ITK and VTK do not have the same orientation

Definition at line 850 of file milxFile.h.

◆ OpenImages()

template<class TImage >
bool milx::File::OpenImages ( std::vector< std::string > &  filenames,
std::vector< typename itk::SmartPointer< TImage > > &  images 
)
static

Opens a number of images, which are any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc.

Returns true if successful. images vector is filled with images. Image is also NOT flipped for VTK. The filenames vector is reassigned to the names that were actually read in (indices corresponding to the vector of images)

Definition at line 586 of file milxFile.h.

◆ OpenITKTransform()

vtkMatrix4x4 * milx::File::OpenITKTransform ( std::string  filename)
static

Opens an ITK transform file and converts it to a VTK transform matrix.

Author
Jurgen Fripp et al., 2010. Modified by Shekhar Chandra, 2011

Definition at line 190 of file milxFile.cxx.

◆ OpenModel()

bool milx::File::OpenModel ( const std::string  filename,
vtkSmartPointer< vtkPolyData > &  data 
)
static

Opens a model file, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj).

Returns true if successful. PolyData is allocated within this member, so pass a NULL pointer. Hence, the pass is by reference.

Definition at line 488 of file milxFile.cxx.

◆ OpenModelCollection() [1/2]

bool milx::File::OpenModelCollection ( std::vector< string >  filenames,
vtkSmartPointer< vtkPolyDataCollection > &  collection 
)
static

Opens model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) into a collection.

Returns true if successful. PolyData and PolyDataCollection are allocated within this member, so pass a NULL pointer. Hence, the pass is by reference.

Definition at line 126 of file milxFile_Threaded.cxx.

◆ OpenModelCollection() [2/2]

bool milx::File::OpenModelCollection ( std::vector< std::string >  filenames,
vtkSmartPointer< vtkPolyDataCollection > &  collection 
)
static

Opens model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) into a collection.

Returns true if successful. PolyData and PolyDataCollection are allocated within this member, so pass a NULL pointer. Hence, the pass is by reference.

Definition at line 611 of file milxFile.cxx.

◆ OpenTransform()

template<class TType >
itk::SmartPointer< itk::Transform< TType > > milx::File::OpenTransform ( std::string  filename)
static

Opens an ITK transform file and returns.

Author
Shekhar Chandra, 2013

Definition at line 1031 of file milxFile.h.

◆ OpenVTKTransform()

vtkMatrix4x4 * milx::File::OpenVTKTransform ( std::string  filename)
static

Opens a VTK transform file and converts it to a VTK transform matrix.

Author
Jurgen Fripp et al., 2010. Modified by Shekhar Chandra, 2011

Definition at line 346 of file milxFile.cxx.

◆ ReadImageInformation()

bool milx::File::ReadImageInformation ( const std::string  filename,
std::string &  pixeltype,
std::string &  componentType,
size_t &  dimensions 
)
static

Reads just the header of an image file (without reading the image data), and writes the info into the arguments passed by reference such as type etc.

//Check type etc. of medical image
std::string pixelType, componentType;
if(!milx::File::ReadImageInformation(filename, pixelType, componentType, dataDimensions))
{
cerr << "Failed reading header of image. File may not be an image. Exiting" << endl;
return false;
}

Definition at line 69 of file milxFile.cxx.

◆ ReadImageUsingITK()

template<class TImage >
itk::SmartPointer< TImage > milx::File::ReadImageUsingITK ( const std::string  filename)
inlinestatic

Opens the image using the ITK file reader class. Returns NULL if failed and outputs the error to std error.

This member is inline deliberately to avoid function call overheads.

Definition at line 988 of file milxFile.h.

◆ SaveDelimitedText()

bool milx::File::SaveDelimitedText ( const std::string  filename,
const vtkSmartPointer< vtkTable >  data,
const std::string  delimiter = "," 
)
static

Saves table as an ASCII Delimited text files such as a CSV file.

Returns true if successful.

Definition at line 754 of file milxFile.cxx.

◆ SaveImage() [1/4]

template<class Type , unsigned int Dimension>
bool milx::File::SaveImage ( const string  filename,
typename itk::Image< Type, Dimension >::Pointer  data 
)

Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc.

Returns true if successful. Image is also NOT flipped, consider using overloaded OpenImage() with VTK image data which is flipped.

Internal structure used for passing image data into the threading library

Definition at line 352 of file milxFile_Threaded.h.

◆ SaveImage() [2/4]

template<class Type , unsigned int Dimension>
bool milx::File::SaveImage ( const string  filename,
vtkSmartPointer< vtkImageData >  data 
)

Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, INR etc. Overloaded for VTK input/output.

ITK Writer is used after transparently converting from a VTK image. Returns true if successful. Image is also flipped since the ITK reader orientation is different to VTK images.

Flip - ITK and VTK do not have the same orientation

Export to VTK

< ITK to VTK image

Definition at line 375 of file milxFile_Threaded.h.

◆ SaveImage() [3/4]

template<class TImage >
bool milx::File::SaveImage ( const std::string  filename,
typename itk::SmartPointer< TImage >  data,
itk::ImageIOBase *  io = NULL 
)
static

Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc.

Returns true if successful. Image is also NOT flipped, consider using overloaded OpenImage() with VTK image data which is flipped.

Definition at line 611 of file milxFile.h.

◆ SaveImage() [4/4]

template<class TImage >
bool milx::File::SaveImage ( const std::string  filename,
vtkSmartPointer< vtkImageData > &  data 
)
static

Saves an image file, which is any of the following: JPEG, PNG, DICOM, TIFF, NIFTI, INR etc. Overloaded for VTK input/output.

ITK Writer is used after transparently converting from a VTK image. Returns true if successful. Image is also flipped since the ITK reader orientation is different to VTK images.

Flip - ITK and VTK do not have the same orientation

Export to VTK

< ITK to VTK image

Definition at line 925 of file milxFile.h.

◆ SaveImages()

template<class TImage >
bool milx::File::SaveImages ( std::vector< std::string > &  filenames,
const std::vector< typename itk::SmartPointer< TImage > >  images 
)
static

Saves a number of images, which are any of the following: JPEG, PNG, DICOM, TIFF, NIFTI etc.

Returns true if successful. images vector is assumed to be filled with images. Image is also NOT flipped for VTK. The filenames vector is reassigned to the names that were actually written (indices corresponding to the vector of images)

Definition at line 637 of file milxFile.h.

◆ SaveModel()

bool milx::File::SaveModel ( const std::string  filename,
vtkSmartPointer< vtkPolyData >  data,
const bool  binary = false 
)
static

Saves a model as a file, which can be a VTK XML or Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk) or a Polygonal File (*.ply).

Returns true if successful.

Definition at line 628 of file milxFile.cxx.

◆ SaveModelCollection() [1/2]

bool milx::File::SaveModelCollection ( std::vector< string >  filenames,
vtkSmartPointer< vtkPolyDataCollection >  collection 
)
static

Saves model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) from a collection.

Returns true if successful.

Definition at line 195 of file milxFile_Threaded.cxx.

◆ SaveModelCollection() [2/2]

bool milx::File::SaveModelCollection ( std::vector< std::string >  filenames,
vtkSmartPointer< vtkPolyDataCollection >  collection,
const bool  binary = false 
)
static

Saves model files, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *.vtp or *.vtk), a Polygonal File (*.ply) or a Object file (*.obj) from a collection.

Returns true if successful.

Definition at line 697 of file milxFile.cxx.

◆ SaveTransform()

bool milx::File::SaveTransform ( const std::string  filename,
vtkSmartPointer< vtkTransform >  data,
const bool  ITK = false 
)
static

Saves a transform file, which can be VTK .trsf or ITK from a collection.

Returns true if successful.

Definition at line 709 of file milxFile.cxx.

◆ SaveTransformCollection()

bool milx::File::SaveTransformCollection ( std::vector< std::string >  filenames,
vtkSmartPointer< vtkTransformCollection >  collection,
const bool  ITK = false 
)
static

Saves transform files, which can be VTK .trsf or ITK from a collection.

Returns true if successful.

Definition at line 726 of file milxFile.cxx.

◆ ThreaderCallback()

ITK_THREAD_RETURN_TYPE milx::File::ThreaderCallback ( void *  arg)
staticprotected

Static function used as a "callback" by the MultiThreader. The threading library will call this routine for each thread, which will delegate the control to ThreadedGenerateData().

Definition at line 281 of file milxFile_Threaded.h.

◆ WriteImageUsingITK()

template<class TImage >
bool milx::File::WriteImageUsingITK ( const std::string  filename,
itk::SmartPointer< TImage >  data 
)
inlinestatic

Saves the image using the ITK file writer class. Returns NULL if failed and outputs the error to std error.

This member is inline deliberately to avoid function call overheads.

Definition at line 1009 of file milxFile.h.


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