20 #include <Poco/Path.h>
29 m_ImageExtension(
".nrrd")
42 if(inputImage.IsNull() || inputImage->IsEmpty())
44 MITK_WARN <<
"Input image is not valid. Cannot save image!";
79 m_LoggedImages.push_back(inputClone);
80 m_LoggedMITKSystemTimes.push_back(m_SystemTimeClock->GetCurrentStamp());
86 m_LoggedMessages.insert(std::make_pair(static_cast<int>(m_LoggedImages.size()-1),message));
91 std::vector<std::string> dummy1;
93 this->SaveImages(path,dummy1,dummy2);
98 filenames = std::vector<std::string>();
101 Poco::Path testPath(path);
102 if(!testPath.isDirectory())
104 mitkThrow() <<
"Attemting to write to directory " << path <<
" which is not valid! Aborting!";
109 std::string uniqueID = myGen.
GetUID();
112 for(
size_t i=0; i<m_LoggedImages.size(); i++)
114 std::stringstream name;
115 name << path << uniqueID <<
"_Image_" << i << m_ImageExtension;
117 filenames.push_back(name.str());
123 std::stringstream csvFilenameStream;
124 csvFilenameStream << path << uniqueID <<
"_ImageMessages.csv";
125 csvFileName = csvFilenameStream.str();
127 fb.open (csvFileName.c_str(),std::ios::out);
128 std::ostream os(&fb);
132 os <<
"image filename; MITK system timestamp; message\n";
135 for(
size_t i=0; i<m_LoggedImages.size(); i++)
137 std::map<int, std::string>::iterator it = m_LoggedMessages.find(i);
138 if (m_LoggedMessages.empty() || (it == m_LoggedMessages.end())) os << filenames.at(i) <<
";" << m_LoggedMITKSystemTimes.at(i) <<
";" <<
"" <<
"\n";
139 else os << filenames.at(i) <<
";" << m_LoggedMITKSystemTimes.at(i) <<
";" << it->second <<
"\n";
148 if(extension.compare(0,1,
".") == 0)
149 extension = extension.substr(1,extension.size()-1);
155 for(std::vector<MimeType>::size_type i = 0 ; i< mimeTypes.size() ; ++i)
157 std::vector<std::string> extensions = mimeTypes[i].GetExtensions();
158 if (std::find(extensions.begin(), extensions.end(), extension) != extensions.end())
160 m_ImageExtension =
"."+extension;
void SaveImages(std::string path, std::vector< std::string > &imageFilenames, std::string &csvFileName)
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
static IMimeTypeProvider * GetMimeTypeProvider(us::ModuleContext *context=us::GetModuleContext())
Get an IMimeTypeProvider instance.
virtual void GenerateData() override
static std::string CATEGORY_IMAGES()
RealTimeClock is a superclass to WindowsRealTimeClock, LinuxRealTimeClock, etc.
bool SetImageFilesExtension(std::string extension)
virtual std::vector< MimeType > GetMimeTypesForCategory(const std::string &category) const =0
virtual ~USImageLoggingFilter()
A RAII helper class for core service objects.
void AddMessageToCurrentImage(std::string message)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.