Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F488
mitkDicomSeriesReader.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
santos
Sep 1 2010, 1:57 PM
2010-09-01 13:57:10 (UTC+2)
Size
6 KB
Referenced Files
None
Subscribers
None
mitkDicomSeriesReader.patch
View Options
Index: mitkDicomSeriesReader.cpp
===================================================================
--- mitkDicomSeriesReader.cpp (revision 25204)
+++ mitkDicomSeriesReader.cpp (working copy)
@@ -28,11 +28,11 @@
typedef itk::GDCMSeriesFileNames DcmFileNamesGeneratorType;
-DataNode::Pointer DicomSeriesReader::LoadDicomSeries(const StringContainer &filenames)
+DataNode::Pointer DicomSeriesReader::LoadDicomSeries(const StringContainer &filenames, UpdateCallBackMethod callback)
{
DataNode::Pointer node = DataNode::New();
- if (DicomSeriesReader::LoadDicomSeries(filenames, *node))
+ if (DicomSeriesReader::LoadDicomSeries(filenames, *node, callback))
{
return node;
}
@@ -42,7 +42,7 @@
}
}
-bool DicomSeriesReader::LoadDicomSeries(const StringContainer &filenames, DataNode &node)
+bool DicomSeriesReader::LoadDicomSeries(const StringContainer &filenames, DataNode &node, UpdateCallBackMethod callback)
{
DcmIoType::Pointer io = DcmIoType::New();
@@ -56,34 +56,34 @@
switch (io->GetComponentType())
{
case DcmIoType::UCHAR:
- DicomSeriesReader::LoadDicom<unsigned char>(filenames, node);
+ DicomSeriesReader::LoadDicom<unsigned char>(filenames, node, callback);
return true;
case DcmIoType::CHAR:
- DicomSeriesReader::LoadDicom<char>(filenames, node);
+ DicomSeriesReader::LoadDicom<char>(filenames, node, callback);
return true;
case DcmIoType::USHORT:
- DicomSeriesReader::LoadDicom<unsigned short>(filenames, node);
+ DicomSeriesReader::LoadDicom<unsigned short>(filenames, node, callback);
return true;
case DcmIoType::SHORT:
- DicomSeriesReader::LoadDicom<short>(filenames, node);
+ DicomSeriesReader::LoadDicom<short>(filenames, node, callback);
return true;
case DcmIoType::UINT:
- DicomSeriesReader::LoadDicom<unsigned int>(filenames, node);
+ DicomSeriesReader::LoadDicom<unsigned int>(filenames, node, callback);
return true;
case DcmIoType::INT:
- DicomSeriesReader::LoadDicom<int>(filenames, node);
+ DicomSeriesReader::LoadDicom<int>(filenames, node, callback);
return true;
case DcmIoType::ULONG:
- DicomSeriesReader::LoadDicom<long unsigned int>(filenames, node);
+ DicomSeriesReader::LoadDicom<long unsigned int>(filenames, node, callback);
return true;
case DcmIoType::LONG:
- DicomSeriesReader::LoadDicom<long int>(filenames, node);
+ DicomSeriesReader::LoadDicom<long int>(filenames, node, callback);
return true;
case DcmIoType::FLOAT:
- DicomSeriesReader::LoadDicom<float>(filenames, node);
+ DicomSeriesReader::LoadDicom<float>(filenames, node, callback);
return true;
case DcmIoType::DOUBLE:
- DicomSeriesReader::LoadDicom<double>(filenames, node);
+ DicomSeriesReader::LoadDicom<double>(filenames, node, callback);
return true;
default:
MITK_ERROR << "Unknown pixel type!";
Index: mitkDicomSeriesReader.h
===================================================================
--- mitkDicomSeriesReader.h (revision 25204)
+++ mitkDicomSeriesReader.h (working copy)
@@ -33,6 +33,8 @@
#include <gdcmDataSet.h>
#endif
+#include <itkCommand.h>
+
namespace mitk
{
@@ -49,16 +51,19 @@
public:
typedef std::vector<std::string> StringContainer;
typedef std::map<std::string, StringContainer> UidFileNamesMap;
+ typedef void (*UpdateCallBackMethod)(float);
/**
* Loads a DICOM series composed by the file names enumerated in the file names container.
+ * If a callback method is supplied, it will be called after every progress update with a progress value in [0,1].
*/
- static DataNode::Pointer LoadDicomSeries(const StringContainer &filenames);
+ static DataNode::Pointer LoadDicomSeries(const StringContainer &filenames, UpdateCallBackMethod callback = 0);
/**
* Loads a DICOM series composed by the file names enumerated in the file names container.
+ * If a callback method is supplied, it will be called after every progress update with a progress value in [0,1].
*/
- static bool LoadDicomSeries(const StringContainer &filenames, DataNode &node);
+ static bool LoadDicomSeries(const StringContainer &filenames, DataNode &node, UpdateCallBackMethod callback = 0);
/**
* Checks if a specific file is a DICOM.
@@ -95,11 +100,31 @@
typedef itk::DICOMImageIO2 DcmIoType;
#endif
+ class CallbackCommand : public itk::Command
+ {
+ public:
+ inline CallbackCommand(UpdateCallBackMethod callback)
+ : m_Callback(callback)
+ {}
+
+ inline void Execute(const itk::Object *caller, const itk::EventObject&)
+ {
+ (*this->m_Callback)(static_cast<const itk::ProcessObject*>(caller)->GetProgress());
+ }
+
+ inline void Execute(itk::Object *caller, const itk::EventObject&)
+ {
+ (*this->m_Callback)(static_cast<itk::ProcessObject*>(caller)->GetProgress());
+ }
+ protected:
+ UpdateCallBackMethod m_Callback;
+ };
+
/**
* Performs the loading of a series and creates an image having the specified pixel type.
*/
template <typename PixelType>
- static void LoadDicom(const StringContainer &filenames, DataNode &node);
+ static void LoadDicom(const StringContainer &filenames, DataNode &node, UpdateCallBackMethod callback);
#if GDCM_MAJOR_VERSION >= 2
/*
Index: mitkDicomSeriesReader.txx
===================================================================
--- mitkDicomSeriesReader.txx (revision 25204)
+++ mitkDicomSeriesReader.txx (working copy)
@@ -31,9 +31,10 @@
{
template <typename PixelType>
-void DicomSeriesReader::LoadDicom(const StringContainer &filenames, DataNode &node)
+void DicomSeriesReader::LoadDicom(const StringContainer &filenames, DataNode &node, UpdateCallBackMethod callback)
{
mitk::Image::Pointer image = mitk::Image::New();
+ CallbackCommand *command = callback ? new CallbackCommand(callback) : 0;
#if GDCM_MAJOR_VERSION >= 2
@@ -83,6 +84,11 @@
reader->SetImageIO(io);
reader->ReverseOrderOff();
+ if (command)
+ {
+ reader->AddObserver(itk::ProgressEvent(), command);
+ }
+
const std::list<StringContainer>::const_iterator df_end = decomposed_filenames.end();
unsigned int act_volume = 1u;
@@ -111,6 +117,11 @@
reader->SetImageIO(io);
reader->ReverseOrderOff();
+ if (command)
+ {
+ reader->AddObserver(itk::ProgressEvent(), command);
+ }
+
reader->SetFileNames(filenames);
reader->Update();
image->InitializeByItk(reader->GetOutput());
@@ -129,6 +140,11 @@
reader->SetImageIO(io);
reader->ReverseOrderOff();
+ if (command)
+ {
+ reader->AddObserver(itk::ProgressEvent(), command);
+ }
+
reader->SetFileNames(filenames);
reader->Update();
image->InitializeByItk(reader->GetOutput());
File Metadata
Details
Attached
Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
467
Default Alt Text
mitkDicomSeriesReader.patch (6 KB)
Attached To
Mode
T3440: There is no progress bar when loading DICOM images with the DICOM browser
Attached
Detach File
Event Timeline
•
santos
added a comment.
Sep 1 2010, 1:57 PM
2010-09-01 13:57:10 (UTC+2)
Comment Actions
Modification in the DicomSeriesReader in order to allow progress callbacks.
Log In to Comment