Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced user controls scar #74

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
parser.addArgument(
"input", "i", mitkCommandLineParser::InputFile,
"input", "i", mitkCommandLineParser::String,
"Input Image", "Any image format known to MITK.",
us::Any(), false);
parser.addArgument(
"output", "o", mitkCommandLineParser::OutputFile,
"output", "o", mitkCommandLineParser::String,
"Output file", "Where to save the output.",
us::Any(), false);
parser.addArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input", "i", mitkCommandLineParser::InputFile,
"input", "i", mitkCommandLineParser::String,
"Surface mesh path", "Full path of mesh vtk polydata file.",
us::Any(), false);
parser.addArgument(
Expand Down
6 changes: 3 additions & 3 deletions CemrgApp/Modules/CemrgAppModule/cmdapps/CemrgClippingTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input-vtk", "i", mitkCommandLineParser::InputFile,
"input-vtk", "i", mitkCommandLineParser::String,
"segmentation (vtk) path", "Full path of segmentation.vtk file.",
us::Any(), false);
parser.addArgument(
"output", "o", mitkCommandLineParser::OutputFile,
"output", "o", mitkCommandLineParser::String,
"Output file", "Where to save the output.",
us::Any(), false);
parser.addArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
parser.addArgument("input-segmentation", "i",
mitkCommandLineParser::InputFile,"Input segmentation (.nii)",
mitkCommandLineParser::String,"Input segmentation (.nii)",
"Input segmentation file (commonly output of CEMRGNET)", us::Any(), false
);

