21 #include <boost/algorithm/string.hpp>
45 MITK_INFO <<
"Writing connectomics network";
49 MITK_ERROR <<
"Sorry, input to ConnectomicsNetworkMatrixWriter is NULL!";
53 this->ValidateOutputLocation();
56 std::ofstream outStream;
58 if( this->GetOutputStream() )
60 out = this->GetOutputStream();
64 outStream.open( this->GetOutputLocation().c_str() );
75 const std::string& locale =
"C";
76 const std::string& currLocale = setlocale( LC_ALL, NULL );
77 setlocale(LC_ALL, locale.c_str());
79 std::locale previousLocale(out->getloc());
84 std::stringstream header;
87 if(addHeaderInfoProperty.IsNotNull())
89 std::string additionalHeaderInfo = addHeaderInfoProperty->GetValue();
92 std::vector<std::string> strings;
93 boost::split(strings, additionalHeaderInfo, boost::is_any_of(
"\n"));
94 for(
unsigned int index(0); index < strings.size(); ++index)
96 header <<
"#" << strings[index] <<
"\n";
101 std::vector< InputType::VertexDescriptorType > nodes = input->GetVectorOfAllVertexDescriptors();
103 for(
unsigned int index(0); index < nodes.size(); ++index)
105 header <<
" " << (input->GetNode(nodes[index])).label;
109 std::stringstream body;
111 for(
unsigned int i(0); i < nodes.size(); ++i)
113 for(
unsigned int j(0); j < nodes.size(); ++j)
115 if( input->EdgeExists(nodes[i], nodes[j]))
117 body << (input->GetEdge(nodes[i], nodes[j])).edge_weight;
123 if(j < nodes.size() - 1)
131 (*out)<< header.str() <<
"\n" << body.str();
132 setlocale(LC_ALL, currLocale.c_str());
133 MITK_INFO <<
"Connectomics network connection list written";
137 mitkThrow() <<
"Error while writing to stream.";
150 return PartiallySupported;
This file defines the data properties for connectomics networks in MITK.
DataCollection - Class to facilitate loading/accessing structured data.
ConnectomicsNetworkMatrixWriter()
virtual ConfidenceLevel GetConfidenceLevel() const override
The confidence level of the reader or writer implementation.
virtual void Write()
Write the base data to the specified location or output stream.
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
static const char * GetStaticNameOfClass()
virtual mitk::ConnectomicsNetworkMatrixWriter * Clone() const
us::ServiceRegistration< IFileWriter > RegisterService(us::ModuleContext *context=us::GetModuleContext())
const std::string connectomicsDataAdditionalHeaderInformation
Additional header information.
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
Base class for writing mitk::BaseData objects to files or streams.
Connectomics Network Class.
static std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
mitk::IFileIO::ConfidenceLevel GetConfidenceLevel() const
The confidence level of the reader or writer implementation.
virtual ~ConnectomicsNetworkMatrixWriter()