g - MITK
Transcrição
g - MITK
BVM-Tutorial BVM Tutorial 2010: Entwicklung g interaktiver medizinischer Bild Bildverarbeitungssysteme b it t mit it MITK Daniel Maleike, Michael Müller, Alexander Seitel, Marco Nolden Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 2 Ablauf des Tutorials • Einführung in ITK, VTK und MITK Praxis 1: Demo der Qt4 Basisapplikation „ExtApp“ D Download l d und d Ei Einrichtung i ht d der MITK U Umgebung b • MITK Grundkonzepte Kaffeepause • Grundlagen des BlueBerry Framework Praxis 2: Erstellung eines Applikationsmoduls Interaktion und Anbindung von Algorithmen • Image Guided Therapy mit MITK: Konzepte und Demonstration • Ausblick und Ende Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 3 Fragen g an die Teilnehmer • Erfahrung g mit ITK, VTK, MITK? • Was ist das Hauptinteresse am MITK? • Plattform für End-User Applikationen • Prototyp-Plattform für Algorithmen-Entwicklung • Navigation • Sonstiges VTK,, ITK,, MITK Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 5 VTK • Visualization Toolkit • The Visualization Toolkit An Object-Oriented Approach to 3D • • • • Graphics. Will Schroeder, Ken Martin, and Bill Lorensen (1993) Unterstützung durch GE Research 1998: Gründung von Kitware Inc. Implementiert in C++, Anbindung von TCL, Python, Java … Viele Visualisierungsverfahren, einfache Bildverarbeitungs und GUI Komponenten Bildverarbeitungs- Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 6 ITK • Insight g Segmentation g and Registration g Toolkit • Ausschreibung durch NLM und NIH 1999 • Sechs Partner aus Industrie und Wissenschaft: GE, Kitware, • • • • University of North Carolina … Datenstrukturen und Algorithmen für Registrierung und Segmentierung in medizinischen Anwendungen Keine GUI oder Applikationskomponenten Generische Programmierung Programmierung, “advanced” advanced C++ Open Source Prozess, Insight Journal Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 7 MITK Softwareplattform des DKFZ • Software‐Bibliothek, seit 2002 vom DKFZ entwickelt seit 2002 vom DKFZ entwickelt • Basis für sämtliche Anwendungen g der Abteilung • Ca. 500.000 Zeilen Open Source C 500 000 Z il O S • Etabliert in Forschung u. Bildung Etabliert in Forschung u. Bildung (ca. 200 forschende Anwender) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 8 Open Source MITK MITK kann auf verschiedene Weise verwendet werden man kann: verwendet werden, man kann: 1. Neue Anwendungen von Beginn an entwickeln von Beginn an entwickeln MITK wird als SW‐Bibliothek verwendet d 2. Die Open‐Source MITK‐Applikation erweitern (neue Module, Plug‐Ins,...) MITK wird als Application‐Framework verwendet 3. Die existierende 3M3‐Applikation verwenden (Seg., Reg., Vermessung, 3D (+t) Visualisierung,...) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 9 Open-source p Toolkits Powerful toolkits for • Visualization: VTK (http://www.vtk.org) • Segmentation / Registration: ITK (http://www.itk.org) But: insufficient support for interactive, multi-view software MITK … • uses parts of NA-MIC: ITK & VTK • adds features outside the scope of boths is not at all a competitor to VTK or ITK Marco Nolden Medizinische und Biologische Informatik MITK Medical Imaging Interaction Toolkit (MITK) • open-source C++ C ttoolkit lkit b based d on ITK/VTK • coordination of visualizations and interactions • combine modules developed independently from each other BlueBerry Plugins / Modules Custom Applications MITK module layer: building blocks; functionality blocks BlueBerry y 3/18/2010 | Seite 10 GUI toolkits (Qt, FLTK, …) MITK: coordination interactivity ITK: algorithms segmentation registration VTK: visualization Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 11 MITK • Object-oriented C++ framework / toolkit • BSD-style license, almost identical to VTK / ITK • Supports • Linux, Linux Windows Windows, Mac OSX • gcc 4.x, VC8, VC9 • Latest VTK release • Latest two ITK releases • MITK-core does not depend on a GUI toolkit • MITK MITK-application-level application level provides • Qt4 base application • Many Qt widgets • FLTK example l • wxWidgets port (part of GIMIAS) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 12 Re-use of design g and concepts p FLTK Qt ITK FLmitk FL itk Qmitk MITK MITK‘s core is GUI independent VTK Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 13 Open p source MITK statistics • ~150 p package g downloads / month • ~100 developers use the public read-only repository • Independent research projects based on the MITK platform • MIT Boston • Mayo Clinic Rochester • RWTH Aachen • Fraunhofer IGD Darmstadt • Charité Berlin • Pompeu Fabra University, Barcelona •… Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 14 MITK uses NA-MIC tools and software p process CMake: config fi and db build ild system t Doxygen: Do gen documentation Subversion: version management SourceForge: mailing ili lilistt Bugzilla: b g tracking bug CTest/CDash: automatic builds and test runs Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 15 Continuous Integration g with public p dashboard Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 16 Quality y Management g • QM-System y according g to DIN EN ISO 13485 • Working group „Clinical Applications“ • Support and application development for MITK What MITK does – a quick i k overview i Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 18 original data sliced original i i ld data ellipse ellipse synchronization h i ti sliced off … segmentation sliced original data 20 objects bj t iin 4 scene-graphs ellipse … position iti off th the other two slices position of the other two slices position of the segmentation other two slices volume rendering of segmentation sliced segmentation sliced original g data in 3D required ! ellipsoid Marco Nolden Medizinische und Biologische Informatik Getting g out of the maze … 3/18/2010 | Seite 19 original data sliced original data ellipse ellipse segmentation sliced original data position of the other two slices sliced position of the segmentation other two slices ellipse volume rendering of segmentation sliced segmentation Instead of creating many scene scene-graphs graphs with even more elements … position of the other two slices sliced original data in 3D ellipsoid original data ellipsoid … ccreate eate a s single g e data repository epos to y with a few data-objects! segmentation t ti display planes Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 20 MITK: Data repository p y instead of scene-graphs g p MITK takes the data repository … original data and builds … ellipsoid VTK scene graphs segmentation display planes original data sliced original data ellipse ellipse segmentation sliced original data position of the other two slices sliced position of the segmentation other two slices ellipse volume rendering of segmentation sliced segmentation position of the other two slices sliced original data in 3D ellipsoid Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 21 Data repository p y • Repositories p for sharing g data objects j between modules • Any number of data objects • Any kind of data objects Abdominal CT (Image) Liver (Surface) Tumor ((Surface)) • Data objects with geometry frame (bounding-box, transform, etc.) Vessels (Graph) MRI (Image) Helper Objects Landmarks (Points) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 22 Rendering g VTK vs. MITK VTK :Actor :Mapper :Renderer R d :Actor A t :Mapper M AD t A:Data :Actor :Mapper B:Data :Actor :Mapper :Renderer MITK :Mappergenerated :Mapper :DataNode :Renderer :Data Storage :Renderer A:Data :Mappergenerated :Mapper :DataNode D t N d … :Data … Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 23 Positioning g of an object j VTK :Actor :Mapper :Renderer R d :Actor A t :Mapper M AD t A:Data :Actor :Mapper B:Data :Actor :Mapper :Renderer MITK :Mapper :DataTreeNode :Renderer :Data Tree :Renderer A:Data :Mapper :DataTreeNode D t T N d :Data :Mapper … :GeometryFrame :Mapper … :GeometryFrame Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 24 Rendering g the data repository p y Render windows: • single RenderWindow class • different diff t types t off views i 2D/3D special i l views i d fi bl (e.g., definable ( f AR) for renderer->SetMapperID(BaseRenderer::Standard3D); • point i t to t the th data d t repository it any number of views on the data: renderer1 >SetData(repository); renderer1->SetData(repository); renderer2->SetData(repository); … Marco Nolden Medizinische und Biologische Informatik Defining how we want to see the data … 3/18/2010 | Seite 25 original data ellipsoid segmentation display planes Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 26 Render and interact on curved planes Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 27 The nodes in the data repository p y DataNode 1 1 1 n 1 n 1 1 BaseData 1 Mapper pp Property Interactor BaseData: the actual data: images, surfaces, etc. G GeometryFrame: t F position iti and d orientation i t ti in i space Mappers: render the data into a renderwindow Properties: define how to draw the data Interactor: defines user interaction with the data 1 GeometryFrame Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 28 How to add a new data type yp Extension for new data types: derive data class derive mapper create file I/O Register mapper / I/O handler at factory Example: • attributed vessel graphs [DKFZ and University of Tübingen] MITK Architecture Marco Nolden Medizinische und Biologische Informatik MITK Architecture 3/18/2010 | Seite 30 MITK application framework level MITK application pp toolkit level (GUI-toolkit dependent) MITK application pp toolkit level (GUI-toolkit independent) MITK data processing level GUIGUI toolkit Optional add-on libraries ITK VTK OpenCV PACSPlugin … Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 35 MITK - MainApp pp Marco Nolden Medizinische und Biologische Informatik MITK functionality modules 3/18/2010 | Seite 36 Functionality y = a module with … • an identification (icon/tooltip/…) • a workspace area • a control area • a option dialog • a help page (manual) • the algorithmic implementation icon/tooltip/… New platform: control area = View workspace k area = Edi Editor workspace area control area Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 37 Combining functionality blocks • Functionalities are independent from each other • They communicate via the data repository Marco Nolden Medizinische und Biologische Informatik Embedding in PACS/tele-conferencing system 3/18/2010 | Seite 39 Integration g in PACS/telemedicine system y CHILI® as a PlugIn: g • PACS • Connection to modalities • DICOM import/export • DICOM “unification” • Data transfer • Tele-radiology • Managementt off results M lt from image processing facilitates clinical integration ITK, VTK, MITK: G Gemeinsamkeiten i k it Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 41 Vorteile einer Standardisierung g • Kombination von neuen mit bereits existierenden Algorithmen und Verfahren • Schnelle Vergleichsmöglichkeit unterschiedlicher Algorithmen und Verfahren für eine spezifische Problemstellung • Schnellere Entwicklungszeiten und Verfügbarkeit der Ergebnisse • Verbesserung der Softwarestabilität und -qualität Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 42 Gemeinsamkeiten • Toolkits • Objekt-orientierte Klassenbibliotheken • C++ • Unterstützung vieler Compiler • Plattform unabhängig • GUI-Toolkit unabhängig • Open source Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 43 Gemeinsamkeiten: Überblick • Download und Build-Prozess • Instantiierung und Pointer • Daten-Pipeline • Kommunikation • Software-Prozess und Dokumentation Download und Build Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 45 Voraussetzungen g C++ Compiler: Plattformunabhängiges Make-Tool: CMake GCC 4.x 4 MinGW VC++ 8 2005 VC++ 9 2008 Projekt / Makefiles für • die eingesetzte Plattform • den verwendeten Compiler • die Entwicklungsumgebung. Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 47 CMake • Skriptsprache p p zur Beschreibung g der • • • • Bestandteile eines (C++)-Projekts: Quelltexte, Header, Bibliotheken Getrennte Dateibäume für Quelltexte und Binärdateien Plattformen: Windows (Visual Studio, Borland, MinGW …), Linux, Mac OS X, seit CMake 2.6: Eclipse Erzeugt spezifische Projekt/Makefiles (nicht nur) für die Übersetzung Übe set u g de der Programme og a eu und d Bibliotheken b ot e e Auch: Testgenerierung und -steuerung, Aufruf von Doxygen, Doxygen LaTeX etc. etc Erstellung von Installern … Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 48 CMake Befehle • SET(VAR [VALUE]) • MESSAGE(“Wert von VAR: ${VAR}”) • Listen: • • • • • LIST(APPEND VAR “NochEinWert”) NochEinWert ) Ausführbares Programm erstellen: ADD_EXECUTABLE(MeinProgramm Quelle1.cpp Quelle2 cpp) Quelle2.cpp) Bibliothek erstellen: ADD_LIBRARY(MeineLib LibQuelle1.cpp …) TARGET LINK LIBRARIES(MeinProgramm MeineLib) TARGET_LINK_LIBRARIES(MeinProgramm INCLUDE_DIRECTORIES(<Pfad für c++ header>) Einbindung von Bibliotheken, z.B. FIND_PACKAGE(Qt) Weiter geht‘s mit einer kurzen Demo … Zweiter Teil: G Grundkonzepte dk t Instantiierung g von Klassen und Pointer Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 56 Instantiierung g I t tii Instantiierung von ITK/VTK/MITK ITK/VTK/MITK-Klassen: Kl Statt new className; className::New(); l N N () Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 57 Instantiierung g Grund für “className::New()” className::New() statt “new”: new : • Factory für Instantiierung • erlaubt dynamischen Austausch von Klassen thisClass* thisClass::New() { vtkObject* ret = vtkObjectFactory::CreateInstance(“thisClass”); if(ret != NULL) return static_cast static cast<thisClass*>(ret); thisClass (ret); else return new thisClass; } [bei ITK/MITK ähnlich] Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 58 Instantiierung g //VTK: vtkRenderer * renderer = vtkRenderer::New(); //ITK/MITK: itk::Command::Pointer command = itk::Command::New(); ACHTUNG: “*” statt “::Pointer” bei Instantiierung führt sehr h bald b ld zum Absturz!! Ab t !! Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 59 ::Pointer ist ein Smart Pointer Smart Pointer Smart Pointer Object counter=3 counter=2 counter=1 counter=0 S lf - Delete Self D l t Smart Pointer Marco Nolden Medizinische und Biologische Informatik VTK: “Manuelles” Reference Counting 3/18/2010 | Seite 60 //VTK: vtkRenderer * renderer = vtkRenderer::New(); //count==1 vtkRenderer * ref_to_renderer; ref_to_renderer = renderer; //weiterhin: count==1 ref_to_renderer->Register(...); //count==2 renderer >Delete(); renderer->Delete(); ref_to_renderer->Delete(); //count==1, (noch) kein //count==1 //wirkliches delete! //count==0, delete! Daten-Pipeline p Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 62 Daten-Pipeline p Objekt-orientierter j Ansatz: • Daten-Klassen und • Algorithmen-Klassen Algorithmen nicht als Funktionen Funktionen, sondern als Klassen realisiert ! Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 63 Daten-Pipeline p Algorithmen-Klassen: g • Oberbegriff: ProcessObject • Daten-Erzeuger: Source, z.B. File Reader • Daten-Verarbeiter: Filter (sind somit ebenfalls Sourcen) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 64 Daten-Pipeline p Sourcen besitzen ihre Ausgabe-Daten-Objekte! g j Umgekehrt kennt das Ausgabe-Daten-Objekt seinen Erzeuger (Source)! Datenfluss :DataSource :DataObject Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 65 Daten-Pipeline p Filter kennen zudem ihre Eingabe-Daten-Objekte: :DataObject :Filter1 :DataObject :Filter2 D Datenfluss fl :DataObject Daten-Pipeline!! Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 66 Daten-Pipeline p Filter können auch mehrere Eingabe-/ g Ausgabe-Dateng Objekte haben: :DataObject :Filter3 :DataObject :Filter1 :DataObject :DataObject :Filter2 Datenfluss :DataObject D t Obj t Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 67 Verbinden von Filtern SourceType::Pointer yp source = SourceType::New(); yp (); FilterType::Pointer filter = FilterType::New(); filter->SetInput(source->GetOutput()); :source :DataObject :filter Daten-Objekte meist “unsichtbar”! Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 68 Update/Leere p Daten-Objekte j SourceType::Pointer yp source = SourceType::New(); yp (); // Achtung: Daten-Objekt ist zunächst leer!! // Garantie für aktuelles Daten-Objekt: Update()! source->Update(); :source :DataObject j :DataObject Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 69 Pipeline p update p … data Update ModifyE F C A B D E F update Keine unnötigen Neuberechnungen !! Kommunikation: Events, Observer, Commands Marco Nolden Medizinische und Biologische Informatik Kommunikation (hier ITK/MITK, ähnlich in VTK) 3/18/2010 | Seite 71 itk::Command itk::Object Objec Event itk::Command Event Event itk::Command Event Event itk::Command itk C itk::Command d Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 72 Kommunikation // Anmeldung eines “commands” (Empfänger) object->AddObserver ( event, command ); // Verschicken eines Events an die angemeldeten // Empfänger object->InvokeEvent( event ); Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 73 Kommunikation GUI ITK/VTK GUI Layer Widget Widget Command C llb k Callback ITK/VTK Layer FilterX FilterX Observer Adaptor p Classes: Connecting g ITK, VTK data classes t MITK to Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 75 Access MITK images g as ITK images g • ITK images g are templated p • mitk::Image is not templated // access method template < … > MyAccessMethod( itk::Image<…>* itkImage, … ) { … } // calling the access method AccessByItk(mitkImage MyAccessMethod, AccessByItk(mitkImage, MyAccessMethod …)) E Example l code d in i mitk/Applications/Tutorial/Step6.cpp itk/A li ti /T t i l/St 6 Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 76 Converting g images g ITKMITK • mitk::CastToItkImage(mitkImage, itk::Image<…>) • converts data type if neccessary • otherwise references memory of data array • dimension of itk::Image must equal dimension of mitkImage • mitk::Image::Pointer mitk::ImportItkImage itk I tItkI (itk::Image<…>,update=true) (itk I d t t ) • references memory of itk::Image Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 77 Connecting g MITK images g to VTK … not a conversion, conversion just accessing: • vtkImageData* mitk::Image::GetVtkImageData(int time=0) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 78 Surfaces MITK VTK Again: not a conversion, conversion just accessing: • vtkPolyData* mitk::Surface::GetVtkPolyData(int time=0) • mitk::Surface:: SetVtkPolyData(vtkPolyData*, int time=0) Interaction Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 80 Interactors DataNode 1 1 1 n 1 n 1 1 BaseData 1 1 Mapper pp Property Interactor Interactors: behavior b h i defined d fi d in i state-machines t t hi undo-/redo concept dimension/geometry dimension/geometry-independent independent definition: (often) identical interaction code for 2D and 3D GeometryFrame Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 81 Interaction Scheme keyboard/mouse/tracking system EventMapper XML GlobalInteraction UndoController Operation SpecialInteractor D t Data E,a XML Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 85 9-step p tutorial Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 86 Vielen Dank! Fragen? Kaffeepause … Ausblick Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 88 Today’s Open‐Source Toolkits y p NAMIC (Slicer) Ki Kitware (ITK VTK) (ITK,VTK) INRIA (MedINRIA) DKFZ (MITK) Siemens (OpenXIP) OpenMAF.org (MAF 3) Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 89 The CTK Concept p Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 90 Starting g points: p DICOM I/O • CTK DICOM modules based on DCMTK • Support for more data types (surfaces, segmentations …) • DICOM communication methods • WG 23: standard for application hosting Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 91 Common Toolkit • Erstes Treffen Juni 2009 in Heidelberg g • Drei weitere Workshops in Oxford, Chicago und San Diego • Erstes „Hackfest“ vergangene Woche in Heidelberg • Weitere Infos: http://commontk.org http://github.com/pieper/CTK Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 92 How to g get started Download options: p • anonymous svn: http://svn.mitk.org/trunk/mitk/ • zipped archive https://sourceforge.net/projects/mitk/ • Windows Installer • Demo Application http://3m3.mitk.org Dokumentation & Tutorial: http://docs.mitk.org/ Support: • mitk-users Mailingliste • http://bugs.mitk.org • Kommerziell Marco Nolden Medizinische und Biologische Informatik 3/18/2010 | Seite 93 Das wars … Vielen Dank! Fragen? Daniel Maleike Michael Müller Marco Nolden Alexander Seitel [email protected] d maleike@dkf de [email protected] [email protected] [email protected]