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.


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.


You can see how to profile in Python here

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:

objId = md.addObject()
md.setValue(MDL_ANGLEROT, 100.0, objId)
md.setValue(MDL_ANGLETILT,   15.5, objId)
md.setValue(MDL_ANGLEPSI,   112.4, objId)

Read and write

Create a and read:
md = MetaData(filename)

Reading a metadata:

md = MetaData()

Reading from a block:

md = MetaData()
blockName = "particles"
md.read(blockName + "@" + filename)


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(fnImages) # 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%06d_images' % ref)
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.


Including libraries