Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Design/DICOMSegmentationConverter.puml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ package dcmqi {
class Helper {
+ {static} tokenizeString(string str, vector<string> &tokens, string delimiter): void
+ {static} splitString(string str, string &head, string &tail, string delimiter): void
+ {static} floatToStrScientific(float f): string
+ {static} floatToStr(float f): string
---
+ {static} stringToCodeSequenceMacro(std::string str): CodeSequenceMacro
+ {static} stringToDSRCodedEntryValue(std::string str): DSRCodedEntryValue
Expand Down Expand Up @@ -96,4 +96,4 @@ class SegmentAttributes {
+ PrintSelf() : void
}

@enduml
@enduml
4 changes: 3 additions & 1 deletion include/dcmqi/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <vector>
#include <map>
#include <algorithm>
#include <limits>
#include <locale>

// DCMQI includes
#include "dcmqi/Exceptions.h"
Expand Down Expand Up @@ -45,7 +47,7 @@ namespace dcmqi {
static vector<string> getFileListRecursively(string directory);
static vector<DcmDataset*> loadDatasets(const vector<string>& dicomImageFiles);

static string floatToStrScientific(float f);
static string floatToStr(float f);
static void tokenizeString(string str, vector<string> &tokens, string delimiter);
static void splitString(string str, string &head, string &tail, string delimiter);

Expand Down
8 changes: 6 additions & 2 deletions libsrc/Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,13 @@ namespace dcmqi {
}


string Helper::floatToStrScientific(float f) {
string Helper::floatToStr(float f) {
ostringstream sstream;
sstream << scientific << f;
sstream.imbue(std::locale::classic());
sstream.precision(9);
sstream << f;
//string f_str = sstream.str();
//cout << "Formatted float (length): " << f_str << "(" << f_str.size() << ")" << endl;
return sstream.str();
}

Expand Down
18 changes: 9 additions & 9 deletions libsrc/ImageSEGConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ namespace dcmqi {

FGPlaneOrientationPatient *planor =
FGPlaneOrientationPatient::createMinimal(
Helper::floatToStrScientific(labelDirMatrix[0][0]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[1][0]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[2][0]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[0][1]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[1][1]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[2][1]).c_str());
Helper::floatToStr(labelDirMatrix[0][0]).c_str(),
Helper::floatToStr(labelDirMatrix[1][0]).c_str(),
Helper::floatToStr(labelDirMatrix[2][0]).c_str(),
Helper::floatToStr(labelDirMatrix[0][1]).c_str(),
Helper::floatToStr(labelDirMatrix[1][1]).c_str(),
Helper::floatToStr(labelDirMatrix[2][1]).c_str());

CHECK_COND(segdoc->addForAllFrames(*planor));
}
Expand Down Expand Up @@ -311,9 +311,9 @@ namespace dcmqi {
segmentations[segFileNumber]->TransformIndexToPhysicalPoint(prevIndex, prevOrigin);
}
fgppp->setImagePositionPatient(
Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[2]).c_str());
Helper::floatToStr(sliceOriginPoint[0]).c_str(),
Helper::floatToStr(sliceOriginPoint[1]).c_str(),
Helper::floatToStr(sliceOriginPoint[2]).c_str());
}

/* Add frame that references this segment */
Expand Down
26 changes: 13 additions & 13 deletions libsrc/ParaMapConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ namespace dcmqi {

FGPlaneOrientationPatient *planor =
FGPlaneOrientationPatient::createMinimal(
Helper::floatToStrScientific(labelDirMatrix[0][0]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[1][0]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[2][0]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[0][1]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[1][1]).c_str(),
Helper::floatToStrScientific(labelDirMatrix[2][1]).c_str());
Helper::floatToStr(labelDirMatrix[0][0]).c_str(),
Helper::floatToStr(labelDirMatrix[1][0]).c_str(),
Helper::floatToStr(labelDirMatrix[2][0]).c_str(),
Helper::floatToStr(labelDirMatrix[0][1]).c_str(),
Helper::floatToStr(labelDirMatrix[1][1]).c_str(),
Helper::floatToStr(labelDirMatrix[2][1]).c_str());

//CHECK_COND(planor->setImageOrientationPatient(imageOrientationPatientStr));
CHECK_COND(pMapDoc->addForAllFrames(*planor));
Expand Down Expand Up @@ -174,7 +174,7 @@ namespace dcmqi {
// initialize optional items, if available
if(metaInfo.metaInfoRoot.isMember("MeasurementMethodCode")){
ContentItemMacro* measureMethod = new ContentItemMacro;

CodeSequenceMacro* qCodeName = new CodeSequenceMacro("370129005", "SCT", "Measurement Method");
CodeSequenceMacro* qSpec = new CodeSequenceMacro(
metaInfo.metaInfoRoot["MeasurementMethodCode"]["CodeValue"].asCString(),
Expand Down Expand Up @@ -383,9 +383,9 @@ namespace dcmqi {
FloatImageType::PointType sliceOriginPoint;
parametricMapImage->TransformIndexToPhysicalPoint(sliceIndex, sliceOriginPoint);
fgppp->setImagePositionPatient(
Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[2]).c_str());
Helper::floatToStr(sliceOriginPoint[0]).c_str(),
Helper::floatToStr(sliceOriginPoint[1]).c_str(),
Helper::floatToStr(sliceOriginPoint[2]).c_str());

// Frame Content
OFCondition result = fgfc->setDimensionIndexValues(sliceNumber+1 /* value within dimension */, 0 /* first dimension */);
Expand Down Expand Up @@ -606,9 +606,9 @@ namespace dcmqi {
FloatImageType::PointType sliceOriginPoint;
parametricMapImage->TransformIndexToPhysicalPoint(sliceIndex, sliceOriginPoint);
fgPlanePos->setImagePositionPatient(
Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[2]).c_str());
Helper::floatToStr(sliceOriginPoint[0]).c_str(),
Helper::floatToStr(sliceOriginPoint[1]).c_str(),
Helper::floatToStr(sliceOriginPoint[2]).c_str());

// Frame Content
OFCondition result = fgFracon->setDimensionIndexValues(frameNo+1 /* value within dimension */, 0 /* first dimension */);
Expand Down