PyAims advanced examples

This section is intended for examples of advanced manipulations with PyAims: beginners do not need look at them, but at the PyAims examples instead.

Manipulating and tricking the plugins loader

Download source:

#!/usr/bin/env python2

'''Maniupulate the plugins loader to avoid loading some of them, or to load additional plugins afterwards
from soma import aims

dicomfile = 'toto.dcm'

pl = aims.carto.PluginLoader
pluginfiles = pl.pluginFiles()

# remove aimsdata plugins
todel = []
i = 0
for f in pluginfiles:
    if f.filename.endswith('aimsdata.plugins'):
    i += 1
for i in todel:
    del pluginfiles[i]

# try to read an object which needs a specific IO plugin
vol =  # Fails

# now set back plugins
import os
import glob
aimspath = glob.glob(
    os.path.join(aims.carto.Paths.globalShared(), 'aims-*', 'plugins', 'aimsdata.plugins'))[0]

vol =  # succeeds