Discussion:
[mitk-users] Geodesic neighborhood on Surface
Sriprabha Ramanarayanan
2016-11-16 07:17:15 UTC
Permalink
Hi all,

I would like to get the nearest neighborhood points on a MITK Surface given
a pick point on the surface. By nearest neighborhood, I mean only those
points with geodesic distances inside the radius.

Thanks for any suggestions.

R. Sriprabha.
Daphné Wallach
2016-11-16 08:35:47 UTC
Permalink
Dear Mitk users,

I am writing an application using Mitk, and I would now need to write a
dicom series from a mitk::Image.

Here is what I am trying to do:
In one part of the code, I read the dicom series using
mitk::IOUtil::Load and load it to a mitk::Image. This image is then
passed to another function, where it should be anonymized and written to
a new dicom folder.

It seems like mitk cannot write dicom images, and I need to use Itk to
do that, is that right ? My problem is when I convert the mitk::Image to
a itk::Image with CastToItkImage, all the dicom tags are lost.

The solution I am considering is to pass the path to the dicom data to
the function in charge of anonymizing and writing the dicom data. This
function would read, modify and write back the data using only itk.

Is there another solution? I would like to avoid re-reading the dicom
data from file if possible.

As always, I would appreciate any help.

Best regards,
Daphné

------------------------------------------------------------------------------
Marco Nolden
2016-11-16 15:15:22 UTC
Permalink
Hi Daphne,

if you just want to remove or replce DICOM tags for anonymization, I
think you should bypass both MITK and ITK and just use DCMTK methods.
Using them it should be quite easy to read a dataset, manipulate it and
write it back. Or you could even just call "dcmodify" as a command line
tool, there are many examples online how to use it. If you are also
modifying the image content ( pixel data), things become a bit more
complicated, since formally you are then creating a new DICOM object
with a new modality which is usually non-trivial to do in full
accordance with the standard.

What are you planning to do with the anonymized files? Which tool should
be able to load them?

Best,
Marco
Post by Daphné Wallach
Dear Mitk users,
I am writing an application using Mitk, and I would now need to write a
dicom series from a mitk::Image.
In one part of the code, I read the dicom series using
mitk::IOUtil::Load and load it to a mitk::Image. This image is then
passed to another function, where it should be anonymized and written to
a new dicom folder.
It seems like mitk cannot write dicom images, and I need to use Itk to
do that, is that right ? My problem is when I convert the mitk::Image to
a itk::Image with CastToItkImage, all the dicom tags are lost.
The solution I am considering is to pass the path to the dicom data to
the function in charge of anonymizing and writing the dicom data. This
function would read, modify and write back the data using only itk.
Is there another solution? I would like to avoid re-reading the dicom
data from file if possible.
As always, I would appreciate any help.
Best regards,
Daphné
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
Daphné Wallach
2016-11-16 15:56:17 UTC
Permalink
Dear Marco,

Thank you for your answer. I will look into DCMTK. I saw there was a
function to anonymize a dataset:

gdcm::File::AnonymizeFile()

which I could use.

I am not modifying the image content in any way, only the header, and I
would like to be able to reload the anonymized dataset using my
application (I currently use mitk::IOUtil::Load).

The thing is, I do not only need to read and anonymize the dicom
dataset, but I actually use it to perform a segmentation. The
application then saves the segmented image and the anonymized dataset,
in order to be able to reload them at a later time.

I would like to avoid reading twice the dicom dataset - once with DCMTK,
to anonymize it, and once with Mitk. Is there a way to convert an image
read by DCMTK into a mitk::Image ? Through Itk, I guess ?

Best regards,

Daphné
Post by Marco Nolden
Hi Daphne,
if you just want to remove or replce DICOM tags for anonymization, I
think you should bypass both MITK and ITK and just use DCMTK methods.
Using them it should be quite easy to read a dataset, manipulate it and
write it back. Or you could even just call "dcmodify" as a command line
tool, there are many examples online how to use it. If you are also
modifying the image content ( pixel data), things become a bit more
complicated, since formally you are then creating a new DICOM object
with a new modality which is usually non-trivial to do in full
accordance with the standard.
What are you planning to do with the anonymized files? Which tool should
be able to load them?
Best,
Marco
Post by Daphné Wallach
Dear Mitk users,
I am writing an application using Mitk, and I would now need to write a
dicom series from a mitk::Image.
In one part of the code, I read the dicom series using
mitk::IOUtil::Load and load it to a mitk::Image. This image is then
passed to another function, where it should be anonymized and written to
a new dicom folder.
It seems like mitk cannot write dicom images, and I need to use Itk to
do that, is that right ? My problem is when I convert the mitk::Image to
a itk::Image with CastToItkImage, all the dicom tags are lost.
The solution I am considering is to pass the path to the dicom data to
the function in charge of anonymizing and writing the dicom data. This
function would read, modify and write back the data using only itk.
Is there another solution? I would like to avoid re-reading the dicom
data from file if possible.
As always, I would appreciate any help.
Best regards,
Daphné
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
Daphné Wallach
2017-03-02 13:44:48 UTC
Permalink
Dear MITK users,

I am developping an application using MITK as a library, and I am
currently trying to display a curved MPR, based on a set of points
placed on the axial view by the user.

I saw two related questions in the mailing list, but both answers were
quite dated (2010 and 2014), so things might have changed since then.
The most recent answer referred to a "Curved MPR" plugin, and mentionned
it was under developpement.

Does anybody have news about this plugin?

Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Daphné Wallach
2017-03-03 15:50:23 UTC
Permalink
Dear Mitk users,

I am still struggling with displaying a curved MPR, based on a set of
points placed on the axial view by the user.

I wrote a piece of code similar to the one presented in a quite old
thread
(http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html,
dating back from 2011). The workflow is the following:
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a
referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through
SetWorldGeometry3D.

However, the code crashes on the last instruction (SetWorldGeometry3D)
with a cryptic message ("0xC0000005: /Access violation reading..."/).

First, is this workflow correct? I saw other examples, where the
ThinPlateSplineCurvedGeometry was also added to the datastorage (I tried
it, and the same crash appears).

Second, I also looked at the code for the curvedmpr pluging (at
http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration),
and I have the impression that the main difference with the workflow I
use is that the ThinPlateSplineCurvedGeometry is added to the
datastorage. Moreover, it seems like development was stopped in 2014, is
that correct?

I would greatly appreciate any help about the correct workflow to
display a curved MPR, or comments about my code below.

Best regards,
Daphné

Code snippet:
mitk::DataNode::Pointer originalImageNode =
_ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer
splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...

if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry =
mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane =
_dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();

// Set a reference 3D geometry (e.g. Geometry3D of an existing
image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());

// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector =
mitk::PlaneLandmarkProjector::New();

planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);

// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();

mitk::BaseRenderer* mappingRenderer =
mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash
happens here
}

