Skip to content

Commit

Permalink
ENH: Renamed Converter to ImageSEGConverter
Browse files Browse the repository at this point in the history
- methods starting with lowercase
- updated design document
  • Loading branch information
che85 committed May 20, 2016
1 parent 0730dab commit bb7a82a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
Binary file modified Design/DICOMSegmentationConverter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions Design/DICOMSegmentationConverter.puml
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ package ReferenceImage(s) as ReferenceImage <<Rectangle>> {

package dcmqi {

Converter ---* JSONMetaInformationHandler: use
Converter ---* Helper : use
ImageSEGConverter ---* JSONMetaInformationHandler: use
ImageSEGConverter ---* Helper : use

JSONMetaInformationHandler -* SegmentAttributes : use

JSONMetaInformationHandler <-> JSON : read/write
Converter <-> DICOM: read/write
Converter <- DICOM1: read
ImageSEGConverter <-> DICOM: read/write
ImageSEGConverter <- DICOM1: read

Converter <- ITK: read
Converter -> NRRD: write
ImageSEGConverter <- ITK: read
ImageSEGConverter -> NRRD: write

SegmentAttributes -* Helper : use
}

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} 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} StringToCodeSequenceMacro(std::string str): CodeSequenceMacro
+ {static} StringToDSRCodedEntryValue(std::string str): DSRCodedEntryValue
+ {static} stringToCodeSequenceMacro(std::string str): CodeSequenceMacro
+ {static} stringToDSRCodedEntryValue(std::string str): DSRCodedEntryValue
---
+ {static} getCIEXYZFromRGB(unsigned *rgb, float *cieXYZ): float*
+ {static} getRGBFromCIEXYZ(float* cieXYZ, unsigned *rgb): unsigned*
Expand All @@ -58,7 +58,7 @@ class Helper {
+ {static} getCIELabFromIntegerScaledCIELab(unsigned* cieLabScaled, float* cieLab): float*
}

