Skip to content

neurospin/dico_toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dico_toolbox

Pythonesque PyAims

dico_toolbox is a set of shared tools developed for the FolDico project.

It mainly contains documented python3 recipies to manipulate and convert pyAIMS entities (volumes, buckets, graphs, meshes) into numpy arrays.

.
└── dico_toolbox/
    ├── anatomist/ (Anatomist wrapper)
    ├── cli/ (Command line tools)
    │   └── volume_to_point_cloud.py (dtb_volume_to_point_cloud)
    ├── recipes/ (Recipes for more complex manipulations)
    ├── bucket.py (pyAims Bucket manipulation)
    ├── convert.py (conversion of pyAims and numpy objects)
    ├── database.py (access Brainvisa databases)
    ├── graph.py (pyAims Graph manipulation)
    ├── mesh.py (PyAims Mesh manipulation)
    ├── skeleton.py (topological values of Aims skeletons)
    ├── transform.py (geometrical transformation)
    ├── volume.py (pyAims Volume manipulation)
    └── wrappers.py (wrappers for pyAims objects e.g. PyMesh)

The Anatomist wrapper

import dico_toolbox as dtb
from soma import aims
import numpy as np
import matplotlib.pyplot as plt
%%capture
%gui qt

# run this cell only once, at the beginning.
an = dtb.anatomist.Anatomist()
# run this line only after the Anatomist window appears
%matplotlib inline
# a random point cloud
rpc1 = (5*np.random.randn(400,3)).astype(int)
rpc2 = (10*np.random.randn(400,3)).astype(int)
# draw objects (with automatic colors) 
an.clear()
an(rpc1, rpc2)

# an.color_random() can be used to re-assign random colors to all the objects
# get a snapshot
plt.imshow(an.snapshot());

png

# use a dictionnary
d = {
    "first" : rpc1,
    "second": rpc2
}

an.clear_quick_window()
an(d)
# set colors
an.set_objects_color('first', r=1, g=1, b=0)
an.set_objects_color('second', r=0, g=0, b=1)
plt.imshow(an.snapshot());

png

an.set_objects_opacity("second",opacity=0.5)
plt.imshow(an.snapshot());

png

# colors can also be specified as string or list
an.set_objects_color('first', color='cyan')
an.set_objects_color('second', color='m') # common colors have short names (m = magenta)
plt.imshow(an.snapshot());

png

# It is possible to set colors for all the objects in a dictionnary
an.set_objects_color(d, color='red')
plt.imshow(an.snapshot());

png

# get the instance of the anatomist object
anatomist_instance = an.get_anatomist_instance()
print(anatomist_instance.getVersion())
5.1.0
# remove one object
an.delete_objects('second')
plt.imshow(an.snapshot());

png

an.delete_all_objects()
an.close()

About

a pythonic toolbox for Brainvisa entities

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages