Hi Mujassim,

let's assume you would start with the lasso tool [1] instead of the livewire 
tool, which uses the same base class but seems to fit your needs even better. 
The base class EditableContourTool [2] sets up the state machine 
"EditableContourTool.xml" for the creation of the contour and connects most of 
the functions. The derived LassoTool class then only connects the MovePoint 
action in addition. But all of this interaction is for the creation of the 
contour, not for editing. In LassoTool::FinishTool() you will see, however, 
that another DataInteractor/StateMachine is associated with the created contour 
data node: ContourModelInteractor [3] with 
ContourModelModificationInteractor.xml as state machine. In this class you find 
the OnMovePoint() method which is called when moving a point of the contour. 
That's where you want to hook in to add your functionality. You can do this for 
example by subclassing ContourModelInteractor and overriding the OnMovePoint() 
method.

To understand/test the ContourModelInteractor in the MITK Workbench first, 
activate the Segmentation plugin, create a segmentation, select the Lasso tool 
from the 2D tools and remove the checkmark from "Auto-confirm contour".  This 
is crucial. Start a contour with a double click, add points with single clicks 
and add the last point again with a double click. Now the editable contour 
should still be on the screen and you can test the ContourModelnteractor by 
moving an existing point of the contour for example.

To start with such a contour right from the beginning I recommend to save the 
contour so you can simply open it later without having to use the segmentation 
plugin. The contour node from the lasso tool is invisible by default, though. 
To make it visible, open the preferences (Ctrl+P), click on Data Manager on the 
very top and set the checkmark for "Show helper objects". While the Lasso tool 
is active with an editable contour, you will see a "working contour node" node 
in the Data Manager now. You can right-click on it and "Save..." it to a .cnt 
file, that you can later open again.

When you implement your subclass you can activate the interaction by calling 
either DataInteractor::SetDataNode() or DataNode::SetDataInteractor() on a 
contour node. A good starting point for that is probably your own plugin/view 
and to wire up a button to do so. Start best with the MITK-ProjectTemplate [4] 
where you could modify the Example View for your first prototype [5].

[1] https://docs.mitk.org/2024.12/classmitk_1_1LassoTool.html
[2] https://docs.mitk.org/2024.12/classmitk_1_1EditableContourTool.html
[3] https://docs.mitk.org/2024.12/classmitk_1_1ContourModelInteractor.html
[4] https://github.com/MITK/MITK-ProjectTemplate/blob/master/README.md
[5] 
https://github.com/MITK/MITK-ProjectTemplate/blob/master/Plugins/org.mitk.gui.qt.exampleplugin/src/internal/QmitkExampleView.cpp

Best,
Stefan
________________________________________
Von: Mujassim Jamal <mujassimjama...@gmail.com>
Gesendet: Dienstag, 18. Februar 2025 13:41
An: Dinkelacker, Stefan
Cc: mitk-users@lists.sourceforge.net
Betreff: Re: [Extern] - [mitk-users] Contour Editing in MITK

Hi Stefan,

I followed your instructions and explored the LiveWire tool, which helped me 
understand how it leverages ContourModelLiveWireInteractor for various 
interactions. I also reviewed its corresponding state machine and configuration 
XML files, which were quite easy to follow.

Next, I traced the inheritance hierarchy of ContourModelLiveWireInteractor up 
to DataInteractor, where each class has a ConnectActionsAndFunctions function 
responsible for linking state machine actions to interactor functions (as you 
mentioned in an earlier response). The description of the DataInteractor class 
also states that new interactor classes can be derived from it.

>From this point, what would you recommend as my next step? Should I proceed 
>with creating a new interactor and its associated XML files, or is there 
>anything else I should refer to before diving into the implementation?

Looking forward to your guidance.

Best,
Mujassim

On Tue, 11 Feb 2025 at 15:33, Dinkelacker, Stefan 
<s.dinkelac...@dkfz-heidelberg.de<mailto:s.dinkelac...@dkfz-heidelberg.de>> 
wrote:
Hi Mujassim,