mitk::RenderingManager::GetInstance()->RequestUpdateAll();
Post by Daphné Wallach
Dear MITK users,
I am developping an application using MITK as a library, and I am
currently trying to display a curved MPR, based on a set of points
placed on the axial view by the user.
I saw two related questions in the mailing list, but both answers were
quite dated (2010 and 2014), so things might have changed since then.
The most recent answer referred to a "Curved MPR" plugin, and
mentionned it was under developpement.
Does anybody have news about this plugin?
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Dinkelacker, Stefan
2017-03-07 14:54:18 UTC
Permalink
Hi Daphné,

Sorry for the late answer. We asked around to check if really nobody is/was using the curved geometry stuff. Unfortunately not. However, I remember that I once implemented a slider in a plugin which was supposed to slide through slices along a curved path. The path was defined by points (center + 2 points for axes) per slice. And here is the snippet (quite old, but shouldn't be too hard to adapt, if necessary at all):

#include <QmitkRenderWindow.h>

void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;

vtkSmartPointer<vtkSphereSource> originSource = vtkSmartPointer<vtkSphereSource>::New();

originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> xAxisSource = vtkSmartPointer<vtkSphereSource>::New();

xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].XAxis[0] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].XAxis[1] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].XAxis[2] * (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> zAxisSource = vtkSmartPointer<vtkSphereSource>::New();

zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].ZAxis[0] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].ZAxis[1] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].ZAxis[2] * (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkAppendPolyData> appendPolyData = vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));

appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));

// this->RequestRenderWindowUpdate();

this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}


From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Freitag, 3. März 2017 16:50
To: mitk-***@lists.sourceforge.net
Subject: Re: [mitk-users] Curved MPR


Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set of points placed on the axial view by the user.

I wrote a piece of code similar to the one presented in a quite old thread (http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html, dating back from 2011). The workflow is the following:
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through SetWorldGeometry3D.

However, the code crashes on the last instruction (SetWorldGeometry3D) with a cryptic message ("0xC0000005: Access violation reading...").

First, is this workflow correct? I saw other examples, where the ThinPlateSplineCurvedGeometry was also added to the datastorage (I tried it, and the same crash appears).

Second, I also looked at the code for the curvedmpr pluging (at http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration), and I have the impression that the main difference with the workflow I use is that the ThinPlateSplineCurvedGeometry is added to the datastorage. Moreover, it seems like development was stopped in 2014, is that correct?

I would greatly appreciate any help about the correct workflow to display a curved MPR, or comments about my code below.

Best regards,
Daphné

Code snippet:
mitk::DataNode::Pointer originalImageNode = _ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...

if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry = mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane = _dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();

// Set a reference 3D geometry (e.g. Geometry3D of an existing image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());

// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector = mitk::PlaneLandmarkProjector::New();

planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);

// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();

mitk::BaseRenderer* mappingRenderer = mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}

mitk::RenderingManager::GetInstance()->RequestUpdateAll();



Le 02/03/2017 à 14:44, Daphné Wallach a écrit :
Dear MITK users,

I am developping an application using MITK as a library, and I am currently trying to display a curved MPR, based on a set of points placed on the axial view by the user.

I saw two related questions in the mailing list, but both answers were quite dated (2010 and 2014), so things might have changed since then. The most recent answer referred to a "Curved MPR" plugin, and mentionned it was under developpement.

Does anybody have news about this plugin?

Best regards,
Daphné



--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com
Daphné Wallach
2017-04-19 09:40:50 UTC
Permalink
Dear Stefan,

I am now using something very similar to the code you sent, and
everything is working perfectly except for one thing: the planar views
are cropped.

I implemented a class similar to QmitkStdMultiWidget, where each
individual viewer belongs to a class inheriting QmitkRenderWindow. I
reimplemented the wheelEvent method to scroll along a curve. The planes
in the 3D viewer are normal, but the images in the individual viewers
are cropped (see attached image).

I tried to call a reinit, which solves the cropping problem, but this
unfortunately also resets the slicing to the default one.

This is the code I use to reinitialize the views:

mitk::DataNode::Pointer originalImageNode =
_dataStorage->GetNamedNode("originalImage");
mitk::RenderingManager::GetInstance()->InitializeViews(originalImageNode->GetData()->GetTimeGeometry(),
mitk::RenderingManager::REQUEST_UPDATE_ALL, true);

Do you know how I could recenter the views on my image, without
resetting the slicing?

Best regards,

Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Post by Dinkelacker, Stefan
Hi Daphné,
Sorry for the late answer. We asked around to check if really nobody
is/was using the curved geometry stuff. Unfortunately not. However, I
remember that I once implemented a slider in a plugin which was
supposed to slide through slices along a curved path. The path was
defined by points (center + 2 points for axes) per slice. And here is
the snippet (quite old, but shouldn’t be too hard to adapt, if
#include <QmitkRenderWindow.h>
void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;
vtkSmartPointer<vtkSphereSource> originSource =
vtkSmartPointer<vtkSphereSource>::New();
originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);
vtkSmartPointer<vtkSphereSource> xAxisSource =
vtkSmartPointer<vtkSphereSource>::New();
xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] +
m_SliceOrientations[value].XAxis[0] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] +
m_SliceOrientations[value].XAxis[1] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] +
m_SliceOrientations[value].XAxis[2] * (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);
vtkSmartPointer<vtkSphereSource> zAxisSource =
vtkSmartPointer<vtkSphereSource>::New();
zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] +
m_SliceOrientations[value].ZAxis[0] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] +
m_SliceOrientations[value].ZAxis[1] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] +
m_SliceOrientations[value].ZAxis[2] * (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);
vtkSmartPointer<vtkAppendPolyData> appendPolyData =
vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));
appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));
// this->RequestRenderWindowUpdate();
this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));
this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));
this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}
*Sent:* Freitag, 3. März 2017 16:50
*Subject:* Re: [mitk-users] Curved MPR
Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set of
points placed on the axial view by the user.
I wrote a piece of code similar to the one presented in a quite old
thread
(http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html,
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the
ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through SetWorldGeometry3D.
However, the code crashes on the last instruction (SetWorldGeometry3D)
with a cryptic message ("0xC0000005: /Access violation reading..."/).
First, is this workflow correct? I saw other examples, where the
ThinPlateSplineCurvedGeometry was also added to the datastorage (I
tried it, and the same crash appears).
Second, I also looked at the code for the curvedmpr pluging (at
http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration),
and I have the impression that the main difference with the workflow I
use is that the ThinPlateSplineCurvedGeometry is added to the
datastorage. Moreover, it seems like development was stopped in 2014,
is that correct?
I would greatly appreciate any help about the correct workflow to
display a curved MPR, or comments about my code below.
Best regards,
Daphné
mitk::DataNode::Pointer originalImageNode =
_ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer
splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...
if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry =
mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane =
_dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();
// Set a reference 3D geometry (e.g. Geometry3D of an existing image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());
// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector =
mitk::PlaneLandmarkProjector::New();
planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);
// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();
mitk::BaseRenderer* mappingRenderer =
mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
Dear MITK users,
I am developping an application using MITK as a library, and I am
currently trying to display a curved MPR, based on a set of points
placed on the axial view by the user.
I saw two related questions in the mailing list, but both answers
were quite dated (2010 and 2014), so things might have changed
since then. The most recent answer referred to a "Curved MPR"
plugin, and mentionned it was under developpement.
Does anybody have news about this plugin?
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Dinkelacker, Stefan
2017-04-19 10:54:31 UTC
Permalink
Hi, sorry, never did this. Maybe you can look into InitializeViews() and isolate the code that you actually want to execute from the slice reset? Best,
Stefan

