Skip to content

XmippPythonJava

Adrian Quintana edited this page Dec 11, 2017 · 1 revision

Introduction

In Xmipp3.0 we have added binding to Python and Java programming languages. So now you can develop Python scripts or Java programs and make use of the Xmipp main classes, libraries and some programs. Not the whole Xmipp package is available from the binding, but the more useful classes and function. If you are missing some utility you can request to be added. We have tried to keep the syntax as near as possible to the C++ counterpart. Follow you will find some practical examples.

Python

Including modules

.... In the rest of the examples the import are ommitted, so you need to be sure that you have imported the required classes or functions.

Profiling

You can see how to profile in Python DebuggingProfiling#Profiling_in_Python

Metadata examples

Metadata is a class to handle different kind of data values in one or several rows. You can perform a lot of operations, like reading, selection, merging,...etc. You can find here a more detailed explanation of the MetaData usage.

Create and setting values

Create a metadata: md = [MetaData]

Adding an object and setting angles values:

Read and write

Create a and read: md = [MetaData]

Reading a metadata: md = [MetaData] ... md.read(filename)

Reading from a block: md = [MetaData] blockName = "particles" ... md.read(blockName + "@" + filename)

Select

You have a metadata with images and each have a ref, where ref indicate one of possible N classes. Then for create N metadata, one per class, containing the images belonging to this class:

mdImages = [MetaData] # Read metadata with images mdRefImages = MetaData() # Create a metadata to write reference images

for ref in range(1, N+1): mdRefImages.importObjects( mdImages, MDValueEQ(MDL_REF, ref)) mdRefImages.write(outRefs, 'class Note in the example the use of importObjects function which select some objects from other metadata and the function MDValueEQ which create a query to select object with some label equal to a value.

Java

Including libraries

Clone this wiki locally