I think at this stage an example-based exploration is probably the most 
efficient way of going forward. For the Live Wire tool, see [1] for example and 
move up the inheritance until you find the code using an Interactor. An 
Interactor is connected to a state machine and a separate config for that 
statemachine. Both are written as .xml files. The Interactor code connects 
actions and conditions of a statemachine to its methods.

Best,
Stefan

[1] https://docs.mitk.org/2024.12/classmitk_1_1LiveWireTool2D.html
________________________________________
Von: Mujassim Jamal 
<mujassimjama...@gmail.com<mailto:mujassimjama...@gmail.com>>
Gesendet: Dienstag, 11. Februar 2025 04:46
An: Dinkelacker, Stefan
Cc: mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>
Betreff: Re: [Extern] - [mitk-users] Contour Editing in MITK

Hi,

Yes, I previously built MITK v2023.12, but I encountered several compiler 
errors related to ITK (conversion type errors) and POCO (OpenSSL version 
mismatch).

Thank you for suggesting these four tools. I have explored all of them and 
found that the Draw Polygon and LiveWire tools closely match my use case, 
though I will still need to make significant customizations. I plan to refer to 
the code of these two tools to get an initial understanding of point adding, 
dragging, picking, etc.

I would appreciate it if you could share any resources on developing a custom 
interactor in MITK.

Best,
Mujassim

On Wed, 5 Feb 2025 at 17:28, Dinkelacker, Stefan 
<s.dinkelac...@dkfz-heidelberg.de<mailto:s.dinkelac...@dkfz-heidelberg.de><mailto:s.dinkelac...@dkfz-heidelberg.de<mailto:s.dinkelac...@dkfz-heidelberg.de>>>
 wrote:
Hi and welcome to MITK!

The last version of MITK that supported Qt 5 was MITK v2023.12, as far as I 
know. Starting with later versions, Qt 6.6+ is a strict requirement.

To get started, I recommend running the MitkWorkbench application and exploring 
the contour interaction functionalities available in two different plugins:

- Measurement [1]: The Draw Polygon and Draw Subdivision Polygon tools 
demonstrate how contours can be interacted with.

- Segmentation [2]: The Lasso and LiveWire tools are both based on contour 
interaction.

MITK provides at least two approaches for working with contours and interacting 
with them. However, you will need to write some code—for example, handling a 
Modified event to map contour changes back to a 3D model (referred to as a 
Surface in MITK). Additionally, MITK's current interactors only operate on 
individual contour vertices.

If you aim to implement an approach similar to what you showed in your 
video—where multiple neighboring vertices of a contour are modified 
simultaneously—you will need to develop a custom interactor. While this is 
certainly possible, it is not the simplest task for a first MITK project.

Best,
Stefan

[1] https://docs.mitk.org/2024.12/org_mitk_views_measurement.html
[2] 
https://docs.mitk.org/2024.12/org_mitk_views_segmentation.html#org_mitk_views_segmentationlivewiretool

________________________________________
Von: Mujassim Jamal 
<mujassimjama...@gmail.com<mailto:mujassimjama...@gmail.com><mailto:mujassimjama...@gmail.com<mailto:mujassimjama...@gmail.com>>>
Gesendet: Mittwoch, 5. Februar 2025 11:27
An: 
mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net><mailto:mitk-users@lists.sourceforge.net<mailto:mitk-users@lists.sourceforge.net>>
Betreff: [Extern] - [mitk-users] Contour Editing in MITK

Hi,

First of all, I am new to using MITK. I am working with Qt 5.15.2, but I 
couldn't find an MITK version compatible with this Qt version. Therefore, I 
built the latest version of MITK (v2024.12).

My question is: Can I use the MITK toolkit to create a contour editing feature 
such that, after projecting a 3D model as a contour onto the 2D segmentation, I 
can pick and drag the points on the contour in 2D and see the effect directly 
on the 3D model? I found that MITK provides various contour-related classes, 
but I am unsure whether they can be used for my specific use case.

I am attaching a Google Drive link that contains a video showcasing what I want 
to achieve using MITK.
Video: 
https://drive.google.com/file/d/1Wu3UJmQQeewlR0Thvx7TPP0iYLEmfu1J/view?usp=sharing

Thank you.


_______________________________________________
mitk-users mailing list
mitk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to