From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Mittwoch, 19. April 2017 11:41
To: Dinkelacker, Stefan; mitk-***@lists.sourceforge.net
Subject: [mitk-users] Cropped planes with curved MPR


Dear Stefan,

I am now using something very similar to the code you sent, and everything is working perfectly except for one thing: the planar views are cropped.

I implemented a class similar to QmitkStdMultiWidget, where each individual viewer belongs to a class inheriting QmitkRenderWindow. I reimplemented the wheelEvent method to scroll along a curve. The planes in the 3D viewer are normal, but the images in the individual viewers are cropped (see attached image).

I tried to call a reinit, which solves the cropping problem, but this unfortunately also resets the slicing to the default one.

This is the code I use to reinitialize the views:

mitk::DataNode::Pointer originalImageNode = _dataStorage->GetNamedNode("originalImage");
mitk::RenderingManager::GetInstance()->InitializeViews(originalImageNode->GetData()->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true);

Do you know how I could recenter the views on my image, without resetting the slicing?

Best regards,

Daphné



--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com


Le 07/03/2017 à 15:54, Dinkelacker, Stefan a écrit :
Hi Daphné,

Sorry for the late answer. We asked around to check if really nobody is/was using the curved geometry stuff. Unfortunately not. However, I remember that I once implemented a slider in a plugin which was supposed to slide through slices along a curved path. The path was defined by points (center + 2 points for axes) per slice. And here is the snippet (quite old, but shouldn't be too hard to adapt, if necessary at all):

#include <QmitkRenderWindow.h>

void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;

vtkSmartPointer<vtkSphereSource> originSource = vtkSmartPointer<vtkSphereSource>::New();

originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> xAxisSource = vtkSmartPointer<vtkSphereSource>::New();

xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].XAxis[0] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].XAxis[1] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].XAxis[2] * (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> zAxisSource = vtkSmartPointer<vtkSphereSource>::New();

zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].ZAxis[0] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].ZAxis[1] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].ZAxis[2] * (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkAppendPolyData> appendPolyData = vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));

appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));

// this->RequestRenderWindowUpdate();

this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}


From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Freitag, 3. März 2017 16:50
To: mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
Subject: Re: [mitk-users] Curved MPR


Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set of points placed on the axial view by the user.

I wrote a piece of code similar to the one presented in a quite old thread (http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html, dating back from 2011). The workflow is the following:
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through SetWorldGeometry3D.

However, the code crashes on the last instruction (SetWorldGeometry3D) with a cryptic message ("0xC0000005: Access violation reading...").

First, is this workflow correct? I saw other examples, where the ThinPlateSplineCurvedGeometry was also added to the datastorage (I tried it, and the same crash appears).

Second, I also looked at the code for the curvedmpr pluging (at http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration), and I have the impression that the main difference with the workflow I use is that the ThinPlateSplineCurvedGeometry is added to the datastorage. Moreover, it seems like development was stopped in 2014, is that correct?

I would greatly appreciate any help about the correct workflow to display a curved MPR, or comments about my code below.

Best regards,
Daphné

Code snippet:
mitk::DataNode::Pointer originalImageNode = _ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...

if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry = mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane = _dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();

// Set a reference 3D geometry (e.g. Geometry3D of an existing image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());

// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector = mitk::PlaneLandmarkProjector::New();

planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);

// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();

mitk::BaseRenderer* mappingRenderer = mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}

mitk::RenderingManager::GetInstance()->RequestUpdateAll();




Le 02/03/2017 à 14:44, Daphné Wallach a écrit :
Dear MITK users,

I am developping an application using MITK as a library, and I am currently trying to display a curved MPR, based on a set of points placed on the axial view by the user.

I saw two related questions in the mailing list, but both answers were quite dated (2010 and 2014), so things might have changed since then. The most recent answer referred to a "Curved MPR" plugin, and mentionned it was under developpement.

Does anybody have news about this plugin?

Best regards,
Daphné




--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com



--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com
Dinkelacker, Stefan
2017-04-20 11:23:09 UTC
Permalink
Hi again, maybe I actually did something similar. Found a code snippet in my Dropbox, which I called "InitViewWithoutCameraReset":

typedef mitk::RenderingManager::RenderWindowVector RenderWindowVector;

mitk::RenderingManager* renderingManager = mitk::RenderingManager::GetInstance();
const RenderWindowVector& renderWindows = renderingManager->GetAllRegisteredRenderWindows();
RenderWindowVector::const_iterator end = renderWindows.end();

for (RenderWindowVector::const_iterator it = renderWindows.begin(); it != end; ++it)
{
mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(*it);
mitk::SliceNavigationController* sliceNavigationController = renderer->GetSliceNavigationController();

sliceNavigationController->SetInputWorldGeometry(m_TubeSurface->GetGeometry());
sliceNavigationController->Update();

if (renderer->GetMapperID() == mitk::BaseRenderer::Standard2D)
{
mitk::Stepper* slice = sliceNavigationController->GetSlice();
slice->SetPos(slice->GetSteps() / 2);
}

renderer->GetDisplayGeometry()->Fit();
}

From: Dinkelacker, Stefan [mailto:***@dkfz-heidelberg.de]
Sent: Mittwoch, 19. April 2017 12:55
To: 'Daphné Wallach'; mitk-***@lists.sourceforge.net
Subject: Re: [mitk-users] Cropped planes with curved MPR

Hi, sorry, never did this. Maybe you can look into InitializeViews() and isolate the code that you actually want to execute from the slice reset? Best,
Stefan

From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Mittwoch, 19. April 2017 11:41
To: Dinkelacker, Stefan; mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
Subject: [mitk-users] Cropped planes with curved MPR


Dear Stefan,

I am now using something very similar to the code you sent, and everything is working perfectly except for one thing: the planar views are cropped.

I implemented a class similar to QmitkStdMultiWidget, where each individual viewer belongs to a class inheriting QmitkRenderWindow. I reimplemented the wheelEvent method to scroll along a curve. The planes in the 3D viewer are normal, but the images in the individual viewers are cropped (see attached image).

I tried to call a reinit, which solves the cropping problem, but this unfortunately also resets the slicing to the default one.

This is the code I use to reinitialize the views:

mitk::DataNode::Pointer originalImageNode = _dataStorage->GetNamedNode("originalImage");
mitk::RenderingManager::GetInstance()->InitializeViews(originalImageNode->GetData()->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true);

Do you know how I could recenter the views on my image, without resetting the slicing?

