08.06.2015 Views

Plugins - mipav

Plugins - mipav

Plugins - mipav

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Plugins</strong><br />

http://<strong>mipav</strong>.cit.nih.gov<br />

1


MIPAV Team<br />

Matthew McAuliffe<br />

William Gandler<br />

Ruida Cheng<br />

Evan McCreedy<br />

Justin Senseney<br />

Contractors<br />

Nish Pandya, SSAI<br />

Alexandra Bokinsky, Geometric Tools Inc.<br />

2


Justin Senseney<br />

Medical Image Processing,<br />

Analysis & Visualization<br />

&<br />

<strong>Plugins</strong><br />

SenseneyJ@mail.nih.gov<br />

Biomedical Imaging Research Services Section (BIRSS)<br />

Imaging Sciences Laboratory<br />

Division of Computational Bioscience<br />

Center for Information Technology<br />

(301) 594-5887<br />

http://<strong>mipav</strong>.cit.nih.gov<br />

3


Mipav Interface<br />

•<br />

Options exist<br />

• How to manipulate<br />

4


<strong>Plugins</strong><br />

•<br />

PlugInAlgorithm – Develop new functionality and ability<br />

to call functions already in MIPAV.<br />

•<br />

PlugInFile – Develop files readers to support unique file<br />

formats.<br />

•<br />

PlugInGeneric – <strong>Plugins</strong> that do not require an open<br />

image.<br />

•<br />

PlugInView – Develop new visualizations of datasets.<br />

•<br />

PlugIn – ImageJ plugin.<br />

6


<strong>Plugins</strong><br />

•<br />

To build a plugin, three files are typically used:<br />

–<br />

PlugInTest.class<br />

• Interface between MIPAV and plugin.<br />

–<br />

PlugInDialogTest.class<br />

• Creates dialog for input.<br />

–<br />

PlugInAlgorithmTest.class<br />

• The actual algorithm.<br />

7


<strong>Plugins</strong> - Location<br />

•<br />

Stored for each user:<br />

–<br />

Windows - C:\Users\{{user_name}}\<strong>mipav</strong>\plugins<br />

–<br />

Linux/Mac OS - /home/{{user_name}}/<strong>mipav</strong>/plugins<br />

8


<strong>Plugins</strong> - Installing<br />

9


<strong>Plugins</strong> – Installing<br />

•<br />

Installing a plugin (<strong>Plugins</strong> -> Install Plugin)<br />

Copies files:<br />

•<br />

.class<br />

•<br />

.jar<br />

•<br />

.zip<br />

into user directory.<br />

HINT:<br />

If something goes wrong, just copy the files yourself using locations on Slide 8.<br />

10


<strong>Plugins</strong> – Installing (2)<br />

11


<strong>Plugins</strong> - Executing<br />

12


<strong>Plugins</strong> - Scripting<br />

Execute plugin<br />

13


Script Running Review<br />

14


Uninstall Plugin<br />

15


Plugin Lab<br />

•<br />

Install<br />

• PlugInCT_MD – already in MIPAV<br />

• MuscleSegmentation –<br />

http://dcb.cit.nih.gov/~senseneyj/code/muscleSeg.html<br />

• Bio-Formats - http://dcb.cit.nih.gov/~<br />

senseneyj/code/bioformats.html<br />

• ImageJ –<br />

http://dcb.cit.nih.gov/~senseneyj/code/imagej.html<br />

16


<strong>Plugins</strong> from<br />

command line<br />

• Mipav –p Plugin_Name<br />

• Can be run headless<br />

17


Break - Review<br />

• <strong>Plugins</strong><br />

•<br />

File<br />

•<br />

Generic<br />

•<br />

Algorithm<br />

•<br />

View<br />

• Stored in user folder<br />

• Install, Run, Uninstall<br />

18


Development environment<br />

•<br />

Textpad: http://www.textpad.com/<br />

•<br />

Simple, few linked files<br />

•<br />

Want to learn Java<br />

•<br />

Eclipse: http://www.eclipse.org/<br />

•<br />

Many files, libraries<br />

•<br />

Source repository<br />

•<br />

Want to use Java<br />

19


Download Eclipse<br />

•<br />

Download here:<br />

http://www.eclipse.org/downloads/<br />

20


“Install” Eclipse<br />

21


Fix Eclipse<br />

ecify Memory<br />

22


Start Eclipse<br />

23


Java Programs<br />

•<br />

Virtual machine = platform independent<br />

•<br />

JRE to execute<br />

24


JRE Setting<br />

25


Add JRE<br />

26


Locate JRE<br />

27


Locate JRE<br />

28


Eclipse project<br />

•<br />

Mipav<br />

•<br />

Java project<br />

•<br />

Contains plugins<br />

29


Make Mipav Project<br />

30


Make Mipav Project<br />

Specify JRE<br />

31


Mipav Program<br />

•<br />

Execution environment needs to be replicated<br />

32


Execution environment<br />

•<br />

