MCPcopy Create free account
hub / github.com/MITK/MITK / ParseDicomPropertyString

Method ParseDicomPropertyString

Modules/CEST/src/mitkCustomTagParser.cpp:247–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245}
246
247mitk::PropertyList::Pointer mitk::CustomTagParser::ParseDicomPropertyString(std::string dicomPropertyString)
248{
249 auto results = mitk::PropertyList::New();
250 if ("" == dicomPropertyString)
251 {
252 //MITK_ERROR << "Could not parse empty custom dicom string";
253 return results;
254 }
255
256 auto comp = [](const std::string& s1, const std::string& s2)
257 {
258 return boost::algorithm::lexicographical_compare(s1, s2, boost::algorithm::is_iless());
259 };
260
261 std::map<std::string, std::string, decltype(comp)> privateParameters(comp);
262
263 // The Siemens private tag contains information like "43\52\23\34".
264 // We jump over each "\" and convert the number;
265 std::string bytes;
266
267 {
268 const std::size_t SUBSTR_LENGTH = 2;
269 const std::size_t INPUT_LENGTH = dicomPropertyString.length();
270
271 if (INPUT_LENGTH < SUBSTR_LENGTH)
272 return results;
273
274 const std::size_t MAX_INPUT_OFFSET = INPUT_LENGTH - SUBSTR_LENGTH;
275 bytes.reserve(INPUT_LENGTH / 3 + 1);
276
277 try
278 {
279 for (std::size_t i = 0; i <= MAX_INPUT_OFFSET; i += 3)
280 {
281 std::string byte_string = dicomPropertyString.substr(i, SUBSTR_LENGTH);
282 int byte = static_cast<std::string::value_type>(std::stoi(byte_string.c_str(), nullptr, 16));
283 bytes.push_back(byte);
284 }
285 }
286 catch (const std::invalid_argument&) // std::stoi() could not perform conversion
287 {
288 return results;
289 }
290 }
291
292 // extract parameter list
293 std::string parameterListString;
294
295 {
296 const std::string ASCCONV_MARKER = "###";
297 const std::string ASCCONV_BEGIN = "### ASCCONV BEGIN";
298 const std::string ASCCONV_END = "### ASCCONV END";
299
300 auto ascconvBeginPos = bytes.find(ASCCONV_BEGIN);
301 if (std::string::npos == ascconvBeginPos)
302 return results;
303 ascconvBeginPos += ASCCONV_BEGIN.length();
304

Calls 15

IsT1SequenceMethod · 0.95
splitFunction · 0.85
whatMethod · 0.80
GetPersistenceServiceFunction · 0.70
NewFunction · 0.50
findMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
SetPropertyMethod · 0.45
valueMethod · 0.45