Best regards,

Daphné




--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com



Le 07/03/2017 à 15:54, Dinkelacker, Stefan a écrit :
Hi Daphné,

Sorry for the late answer. We asked around to check if really nobody is/was using the curved geometry stuff. Unfortunately not. However, I remember that I once implemented a slider in a plugin which was supposed to slide through slices along a curved path. The path was defined by points (center + 2 points for axes) per slice. And here is the snippet (quite old, but shouldn't be too hard to adapt, if necessary at all):

#include <QmitkRenderWindow.h>

void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;

vtkSmartPointer<vtkSphereSource> originSource = vtkSmartPointer<vtkSphereSource>::New();

originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> xAxisSource = vtkSmartPointer<vtkSphereSource>::New();

xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].XAxis[0] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].XAxis[1] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].XAxis[2] * (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> zAxisSource = vtkSmartPointer<vtkSphereSource>::New();

zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].ZAxis[0] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].ZAxis[1] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].ZAxis[2] * (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkAppendPolyData> appendPolyData = vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));

appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));

// this->RequestRenderWindowUpdate();

this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}


From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Freitag, 3. März 2017 16:50
To: mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
Subject: Re: [mitk-users] Curved MPR


Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set of points placed on the axial view by the user.

I wrote a piece of code similar to the one presented in a quite old thread (http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html, dating back from 2011). The workflow is the following:
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through SetWorldGeometry3D.

However, the code crashes on the last instruction (SetWorldGeometry3D) with a cryptic message ("0xC0000005: Access violation reading...").

First, is this workflow correct? I saw other examples, where the ThinPlateSplineCurvedGeometry was also added to the datastorage (I tried it, and the same crash appears).

Second, I also looked at the code for the curvedmpr pluging (at http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration), and I have the impression that the main difference with the workflow I use is that the ThinPlateSplineCurvedGeometry is added to the datastorage. Moreover, it seems like development was stopped in 2014, is that correct?

I would greatly appreciate any help about the correct workflow to display a curved MPR, or comments about my code below.

Best regards,
Daphné

Code snippet:
mitk::DataNode::Pointer originalImageNode = _ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...

if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry = mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane = _dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();

// Set a reference 3D geometry (e.g. Geometry3D of an existing image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());

// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector = mitk::PlaneLandmarkProjector::New();

planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);

// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();

mitk::BaseRenderer* mappingRenderer = mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}

mitk::RenderingManager::GetInstance()->RequestUpdateAll();





Le 02/03/2017 à 14:44, Daphné Wallach a écrit :
Dear MITK users,

I am developping an application using MITK as a library, and I am currently trying to display a curved MPR, based on a set of points placed on the axial view by the user.

I saw two related questions in the mailing list, but both answers were quite dated (2010 and 2014), so things might have changed since then. The most recent answer referred to a "Curved MPR" plugin, and mentionned it was under developpement.

Does anybody have news about this plugin?

Best regards,
Daphné





--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com




--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com
Daphné Wallach
2017-04-21 13:22:51 UTC
Permalink
Dear Stefan,

Thank you for this code snippet!

What is m_TubeSurface?
Post by Dinkelacker, Stefan
Hi again, maybe I actually did something similar. Found a code snippet
typedef mitk::RenderingManager::RenderWindowVector RenderWindowVector;
mitk::RenderingManager* renderingManager =
mitk::RenderingManager::GetInstance();
const RenderWindowVector& renderWindows =
renderingManager->GetAllRegisteredRenderWindows();
RenderWindowVector::const_iterator end = renderWindows.end();
for (RenderWindowVector::const_iterator it = renderWindows.begin(); it != end; ++it)
{
mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(*it);
mitk::SliceNavigationController* sliceNavigationController =
renderer->GetSliceNavigationController();
sliceNavigationController->SetInputWorldGeometry(m_TubeSurface->GetGeometry());
sliceNavigationController->Update();
if (renderer->GetMapperID() == mitk::BaseRenderer::Standard2D)
{
mitk::Stepper* slice = sliceNavigationController->GetSlice();
slice->SetPos(slice->GetSteps() / 2);
}
renderer->GetDisplayGeometry()->Fit();
}
*Sent:* Mittwoch, 19. April 2017 12:55
*Subject:* Re: [mitk-users] Cropped planes with curved MPR
Hi, sorry, never did this. Maybe you can look into InitializeViews()
and isolate the code that you actually want to execute from the slice
reset? Best,
Stefan
*Sent:* Mittwoch, 19. April 2017 11:41
*Subject:* [mitk-users] Cropped planes with curved MPR
Dear Stefan,
I am now using something very similar to the code you sent, and
everything is working perfectly except for one thing: the planar views
are cropped.
I implemented a class similar to QmitkStdMultiWidget, where each
individual viewer belongs to a class inheriting QmitkRenderWindow. I
reimplemented the wheelEvent method to scroll along a curve. The
planes in the 3D viewer are normal, but the images in the individual
viewers are cropped (see attached image).
I tried to call a reinit, which solves the cropping problem, but this
unfortunately also resets the slicing to the default one.
mitk::DataNode::Pointer originalImageNode =
_dataStorage->GetNamedNode("originalImage");
mitk::RenderingManager::GetInstance()->InitializeViews(originalImageNode->GetData()->GetTimeGeometry(),
mitk::RenderingManager::REQUEST_UPDATE_ALL, true);
Do you know how I could recenter the views on my image, without resetting the slicing?
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Hi Daphné,
Sorry for the late answer. We asked around to check if really
nobody is/was using the curved geometry stuff. Unfortunately not.
However, I remember that I once implemented a slider in a plugin
which was supposed to slide through slices along a curved path.
The path was defined by points (center + 2 points for axes) per
slice. And here is the snippet (quite old, but shouldn’t be too
#include <QmitkRenderWindow.h>
void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;
vtkSmartPointer<vtkSphereSource> originSource =
vtkSmartPointer<vtkSphereSource>::New();
originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);
vtkSmartPointer<vtkSphereSource> xAxisSource =
vtkSmartPointer<vtkSphereSource>::New();
xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] +
m_SliceOrientations[value].XAxis[0] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] +
m_SliceOrientations[value].XAxis[1] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] +
m_SliceOrientations[value].XAxis[2] * (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);
vtkSmartPointer<vtkSphereSource> zAxisSource =
vtkSmartPointer<vtkSphereSource>::New();
zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] +
m_SliceOrientations[value].ZAxis[0] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] +
m_SliceOrientations[value].ZAxis[1] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] +
m_SliceOrientations[value].ZAxis[2] * (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);
vtkSmartPointer<vtkAppendPolyData> appendPolyData =
vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));
appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));
// this->RequestRenderWindowUpdate();
this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));
this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));
this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin +
mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}
*Sent:* Freitag, 3. März 2017 16:50
*Subject:* Re: [mitk-users] Curved MPR
Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set
of points placed on the axial view by the user.
I wrote a piece of code similar to the one presented in a quite
old thread
(http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html,
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a
referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the
ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget
through SetWorldGeometry3D.
However, the code crashes on the last instruction
(SetWorldGeometry3D) with a cryptic message ("0xC0000005: /Access
violation reading..."/).
First, is this workflow correct? I saw other examples, where the
ThinPlateSplineCurvedGeometry was also added to the datastorage (I
tried it, and the same crash appears).
Second, I also looked at the code for the curvedmpr pluging (at
http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration),
and I have the impression that the main difference with the
workflow I use is that the ThinPlateSplineCurvedGeometry is added
to the datastorage. Moreover, it seems like development was
stopped in 2014, is that correct?
I would greatly appreciate any help about the correct workflow to
display a curved MPR, or comments about my code below.
Best regards,
Daphné
mitk::DataNode::Pointer originalImageNode =
_ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer
splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...
if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry =
mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane =
_dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();
// Set a reference 3D geometry (e.g. Geometry3D of an
existing image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());
// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer
planeLandmarkProjector = mitk::PlaneLandmarkProjector::New();
planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);
// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();
mitk::BaseRenderer* mappingRenderer =
mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
Dear MITK users,
I am developping an application using MITK as a library, and I
am currently trying to display a curved MPR, based on a set of
points placed on the axial view by the user.
I saw two related questions in the mailing list, but both
answers were quite dated (2010 and 2014), so things might have
changed since then. The most recent answer referred to a
"Curved MPR" plugin, and mentionned it was under developpement.
Does anybody have news about this plugin?
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Dinkelacker, Stefan
2017-04-21 13:27:45 UTC
Permalink
You're welcome. m_TubeSurface was just a domain specific base data. You would need to replace that with your data, if that snippet is of interest for you. Best, Stefan