Expand Down
6 changes: 3 additions & 3 deletions CemrgApp/Modules/CemrgAppModule/cmdapps/CemrgFixShellApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input-lge", "i", mitkCommandLineParser::InputFile,
"input-lge", "i", mitkCommandLineParser::String,
"LGE path", "Full path of LGE.nii file.",
us::Any(), false);
parser.addArgument(
"output", "o", mitkCommandLineParser::OutputFile,
"output", "o", mitkCommandLineParser::String,
"Output file", "Where to save the output.",
us::Any(), false);
parser.addArgument( // optional
Expand Down
4 changes: 2 additions & 2 deletions CemrgApp/Modules/CemrgAppModule/cmdapps/CemrgIM2INR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input", "i", mitkCommandLineParser::InputFile,
"input", "i", mitkCommandLineParser::String,
"Input image", "Full path of image file.",
us::Any(), false);
parser.addArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input", "i", mitkCommandLineParser::InputFile,
"input", "i", mitkCommandLineParser::String,
"Input image", "Full path of image file.",
us::Any(), false);
parser.addArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {

// Add arguments. Unless specified otherwise, each argument is optional.
parser.addArgument(
"directory", "d", mitkCommandLineParser::InputFile,
"directory", "d", mitkCommandLineParser::String,
"Directory path", "Full path of directory",
us::Any(), false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
parser.addArgument(
"input-lge", "lge", mitkCommandLineParser::InputFile,
"input-lge", "lge", mitkCommandLineParser::String,
"LGE Image", "Full path to the .nii file with the lge score.",
us::Any(), false);
parser.addArgument(
"input-surface", "surf", mitkCommandLineParser::InputFile,
"input-surface", "surf", mitkCommandLineParser::String,
"Surface Image", "Full path to the .vtk file with the surface.",
us::Any(), false);
parser.addArgument(
"output", "o", mitkCommandLineParser::OutputFile,
"output", "o", mitkCommandLineParser::String,
"Output file", "Where to save the output.",
us::Any(), false);
parser.addArgument(
Expand Down
24 changes: 22 additions & 2 deletions CemrgApp/Modules/CemrgAppModule/cmdapps/CemrgProjectionOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input-lge", "i", mitkCommandLineParser::InputFile,
"input-lge", "i", mitkCommandLineParser::String,
"LGE path", "Full path of LGE.nii file.",
us::Any(), false);
parser.addArgument( // optional
Expand All @@ -101,6 +101,12 @@ int main(int argc, char* argv[]) {
parser.addArgument( // optional
"multi-thresholds", "t", mitkCommandLineParser::Bool,
"Multiple thresholds", "Produce the output for the scar score using multiple thresholds:\n\t (mean+V*stdev) V = 1:0.1:5\n\t (V*IIR) V = 0.7:0.01:1.61");
parser.addArgument( // optional
"roi-radius", "radius", mitkCommandLineParser::Bool,
"ROI Radius ON", "Whether to create ROI radius");
parser.addArgument( // optional
"legacy-projection", "old", mitkCommandLineParser::Bool,
"Legacy (old) projection algorithm", "Legacy (old) projection algorithm");
parser.addArgument( // optional
"verbose", "v", mitkCommandLineParser::Bool,
"Verbose Output", "Whether to produce verbose output");
Expand All @@ -127,6 +133,8 @@ int main(int argc, char* argv[]) {
auto thresmethod = 2;
auto singlevoxelprojection = false;
auto multithreshold = false;
auto roi_radius = false;
auto legacy_projection = false;
auto verbose = false;

// Parse, cast and set optional argument
Expand All @@ -146,6 +154,16 @@ int main(int argc, char* argv[]) {
}
std::cout << "single voxel " << singlevoxelprojection << '\n';

if (parsedArgs.end() != parsedArgs.find("roi-radius")) {
roi_radius = us::any_cast<bool>(parsedArgs["roi-radius"]);
}

if (parsedArgs.end() != parsedArgs.find("legacy-projection")) {
legacy_projection = us::any_cast<bool>(parsedArgs["legacy-projection"]);
}

roi_radius = roi_radius && !legacy_projection;

if (parsedArgs.end() != parsedArgs.find("verbose")) {
verbose = us::any_cast<bool>(parsedArgs["verbose"]);
}
Expand Down Expand Up @@ -195,6 +213,8 @@ int main(int argc, char* argv[]) {
scar->SetMinStep(minStep);
scar->SetMaxStep(maxStep);
scar->SetMethodType(methodType);
scar->SetRoiLegacyNormals(legacy_projection);
scar->SetRoiRadiusOption(roi_radius);

MITK_INFO(singlevoxelprojection) << "Setting Single voxel projection";
MITK_INFO(!singlevoxelprojection) << "Setting multiple voxels projection";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ int main(int argc, char* argv[]) {

// Add arguments. Unless specified otherwise, each argument is optional.
parser.addArgument(
"input", "i", mitkCommandLineParser::InputFile,
"input", "i", mitkCommandLineParser::String,
"NIFTI file path", "Full path of .nii file.",
us::Any(), false);
parser.addArgument(
"output", "o", mitkCommandLineParser::OutputFile,
"output", "o", mitkCommandLineParser::String,
"Output file", "Where to save the output.",
us::Any(), false);
parser.addArgument( // optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
parser.addArgument(
"reference", "i", mitkCommandLineParser::InputFile,
"reference", "i", mitkCommandLineParser::String,
"Input object (reference)", "Reference for registration. Accepts any image format known to MITK.",
us::Any(), false);
parser.addArgument(
"otherimage", "j", mitkCommandLineParser::InputFile,
"otherimage", "j", mitkCommandLineParser::String,
"Input object (reference)", "Image to calculate transformation from. Accepts any image format known to MITK.",
us::Any(), false);
parser.addArgument( // optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ int main(int argc, char* argv[]) {
// Add arguments. Unless specified otherwise, each argument is optional.
// See mitkCommandLineParser::addArgument() for more information.
// parser.addArgument(
// "input-path", "p", mitkCommandLineParser::InputFile,
// "input-path", "p", mitkCommandLineParser::String,
// "Input Directory Path", "Path of directory containing LGE files.",
// us::Any(), false);
parser.addArgument(
"input", "i", mitkCommandLineParser::InputFile,
"input", "i", mitkCommandLineParser::String,
"Input image segmentation", "Full path of segmentation file.",
us::Any(), false);
parser.addArgument(
"bloodpool", "b", mitkCommandLineParser::InputFile,
"bloodpool", "b", mitkCommandLineParser::String,
"Input image bloodpool seg", "Full path of bloodpool file.",
us::Any(), false);
parser.addArgument( // optional
Expand Down
4 changes: 3 additions & 1 deletion CemrgApp/Modules/CemrgAppModule/include/CemrgCommonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ class MITKCEMRGAPPMODULE_EXPORT CemrgCommonUtils {

// Image Analysis Utils
static void SetSegmentationEdgesToZero(mitk::Image::Pointer image, QString outPath="");
static void Binarise(mitk::Image::Pointer image, float background=0);
static mitk::Image::Pointer ReturnBinarised(mitk::Image::Pointer image, float background=0);

static void Binarise(mitk::Image::Pointer image, float background=0);
static mitk::Image::Pointer Zeros(mitk::Image::Pointer image);

//Nifti Conversion Utils
static bool ConvertToNifti(mitk::BaseData::Pointer oneNode, QString path2file, bool resample=false, bool reorient=false);
static void RoundPixelValues(QString pathToImage, QString outputPath="");
Expand Down
23 changes: 12 additions & 11 deletions CemrgApp/Modules/CemrgAppModule/include/CemrgScar3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ PURPOSE. See the above copyright notices for more information.
#include <vtkFloatArray.h>
#include <MitkCemrgAppModuleExports.h>
#include <QString>
#include <QDir>

class MITKCEMRGAPPMODULE_EXPORT CemrgScar3D {

public:
enum DebugImageType { BACKGROUND=0, CORRIDOR, PROJECTED };

CemrgScar3D();
mitk::Surface::Pointer Scar3D(std::string directory, mitk::Image::Pointer lgeImage, std::string segname = "segmentation.vtk");
Expand All @@ -52,29 +54,28 @@ class MITKCEMRGAPPMODULE_EXPORT CemrgScar3D {
void PrintThresholdingResults(QString dir, std::vector<double> values_vector, int threshType, double mean, double stdv, bool printGuide = true);
void PrintSingleThresholdingResult(QString dir, double value, int threshType, double mean, double stdv);

double GetMinScalar() const;
double GetMaxScalar() const;
void SetMinStep(int value);
void SetMaxStep(int value);
void SetMethodType(int value);
inline double GetMinScalar() const { return minScalar; };
inline double GetMaxScalar() const { return maxScalar; };
inline void SetMinStep(int value) { minStep = value; };
inline void SetMaxStep(int value) { maxStep = value; };
inline void SetMethodType(int value) { methodType = value; };
void SetScarSegImage(const mitk::Image::Pointer image);
void SetVoxelBasedProjection(bool value);

inline void SetDebug(bool b){debugging=b;};
inline void SetDebugOn(){SetDebug(true);};
inline void SetDebugOff(){SetDebug(false);};
inline void SetVoxelBasedProjection(bool value){voxelBasedProjection=value;};
inline void SetRoiLegacyNormals(bool value){roiLegacyNormals=value;};
inline void SetRoiRadiusOption(bool value){roiRadiusOption=value;};

private:

int methodType;
int minStep, maxStep;
bool voxelBasedProjection, debugging;
bool voxelBasedProjection, roiLegacyNormals, roiRadiusOption;
double minScalar, maxScalar;
vtkSmartPointer<vtkFloatArray> scalars;

typedef itk::Image<short, 3> itkImageType;
itkImageType::Pointer scarSegImage;
itk::Image<short, 3>::Pointer scarDebugLabel;
itk::Image<short, 3>::Pointer scarDebugCorridor;

double GetIntensityAlongNormal(
itkImageType::Pointer scarImage, itkImageType::Pointer visitedImage,
Expand Down
20 changes: 20 additions & 0 deletions CemrgApp/Modules/CemrgAppModule/src/CemrgCommonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,26 @@ void CemrgCommonUtils::SetSegmentationEdgesToZero(mitk::Image::Pointer image, QS
}
}

mitk::Image::Pointer CemrgCommonUtils::Zeros(mitk::Image::Pointer image){
using ImageType = itk::Image<short,3>;

ImageType::Pointer outputImg = ImageType::New();
mitk::CastToItkImage(image->Clone(), outputImg);

using IteratorType = itk::ImageRegionIterator<ImageType>;
IteratorType imIter(outputImg, outputImg->GetLargestPossibleRegion());
imIter.GoToBegin();
while(!imIter.IsAtEnd()){
imIter.Set(0);
++imIter;
}

mitk::Image::Pointer outim = mitk::Image::New();
mitk::CastToMitkImage(outputImg, outim);

return outim;
}

void CemrgCommonUtils::RoundPixelValues(QString pathToImage, QString outputPath) {
QFileInfo fi(pathToImage);
if (fi.exists()) {
Expand Down
Loading