Classpath<br />

•<br />

Libraries - jars<br />

•<br />

Associated class files<br />

•<br />

Memory – used by VM<br />

•<br />

Launching class file<br />

33


•<br />

Libraries<br />

•<br />

PDFbox<br />

•<br />

JPEG2000<br />

•<br />

ImageJ<br />

•<br />

Help files<br />

•<br />

Insight Toolkit wrappers<br />

Jars<br />

34


Add Jars<br />

35


More Jars<br />

36


More Jars: Help<br />

37


More Jars: ITK<br />

38


•<br />

Object-oriented<br />

•<br />

Executable programs<br />

•<br />

In Mipav:<br />

•<br />

Read/write images<br />

•<br />

Apply filters<br />

•<br />

Run plugins!<br />

Class files<br />

39


External class folder<br />

Select the<br />

correct version<br />

of Mipav<br />

40


Click Finish!<br />

Note class folder<br />

and JRE<br />

selection<br />

41


MipavMain<br />

42


Run Configuration<br />

43


New Configuration<br />

44


Select Main Type<br />

45


-Xms (min), -Xmx (max)<br />

Java Memory<br />

46


Memory<br />

47


Run Mipav<br />

•<br />

MipavMain is executed<br />

•<br />

Classpath is set<br />

•<br />

Memory allocated<br />

•<br />

Libraries are referenced<br />

48


Mipav Launched<br />

Version number<br />

VM Memory<br />

49


View JVM Info<br />

50


JVM Info<br />

JRE in <strong>mipav</strong><br />

Plugin folder in<br />

workspace<br />

51


Java Compiler<br />

•<br />

Source code:<br />

•<br />

*.java files<br />

•<br />

Text-editor readable<br />

•<br />

Platform independent byte-code:<br />

•<br />

*.class files<br />

52


Get NewGeneric2<br />

•<br />

Download three files from<br />

http://dcb.cit.nih.gov/~senseneyj/code/plugin.html<br />

•<br />

PlugInNewGeneric2.java<br />

•<br />

PlugInDialogNewGeneric2.java<br />

•<br />

PlugInAlgorithmNewGeneric2.java<br />

53


Import NewGeneric2<br />

•<br />

In Eclipse: Press File->Import<br />

54


Compile NewGeneric2<br />

•<br />

This is done for you, incrementally in Eclipse<br />

•<br />

Errors and warnings update with each change<br />

55


Install NewGeneric2<br />

•<br />

Only install PlugInNewGeneric2.class<br />

Why did this work?<br />

56


Run NewGeneric2<br />

•<br />

Open an image, try it out<br />

57


Look at NewGeneric2<br />

•<br />

Open Dialog, try to change the title “Generic Plugin”<br />

58


Change NewGeneric2<br />

•<br />

Location:<br />

59


Run NewGeneric2<br />

•<br />

See change:<br />

60


NewGeneric Algorithm<br />

•<br />

Look at algorithm construction, extecution<br />

61


MIPAV Documentation<br />

•<br />

CTRL-click on run algorithm, now try hovering:<br />

62


<strong>Plugins</strong> - MIPAV API<br />

Download from:<br />

http://<strong>mipav</strong>.cit.nih.gov/documentation/api.zip<br />

63


<strong>Plugins</strong> - MIPAV API<br />

Attach here:<br />

64


<strong>Plugins</strong> - MIPAV API<br />

View here:<br />

65


Modify Plugin Lab<br />

10pt<br />

•<br />

Edit PlugInNewGeneric2:<br />

•<br />

Change text in plugin dialog.<br />

10pt<br />

•<br />

Print out when algorithm has completed.<br />

10pt<br />

20pt<br />

80pt<br />

•<br />

Increase kernel size.<br />

•<br />

Change 3D to 2.5D processing.<br />

•<br />

Add check box to allow user to select either 3D or<br />

2.5D processing.<br />

66


<strong>Plugins</strong> - Documentation<br />

•<br />

Plugin development documentation<br />

http://<strong>mipav</strong>.cit.nih.gov/documentation/userguide/volume1/MIPAV_PlugIns.pdf<br />

•<br />

This presentation is posted at:<br />

• http://dcb.cit.nih.gov/~senseneyj/code/plugin.html<br />

•<br />

Will also be posted here:<br />

• http://<strong>mipav</strong>.cit.nih.gov/documentation/presentations/<br />

•<br />

Also see this wiki page:<br />

• http://<strong>mipav</strong>.cit.nih.gov/pubwiki/index.php/Writing_MIPAV_plugins_without_MIPAV_sour<br />

67


Summary<br />

•<br />

<strong>Plugins</strong><br />

–<br />

Unique functionality using MIPAV API<br />

•<br />

Develop in Eclipse<br />

•<br />

Use MIPAV API<br />

68


Visualization<br />

Processing<br />

Quantification File reader<br />

Macros<br />

File writer<br />

69


http://<strong>mipav</strong>.cit.nih.gov<br />

70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!