From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Freitag, 21. April 2017 15:23
To: Dinkelacker, Stefan; mitk-***@lists.sourceforge.net
Subject: Re: [mitk-users] Cropped planes with curved MPR


Dear Stefan,

Thank you for this code snippet!

What is m_TubeSurface?

Le 20/04/2017 à 13:23, Dinkelacker, Stefan a écrit :
Hi again, maybe I actually did something similar. Found a code snippet in my Dropbox, which I called "InitViewWithoutCameraReset":

typedef mitk::RenderingManager::RenderWindowVector RenderWindowVector;

mitk::RenderingManager* renderingManager = mitk::RenderingManager::GetInstance();
const RenderWindowVector& renderWindows = renderingManager->GetAllRegisteredRenderWindows();
RenderWindowVector::const_iterator end = renderWindows.end();

for (RenderWindowVector::const_iterator it = renderWindows.begin(); it != end; ++it)
{
mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(*it);
mitk::SliceNavigationController* sliceNavigationController = renderer->GetSliceNavigationController();

sliceNavigationController->SetInputWorldGeometry(m_TubeSurface->GetGeometry());
sliceNavigationController->Update();

if (renderer->GetMapperID() == mitk::BaseRenderer::Standard2D)
{
mitk::Stepper* slice = sliceNavigationController->GetSlice();
slice->SetPos(slice->GetSteps() / 2);
}

renderer->GetDisplayGeometry()->Fit();
}

From: Dinkelacker, Stefan [mailto:***@dkfz-heidelberg.de]
Sent: Mittwoch, 19. April 2017 12:55
To: 'Daphné Wallach'; mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
Subject: Re: [mitk-users] Cropped planes with curved MPR

Hi, sorry, never did this. Maybe you can look into InitializeViews() and isolate the code that you actually want to execute from the slice reset? Best,
Stefan

From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Mittwoch, 19. April 2017 11:41
To: Dinkelacker, Stefan; mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
Subject: [mitk-users] Cropped planes with curved MPR


Dear Stefan,

I am now using something very similar to the code you sent, and everything is working perfectly except for one thing: the planar views are cropped.

I implemented a class similar to QmitkStdMultiWidget, where each individual viewer belongs to a class inheriting QmitkRenderWindow. I reimplemented the wheelEvent method to scroll along a curve. The planes in the 3D viewer are normal, but the images in the individual viewers are cropped (see attached image).

I tried to call a reinit, which solves the cropping problem, but this unfortunately also resets the slicing to the default one.

This is the code I use to reinitialize the views:

mitk::DataNode::Pointer originalImageNode = _dataStorage->GetNamedNode("originalImage");
mitk::RenderingManager::GetInstance()->InitializeViews(originalImageNode->GetData()->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true);

Do you know how I could recenter the views on my image, without resetting the slicing?

Best regards,

Daphné





--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com




Le 07/03/2017 à 15:54, Dinkelacker, Stefan a écrit :
Hi Daphné,

Sorry for the late answer. We asked around to check if really nobody is/was using the curved geometry stuff. Unfortunately not. However, I remember that I once implemented a slider in a plugin which was supposed to slide through slices along a curved path. The path was defined by points (center + 2 points for axes) per slice. And here is the snippet (quite old, but shouldn't be too hard to adapt, if necessary at all):

#include <QmitkRenderWindow.h>

void QmitkMyPrototypeView::OnSliderValueChanged(int value)
{
if (value >= m_SliceOrientations.size())
return;

vtkSmartPointer<vtkSphereSource> originSource = vtkSmartPointer<vtkSphereSource>::New();

originSource->SetCenter(
m_SliceOrientations[value].Origin[0],
m_SliceOrientations[value].Origin[1],
m_SliceOrientations[value].Origin[2]);
originSource->SetRadius(1.0);
originSource->SetThetaResolution(32);
originSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> xAxisSource = vtkSmartPointer<vtkSphereSource>::New();

xAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].XAxis[0] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].XAxis[1] * (0.5 * m_TubeMajorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].XAxis[2] * (0.5 * m_TubeMajorAxis));
xAxisSource->SetRadius(0.5);
xAxisSource->SetThetaResolution(32);
xAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkSphereSource> zAxisSource = vtkSmartPointer<vtkSphereSource>::New();

zAxisSource->SetCenter(
m_SliceOrientations[value].Origin[0] + m_SliceOrientations[value].ZAxis[0] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[1] + m_SliceOrientations[value].ZAxis[1] * (0.5 * m_TubeMinorAxis),
m_SliceOrientations[value].Origin[2] + m_SliceOrientations[value].ZAxis[2] * (0.5 * m_TubeMinorAxis));
zAxisSource->SetRadius(0.5);
zAxisSource->SetThetaResolution(32);
zAxisSource->SetPhiResolution(32);

vtkSmartPointer<vtkAppendPolyData> appendPolyData = vtkSmartPointer<vtkAppendPolyData>::New();
appendPolyData->AddInputConnection(originSource->GetOutputPort(0));
appendPolyData->AddInputConnection(xAxisSource->GetOutputPort(0));
appendPolyData->AddInputConnection(zAxisSource->GetOutputPort(0));

appendPolyData->Update();
m_Surface->SetVtkPolyData(static_cast<vtkPolyData*>(appendPolyData->GetOutputDataObject(0)));

