Skip to content

Commit 6f4a54c

Browse files
author
Jose Alonso Solis-Lemus
committed
Merge branch 'feature/plugin/atrialfibres' into development
2 parents 2de3ce4 + e01a5ad commit 6f4a54c

6 files changed

Lines changed: 63 additions & 12 deletions

File tree

CemrgApp/Modules/CemrgAppModule/include/CemrgCommonUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class MITKCEMRGAPPMODULE_EXPORT CemrgCommonUtils {
8181
static bool ConvertToCarto(std::string vtkPath, std::vector<double>, double, double, int, bool);
8282
static void CalculatePolyDataNormals(vtkSmartPointer<vtkPolyData>& pd, bool celldata=true);
8383
static void FillHoles(mitk::Surface::Pointer surf, QString dir="", QString vtkname="");
84-
static mitk::Image::Pointer ImageFromSurfaceMesh(mitk::Surface::Pointer surf, double origin[3], double spacing[3]);
85-
static void SaveImageFromSurfaceMesh(QString surfPath, double origin[3], double spacing[3], QString outputPath="");
84+
static mitk::Image::Pointer ImageFromSurfaceMesh(mitk::Surface::Pointer surf, double origin[3], double spacing[3], int pad_num=0);
85+
static void SaveImageFromSurfaceMesh(QString surfPath, double origin[3], double spacing[3], QString outputPath="", int pad_num=0);
8686
static double GetSphereParametersFromLandmarks(mitk::PointSet::Pointer landmarks, double * centre);
8787

8888
//Tracking Utils

CemrgApp/Modules/CemrgAppModule/src/CemrgCommonUtils.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ mitk::Image::Pointer CemrgCommonUtils::PadImageWithConstant(mitk::Image::Pointer
342342

343343
ImageType::Pointer outputImg = ImageType::New();
344344
ImageType::IndexType start;
345+
346+
double origin[3];
347+
image->GetGeometry()->GetOrigin().ToArray(origin);
348+
345349
start[0] = 0; start[1] = 0; start[2] = 0;
346350

347351
ImageType::SizeType size;
@@ -377,6 +381,7 @@ mitk::Image::Pointer CemrgCommonUtils::PadImageWithConstant(mitk::Image::Pointer
377381
paste->SetDestinationIndex(indexForOutput);
378382

379383
image = mitk::ImportItkImage(paste->GetOutput())->Clone();
384+
image->GetGeometry()->SetOrigin(origin);
380385

381386
return image;
382387
}
@@ -1155,11 +1160,18 @@ QJsonObject CemrgCommonUtils::CreateJSONObject(QStringList keys_list, QStringLis
11551160
return jsonObj;
11561161
}
11571162

1158-
mitk::Image::Pointer CemrgCommonUtils::ImageFromSurfaceMesh(mitk::Surface::Pointer surf, double origin[3], double spacing[3]){
1163+
mitk::Image::Pointer CemrgCommonUtils::ImageFromSurfaceMesh(mitk::Surface::Pointer surf, double origin[3], double spacing[3], int pad_num){
11591164
vtkSmartPointer<vtkPolyData> pd = surf->GetVtkPolyData();
11601165
double bounds[6];
11611166
pd->GetBounds(bounds);
11621167

1168+
// prepare for padding (pad_num=0 by default, so it does not affect)
1169+
for (int ix = 0; ix < 3; ix++) {
1170+
double pad_offset = pad_num*spacing[ix];
1171+
bounds[2*ix] -= pad_offset;
1172+
bounds[2*ix + 1] += pad_offset;
1173+
}
1174+
11631175
int dimensions[3];
11641176
for (int ix = 0; ix < 3; ix++) {
11651177
dimensions[ix] = static_cast<int>(std::ceil((bounds[ix * 2 + 1] - bounds[ix * 2]) / spacing[ix]));
@@ -1168,7 +1180,6 @@ mitk::Image::Pointer CemrgCommonUtils::ImageFromSurfaceMesh(mitk::Surface::Point
11681180
for (int jx = 0; jx < 3; jx++) {
11691181
origin[jx] = bounds[2*jx] + spacing[jx]/2;
11701182
}
1171-
std::cout << "o = (" << origin[0] << ", " << origin[1] << ", " << origin[2] << ")"<< '\n';
11721183

11731184
//Prepare empty image
11741185
vtkSmartPointer<vtkImageData> whiteImage = vtkSmartPointer<vtkImageData>::New();
@@ -1211,7 +1222,7 @@ mitk::Image::Pointer CemrgCommonUtils::ImageFromSurfaceMesh(mitk::Surface::Point
12111222

12121223
}
12131224

1214-
void CemrgCommonUtils::SaveImageFromSurfaceMesh(QString surfPath, double origin[3], double spacing[3], QString outputPath){
1225+
void CemrgCommonUtils::SaveImageFromSurfaceMesh(QString surfPath, double origin[3], double spacing[3], QString outputPath, int pad_num){
12151226
QString out;
12161227

12171228
if(outputPath.isEmpty()){
@@ -1221,7 +1232,7 @@ void CemrgCommonUtils::SaveImageFromSurfaceMesh(QString surfPath, double origin[
12211232
out = outputPath;
12221233
}
12231234
mitk::Surface::Pointer surf = mitk::IOUtil::Load<mitk::Surface>(surfPath.toStdString());
1224-
mitk::Image::Pointer im = CemrgCommonUtils::ImageFromSurfaceMesh(surf, origin, spacing);
1235+
mitk::Image::Pointer im = CemrgCommonUtils::ImageFromSurfaceMesh(surf, origin, spacing, pad_num);
12251236

12261237
mitk::IOUtil::Save(im, out.toStdString());
12271238
}

CemrgApp/Plugins/kcl.cemrgapp.atrialfibres/src/internal/AtrialFibresClipperView.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,17 @@ void AtrialFibresClipperView::KeyCallBackFunc(vtkObject*, long unsigned int, voi
12611261

12621262
}//_if
12631263
}//_if_main
1264+
//
1265+
if (key == "h" || key == "H"){
1266+
self->Help();
1267+
}
12641268

12651269
}
12661270

1271+
void AtrialFibresClipperView::Help(){
1272+
std::string str = GetHelp();
1273+
QMessageBox::information(NULL, "Help", str.c_str());
1274+
}
12671275
// helper functions
12681276
void AtrialFibresClipperView::InitialisePickerObjects(){
12691277
pickedSeedIds = vtkSmartPointer<vtkIdList>::New();
@@ -1319,6 +1327,7 @@ std::string AtrialFibresClipperView::GetShortcuts(){
13191327
} else{
13201328
res += "R: reset centrelines\nSpace: add seed point\nDelete: remove seed point";
13211329
}
1330+
res += "\nH: Show help";
13221331
return res;
13231332
}
13241333

@@ -1457,3 +1466,25 @@ void AtrialFibresClipperView::PrintCorridorIds(){
14571466
std::cout << "[PriontCorridorIds] No points in corridor" << '\n';
14581467
}
14591468
}
1469+
1470+
1471+
std::string AtrialFibresClipperView::GetHelp(){
1472+
std::string msg = "";
1473+
if (automaticPipeline) {
1474+
msg += "FIX LABELS: \n\n * Press X to select (blue) seed points for fixing labels\n";
1475+
msg += " * Click the Fix Meshing button at the top.";
1476+
msg += "\n * Select the structure (LA body, LSPV, LIPV, etc...)";
1477+
msg += "\n\nIDENITFY PVs";
1478+
msg += "\n * Press SPACE to select (red) seed points";
1479+
msg += "\n * Click the Store Landmarks and Labels, then the Click the Display PV Clippers button";
1480+
msg += "\n * Edit the sphere clippers' size, then click Save Clippers";
1481+
} else{
1482+
msg += "\n\nIDENTIFY START OF PVs";
1483+
msg += "\n * Press SPACE to select (red) seed points in all PVs and Appendage";
1484+
msg += "\n * Click the Find Centrelines button";
1485+
msg += "\n * Click the Display Disk Clippers button - edit disks";
1486+
msg += "\n * Click the Mark PV Start on Image button";
1487+
}
1488+
1489+
return msg;
1490+
}

CemrgApp/Plugins/kcl.cemrgapp.atrialfibres/src/internal/AtrialFibresClipperView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class AtrialFibresClipperView : public QmitkAbstractView {
7070

7171
// helper functions
7272
std::string GetShortcuts();
73+
std::string GetHelp();
7374
bool IsPointSelectionControlsAvailable();
7475
bool IsClipperManualControlsAvailable();
7576
void UserSelectPvLabel();
@@ -105,6 +106,7 @@ protected slots:
105106
void PvClipperSelector(int);
106107

107108
void ClipPVs();
109+
void Help();
108110

109111

110112
protected:

CemrgApp/Plugins/kcl.cemrgapp.atrialfibres/src/internal/AtrialFibresClipperViewControls.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<item row="1" column="2">
3434
<widget class="QPushButton" name="button_man2_clippers">
3535
<property name="text">
36-
<string>Display Clippers</string>
36+
<string>Display Disk Clippers</string>
3737
</property>
3838
</widget>
3939
</item>

CemrgApp/Plugins/kcl.cemrgapp.atrialfibres/src/internal/AtrialFibresView.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@ void AtrialFibresView::AnalysisChoice(){
375375
// Create fake segmentation image for labelling
376376
double origin[3] = {0, 0, 0};
377377
double spacing[3] = {1, 1, 1};
378-
CemrgCommonUtils::SaveImageFromSurfaceMesh(Path(tagName+".vtk"), origin, spacing);
379-
CemrgCommonUtils::SavePadImageWithConstant(Path(tagName+".nii"));
378+
int pad_scale = 1; // pad_scale*spacing added to bounds in function below
379+
QString output_path = ""; // makes input to be overwritten
380+
CemrgCommonUtils::SaveImageFromSurfaceMesh(Path(tagName+".vtk"), origin, spacing, output_path, pad_scale);
381+
// CemrgCommonUtils::SavePadImageWithConstant(Path(tagName+".nii"));
380382

381383
mitk::Image::Pointer im = CemrgCommonUtils::ReturnBinarised(mitk::IOUtil::Load<mitk::Image>(StdStringPath(tagName+".nii")));
382384
// CemrgCommonUtils::Binarise(im);
@@ -1579,8 +1581,6 @@ void AtrialFibresView::ScarProjection(){
15791581

15801582
void AtrialFibresView::Reset() {
15811583

1582-
1583-
15841584
try {
15851585

15861586
ctkPluginContext* context = mitk::kcl_cemrgapp_atrialfibres_Activator::getContext();
@@ -1639,7 +1639,14 @@ void AtrialFibresView::Reset() {
16391639

16401640
//Clear project directory
16411641
directory.clear();
1642-
this->GetSite()->GetPage()->ResetPerspective();
1642+
cnnPath.clear();
1643+
fileName.clear();
1644+
tagName.clear();
1645+
refinedSuffix.clear();
1646+
1647+
this->GetSite()
1648+
->GetPage()
1649+
->ResetPerspective();
16431650
}
16441651

16451652

0 commit comments

Comments
 (0)