class Converter {
class ImageSEGConverter {
+ {static} itkimage2dcmSegmentation(dcmImages, itkimages, jsonMetaFile, outputFileName)
+ {static} dcmSegmentation2itkimage(dcmImage, ...)
---
Expand Down
10 changes: 5 additions & 5 deletions apps/seg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ set(MODULE_SRCS
${MODULE_NAME}.cxx
Helper.h
Helper.cpp
Converter.h
Converter.cpp
ImageSEGConverter.h
ImageSEGConverter.cpp
SegmentAttributes.h)

SEMMacroBuildCLI(
Expand Down Expand Up @@ -45,11 +45,11 @@ set(MODULE_NAME itkimage2segimage)

set(MODULE_SRCS
${MODULE_NAME}.cxx
../../jsoncpp/jsoncpp.cpp
${CMAKE_SOURCE_DIR}/jsoncpp/jsoncpp.cpp
Helper.h
Helper.cpp
Converter.h
Converter.cpp
ImageSEGConverter.h
ImageSEGConverter.cpp
JSONMetaInformationHandler.h
JSONMetaInformationHandler.cpp
SegmentAttributes.h
Expand Down
18 changes: 9 additions & 9 deletions apps/seg/Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace dcmqi {

string Helper::FloatToStrScientific(float f) {
string Helper::floatToStrScientific(float f) {
ostringstream sstream;
sstream << scientific << f;
return sstream.str();
Expand All @@ -27,7 +27,7 @@ namespace dcmqi {
}
}

void Helper::TokenizeString(string str, vector<string> &tokens, string delimiter) {
void Helper::tokenizeString(string str, vector<string> &tokens, string delimiter) {
// http://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c
size_t pos = 0;
while ((pos = str.find(delimiter)) != string::npos) {
Expand All @@ -38,7 +38,7 @@ namespace dcmqi {
tokens.push_back(str);
};

void Helper::SplitString(string str, string &head, string &tail, string delimiter) {
void Helper::splitString(string str, string &head, string &tail, string delimiter) {
// http://stackoverflow.com/questions/14265581/parse-split-a-string-in-c-using-string-delimiter-standard-c
size_t pos = str.find(delimiter);
if (pos != string::npos) {
Expand Down Expand Up @@ -244,17 +244,17 @@ namespace dcmqi {
return cieLab;
}

CodeSequenceMacro Helper::StringToCodeSequenceMacro(string str) {
CodeSequenceMacro Helper::stringToCodeSequenceMacro(string str) {
string tail, code, designator, meaning;
SplitString(str, code, tail, ",");
SplitString(tail, designator, meaning, ",");
splitString(str, code, tail, ",");
splitString(tail, designator, meaning, ",");
return CodeSequenceMacro(code.c_str(), designator.c_str(), meaning.c_str());
}

DSRCodedEntryValue Helper::StringToDSRCodedEntryValue(string str) {
DSRCodedEntryValue Helper::stringToDSRCodedEntryValue(string str) {
string tail, code, designator, meaning;
SplitString(str, code, tail, ",");
SplitString(tail, designator, meaning, ",");
splitString(str, code, tail, ",");
splitString(tail, designator, meaning, ",");
return DSRCodedEntryValue(code.c_str(), designator.c_str(), meaning.c_str());
}

Expand Down
10 changes: 5 additions & 5 deletions apps/seg/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace dcmqi {

public:

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

static float *getCIEXYZFromRGB(unsigned *rgb, float *cieXYZ);
static float *getCIEXYZFromCIELab(float *cieLab, float *cieXYZ);
Expand All @@ -30,8 +30,8 @@ namespace dcmqi {
static unsigned *getIntegerScaledCIELabFromCIELab(float *cieLab, unsigned *cieLabScaled);
static unsigned *getRGBFromCIEXYZ(float *cieXYZ, unsigned *rgb);

static CodeSequenceMacro StringToCodeSequenceMacro(string str);
static DSRCodedEntryValue StringToDSRCodedEntryValue(string str);
static CodeSequenceMacro stringToCodeSequenceMacro(string str);
static DSRCodedEntryValue stringToDSRCodedEntryValue(string str);

static void checkValidityOfFirstSrcImage(DcmSegmentation *segdoc);
};
Expand Down
30 changes: 15 additions & 15 deletions apps/seg/Converter.cpp → apps/seg/ImageSEGConverter.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "Converter.h"
#include "ImageSEGConverter.h"
#include <iostream>


namespace dcmqi {

bool Converter::itkimage2dcmSegmentation(vector<string> dicomImageFileNames, vector<string> segmentationFileNames,
bool ImageSEGConverter::itkimage2dcmSegmentation(vector<string> dicomImageFileNames, vector<string> segmentationFileNames,
const char *metaDataFileName, const char *outputFileName) {

typedef short PixelType;
Expand Down Expand Up @@ -91,12 +91,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::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());


//CHECK_COND(planor->setImageOrientationPatient(imageOrientationPatientStr));
Expand Down Expand Up @@ -325,9 +325,9 @@ namespace dcmqi {
labelImage->TransformIndexToPhysicalPoint(prevIndex, prevOrigin);
}
fgppp->setImagePositionPatient(
Helper::FloatToStrScientific(sliceOriginPoint[0]).c_str(),
Helper::FloatToStrScientific(sliceOriginPoint[1]).c_str(),
Helper::FloatToStrScientific(sliceOriginPoint[2]).c_str());
Helper::floatToStrScientific(sliceOriginPoint[0]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[1]).c_str(),
Helper::floatToStrScientific(sliceOriginPoint[2]).c_str());
}

/* Add frame that references this segment */
Expand Down Expand Up @@ -478,11 +478,11 @@ namespace dcmqi {
return true;
}

bool Converter::dcmSegmentation2itkimage() {
bool ImageSEGConverter::dcmSegmentation2itkimage() {
return true;
}

IODGeneralEquipmentModule::EquipmentInfo Converter::getEquipmentInfo() {
IODGeneralEquipmentModule::EquipmentInfo ImageSEGConverter::getEquipmentInfo() {
IODGeneralEquipmentModule::EquipmentInfo eq;
eq.m_Manufacturer = "QIICR";
eq.m_DeviceSerialNumber = "0";
Expand All @@ -491,15 +491,15 @@ namespace dcmqi {
return eq;
}

ContentIdentificationMacro Converter::createContentIdentificationInformation() {
ContentIdentificationMacro ImageSEGConverter::createContentIdentificationInformation() {
ContentIdentificationMacro ident;
CHECK_COND(ident.setContentCreatorName("QIICR"));
CHECK_COND(ident.setContentDescription("Iowa QIN segmentation result"));
CHECK_COND(ident.setContentLabel("QIICR QIN IOWA"));
return ident;
}

int Converter::CHECK_COND(const OFCondition& condition) {
int ImageSEGConverter::CHECK_COND(const OFCondition& condition) {
if (condition.bad()) {
cerr << condition.text() << " in " __FILE__ << ":" << __LINE__ << endl;
throw OFConditionBadException();
Expand Down
2 changes: 1 addition & 1 deletion apps/seg/Converter.h → apps/seg/ImageSEGConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace dcmqi {
}
};

class Converter {
class ImageSEGConverter {

public:
static bool itkimage2dcmSegmentation(vector<string> dicomImageFileNames, vector<string> segmentationFileNames,
Expand Down
4 changes: 2 additions & 2 deletions apps/seg/itkimage2segimage.cxx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// CLP includes
#include "itkimage2segimageCLP.h"

#include "Converter.h"
#include "ImageSEGConverter.h"

int main(int argc, char *argv[])
{
PARSE_ARGS;

return dcmqi::Converter::itkimage2dcmSegmentation(inputDICOMImageFileNames, inputSegmentationsFileNames,
return dcmqi::ImageSEGConverter::itkimage2dcmSegmentation(inputDICOMImageFileNames, inputSegmentationsFileNames,
metaDataFileName.c_str(), outputSEGFileName.c_str());
}

0 comments on commit bb7a82a

Please sign in to comment.