// this->RequestRenderWindowUpdate();

this->GetRenderWindowPart()->GetQmitkRenderWindow("axial")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("sagittal")->GetSliceNavigationController()->SelectSliceByPoint(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()));

this->GetRenderWindowPart()->GetQmitkRenderWindow("coronal")->GetSliceNavigationController()->ReorientSlices(
m_SliceOrientations[value].Origin + mitk::Vector3D(m_Surface->GetGeometry()->GetOrigin().GetDataPointer()),
m_SliceOrientations[value].XAxis,
m_SliceOrientations[value].ZAxis);
}


From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Freitag, 3. März 2017 16:50
To: mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
Subject: Re: [mitk-users] Curved MPR


Dear Mitk users,
I am still struggling with displaying a curved MPR, based on a set of points placed on the axial view by the user.

I wrote a piece of code similar to the one presented in a quite old thread (http://mitk-users.1123740.n5.nabble.com/Curved-MPR-is-cropped-for-some-reason-td2823.html, dating back from 2011). The workflow is the following:
- create a ThinPlateSplineCurvedGeometry
- give a frameGeometry (the same one as the dicom image) and a referenceGeometry to it
- create a PlaneLandmarkProjector
- give a projection plane and the landmarks to it
- give the projector and the landmark to the ThinPlateSplineCurvedGeometry
- compute the geometry of the ThinPlateSplineCurvedGeometry
- give the ThinPlateSplineCurvedGeometry to the multiWidget through SetWorldGeometry3D.

However, the code crashes on the last instruction (SetWorldGeometry3D) with a cryptic message ("0xC0000005: Access violation reading...").

First, is this workflow correct? I saw other examples, where the ThinPlateSplineCurvedGeometry was also added to the datastorage (I tried it, and the same crash appears).

Second, I also looked at the code for the curvedmpr pluging (at http://mitk.org/git/?p=MITK.git;a=shortlog;h=refs/heads/bug-10719-curved-mpr-master-integration), and I have the impression that the main difference with the workflow I use is that the ThinPlateSplineCurvedGeometry is added to the datastorage. Moreover, it seems like development was stopped in 2014, is that correct?

I would greatly appreciate any help about the correct workflow to display a curved MPR, or comments about my code below.

Best regards,
Daphné

Code snippet:
mitk::DataNode::Pointer originalImageNode = _ds->GetNamedNode("originalImage");
const mitk::PointSet::DataType::PointsContainer::Pointer splineLandmarks = mitk::PointSet::DataType::PointsContainer::New();
// Get landmarks...

if (splineLandmarks->Size() != 0 && originalImageNode->GetData())
{
mitk::ThinPlateSplineCurvedGeometry::Pointer tpsGeometry = mitk::ThinPlateSplineCurvedGeometry::New();
const mitk::PlaneGeometry *plane = _dataView->GetRenderWindow2()->GetSliceNavigationController()->GetCurrentPlaneGeometry();

// Set a reference 3D geometry (e.g. Geometry3D of an existing image volume)
tpsGeometry->SetFrameGeometry(originalImageNode->GetData()->GetGeometry());
tpsGeometry->SetReferenceGeometry(plane->GetReferenceGeometry());

// Create projector class; target landmarks will be projected on
// a plane to create source landmarks for thin plate spline
// (plane is a mitk::PlaneGeometry, e.g. one of the standard
// coronal, sagittal, or transversal planes)
mitk::PlaneLandmarkProjector::Pointer planeLandmarkProjector = mitk::PlaneLandmarkProjector::New();

planeLandmarkProjector->SetProjectionPlane(plane);
planeLandmarkProjector->ProjectLandmarks(splineLandmarks);

// Initialize TPS geometry with projector
tpsGeometry->SetLandmarkProjector(planeLandmarkProjector);
tpsGeometry->SetTargetLandmarks(splineLandmarks);
tpsGeometry->ComputeGeometry();

mitk::BaseRenderer* mappingRenderer = mitk::BaseRenderer::GetInstance(_dataView->mitkWidget2->GetRenderWindow());
mappingRenderer->SetWorldGeometry3D(tpsGeometry); // Crash happens here
}

mitk::RenderingManager::GetInstance()->RequestUpdateAll();






Le 02/03/2017 à 14:44, Daphné Wallach a écrit :
Dear MITK users,

I am developping an application using MITK as a library, and I am currently trying to display a curved MPR, based on a set of points placed on the axial view by the user.

I saw two related questions in the mailing list, but both answers were quite dated (2010 and 2014), so things might have changed since then. The most recent answer referred to a "Curved MPR" plugin, and mentionned it was under developpement.

Does anybody have news about this plugin?

Best regards,
Daphné






--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com





--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com



--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com
Daphné Wallach
2017-05-04 07:45:07 UTC
Permalink
Dear Mitk users,

We are developping an application using MITK as a library, and, for
compatibilty reasons, we need to use openGL2.

We saw that the branch T18922-OpenGLBackend2-kislinsk-2 was using
OpenGL2, so we built this branch and used it in our application.
Everything is working fine, except for one thing: planar figures are not
displayed. Control points are displayed as they are defined, but they
disappear right away, and the polyline is not displayed.

Is this a known problem with the branch, or should planar figures be
defined differently than before?

Any help would be greatly appreciated.

Best regards,

Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Goch, Caspar Jonas
2017-05-04 08:26:47 UTC
Permalink
Hi Daphné,

I added your report to
https://phabricator.mitk.org/T18922

The OpenGL2 migration is still work in progress, but we hope to have someone dedicated to working on it in June/July.

Best,
Caspar

Von: Daphné Wallach [mailto:***@hrv-simulation.com]
Gesendet: Donnerstag, 4. Mai 2017 09:45
An: mitk-***@lists.sourceforge.net
Betreff: [mitk-users] Planar figures not displayed in branch T18922-OpenGLBackend2-kislinsk-2


Dear Mitk users,

We are developping an application using MITK as a library, and, for compatibilty reasons, we need to use openGL2.

We saw that the branch T18922-OpenGLBackend2-kislinsk-2 was using OpenGL2, so we built this branch and used it in our application. Everything is working fine, except for one thing: planar figures are not displayed. Control points are displayed as they are defined, but they disappear right away, and the polyline is not displayed.

Is this a known problem with the branch, or should planar figures be defined differently than before?

Any help would be greatly appreciated.

Best regards,

Daphné

--

Daphné Wallach

Ingénieur de recherche

http://www.hrv-simulation.com

Daphné Wallach
2017-03-16 11:08:19 UTC
Permalink
Dear MITK users,

I am developping an application using MITK as a library, and I am
currently trying to load a planar figure from its 3D control points.
However, I can only manage to display the figure when I start
interacting with it. Otherwise, the figure is not displayed.

Here is the workflow I am using:
- create a new figure
- create a new node containing the figure, select it, and add to the
datastorage
- set a planar figure interactor to the node
- set the geometry of the figure: the geometry is computed from a
dicom image stored in the datastorage. The planar figure is placed on an
axial slice of this image.
- set the points to the figure
- finalize the interaction
- update all viewers

When I comment the lines in the "Finalize interaction" part, the figure
appears when I click on the viewer at the slice where the figure is (and
a new point is added at the click).

I have struggled with this issue for several days now, and I would
grealty appreciate any help!

Best regards,
Daphné

Below is a snippet of my code:

mitk::PlanarFigure::Pointer figure =
mitk::PlanarBezierCurve::New();

// Create node containing the curve, select it and add it to
datastorage
mitk::DataNode::Pointer newNode = mitk::DataNode::New();
newNode->SetData(figure);
newNode->SetSelected(true);

if (!_ds->Exists(newNode))
{
_ds->Add(newNode);
}

// Set new interactor
mitk::PlanarFigureInteractor::Pointer interactor =
dynamic_cast<mitk::PlanarFigureInteractor*>(newNode->GetDataInteractor().GetPointer());
if (interactor.IsNull())
{
interactor = mitk::PlanarFigureInteractor::New();
auto planarFigureModule =
us::ModuleRegistry::GetModule("MitkPlanarFigure");

interactor->LoadStateMachine("PlanarFigureInteraction.xml",
planarFigureModule);
interactor->SetEventConfig("PlanarFigureConfig.xml",
planarFigureModule);
}
interactor->SetDataNode(newNode);

// Set figure plane geometry
mitk::PlaneGeometry::Pointer curvePlane =
mitk::PlaneGeometry::New();

mitk::DataNode::Pointer originalImageNode =
_ds->GetNamedNode("originalImage"); // This node contains a dicom image
on which we want to draw the planar figure
mitk::BaseGeometry* originalImageGeometry =
originalImageNode->GetData()->GetGeometry();

itk::Index<3> idx;
originalImageGeometry->WorldToIndex(curve.points[0], idx); //
the "curve" variable contains the 3D control points
mitk::ScalarType planeZPosition = idx[2];

curvePlane->InitializeStandardPlane(originalImageGeometry,
mitk::PlaneGeometry::Axial, planeZPosition);
figure->SetPlaneGeometry(curvePlane);

//Set points to figure
for (int i = 0; i < curve.points.size(); i++)
{
mitk::Point2D indexPoint2d;
for (int dim = 0; dim < 2; dim++)
{
indexPoint2d[dim] = (curve.points[i][dim] -
originalImageGeometry->GetOrigin()[dim]);
}
if (i == 0)
{
figure->InvokeEvent(mitk::StartPlacementPlanarFigureEvent());
figure->PlaceFigure(indexPoint2d);
newNode->SetBoolProperty("PlanarFigureInitializedWindow", true);
}
else
{
figure->SetControlPoint(i, indexPoint2d, true);
}
}

figure->EvaluateFeatures();
figure->DeselectControlPoint();

// Finalize interaction: when these six lines are commented,
the figure is displayed when the user clicks on the slice where the
figure is placed
figure->Modified();
figure->SetProperty("initiallyplaced",
mitk::BoolProperty::New(true));
newNode->SetBoolProperty("planarfigure.drawcontrolpoints", true);
newNode->Modified();
figure->InvokeEvent(mitk::EndPlacementPlanarFigureEvent());
figure->InvokeEvent(mitk::EndInteractionPlanarFigureEvent());

mitk::RenderingManager::GetInstance()->RequestUpdateAll();
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Dinkelacker, Stefan
2017-03-16 12:18:20 UTC
Permalink
Hi, Planar Figures can be a bit tricky when constructing them programmatically. See the Planar Figure tests for examples [1]. The thing is (which I assume you didn't do) that you use the PlaceFigure() method for the first control point and AddControlPoint() for the subsequent control points only. You also do not need to add an interactor, if you do not want the user to modify the planar figure. BTW you can also query if a planar figure is in its "placed" state by calling IsPlaced().

Hope that helps,
Stefan

[1] https://github.com/MITK/MITK/tree/master/Modules/PlanarFigure/test

-----Original Message-----
From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Donnerstag, 16. März 2017 12:08
To: mitk-***@lists.sourceforge.net
Subject: [mitk-users] Displaying a planar figure created from a set of 3D points

Dear MITK users,

I am developping an application using MITK as a library, and I am currently trying to load a planar figure from its 3D control points.
However, I can only manage to display the figure when I start interacting with it. Otherwise, the figure is not displayed.

Here is the workflow I am using:
- create a new figure
- create a new node containing the figure, select it, and add to the datastorage
- set a planar figure interactor to the node
- set the geometry of the figure: the geometry is computed from a dicom image stored in the datastorage. The planar figure is placed on an axial slice of this image.
- set the points to the figure
- finalize the interaction
- update all viewers

When I comment the lines in the "Finalize interaction" part, the figure appears when I click on the viewer at the slice where the figure is (and a new point is added at the click).

I have struggled with this issue for several days now, and I would grealty appreciate any help!

Best regards,
Daphné

Below is a snippet of my code:

mitk::PlanarFigure::Pointer figure = mitk::PlanarBezierCurve::New();

// Create node containing the curve, select it and add it to datastorage
mitk::DataNode::Pointer newNode = mitk::DataNode::New();
newNode->SetData(figure);
newNode->SetSelected(true);

if (!_ds->Exists(newNode))
{
_ds->Add(newNode);
}

// Set new interactor
mitk::PlanarFigureInteractor::Pointer interactor = dynamic_cast<mitk::PlanarFigureInteractor*>(newNode->GetDataInteractor().GetPointer());
if (interactor.IsNull())
{
interactor = mitk::PlanarFigureInteractor::New();
auto planarFigureModule =
us::ModuleRegistry::GetModule("MitkPlanarFigure");

interactor->LoadStateMachine("PlanarFigureInteraction.xml",
planarFigureModule);
interactor->SetEventConfig("PlanarFigureConfig.xml",
planarFigureModule);
}
interactor->SetDataNode(newNode);

// Set figure plane geometry
mitk::PlaneGeometry::Pointer curvePlane = mitk::PlaneGeometry::New();

mitk::DataNode::Pointer originalImageNode = _ds->GetNamedNode("originalImage"); // This node contains a dicom image on which we want to draw the planar figure
mitk::BaseGeometry* originalImageGeometry =
originalImageNode->GetData()->GetGeometry();

itk::Index<3> idx;
originalImageGeometry->WorldToIndex(curve.points[0], idx); // the "curve" variable contains the 3D control points
mitk::ScalarType planeZPosition = idx[2];

curvePlane->InitializeStandardPlane(originalImageGeometry,
mitk::PlaneGeometry::Axial, planeZPosition);
figure->SetPlaneGeometry(curvePlane);

//Set points to figure
for (int i = 0; i < curve.points.size(); i++)
{
mitk::Point2D indexPoint2d;
for (int dim = 0; dim < 2; dim++)
{
indexPoint2d[dim] = (curve.points[i][dim] -
originalImageGeometry->GetOrigin()[dim]);
}
if (i == 0)
{
figure->InvokeEvent(mitk::StartPlacementPlanarFigureEvent());
figure->PlaceFigure(indexPoint2d);
newNode->SetBoolProperty("PlanarFigureInitializedWindow", true);
}
else
{
figure->SetControlPoint(i, indexPoint2d, true);
}
}

figure->EvaluateFeatures();
figure->DeselectControlPoint();

// Finalize interaction: when these six lines are commented, the figure is displayed when the user clicks on the slice where the figure is placed
figure->Modified();
figure->SetProperty("initiallyplaced",
mitk::BoolProperty::New(true));
newNode->SetBoolProperty("planarfigure.drawcontrolpoints", true);
newNode->Modified();
figure->InvokeEvent(mitk::EndPlacementPlanarFigureEvent());
figure->InvokeEvent(mitk::EndInteractionPlanarFigureEvent());

mitk::RenderingManager::GetInstance()->RequestUpdateAll();



--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mitk-users mailing list
mitk-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users
Dinkelacker, Stefan
2017-03-17 14:17:19 UTC
Permalink
There's not a direct connection between reading planar figures and the measurement plugin but the plugin listens to the data manager with its implementation of the NodeAdded() method [1]. That's where the plugin sets the interactor. The display is completely independent from the plugin, as the planar figure mappers are automatically added to the data node as soon as you add the node containing the PF to the data storage.

[1] https://github.com/MITK/MITK/blob/master/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkMeasurementView.cpp#L261-L283


-----Original Message-----
From: Daphné Wallach [mailto:***@hrv-simulation.com]
Sent: Donnerstag, 16. März 2017 17:03
To: Dinkelacker, Stefan
Subject: Re: [mitk-users] Displaying a planar figure created from a set of 3D points

Dear Stefan,

Thank you for your prompt answer.

I am already using PlaceFigure() for the first control point, and
AddControlPoint() for the subsequent points. Moreover, I do need to add an interactor.

Actually, I just realized that what I need to do is close to what is done in the "Measurement" plugin, when measures are saved to a file and then loaded again. However, I cannot find the relevant classes: the figure points and geometry are read in "mitkPlanarFigureReader", but I don't see where the interactor is created.

If anyone had any idea about how I could display the figure and interact with it, that would be most helpful.

Best regards,

Daphné

Below is a snippet of my code:


mitk::PlanarFigure::Pointer figure = mitk::PlanarBezierCurve::New();

// Create node containing the curve, select it and add it to datastorage
mitk::DataNode::Pointer newNode = mitk::DataNode::New();
newNode->SetData(figure);
newNode->SetSelected(true);

if (!_ds->Exists(newNode))
{
_ds->Add(newNode);
}

// Set new interactor
mitk::PlanarFigureInteractor::Pointer interactor = dynamic_cast<mitk::PlanarFigureInteractor*>(newNode->GetDataInteractor().GetPointer());
if (interactor.IsNull())
{
interactor = mitk::PlanarFigureInteractor::New();
auto planarFigureModule =
us::ModuleRegistry::GetModule("MitkPlanarFigure");

interactor->LoadStateMachine("PlanarFigureInteraction.xml",
planarFigureModule);
interactor->SetEventConfig("PlanarFigureConfig.xml",
planarFigureModule);
}
interactor->SetDataNode(newNode);

// Set figure plane geometry
mitk::PlaneGeometry::Pointer curvePlane = mitk::PlaneGeometry::New();

mitk::DataNode::Pointer originalImageNode = _ds->GetNamedNode("originalImage"); // This node contains a dicom image on which we want to draw the planar figure
mitk::BaseGeometry* originalImageGeometry =
originalImageNode->GetData()->GetGeometry();

itk::Index<3> idx;
originalImageGeometry->WorldToIndex(curve.points[0], idx); // the "curve" variable contains the 3D control points
mitk::ScalarType planeZPosition = idx[2];

curvePlane->InitializeStandardPlane(originalImageGeometry,
mitk::PlaneGeometry::Axial, planeZPosition);
figure->SetPlaneGeometry(curvePlane);

//Set points to figure
for (int i = 0; i < curve.points.size(); i++)
{
mitk::Point2D indexPoint2d;
for (int dim = 0; dim < 2; dim++)
{
indexPoint2d[dim] = (curve.points[i][dim] -
originalImageGeometry->GetOrigin()[dim]);
}
if (i == 0)
{
figure->InvokeEvent(mitk::StartPlacementPlanarFigureEvent());
figure->PlaceFigure(indexPoint2d);
newNode->SetBoolProperty("PlanarFigureInitializedWindow", true);
}
else
{
figure->SetControlPoint(i, indexPoint2d, true);
}
}

figure->EvaluateFeatures();
figure->DeselectControlPoint();

// Finalize interaction: when these six lines are commented, the figure is displayed when the user clicks on the slice where the figure is placed
figure->Modified();
figure->SetProperty("initiallyplaced",
mitk::BoolProperty::New(true));
newNode->SetBoolProperty("planarfigure.drawcontrolpoints", true);
newNode->Modified();
figure->InvokeEvent(mitk::EndPlacementPlanarFigureEvent());
figure->InvokeEvent(mitk::EndInteractionPlanarFigureEvent());

mitk::RenderingManager::GetInstance()->RequestUpdateAll();
Post by Dinkelacker, Stefan
Hi, Planar Figures can be a bit tricky when constructing them programmatically. See the Planar Figure tests for examples [1]. The thing is (which I assume you didn't do) that you use the PlaceFigure() method for the first control point and AddControlPoint() for the subsequent control points only. You also do not need to add an interactor, if you do not want the user to modify the planar figure. BTW you can also query if a planar figure is in its "placed" state by calling IsPlaced().
Hope that helps,
Stefan
[1] https://github.com/MITK/MITK/tree/master/Modules/PlanarFigure/test
-----Original Message-----
Sent: Donnerstag, 16. März 2017 12:08
Subject: [mitk-users] Displaying a planar figure created from a set of 3D points
Dear MITK users,
I am developping an application using MITK as a library, and I am currently trying to load a planar figure from its 3D control points.
However, I can only manage to display the figure when I start interacting with it. Otherwise, the figure is not displayed.
- create a new figure
- create a new node containing the figure, select it, and add to the datastorage
- set a planar figure interactor to the node
- set the geometry of the figure: the geometry is computed from a dicom image stored in the datastorage. The planar figure is placed on an axial slice of this image.
- set the points to the figure
- finalize the interaction
- update all viewers
When I comment the lines in the "Finalize interaction" part, the figure appears when I click on the viewer at the slice where the figure is (and a new point is added at the click).
I have struggled with this issue for several days now, and I would grealty appreciate any help!
Best regards,
Daphné
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
----------------------------------------------------------------------
-------- Check out the vibrant tech community on one of the world's
most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mitk-users mailing list
https://lists.sourceforge.net/lists/listinfo/mitk-users
--
Daphné Wallach
Ingénieur de recherche
http://www.hrv-simulation.com
Continue reading on narkive:
Loading...