├── run ├── orders ├── cvu ├── fsavg5 │ ├── surf │ │ ├── lh.sphere │ │ ├── rh.sphere │ │ ├── lh.orig │ │ ├── lh.pial │ │ ├── lh.white │ │ ├── rh.orig │ │ ├── rh.pial │ │ ├── rh.white │ │ ├── lh.inflated │ │ ├── rh.inflated │ │ ├── lh.sphere.reg │ │ └── rh.sphere.reg │ ├── label │ │ ├── lh.test4rois.annot │ │ ├── rh.test4rois.annot │ │ ├── lh.aparc.annot │ │ ├── lh.laus36.annot │ │ ├── lh.laus60.annot │ │ ├── lh.sparc.annot │ │ ├── rh.aparc.annot │ │ ├── rh.laus36.annot │ │ ├── rh.laus60.annot │ │ ├── rh.sparc.annot │ │ ├── lh.laus125.annot │ │ ├── lh.laus250.annot │ │ ├── lh.laus500.annot │ │ ├── rh.laus125.annot │ │ ├── rh.laus250.annot │ │ ├── rh.laus500.annot │ │ ├── lh.aparc.a2009s.annot │ │ └── rh.aparc.a2009s.annot │ └── mri │ │ └── aseg.mgz ├── cmap_images │ ├── bone.gif │ ├── brbg.gif │ ├── bugn.gif │ ├── bupu.gif │ ├── cool.gif │ ├── file.gif │ ├── flag.gif │ ├── gnbu.gif │ ├── gray.gif │ ├── hot.gif │ ├── hsv.gif │ ├── jet.gif │ ├── orrd.gif │ ├── pink.gif │ ├── piyg.gif │ ├── prgn.gif │ ├── pubu.gif │ ├── puor.gif │ ├── purd.gif │ ├── rdbu.gif │ ├── rdgy.gif │ ├── rdpu.gif │ ├── reds.gif │ ├── set1.gif │ ├── set2.gif │ ├── set3.gif │ ├── ylgn.gif │ ├── accent.gif │ ├── autumn.gif │ ├── binary.gif │ ├── blues.gif │ ├── copper.gif │ ├── dark2.gif │ ├── greens.gif │ ├── greys.gif │ ├── oranges.gif │ ├── paired.gif │ ├── pastel1.gif │ ├── pastel2.gif │ ├── prism.gif │ ├── pubugn.gif │ ├── purples.gif │ ├── rdylbu.gif │ ├── rdylgn.gif │ ├── spring.gif │ ├── summer.gif │ ├── winter.gif │ ├── ylgnbu.gif │ ├── ylorbr.gif │ ├── ylorrd.gif │ ├── blue-red.gif │ ├── gist_gray.gif │ ├── gist_heat.gif │ ├── gist_ncar.gif │ ├── gist_yarg.gif │ ├── spectral.gif │ ├── black-white.gif │ ├── custom_heat.gif │ ├── gist_earth.gif │ ├── gist_rainbow.gif │ ├── gist_stern.gif │ ├── custom_heat_1t.gif │ ├── __init__.py │ └── README.txt ├── data │ ├── sample_data.npy │ ├── sample_fmri.npy │ ├── sample_gqi.npy │ └── sample_meg.npy ├── cmaps │ ├── sample_heat.jpg │ ├── sample_heat.grad │ └── sample_heat.lut ├── __init__.py ├── orders │ ├── aparc_alph.txt │ ├── aparc_cmp.txt │ ├── laus36_alph.txt │ ├── laus36_cmp.txt │ ├── laus60_alph.txt │ ├── laus60_cmp.txt │ ├── sparc.txt │ ├── aparc2009_alph.txt │ ├── aparc2009_cmplike.txt │ ├── laus125_alph.txt │ ├── laus125_fsfast.txt │ ├── laus125_cmp.txt │ ├── laus250_alph.txt │ └── laus250_cmp.txt ├── parsing_utils.py ├── color_legend.py ├── utils.py ├── shell_utils.py ├── graph.py ├── directory_dialog.py ├── color_axis.py ├── volume.py ├── custom_file_editor.py ├── color_map.py ├── mpleditor.py ├── viewport.py ├── options_struct.py └── controller.py ├── tests ├── isolate_connections.py ├── simple_select_node.py ├── output │ ├── first_3D.png │ ├── sparc_3D.png │ ├── sparc_circ.png │ └── sparc_mat.png ├── show_module.py ├── show_all_modules.py ├── color_scheme_customheat.py ├── show_random_scalars_short.py ├── show_random_scalars.py ├── color_scheme_reverse.py ├── show_clustering_coef.py ├── change_color_scheme.py ├── load_sample_fmri.py ├── color_scheme_file.py ├── tractography_debug.py ├── color_scheme_scalars.py ├── new_dataset.py ├── sample_across_modalities_shortcut.py ├── tractography_window.py ├── tractography_native.py ├── simple_screenshots.py └── sample_across_modalities_menus.py ├── screenshots ├── cvu1.png ├── cvu2.png ├── cvu3.png ├── cvu4.png ├── cvu5.png ├── cvu03rc_1.png ├── cvu03rc_2.png ├── cvu03rc_3.png ├── cvu03rc_4.png ├── cvu03rc_5.png ├── cvu03rc_6.png ├── cvu03rc_7.png └── cvu03rc_images.tar.gz ├── docs └── help ├── MANIFEST.in ├── bin └── cvu ├── setup.py ├── licenses ├── ENTHOUGHT_LICENSE ├── COLORBREWER_LICENSE └── YORICK_LICENSE └── README /run: -------------------------------------------------------------------------------- 1 | bin/cvu -------------------------------------------------------------------------------- /orders: -------------------------------------------------------------------------------- 1 | cvu/orders/ -------------------------------------------------------------------------------- /cvu/fsavg5/surf/lh.sphere: -------------------------------------------------------------------------------- 1 | lh.sphere.reg -------------------------------------------------------------------------------- /cvu/fsavg5/surf/rh.sphere: -------------------------------------------------------------------------------- 1 | rh.sphere.reg -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.test4rois.annot: -------------------------------------------------------------------------------- 1 | lh.aparc.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.test4rois.annot: -------------------------------------------------------------------------------- 1 | rh.aparc.annot -------------------------------------------------------------------------------- /tests/isolate_connections.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.display_node(0) 2 | -------------------------------------------------------------------------------- /tests/simple_select_node.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.display_node(0) 2 | -------------------------------------------------------------------------------- /screenshots/cvu1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu1.png -------------------------------------------------------------------------------- /screenshots/cvu2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu2.png -------------------------------------------------------------------------------- /screenshots/cvu3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu3.png -------------------------------------------------------------------------------- /screenshots/cvu4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu4.png -------------------------------------------------------------------------------- /screenshots/cvu5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu5.png -------------------------------------------------------------------------------- /cvu/cmap_images/bone.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/bone.gif -------------------------------------------------------------------------------- /cvu/cmap_images/brbg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/brbg.gif -------------------------------------------------------------------------------- /cvu/cmap_images/bugn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/bugn.gif -------------------------------------------------------------------------------- /cvu/cmap_images/bupu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/bupu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/cool.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/cool.gif -------------------------------------------------------------------------------- /cvu/cmap_images/file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/file.gif -------------------------------------------------------------------------------- /cvu/cmap_images/flag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/flag.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gnbu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gnbu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gray.gif -------------------------------------------------------------------------------- /cvu/cmap_images/hot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/hot.gif -------------------------------------------------------------------------------- /cvu/cmap_images/hsv.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/hsv.gif -------------------------------------------------------------------------------- /cvu/cmap_images/jet.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/jet.gif -------------------------------------------------------------------------------- /cvu/cmap_images/orrd.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/orrd.gif -------------------------------------------------------------------------------- /cvu/cmap_images/pink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/pink.gif -------------------------------------------------------------------------------- /cvu/cmap_images/piyg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/piyg.gif -------------------------------------------------------------------------------- /cvu/cmap_images/prgn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/prgn.gif -------------------------------------------------------------------------------- /cvu/cmap_images/pubu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/pubu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/puor.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/puor.gif -------------------------------------------------------------------------------- /cvu/cmap_images/purd.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/purd.gif -------------------------------------------------------------------------------- /cvu/cmap_images/rdbu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/rdbu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/rdgy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/rdgy.gif -------------------------------------------------------------------------------- /cvu/cmap_images/rdpu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/rdpu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/reds.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/reds.gif -------------------------------------------------------------------------------- /cvu/cmap_images/set1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/set1.gif -------------------------------------------------------------------------------- /cvu/cmap_images/set2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/set2.gif -------------------------------------------------------------------------------- /cvu/cmap_images/set3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/set3.gif -------------------------------------------------------------------------------- /cvu/cmap_images/ylgn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/ylgn.gif -------------------------------------------------------------------------------- /cvu/data/sample_data.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/data/sample_data.npy -------------------------------------------------------------------------------- /cvu/data/sample_fmri.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/data/sample_fmri.npy -------------------------------------------------------------------------------- /cvu/data/sample_gqi.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/data/sample_gqi.npy -------------------------------------------------------------------------------- /cvu/data/sample_meg.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/data/sample_meg.npy -------------------------------------------------------------------------------- /cvu/fsavg5/mri/aseg.mgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/mri/aseg.mgz -------------------------------------------------------------------------------- /cvu/fsavg5/surf/lh.orig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/lh.orig -------------------------------------------------------------------------------- /cvu/fsavg5/surf/lh.pial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/lh.pial -------------------------------------------------------------------------------- /cvu/fsavg5/surf/lh.white: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/lh.white -------------------------------------------------------------------------------- /cvu/fsavg5/surf/rh.orig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/rh.orig -------------------------------------------------------------------------------- /cvu/fsavg5/surf/rh.pial: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/rh.pial -------------------------------------------------------------------------------- /cvu/fsavg5/surf/rh.white: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/rh.white -------------------------------------------------------------------------------- /cvu/cmap_images/accent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/accent.gif -------------------------------------------------------------------------------- /cvu/cmap_images/autumn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/autumn.gif -------------------------------------------------------------------------------- /cvu/cmap_images/binary.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/binary.gif -------------------------------------------------------------------------------- /cvu/cmap_images/blues.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/blues.gif -------------------------------------------------------------------------------- /cvu/cmap_images/copper.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/copper.gif -------------------------------------------------------------------------------- /cvu/cmap_images/dark2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/dark2.gif -------------------------------------------------------------------------------- /cvu/cmap_images/greens.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/greens.gif -------------------------------------------------------------------------------- /cvu/cmap_images/greys.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/greys.gif -------------------------------------------------------------------------------- /cvu/cmap_images/oranges.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/oranges.gif -------------------------------------------------------------------------------- /cvu/cmap_images/paired.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/paired.gif -------------------------------------------------------------------------------- /cvu/cmap_images/pastel1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/pastel1.gif -------------------------------------------------------------------------------- /cvu/cmap_images/pastel2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/pastel2.gif -------------------------------------------------------------------------------- /cvu/cmap_images/prism.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/prism.gif -------------------------------------------------------------------------------- /cvu/cmap_images/pubugn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/pubugn.gif -------------------------------------------------------------------------------- /cvu/cmap_images/purples.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/purples.gif -------------------------------------------------------------------------------- /cvu/cmap_images/rdylbu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/rdylbu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/rdylgn.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/rdylgn.gif -------------------------------------------------------------------------------- /cvu/cmap_images/spring.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/spring.gif -------------------------------------------------------------------------------- /cvu/cmap_images/summer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/summer.gif -------------------------------------------------------------------------------- /cvu/cmap_images/winter.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/winter.gif -------------------------------------------------------------------------------- /cvu/cmap_images/ylgnbu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/ylgnbu.gif -------------------------------------------------------------------------------- /cvu/cmap_images/ylorbr.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/ylorbr.gif -------------------------------------------------------------------------------- /cvu/cmap_images/ylorrd.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/ylorrd.gif -------------------------------------------------------------------------------- /cvu/cmaps/sample_heat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmaps/sample_heat.jpg -------------------------------------------------------------------------------- /cvu/fsavg5/surf/lh.inflated: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/lh.inflated -------------------------------------------------------------------------------- /cvu/fsavg5/surf/rh.inflated: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/rh.inflated -------------------------------------------------------------------------------- /screenshots/cvu03rc_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_1.png -------------------------------------------------------------------------------- /screenshots/cvu03rc_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_2.png -------------------------------------------------------------------------------- /screenshots/cvu03rc_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_3.png -------------------------------------------------------------------------------- /screenshots/cvu03rc_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_4.png -------------------------------------------------------------------------------- /screenshots/cvu03rc_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_5.png -------------------------------------------------------------------------------- /screenshots/cvu03rc_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_6.png -------------------------------------------------------------------------------- /screenshots/cvu03rc_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_7.png -------------------------------------------------------------------------------- /tests/output/first_3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/tests/output/first_3D.png -------------------------------------------------------------------------------- /tests/output/sparc_3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/tests/output/sparc_3D.png -------------------------------------------------------------------------------- /tests/output/sparc_circ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/tests/output/sparc_circ.png -------------------------------------------------------------------------------- /tests/output/sparc_mat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/tests/output/sparc_mat.png -------------------------------------------------------------------------------- /cvu/cmap_images/blue-red.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/blue-red.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_gray.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_heat.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_heat.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_ncar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_ncar.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_yarg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_yarg.gif -------------------------------------------------------------------------------- /cvu/cmap_images/spectral.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/spectral.gif -------------------------------------------------------------------------------- /cvu/fsavg5/surf/lh.sphere.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/lh.sphere.reg -------------------------------------------------------------------------------- /cvu/fsavg5/surf/rh.sphere.reg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/surf/rh.sphere.reg -------------------------------------------------------------------------------- /cvu/cmap_images/black-white.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/black-white.gif -------------------------------------------------------------------------------- /cvu/cmap_images/custom_heat.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/custom_heat.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_earth.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_earth.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_rainbow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_rainbow.gif -------------------------------------------------------------------------------- /cvu/cmap_images/gist_stern.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/gist_stern.gif -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.aparc.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.aparc.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.laus36.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.laus36.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.laus60.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.laus60.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.sparc.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.sparc.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.aparc.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.aparc.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.laus36.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.laus36.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.laus60.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.laus60.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.sparc.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.sparc.annot -------------------------------------------------------------------------------- /cvu/cmap_images/custom_heat_1t.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/cmap_images/custom_heat_1t.gif -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.laus125.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.laus125.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.laus250.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.laus250.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.laus500.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.laus500.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.laus125.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.laus125.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.laus250.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.laus250.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.laus500.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.laus500.annot -------------------------------------------------------------------------------- /screenshots/cvu03rc_images.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/screenshots/cvu03rc_images.tar.gz -------------------------------------------------------------------------------- /tests/show_module.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.calculate_modules(2.) 2 | self.controller.ds_orig.display_module(0) 3 | -------------------------------------------------------------------------------- /cvu/fsavg5/label/lh.aparc.a2009s.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/lh.aparc.a2009s.annot -------------------------------------------------------------------------------- /cvu/fsavg5/label/rh.aparc.a2009s.annot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aestrivex/cvu/HEAD/cvu/fsavg5/label/rh.aparc.a2009s.annot -------------------------------------------------------------------------------- /tests/show_all_modules.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.calculate_modules(2.) 2 | self.controller.ds_orig.display_multi_module() 3 | -------------------------------------------------------------------------------- /cvu/cmap_images/__init__.py: -------------------------------------------------------------------------------- 1 | # Author: Gael Varoquaux 2 | # Copyright (c) 2005, Enthought, Inc. 3 | # License: BSD Style. 4 | 5 | -------------------------------------------------------------------------------- /docs/help: -------------------------------------------------------------------------------- 1 | This documentation has moved to the cloud. Please read the documentation for 2 | cvu at https://github.com/aestrivex/cvu/wiki/ 3 | -------------------------------------------------------------------------------- /tests/color_scheme_customheat.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.opts.default_map.cmap='custom_heat' 2 | self.controller.ds_orig.opts.activation_map.cmap='custom_heat' 3 | self.controller.ds_orig.opts.connmat_map.cmap='custom_heat' 4 | 5 | load_parc('laus125', 'orders/laus125_cmp.txt', dataset=self.controller.ds_orig) 6 | load_adj('data/sample_gqi.npy', self.controller.ds_orig) 7 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | graft cvu/data 2 | graft cvu/cmaps 3 | graft cvu/cmap_images 4 | graft licenses 5 | 6 | graft cvu/orders 7 | recursive-exclude cvu/orders *kerrmbsr* 8 | recursive-exclude cvu/orders questionable 9 | 10 | graft cvu/fsavg5 11 | recursive-exclude cvu/fsavg5 *test4rois* 12 | recursive-exclude cvu/fsavg5 *.gii 13 | 14 | include LICENSE 15 | include README 16 | include run 17 | -------------------------------------------------------------------------------- /tests/show_random_scalars_short.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | self.controller.ds_orig.node_scalars.update( 3 | {'random scalars':np.random.random(138)}) 4 | self.configure_scalars_window.ctl.node_size='random scalars' 5 | #self.configure_scalars_window.ctl.surf_color=None 6 | self.configure_scalars_window.ctl.node_color='random scalars' 7 | #self.configure_scalars_window.ctl.circle=None 8 | #self.configure_scalars_window.ctl.connmat=None 9 | self.controller.ds_orig.display_scalars() 10 | -------------------------------------------------------------------------------- /tests/show_random_scalars.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | self.controller.ds_orig.node_scalars.update( 3 | {'random scalars':np.random.random(138)}) 4 | self.configure_scalars_window.ctl.node_size='random scalars' 5 | self.configure_scalars_window.ctl.surf_color=None 6 | self.configure_scalars_window.ctl.node_color='random scalars' 7 | self.configure_scalars_window.ctl.circle=None 8 | self.configure_scalars_window.ctl.connmat=None 9 | self.configure_scalars_window.finished=True 10 | self.configure_scalars_window.notify=True 11 | -------------------------------------------------------------------------------- /tests/color_scheme_reverse.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.opts.default_map.cmap='bone' 2 | self.controller.ds_orig.opts.default_map.reverse=True 3 | self.controller.ds_orig.opts.activation_map.cmap='bone' 4 | self.controller.ds_orig.opts.activation_map.reverse=True 5 | self.controller.ds_orig.opts.connmat_map.cmap='bone' 6 | self.controller.ds_orig.opts.connmat_map.reverse=True 7 | 8 | load_parc('laus125', 'orders/laus125_cmp.txt', dataset=self.controller.ds_orig) 9 | load_adj('data/sample_gqi.npy', self.controller.ds_orig) 10 | -------------------------------------------------------------------------------- /tests/show_clustering_coef.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.calculate_graph_stats(2.) 2 | self.configure_scalars_window.ctl.node_size='clustering coefficient' 3 | self.configure_scalars_window.ctl.node_color='clustering coefficient' 4 | self.configure_scalars_window.ctl.surf_color='clustering coefficient' 5 | self.configure_scalars_window.ctl.circle='clustering coefficient' 6 | self.configure_scalars_window.ctl.connmat='clustering coefficient' 7 | self.configure_scalars_window.finished=True 8 | self.configure_scalars_window.notify=True 9 | -------------------------------------------------------------------------------- /tests/change_color_scheme.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.opts.default_map.cmap='bone' 2 | self.controller.ds_orig.opts.activation_map.cmap='custom_heat' 3 | self.controller.ds_orig.opts.activation_map.reverse=True 4 | self.controller.ds_orig.opts.connmat_map.cmap='file' 5 | self.controller.ds_orig.opts.connmat_map.fname='cmaps/sample_heat.lut' 6 | self.controller.ds_orig.opts.connmat_map.reverse=True 7 | 8 | load_parc('laus125', 'orders/laus125_cmp.txt', dataset=self.controller.ds_orig) 9 | 10 | load_adj('data/sample_gqi.npy', self.controller.ds_orig) 11 | -------------------------------------------------------------------------------- /tests/load_sample_fmri.py: -------------------------------------------------------------------------------- 1 | self.parcellation_chooser_window.ctl.parcellation_name='laus125' 2 | self.parcellation_chooser_window.ctl.labelnames_file='orders/laus125_cmp.txt' 3 | self.parcellation_chooser_window.finished=True 4 | self.parcellation_chooser_window.notify=True 5 | 6 | self.adjmat_chooser_window.ctl.adjmat='data/sample_fmri.npy' 7 | self.adjmat_chooser_window.ctl.adjmat_order='orders/laus125_cmp.txt' 8 | self.adjmat_chooser_window.ctl.ignore_deletes=True 9 | self.adjmat_chooser_window.finished=True 10 | self.adjmat_chooser_window.notify=True 11 | -------------------------------------------------------------------------------- /tests/color_scheme_file.py: -------------------------------------------------------------------------------- 1 | self.controller.ds_orig.opts.default_map.cmap='file' 2 | self.controller.ds_orig.opts.default_map.fname='cmaps/sample_heat.lut' 3 | self.controller.ds_orig.opts.activation_map.cmap='file' 4 | self.controller.ds_orig.opts.activation_map.fname='cmaps/sample_heat.lut' 5 | self.controller.ds_orig.opts.connmat_map.cmap='file' 6 | self.controller.ds_orig.opts.connmat_map.fname='cmaps/sample_heat.lut' 7 | 8 | load_parc('laus125', 'orders/laus125_cmp.txt', dataset=self.controller.ds_orig) 9 | load_adj('data/sample_gqi.npy', self.controller.ds_orig) 10 | -------------------------------------------------------------------------------- /cvu/cmaps/sample_heat.grad: -------------------------------------------------------------------------------- 1 | V 2.0 Color Gradient File 2 | ScalingFunction: 3 | ScalingParameter: 0.5 4 | ControlPoints: (pos fixed bindings h s v a) 5 | 0.0 True rgbhsva 0.604938271605 0.341772151899 1.0 0.0 6 | 0.137123745819 False rgbhsv 0.665535168196 0.812462731067 0.987341772152 0.0247491638796 7 | 0.28762541806 False rgbhsv 0.583333333333 0.0555555555556 0.455696202532 0.1 8 | 0.725752508361 False rgbhsv 0.5 0.0277777777778 0.455696202532 0.15 9 | 0.889632107023 False rgbhsv 0.0 1.0 0.974683544304 0.180602006689 10 | 1.0 True rgbhsva 0.160337552743 1.0 1.0 0.2 11 | -------------------------------------------------------------------------------- /tests/tractography_debug.py: -------------------------------------------------------------------------------- 1 | import tractography 2 | import os 3 | 4 | truff='/local_mount/space/truffles/1/users/rlaplant/' 5 | 6 | trk=os.path.join(truff,'data/qbi/hcps030/tracts20k.trk') 7 | b0=os.path.join(truff,'data/qbi/hcps030/dset/b0.nii.gz') 8 | subj='hcps030_FS' 9 | subjects_dir=os.path.join(truff,'data/hcpnmr/') 10 | fs_script='/usr/local/freesurfer/nmr-stable53-env' 11 | 12 | self.tark = tark = tractography.plot_fancily(trk) 13 | 14 | tractography.apply_affines_carefully(tark, b0, trk, subj, subjects_dir, 15 | fsenvsrc=fs_script) 16 | 17 | tractography.fix_skewing(tark) 18 | -------------------------------------------------------------------------------- /tests/color_scheme_scalars.py: -------------------------------------------------------------------------------- 1 | load_parc('laus125', 'orders/laus125_cmp.txt', dataset=self.controller.ds_orig) 2 | load_adj('data/sample_gqi.npy', self.controller.ds_orig) 3 | 4 | self.controller.ds_orig.calculate_graph_stats(1) #threshold as argument 5 | #this function does not block. the blocking is done in the GUI 6 | 7 | self.controller.ds_orig.opts.scalar_map.cmap='custom_heat' 8 | self.controller.ds_orig.opts.scalar_map.reverse=True 9 | 10 | self.configure_scalars_window.ctl.node_size='eigenvector centrality' 11 | self.configure_scalars_window.ctl.node_color='clustering coefficient' 12 | self.configure_scalars_window.ctl.connmat='average strength' 13 | self.configure_scalars_window.ctl.circle='binary kcore' 14 | self.controller.ds_orig.display_scalars() 15 | -------------------------------------------------------------------------------- /tests/new_dataset.py: -------------------------------------------------------------------------------- 1 | self.parcellation_chooser_window.ctl.new_dataset=True 2 | self.parcellation_chooser_window.ctl.new_dataset_name='sample_laus125' 3 | self.parcellation_chooser_window.ctl.parcellation_name='laus125' 4 | self.parcellation_chooser_window.ctl.labelnames_file='orders/laus125_cmp.txt' 5 | self.parcellation_chooser_window.finished=True 6 | self.parcellation_chooser_window.notify=True 7 | 8 | self.adjmat_chooser_window._current_dataset_list=[ 9 | self.controller.ds_instances['sample_laus125']] 10 | self.adjmat_chooser_window.ctl.adjmat='data/sample_laus125.npy' 11 | self.adjmat_chooser_window.ctl.adjmat_order='orders/laus125_alph.txt' 12 | self.adjmat_chooser_window.ctl.ignore_deletes=True 13 | self.adjmat_chooser_window.finished=True 14 | self.adjmat_chooser_window.notify=True 15 | -------------------------------------------------------------------------------- /tests/sample_across_modalities_shortcut.py: -------------------------------------------------------------------------------- 1 | fmri_ds = load_parc('laus125', 'orders/laus125_cmp.txt', new_dataset=True, 2 | dataset_name='fMRI network') 3 | gqi_ds = load_parc('laus125', 'orders/laus125_cmp.txt', new_dataset=True, 4 | dataset_name='Generalized Q-space Imaging network') 5 | meg_ds = load_parc('laus125', 'orders/laus125_cmp.txt', new_dataset=True, 6 | dataset_name='MEG synchronization likelihood network') 7 | 8 | #fMRI sample dataset is already in CMP ordering, no ordering arguments needed 9 | load_adj('data/sample_fmri.npy', fmri_ds) 10 | 11 | #GQI sample dataset is already in CMP ordering, no ordering arguments needed 12 | load_adj('data/sample_gqi.npy', gqi_ds) 13 | 14 | #to illustrate ordering operations the MEG sample dataset has been left in 15 | #alphabetical ordering 16 | load_adj('data/sample_meg_alphorder.npy', meg_ds, 17 | ordering='orders/laus125_alph.txt', 18 | ignore_deletes=True) 19 | -------------------------------------------------------------------------------- /cvu/cmap_images/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains lookup tables imported from pylab automaticaly by 2 | "cm2lut" script. Do not modify manually 3 | 4 | These colormaps are borrowed from matplotlib. See matplotlib license 5 | for license agreement (http://matplotlib.sourceforge.net/license.html) 6 | 7 | 34 of the colormaps are based on color specifications and designs 8 | developed by Cynthia Brewer (http://colorbrewer.org). The ColorBrewer 9 | palettes have been included under the terms of an Apache-stype license 10 | (for details, see the file LICENSE_COLORBREWER in the base directory of 11 | mayavi source). 12 | 13 | 7 palettes are from the Yorick scientific visalisation package, an 14 | evolution of the GIST package, both by David H. Munro. They are 15 | released under a BSD-like license (see LICENSE_YORICK in the base 16 | directory of mayavi source). 17 | 18 | 2 palettes are original creations of Roan LaPante, developed specially for cvu. 19 | The palettes themselves are released into the public domain. 20 | -------------------------------------------------------------------------------- /cvu/__init__.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | __version__='0.5.2' 19 | 20 | from .main import load_adj, load_parc, usage, main 21 | from .preprocessing import * 22 | from .shell_utils import * 23 | from .parsing_utils import * 24 | -------------------------------------------------------------------------------- /tests/tractography_window.py: -------------------------------------------------------------------------------- 1 | import tractography 2 | import os 3 | from options_struct import ParcellationChooserParameters 4 | 5 | truff='/local_mount/space/truffles/1/users/rlaplant/' 6 | 7 | subj='hcps030_FS' 8 | subjects_dir=os.path.join(truff,'data/hcpnmr/') 9 | 10 | pcp = self.parcellation_chooser_window.ctl 11 | pcp.subjects_dir = subjects_dir 12 | pcp.subject = subj 13 | pcp.parcellation_name = 'laus125' 14 | pcp.labelnames_file = 'orders/laus125_cmp.txt' 15 | pcp.surface_type = 'pial' 16 | 17 | self.parcellation_chooser_window.finished=True 18 | self.parcellation_chooser_window.notify=True 19 | 20 | trk=os.path.join(truff,'data/qbi/hcps030/tracts20k.trk') 21 | b0=os.path.join(truff,'data/qbi/hcps030/dset/b0.nii.gz') 22 | fs_script='/usr/local/freesurfer/nmr-stable53-env' 23 | 24 | tcp = self.tractography_chooser_window.ctl 25 | tcp.track_file = trk 26 | tcp.b0_volume = b0 27 | tcp.fs_setup = fs_script 28 | tcp.subjects_dir = subjects_dir 29 | tcp.subject = subj 30 | 31 | self.tractography_chooser_window.finished=True 32 | self.tractography_chooser_window.notify=True 33 | -------------------------------------------------------------------------------- /tests/tractography_native.py: -------------------------------------------------------------------------------- 1 | import tractography 2 | import os 3 | from options_struct import ParcellationChooserParameters 4 | 5 | truff='/local_mount/space/truffles/1/users/rlaplant/' 6 | 7 | s='hcps026' 8 | subj='%s_FS'%s 9 | subjects_dir=os.path.join(truff,'data/hcpnmr/') 10 | 11 | pcp = self.parcellation_chooser_window.ctl 12 | pcp.subjects_dir = subjects_dir 13 | pcp.subject = subj 14 | pcp.parcellation_name = 'aparc' 15 | pcp.labelnames_file = 'orders/aparc_cmp.txt' 16 | pcp.surface_type = 'pial' 17 | 18 | self.parcellation_chooser_window.finished=True 19 | self.parcellation_chooser_window.notify=True 20 | 21 | 22 | trk=os.path.join(truff,'data/qbi/%s/tracts20k.trk'%s) 23 | b0=os.path.join(truff,'data/qbi/%s/dset/b0.nii.gz'%s) 24 | fs_script='/usr/local/freesurfer/nmr-stable53-env' 25 | 26 | self.tark = tark = tractography.plot_fancily(trk) 27 | 28 | tractography.apply_affines_carefully(tark, b0, trk, subj, subjects_dir, 29 | fsenvsrc=fs_script) 30 | 31 | ds = self.controller.ds_orig 32 | 33 | tractography.fix_skewing(tark,use_fsavg5=False, 34 | lhsurf=ds.dv_3d.syrf_lh, rhsurf=ds.dv_3d.syrf_rh) 35 | -------------------------------------------------------------------------------- /bin/cvu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os 4 | import sys 5 | 6 | #pyside can cause problems with old versions of enable 7 | #however, forcing traits to use pyqt causes problems in anaconda 8 | #We will let the user set this optionally, it is good for debugging to not set. 9 | 10 | #os.environ['QT_API']='pyqt' 11 | #os.environ['QT_API']='pyside' 12 | 13 | #One or the other should usually be set so that matplotlib and pyface can 14 | #communicate and use the right Qt backend 15 | #pyside is a better default choice 16 | 17 | scriptdir=os.getcwd() 18 | python_cmd = 'pythonw' if sys.platform=='darwin' else 'python' 19 | #arguments = '%s %s'%(scriptdir, " ".join(sys.argv[1:])) 20 | #exec_cmd = "%s main.py %s" % (python_cmd, arguments) 21 | 22 | arguments = '%s main.py %s %s' % (python_cmd, scriptdir, " ".join(sys.argv[1:])) 23 | 24 | try: 25 | #see if cvu extracted locally 26 | os.chdir(os.path.join(os.path.dirname(os.path.dirname( 27 | os.path.realpath(__file__))),'cvu')) 28 | os.system(arguments) 29 | 30 | except OSError: 31 | #see if cvu installed to system python 32 | 33 | from cvu.main import main 34 | sys.argv = arguments.split() 35 | main() 36 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import setuptools 3 | 4 | def read(fname): 5 | return open(os.path.join(os.path.dirname(__file__), fname)).read() 6 | 7 | setuptools.setup( 8 | name="cvu", 9 | version="0.5.2", 10 | maintainer="Roan LaPlante", 11 | maintainer_email="rlaplant@nmr.mgh.harvard.edu", 12 | description=("A visualizer for human brain networks"), 13 | license="Visuddhimagga Sutta; GPLv3+", 14 | packages=["cvu"], 15 | package_data={'cvu':['data/*','fsavg5/label/*','fsavg5/surf/*','orders/*', 16 | 'cmaps/*', 'cmap_images/*']}, 17 | data_files=[('licenses',['licenses/ENTHOUGHT_LICENSE', 18 | 'licenses/YORICK_LICENSE','licenses/COLORBREWER_LICENSE']), 19 | ('',['README','LICENSE'])], 20 | scripts=['bin/cvu'], 21 | url="https://github.com/aestrivex/cvu", 22 | long_description=read('README'), 23 | classifiers=[ 24 | "Development Status :: 4 - Beta", 25 | "Environment :: X11 Applications", 26 | "Intended Audience :: Science/Research", 27 | "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", 28 | "Natural Language :: English", 29 | "Programming Language :: Python :: 2.7", 30 | "Topic :: Scientific/Engineering :: Visualization", 31 | ], 32 | platforms=['any'], 33 | install_requires=["bctpy","mne","nibabel"] 34 | ) 35 | -------------------------------------------------------------------------------- /cvu/orders/aparc_alph.txt: -------------------------------------------------------------------------------- 1 | lh_bankssts 2 | lh_caudalanteriorcingulate 3 | lh_caudalmiddlefrontal 4 | lh_cuneus 5 | lh_entorhinal 6 | lh_frontalpole 7 | lh_fusiform 8 | lh_inferiorparietal 9 | lh_inferiortemporal 10 | lh_insula 11 | lh_isthmuscingulate 12 | lh_lateraloccipital 13 | lh_lateralorbitofrontal 14 | lh_lingual 15 | lh_medialorbitofrontal 16 | lh_middletemporal 17 | lh_paracentral 18 | lh_parahippocampal 19 | lh_parsopercularis 20 | lh_parsorbitalis 21 | lh_parstriangularis 22 | lh_pericalcarine 23 | lh_postcentral 24 | lh_posteriorcingulate 25 | lh_precentral 26 | lh_precuneus 27 | lh_rostralanteriorcingulate 28 | lh_rostralmiddlefrontal 29 | lh_superiorfrontal 30 | lh_superiorparietal 31 | lh_superiortemporal 32 | lh_supramarginal 33 | lh_temporalpole 34 | lh_transversetemporal 35 | rh_bankssts 36 | rh_caudalanteriorcingulate 37 | rh_caudalmiddlefrontal 38 | rh_cuneus 39 | rh_entorhinal 40 | rh_frontalpole 41 | rh_fusiform 42 | rh_inferiorparietal 43 | rh_inferiortemporal 44 | rh_insula 45 | rh_isthmuscingulate 46 | rh_lateraloccipital 47 | rh_lateralorbitofrontal 48 | rh_lingual 49 | rh_medialorbitofrontal 50 | rh_middletemporal 51 | rh_paracentral 52 | rh_parahippocampal 53 | rh_parsopercularis 54 | rh_parsorbitalis 55 | rh_parstriangularis 56 | rh_pericalcarine 57 | rh_postcentral 58 | rh_posteriorcingulate 59 | rh_precentral 60 | rh_precuneus 61 | rh_rostralanteriorcingulate 62 | rh_rostralmiddlefrontal 63 | rh_superiorfrontal 64 | rh_superiorparietal 65 | rh_superiortemporal 66 | rh_supramarginal 67 | rh_temporalpole 68 | rh_transversetemporal 69 | -------------------------------------------------------------------------------- /cvu/orders/aparc_cmp.txt: -------------------------------------------------------------------------------- 1 | rh_lateralorbitofrontal 2 | rh_parsorbitalis 3 | rh_frontalpole 4 | rh_medialorbitofrontal 5 | rh_parstriangularis 6 | rh_parsopercularis 7 | rh_rostralmiddlefrontal 8 | rh_superiorfrontal 9 | rh_caudalmiddlefrontal 10 | rh_precentral 11 | rh_paracentral 12 | rh_rostralanteriorcingulate 13 | rh_caudalanteriorcingulate 14 | rh_posteriorcingulate 15 | rh_isthmuscingulate 16 | rh_postcentral 17 | rh_supramarginal 18 | rh_superiorparietal 19 | rh_inferiorparietal 20 | rh_precuneus 21 | rh_cuneus 22 | rh_pericalcarine 23 | rh_lateraloccipital 24 | rh_lingual 25 | rh_fusiform 26 | rh_parahippocampal 27 | rh_entorhinal 28 | rh_temporalpole 29 | rh_inferiortemporal 30 | rh_middletemporal 31 | rh_bankssts 32 | rh_superiortemporal 33 | rh_transversetemporal 34 | rh_insula 35 | lh_lateralorbitofrontal 36 | lh_parsorbitalis 37 | lh_frontalpole 38 | lh_medialorbitofrontal 39 | lh_parstriangularis 40 | lh_parsopercularis 41 | lh_rostralmiddlefrontal 42 | lh_superiorfrontal 43 | lh_caudalmiddlefrontal 44 | lh_precentral 45 | lh_paracentral 46 | lh_rostralanteriorcingulate 47 | lh_caudalanteriorcingulate 48 | lh_posteriorcingulate 49 | lh_isthmuscingulate 50 | lh_postcentral 51 | lh_supramarginal 52 | lh_superiorparietal 53 | lh_inferiorparietal 54 | lh_precuneus 55 | lh_cuneus 56 | lh_pericalcarine 57 | lh_lateraloccipital 58 | lh_lingual 59 | lh_fusiform 60 | lh_parahippocampal 61 | lh_entorhinal 62 | lh_temporalpole 63 | lh_inferiortemporal 64 | lh_middletemporal 65 | lh_bankssts 66 | lh_superiortemporal 67 | lh_transversetemporal 68 | lh_insula 69 | -------------------------------------------------------------------------------- /cvu/orders/laus36_alph.txt: -------------------------------------------------------------------------------- 1 | lh_bankssts 2 | lh_caudalanteriorcingulate 3 | lh_caudalmiddlefrontal 4 | delete 5 | lh_cuneus 6 | lh_entorhinal 7 | lh_fusiform 8 | lh_inferiorparietal 9 | lh_inferiortemporal 10 | lh_insula 11 | lh_isthmuscingulate 12 | lh_lateraloccipital 13 | lh_lateralorbitofrontal 14 | lh_lingual 15 | lh_medialorbitofrontal 16 | lh_middletemporal 17 | lh_paracentral 18 | lh_parahippocampal 19 | lh_parsopercularis 20 | lh_parsorbitalis 21 | lh_parstriangularis 22 | lh_pericalcarine 23 | lh_postcentral 24 | lh_posteriorcingulate 25 | lh_precentral 26 | lh_precuneus 27 | lh_rostralanteriorcingulate 28 | lh_rostralmiddlefrontal 29 | lh_superiorfrontal 30 | lh_superiorparietal 31 | lh_superiortemporal 32 | lh_supramarginal 33 | lh_temporalpole 34 | lh_transversetemporal 35 | delete 36 | rh_bankssts 37 | rh_caudalanteriorcingulate 38 | rh_caudalmiddlefrontal 39 | delete 40 | rh_cuneus 41 | rh_entorhinal 42 | rh_frontalpole 43 | rh_fusiform 44 | rh_inferiorparietal 45 | rh_inferiortemporal 46 | rh_insula 47 | rh_isthmuscingulate 48 | rh_lateraloccipital 49 | rh_lateralorbitofrontal 50 | rh_lingual 51 | rh_medialorbitofrontal 52 | rh_middletemporal 53 | rh_paracentral 54 | rh_parahippocampal 55 | rh_parsopercularis 56 | rh_parsorbitalis 57 | rh_parstriangularis 58 | rh_pericalcarine 59 | rh_postcentral 60 | rh_posteriorcingulate 61 | rh_precentral 62 | rh_precuneus 63 | rh_rostralanteriorcingulate 64 | rh_rostralmiddlefrontal 65 | rh_superiorfrontal 66 | rh_superiorparietal 67 | rh_superiortemporal 68 | rh_supramarginal 69 | rh_temporalpole 70 | rh_transversetemporal 71 | delete 72 | -------------------------------------------------------------------------------- /cvu/orders/laus36_cmp.txt: -------------------------------------------------------------------------------- 1 | rh_lateralorbitofrontal 2 | rh_parsorbitalis 3 | rh_frontalpole 4 | rh_medialorbitofrontal 5 | rh_parstriangularis 6 | rh_parsopercularis 7 | rh_rostralmiddlefrontal 8 | rh_superiorfrontal 9 | rh_caudalmiddlefrontal 10 | rh_precentral 11 | rh_paracentral 12 | rh_rostralanteriorcingulate 13 | rh_caudalanteriorcingulate 14 | rh_posteriorcingulate 15 | rh_isthmuscingulate 16 | rh_postcentral 17 | rh_supramarginal 18 | rh_superiorparietal 19 | rh_inferiorparietal 20 | rh_precuneus 21 | rh_cuneus 22 | rh_pericalcarine 23 | rh_lateraloccipital 24 | rh_lingual 25 | rh_fusiform 26 | rh_parahippocampal 27 | rh_entorhinal 28 | rh_temporalpole 29 | rh_inferiortemporal 30 | rh_middletemporal 31 | rh_bankssts 32 | rh_superiortemporal 33 | rh_transversetemporal 34 | rh_insula 35 | delete 36 | delete 37 | delete 38 | delete 39 | delete 40 | delete 41 | delete 42 | lh_lateralorbitofrontal 43 | lh_parsorbitalis 44 | delete 45 | lh_medialorbitofrontal 46 | lh_parstriangularis 47 | lh_parsopercularis 48 | lh_rostralmiddlefrontal 49 | lh_superiorfrontal 50 | lh_caudalmiddlefrontal 51 | lh_precentral 52 | lh_paracentral 53 | lh_rostralanteriorcingulate 54 | lh_caudalanteriorcingulate 55 | lh_posteriorcingulate 56 | lh_isthmuscingulate 57 | lh_postcentral 58 | lh_supramarginal 59 | lh_superiorparietal 60 | lh_inferiorparietal 61 | lh_precuneus 62 | lh_cuneus 63 | lh_pericalcarine 64 | lh_lateraloccipital 65 | lh_lingual 66 | lh_fusiform 67 | lh_parahippocampal 68 | lh_entorhinal 69 | lh_temporalpole 70 | lh_inferiortemporal 71 | lh_middletemporal 72 | lh_bankssts 73 | lh_superiortemporal 74 | lh_transversetemporal 75 | lh_insula 76 | delete 77 | delete 78 | delete 79 | delete 80 | delete 81 | delete 82 | delete 83 | delete 84 | -------------------------------------------------------------------------------- /tests/simple_screenshots.py: -------------------------------------------------------------------------------- 1 | try: 2 | os.makedirs('../tests/') 3 | except: 4 | pass 5 | 6 | try: 7 | os.remove('../tests/output/first_3D.png') 8 | except: 9 | pass 10 | 11 | try: 12 | os.remove('../tests/output/sparc_3D.png') 13 | except: 14 | pass 15 | 16 | try: 17 | os.remove('../tests/output/sparc_mat.png') 18 | except: 19 | pass 20 | 21 | try: 22 | os.remove('../tests/output/sparc_circ.png') 23 | except: 24 | pass 25 | 26 | #the incorrect scaling is done on whichever method goes first 27 | 28 | from mayavi import mlab 29 | #print self.controller.ds_orig.dv_3d.scene.mayavi_scene 30 | 31 | #mlab.savefig('../tests/output/direct3d.png',figure=self.controller.ds_orig.dv_3d.scene.mayavi_scene,size=(694,694)) 32 | 33 | 34 | self.save_snapshot_window.ctl.dpi=100 35 | 36 | self.save_snapshot_window.ctl.whichplot='connection matrix' 37 | self.save_snapshot_window.ctl.savefile='../tests/output/sparc_mat.png' 38 | self.save_snapshot_window.finished=True 39 | self.save_snapshot_window.notify=True 40 | 41 | #self.controller.ds_orig.dv_3d.hack_mlabsavefig('../tests/output/test3d.png', 42 | # size=(694,694)) 43 | 44 | self.save_snapshot_window.ctl.whichplot='3D brain' 45 | self.save_snapshot_window.ctl.savefile='../tests/output/first_3D.png' 46 | self.save_snapshot_window.finished=True 47 | self.save_snapshot_window.notify=True 48 | 49 | self.save_snapshot_window.ctl.dpi=100 50 | self.save_snapshot_window.ctl.whichplot='3D brain' 51 | self.save_snapshot_window.ctl.savefile='../tests/output/sparc_3D.png' 52 | self.save_snapshot_window.finished=True 53 | self.save_snapshot_window.notify=True 54 | 55 | self.save_snapshot_window.ctl.whichplot='circle plot' 56 | self.save_snapshot_window.ctl.savefile='../tests/output/sparc_circ.png' 57 | self.save_snapshot_window.finished=True 58 | self.save_snapshot_window.notify=True 59 | 60 | sys.exit(0) 61 | -------------------------------------------------------------------------------- /cvu/parsing_utils.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | def rreplace(s,old,new,occurrence): 19 | li=s.rsplit(old,occurrence) 20 | return new.join(li) 21 | 22 | def hemineutral(s): 23 | lhind=s.lower().find('lh') 24 | rhind=s.lower().find('rh') 25 | if lhind>rhind: 26 | return rreplace(s,'lh','%s',1) 27 | elif rhind>lhind: 28 | return rreplace(s,'rh','%s',1) 29 | else: 30 | return s 31 | 32 | def mangle_hemi(s): 33 | return '%s_%s'%(s[-2:],s[:-3]) 34 | 35 | def demangle_hemi(s): 36 | return '%s-%s'%(s[3:],s[:2]) 37 | 38 | def same_hemi(s1,s2,char=None): 39 | if char is None: return s1[0]==s2[0] 40 | else: return s1[0]==s2[0]==char 41 | 42 | #ALL FUNCTIONS THAT FOLLOW ARE NEEDED FOR GIFTI PROCESSING ONLY 43 | 44 | def str2intlist(s): 45 | import re 46 | return re.split(',| |;',s.strip('[]')) 47 | 48 | def appendhemis(olddict,hemi): 49 | return dict(map(lambda (k,v):(k,'%s%s'%(hemi,str(v))),olddict.items())) 50 | 51 | def eqfun(x): 52 | return lambda y:y==x 53 | -------------------------------------------------------------------------------- /licenses/ENTHOUGHT_LICENSE: -------------------------------------------------------------------------------- 1 | This license applies to mayavi, chaco, traits, traitsui, numpy, scipy, and 2 | other packages maintained from enthought via epd, canopy, or other various 3 | future incarnations. 4 | 5 | 6 | This software is OSI Certified Open Source Software. 7 | OSI Certified is a certification mark of the Open Source Initiative. 8 | 9 | Copyright (c) 2006, Enthought, Inc. 10 | All rights reserved. 11 | 12 | Redistribution and use in source and binary forms, with or without 13 | modification, are permitted provided that the following conditions are met: 14 | 15 | * Redistributions of source code must retain the above copyright notice, this 16 | list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above copyright notice, 18 | this list of conditions and the following disclaimer in the documentation 19 | and/or other materials provided with the distribution. 20 | * Neither the name of Enthought, Inc. nor the names of its contributors may 21 | be used to endorse or promote products derived from this software without 22 | specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 25 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 28 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /licenses/COLORBREWER_LICENSE: -------------------------------------------------------------------------------- 1 | Apache-Style Software License for ColorBrewer Color Schemes 2 | 3 | Version 1.1 4 | 5 | Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania 6 | State University. All rights reserved. Redistribution and use in source 7 | and binary forms, with or without modification, are permitted provided 8 | that the following conditions are met: 9 | 10 | 1. Redistributions as source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2. The end-user documentation included with the redistribution, if any, 14 | must include the following acknowledgment: "This product includes color 15 | specifications and designs developed by Cynthia Brewer 16 | (http://colorbrewer.org/)." Alternately, this acknowledgment may appear 17 | in 18 | the software itself, if and wherever such third-party acknowledgments 19 | normally appear. 20 | 21 | 3. The name "ColorBrewer" must not be used to endorse or promote products 22 | derived from this software without prior written permission. For written 23 | permission, please contact Cynthia Brewer at cbrewer@psu.edu. 24 | 25 | 4. Products derived from this software may not be called "ColorBrewer", 26 | nor may "ColorBrewer" appear in their name, without prior written 27 | permission of Cynthia Brewer. 28 | 29 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 30 | WARRANTIES, 31 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 32 | AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 33 | CYNTHIA BREWER, MARK HARROWER, OR THE PENNSYLVANIA STATE UNIVERSITY BE 34 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 35 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 36 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 37 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 38 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 40 | THE 41 | POSSIBILITY OF SUCH DAMAGE. 42 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Connectome Visualization Utility version 0.5.1 2 | Author: Roan LaPlante 3 | 4 | DESCRIPTION 5 | 6 | The Connectome Visualization Utility is a free and open source software project 7 | designed for the visualization of multi-modal, abstract brain networks. To 8 | facilitate visualization of network topology and modularity, cvu additionally 9 | interfaces with graph theory tools. 10 | 11 | The program is designed for scientists, but to run as a standalone application. 12 | 13 | COPYRIGHT INFORMATION 14 | 15 | This program strictly observes the tenets of fundamentalist Theravada Mahasi 16 | style Buddhism. Any use of this program in violation of these aforementioned 17 | tenets or in violation of the principles described in the Visuddhimagga Sutta is 18 | strictly prohibited and punishable by extensive Mahayana style practice. 19 | 20 | Note that the observation of the tenets of fundamentalist Theravada Mahasi 21 | style Buddhism and the Visuddhimagga Sutta is optional as long as the terms and 22 | conditions of the GNU GPLv3+ are upheld. 23 | 24 | DEPENDENCIES 25 | 26 | These dependencies are satisfied by installing a scientific python distribution 27 | such as Canopy or anaconda: 28 | 29 | matplotlib -- plotting library 30 | chaco -- interactive plotting library 31 | numpy -- math library 32 | mayavi -- interactive 3D visualization library 33 | 34 | These dependencies are *required* and must be manually installed into your 35 | python distribution. Typically this is as simple as typing 'pip install package' 36 | 37 | mne -- MNE python, a broad library for MNE processing that is used in CVU to 38 | manipulate surface and parcellation files. 39 | bctpy -- a graph theory library 40 | 41 | Optional dependencies: 42 | 43 | nibabel -- nibabel is a neuroimaging library that is used to locate subcortical 44 | structures. Without nibabel, subcortical structures may not appear in any 45 | parcellations. 46 | freesurfer -- freesurfer is a very powerful set of tools to do automatic 47 | segmentation and parcellation. CVU calls freesurfer commands to register 48 | tractography to the structural space. Without freesurfer, tractography 49 | cannot be visualized. 50 | -------------------------------------------------------------------------------- /cvu/color_legend.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | 20 | from traits.api import HasTraits,Str,List,RGBColor,Any 21 | from traitsui.api import View,Item,TableEditor,TextEditor,ObjectColumn 22 | 23 | class ColorColumn(ObjectColumn): 24 | def get_cell_color(self,object): 25 | #quick-and-dirty conversion from rgbcolor to color 26 | #TODO less hacky? 27 | return tuple(map(lambda c:int(round(c*255)),object.col)) 28 | 29 | class LegendEntry(HasTraits): 30 | metaregion=Str 31 | col=Any #RGBColor doesn't support alpha. It is easier to convert the 32 | #matplotlib alpha value to Color directly which does support alpha 33 | blank=Str('') 34 | def __init__(self,**traits): 35 | super(LegendEntry,self).__init__(**traits) 36 | 37 | class ColorLegend(HasTraits): 38 | entries=List(LegendEntry) 39 | 40 | class ColorLegendWindow(HasTraits): 41 | legend=List(LegendEntry) 42 | traits_view=View(Item(name='legend', 43 | editor=TableEditor(columns= 44 | [ObjectColumn(label='ROI',editor=TextEditor(), 45 | name='metaregion',style='readonly',editable=False), 46 | ColorColumn(label='color',editor=TextEditor(), 47 | name='blank',editable=False)], 48 | selection_bg_color=None,),show_label=False), 49 | kind='nonmodal',height=500,width=325,resizable=True, 50 | title='Fresh artichokes just -$3/lb',) 51 | -------------------------------------------------------------------------------- /tests/sample_across_modalities_menus.py: -------------------------------------------------------------------------------- 1 | #create the fMRI dataset 2 | self.parcellation_chooser_window.ctl.new_dataset=True 3 | self.parcellation_chooser_window.ctl.parcellation_name='laus125' 4 | self.parcellation_chooser_window.ctl.labelnames_file='orders/laus125_cmp.txt' 5 | self.parcellation_chooser_window.ctl.new_dataset_name='fMRI network' 6 | self.parcellation_chooser_window.finished=True 7 | self.parcellation_chooser_window.notify=True 8 | 9 | #create the GQI dataset. Most parameters in the window are left unchanged. 10 | self.parcellation_chooser_window.ctl.new_dataset_name=('Generalized Q-Space ' 11 | 'Imaging network') 12 | self.parcellation_chooser_window.notify=True 13 | 14 | #create the MEG dataset. Most parameters in the window are left unchanged. 15 | self.parcellation_chooser_window.ctl.new_dataset_name=('MEG synchronization ' 16 | 'likelihood network') 17 | self.parcellation_chooser_window.notify=True 18 | 19 | #load the fMRI data into the fMRI dataset 20 | self.adjmat_chooser_window._current_dataset_list = [ 21 | self.controller.ds_instances['fMRI network']] 22 | self.adjmat_chooser_window.ctl.adjmat='data/sample_fmri.npy' 23 | #parcellation and matrix orderings are the same so we leave the ordering blank 24 | self.adjmat_chooser_window.ctl.adjmat_order='' 25 | self.adjmat_chooser_window.finished=True 26 | self.adjmat_chooser_window.notify=True 27 | 28 | 29 | #load the GQI data into the GQI dataset 30 | self.adjmat_chooser_window._current_dataset_list = [ 31 | self.controller.ds_instances['Generalized Q-Space Imaging network']] 32 | self.adjmat_chooser_window.ctl.adjmat='data/sample_gqi.npy' 33 | # we leave the ordering information the same 34 | self.adjmat_chooser_window.notify=True 35 | 36 | 37 | #load the fMRI data into the fMRI dataset 38 | #to illustrate ordering operations the MEG sample dataset has been left in 39 | #alphabetical ordering 40 | self.adjmat_chooser_window._current_dataset_list = [ 41 | self.controller.ds_instances['MEG synchronization likelihood network']] 42 | self.adjmat_chooser_window.ctl.adjmat='data/sample_meg.npy' 43 | self.adjmat_chooser_window.ctl.adjmat_order='orders/laus125_alph.txt' 44 | self.adjmat_chooser_window.ctl.ignore_deletes=True 45 | self.adjmat_chooser_window.notify=True 46 | -------------------------------------------------------------------------------- /licenses/YORICK_LICENSE: -------------------------------------------------------------------------------- 1 | BSD-style license for gist/yorick colormaps. 2 | 3 | Copyright: 4 | 5 | Copyright (c) 1996. The Regents of the University of California. 6 | All rights reserved. 7 | 8 | Permission to use, copy, modify, and distribute this software for any 9 | purpose without fee is hereby granted, provided that this entire 10 | notice is included in all copies of any software which is or includes 11 | a copy or modification of this software and in all copies of the 12 | supporting documentation for such software. 13 | 14 | This work was produced at the University of California, Lawrence 15 | Livermore National Laboratory under contract no. W-7405-ENG-48 between 16 | the U.S. Department of Energy and The Regents of the University of 17 | California for the operation of UC LLNL. 18 | 19 | 20 | DISCLAIMER 21 | 22 | This software was prepared as an account of work sponsored by an 23 | agency of the United States Government. Neither the United States 24 | Government nor the University of California nor any of their 25 | employees, makes any warranty, express or implied, or assumes any 26 | liability or responsibility for the accuracy, completeness, or 27 | usefulness of any information, apparatus, product, or process 28 | disclosed, or represents that its use would not infringe 29 | privately-owned rights. Reference herein to any specific commercial 30 | products, process, or service by trade name, trademark, manufacturer, 31 | or otherwise, does not necessarily constitute or imply its 32 | endorsement, recommendation, or favoring by the United States 33 | Government or the University of California. The views and opinions of 34 | authors expressed herein do not necessarily state or reflect those of 35 | the United States Government or the University of California, and 36 | shall not be used for advertising or product endorsement purposes. 37 | 38 | 39 | AUTHOR 40 | 41 | David H. Munro wrote Yorick and Gist. Berkeley Yacc (byacc) generated 42 | the Yorick parser. The routines in Math are from LAPACK and FFTPACK; 43 | MathC contains C translations by David H. Munro. The algorithms for 44 | Yorick's random number generator and several special functions in 45 | Yorick/include were taken from Numerical Recipes by Press, et. al., 46 | although the Yorick implementations are unrelated to those in 47 | Numerical Recipes. A small amount of code in Gist was adapted from 48 | the X11R4 release, copyright M.I.T. -- the complete copyright notice 49 | may be found in the (unused) file Gist/host.c. 50 | -------------------------------------------------------------------------------- /cvu/orders/laus60_alph.txt: -------------------------------------------------------------------------------- 1 | lh_bankssts_1 2 | lh_caudalanteriorcingulate_1 3 | lh_caudalmiddlefrontal_1 4 | delete 5 | lh_cuneus_1 6 | lh_entorhinal_1 7 | lh_fusiform_1 8 | lh_fusiform_2 9 | lh_inferiorparietal_1 10 | lh_inferiorparietal_2 11 | lh_inferiortemporal_1 12 | lh_inferiortemporal_2 13 | lh_insula_1 14 | lh_insula_2 15 | lh_isthmuscingulate_1 16 | lh_lateraloccipital_1 17 | lh_lateraloccipital_2 18 | lh_lateralorbitofrontal_1 19 | lh_lateralorbitofrontal_2 20 | lh_lingual_1 21 | lh_lingual_2 22 | lh_medialorbitofrontal_1 23 | lh_middletemporal_1 24 | lh_middletemporal_2 25 | lh_paracentral_1 26 | lh_parahippocampal_1 27 | lh_parsopercularis_1 28 | lh_parsorbitalis_1 29 | lh_parstriangularis_1 30 | lh_pericalcarine_1 31 | lh_postcentral_1 32 | lh_postcentral_2 33 | lh_postcentral_3 34 | lh_posteriorcingulate_1 35 | lh_precentral_1 36 | lh_precentral_2 37 | lh_precentral_3 38 | lh_precentral_4 39 | lh_precuneus_1 40 | lh_precuneus_2 41 | lh_rostralanteriorcingulate_1 42 | lh_rostralmiddlefrontal_1 43 | lh_rostralmiddlefrontal_2 44 | lh_rostralmiddlefrontal_3 45 | lh_superiorfrontal_1 46 | lh_superiorfrontal_2 47 | lh_superiorfrontal_3 48 | lh_superiorfrontal_4 49 | lh_superiorparietal_1 50 | lh_superiorparietal_2 51 | lh_superiorparietal_3 52 | lh_superiortemporal_1 53 | lh_superiortemporal_2 54 | lh_supramarginal_1 55 | lh_supramarginal_2 56 | lh_temporalpole_1 57 | lh_transversetemporal_1 58 | delete 59 | rh_bankssts_1 60 | rh_caudalanteriorcingulate_1 61 | rh_caudalmiddlefrontal_1 62 | delete 63 | rh_cuneus_1 64 | rh_entorhinal_1 65 | rh_frontalpole_1 66 | rh_fusiform_1 67 | rh_fusiform_2 68 | rh_inferiorparietal_1 69 | rh_inferiorparietal_2 70 | rh_inferiorparietal_3 71 | rh_inferiortemporal_1 72 | rh_inferiortemporal_2 73 | rh_insula_1 74 | rh_insula_2 75 | rh_isthmuscingulate_1 76 | rh_lateraloccipital_1 77 | rh_lateraloccipital_2 78 | rh_lateraloccipital_3 79 | rh_lateralorbitofrontal_1 80 | rh_lateralorbitofrontal_2 81 | rh_lingual_1 82 | rh_lingual_2 83 | rh_medialorbitofrontal_1 84 | rh_medialorbitofrontal_2 85 | rh_middletemporal_1 86 | rh_middletemporal_2 87 | rh_paracentral_1 88 | rh_parahippocampal_1 89 | rh_parsopercularis_1 90 | rh_parsorbitalis_1 91 | rh_parstriangularis_1 92 | rh_pericalcarine_1 93 | rh_postcentral_1 94 | rh_postcentral_2 95 | rh_posteriorcingulate_1 96 | rh_precentral_1 97 | rh_precentral_2 98 | rh_precentral_3 99 | rh_precuneus_1 100 | rh_precuneus_2 101 | rh_rostralanteriorcingulate_1 102 | rh_rostralmiddlefrontal_1 103 | rh_rostralmiddlefrontal_2 104 | rh_superiorfrontal_1 105 | rh_superiorfrontal_2 106 | rh_superiorfrontal_3 107 | rh_superiorfrontal_4 108 | rh_superiorparietal_1 109 | rh_superiorparietal_2 110 | rh_superiorparietal_3 111 | rh_superiortemporal_1 112 | rh_superiortemporal_2 113 | rh_supramarginal_1 114 | rh_supramarginal_2 115 | rh_temporalpole_1 116 | rh_transversetemporal_1 117 | delete 118 | -------------------------------------------------------------------------------- /cvu/orders/laus60_cmp.txt: -------------------------------------------------------------------------------- 1 | rh_lateralorbitofrontal_1 2 | rh_lateralorbitofrontal_2 3 | rh_parsorbitalis_1 4 | rh_frontalpole_1 5 | rh_medialorbitofrontal_1 6 | rh_medialorbitofrontal_2 7 | rh_parstriangularis_1 8 | rh_parsopercularis_1 9 | rh_rostralmiddlefrontal_1 10 | rh_rostralmiddlefrontal_2 11 | rh_superiorfrontal_1 12 | rh_superiorfrontal_2 13 | rh_superiorfrontal_3 14 | rh_superiorfrontal_4 15 | rh_caudalmiddlefrontal_1 16 | rh_precentral_1 17 | rh_precentral_2 18 | rh_precentral_3 19 | rh_paracentral_1 20 | rh_rostralanteriorcingulate_1 21 | rh_caudalanteriorcingulate_1 22 | rh_posteriorcingulate_1 23 | rh_isthmuscingulate_1 24 | rh_postcentral_1 25 | rh_postcentral_2 26 | rh_supramarginal_1 27 | rh_supramarginal_2 28 | rh_superiorparietal_1 29 | rh_superiorparietal_2 30 | rh_superiorparietal_3 31 | rh_inferiorparietal_1 32 | rh_inferiorparietal_2 33 | rh_inferiorparietal_3 34 | rh_precuneus_1 35 | rh_precuneus_2 36 | rh_cuneus_1 37 | rh_pericalcarine_1 38 | rh_lateraloccipital_1 39 | rh_lateraloccipital_2 40 | rh_lateraloccipital_3 41 | rh_lingual_1 42 | rh_lingual_2 43 | rh_fusiform_1 44 | rh_fusiform_2 45 | rh_parahippocampal_1 46 | rh_entorhinal_1 47 | rh_temporalpole_1 48 | rh_inferiortemporal_1 49 | rh_inferiortemporal_2 50 | rh_middletemporal_1 51 | rh_middletemporal_2 52 | rh_bankssts_1 53 | rh_superiortemporal_1 54 | rh_superiortemporal_2 55 | rh_transversetemporal_1 56 | rh_insula_1 57 | rh_insula_2 58 | delete 59 | delete 60 | delete 61 | delete 62 | delete 63 | delete 64 | delete 65 | lh_lateralorbitofrontal_1 66 | lh_lateralorbitofrontal_2 67 | lh_parsorbitalis_1 68 | delete 69 | lh_medialorbitofrontal_1 70 | lh_parstriangularis_1 71 | lh_parsopercularis_1 72 | lh_rostralmiddlefrontal_1 73 | lh_rostralmiddlefrontal_2 74 | lh_rostralmiddlefrontal_3 75 | lh_superiorfrontal_1 76 | lh_superiorfrontal_2 77 | lh_superiorfrontal_3 78 | lh_superiorfrontal_4 79 | lh_caudalmiddlefrontal_1 80 | lh_precentral_1 81 | lh_precentral_2 82 | lh_precentral_3 83 | lh_precentral_4 84 | lh_paracentral_1 85 | lh_rostralanteriorcingulate_1 86 | lh_caudalanteriorcingulate_1 87 | lh_posteriorcingulate_1 88 | lh_isthmuscingulate_1 89 | lh_postcentral_1 90 | lh_postcentral_2 91 | lh_postcentral_3 92 | lh_supramarginal_1 93 | lh_supramarginal_2 94 | lh_superiorparietal_1 95 | lh_superiorparietal_2 96 | lh_superiorparietal_3 97 | lh_inferiorparietal_1 98 | lh_inferiorparietal_2 99 | lh_precuneus_1 100 | lh_precuneus_2 101 | lh_cuneus_1 102 | lh_pericalcarine_1 103 | lh_lateraloccipital_1 104 | lh_lateraloccipital_2 105 | lh_lingual_1 106 | lh_lingual_2 107 | lh_fusiform_1 108 | lh_fusiform_2 109 | lh_parahippocampal_1 110 | lh_entorhinal_1 111 | lh_temporalpole_1 112 | lh_inferiortemporal_1 113 | lh_inferiortemporal_2 114 | lh_middletemporal_1 115 | lh_middletemporal_2 116 | lh_bankssts_1 117 | lh_superiortemporal_1 118 | lh_superiortemporal_2 119 | lh_transversetemporal_1 120 | lh_insula_1 121 | lh_insula_2 122 | delete 123 | delete 124 | delete 125 | delete 126 | delete 127 | delete 128 | delete 129 | delete 130 | -------------------------------------------------------------------------------- /cvu/utils.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | from traits.api import (HasTraits,Any,Property,List,Str) 19 | from traitsui.api import (View,Item) 20 | 21 | class CVUError(Exception): 22 | pass 23 | 24 | class DisplayMetadata(HasTraits): 25 | subject_name=Str 26 | parc_name=Str 27 | adj_filename=Str 28 | 29 | traits_view = View( 30 | Item('subject_name',style='readonly'), 31 | Item('parc_name',style='readonly'), 32 | Item('adj_filename',style='readonly',width=250,height=5),) 33 | 34 | class DatasetMetadataElement(HasTraits): 35 | _controller=Any #Controller for the entire program 36 | all_datasets=Property(depends_on='_controller:datasets') 37 | def _get_all_datasets(self): 38 | return self._controller.ds_instances.values() 39 | 40 | _current_dataset_list=List #List(Dataset) 41 | current_dataset=Property(depends_on='_current_dataset_list') 42 | def _get_current_dataset(self): 43 | try: return self._current_dataset_list[0] 44 | except IndexError: return None 45 | 46 | def __init__(self,controller,dataset=None,**kwargs): 47 | super(DatasetMetadataElement,self).__init__(**kwargs) 48 | self._controller=controller 49 | if dataset==None: 50 | self._current_dataset_list=[controller.ds_orig] 51 | else: 52 | self._current_dataset_list=[dataset] 53 | 54 | # file chooser functions are deprecated 55 | def file_chooser(**kwargs): 56 | # use kwarg initialdir='/some_path' 57 | from Tkinter import Tk 58 | Tk().withdraw() 59 | from tkFileDialog import askopenfilename 60 | return askopenfilename(**kwargs) 61 | 62 | def fancy_file_chooser(main_window): 63 | from traits.api import HasPrivateTraits,File,Str,on_trait_change 64 | from traitsui.api import View,Item,FileEditor,OKCancelButtons 65 | 66 | class FileChooserWindow(HasPrivateTraits): 67 | f=File 68 | _fn=Str 69 | traits_view=View( 70 | Item(name='_fn',show_label=False), 71 | Item(name='f',editor=FileEditor(),style='custom', 72 | height=500,width=500,show_label=False), 73 | buttons=OKCancelButtons,kind='nonmodal', 74 | title="This should be extremely inconvenient") 75 | 76 | @on_trait_change('_fn') 77 | def f_chg(self): 78 | self.f=self._fn 79 | 80 | main_window.file_chooser_window=FileChooserWindow() 81 | main_window.file_chooser_window.edit_traits() 82 | -------------------------------------------------------------------------------- /cvu/shell_utils.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | from utils import CVUError 19 | 20 | def sh_cmd(cmd): 21 | import subprocess; import os 22 | with open(os.devnull,'wb') as devnull: 23 | try: 24 | subprocess.check_call(cmd,#stdout=devnull,stderr=subprocess.STDOUT, 25 | shell=True) 26 | except subprocess.CalledProcessError as e: 27 | raise CVUError(str(e)) 28 | 29 | def sh_cmd_grep(cmd,grep): 30 | #this function is inspired by a similar function from connectomemapper 31 | import subprocess; import os; import random; import time; import tempfile 32 | t=random.randint(1,10000000) 33 | try: os.mkdir(os.path.join(tempfile.gettempdir(),'cvu')) 34 | except OSError: pass 35 | fname=os.path.join(tempfile.gettempdir(),"out_fifo_%s" % str(t)) 36 | 37 | try: os.unlink(fname) 38 | except: pass 39 | 40 | retln=[] 41 | os.mkfifo(fname) 42 | try: 43 | fifo=os.fdopen(os.open(fname,os.O_RDONLY|os.O_NONBLOCK)) 44 | newcmd="( %s ) 1>%s"%(cmd,fname) 45 | process=subprocess.Popen( newcmd, shell=True, stdout=subprocess.PIPE, 46 | stderr=subprocess.PIPE ) 47 | 48 | while process.returncode == None: 49 | time.sleep(.5) 50 | process.poll() 51 | try: 52 | ln=fifo.readline().strip() 53 | except: continue 54 | if ln and grep in ln: 55 | retln.append(ln) 56 | rem=fifo.read() 57 | if rem: 58 | for ln in [ln for ln in rem.split('\n') if ln.strip()]: 59 | if grep in ln: 60 | retln.append(ln) 61 | if process.returncode: 62 | raise CVUError('%s failed with error code %s' % 63 | (cmd,process.returncode)) 64 | finally: 65 | try: os.unlink(fname) 66 | except: pass 67 | return retln 68 | 69 | def sh_cmd_retproc(cmd, debug=False): 70 | import subprocess; import os 71 | with open(os.devnull,'wb') as devnull: 72 | outfd = None if debug else devnull 73 | 74 | process=subprocess.Popen(cmd,shell=True,stdin=subprocess.PIPE, 75 | stdout=outfd,stderr=outfd) 76 | 77 | #checks to see if the specified command was bad 78 | if process.poll(): 79 | process.kill() 80 | raise CVUError('% failed with error code %s' % 81 | (cmd,process.returncode)) 82 | return process 83 | 84 | def tcsh_env_interpreter(source_fname): 85 | import subprocess; import os 86 | 87 | cmd=['tcsh','-c','source %s && env' % source_fname] 88 | 89 | proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=False) 90 | for ln in proc.stdout: 91 | ln=ln.strip() 92 | k,_,v=ln.partition("=") 93 | os.environ[k]=v 94 | 95 | #proc.communicate() 96 | -------------------------------------------------------------------------------- /cvu/orders/sparc.txt: -------------------------------------------------------------------------------- 1 | delete 2 | lh_bankssts 3 | lh_caudalanteriorcingulate 4 | delete 5 | lh_cuneus 6 | lh_entorhinal 7 | lh_isthmuscingulate 8 | lh_parahippocampal 9 | lh_parsopercularis 10 | lh_parsorbitalis 11 | lh_parstriangularis 12 | lh_pericalcarine 13 | lh_posteriorcingulate 14 | lh_rostralanteriorcingulate 15 | lh_frontalpole 16 | lh_temporalpole 17 | lh_transversetemporal 18 | lh_insula 19 | lh_caudalmiddlefrontal_div1 20 | lh_caudalmiddlefrontal_div2 21 | lh_fusiform_div1 22 | lh_fusiform_div2 23 | lh_fusiform_div3 24 | lh_inferiorparietal_div1 25 | lh_inferiorparietal_div2 26 | lh_inferiorparietal_div3 27 | lh_inferiortemporal_div1 28 | lh_inferiortemporal_div2 29 | lh_inferiortemporal_div3 30 | lh_lateraloccipital_div1 31 | lh_lateraloccipital_div2 32 | lh_lateralorbitofrontal_div1 33 | lh_lateralorbitofrontal_div2 34 | lh_lingual_div1 35 | lh_lingual_div2 36 | lh_medialorbitofrontal_div1 37 | lh_medialorbitofrontal_div2 38 | lh_middletemporal_div1 39 | lh_middletemporal_div2 40 | lh_middletemporal_div3 41 | lh_paracentral_div1 42 | lh_paracentral_div2 43 | lh_postcentral_div1 44 | lh_postcentral_div2 45 | lh_postcentral_div3 46 | lh_postcentral_div4 47 | lh_precentral_div1 48 | lh_precentral_div2 49 | lh_precentral_div3 50 | lh_precentral_div4 51 | lh_precuneus_div1 52 | lh_precuneus_div2 53 | lh_precuneus_div3 54 | lh_rostralmiddlefrontal_div1 55 | lh_rostralmiddlefrontal_div2 56 | lh_rostralmiddlefrontal_div3 57 | lh_superiorfrontal_div1 58 | lh_superiorfrontal_div2 59 | lh_superiorfrontal_div3 60 | lh_superiorfrontal_div4 61 | lh_superiorfrontal_div5 62 | lh_superiorfrontal_div6 63 | lh_superiorparietal_div1 64 | lh_superiorparietal_div2 65 | lh_superiorparietal_div3 66 | lh_superiorparietal_div4 67 | lh_superiortemporal_div1 68 | lh_superiortemporal_div2 69 | lh_superiortemporal_div3 70 | lh_supramarginal_div1 71 | lh_supramarginal_div2 72 | delete 73 | rh_bankssts 74 | rh_caudalanteriorcingulate 75 | delete 76 | rh_cuneus 77 | rh_entorhinal 78 | rh_isthmuscingulate 79 | rh_parahippocampal 80 | rh_parsopercularis 81 | rh_parsorbitalis 82 | rh_parstriangularis 83 | rh_pericalcarine 84 | rh_posteriorcingulate 85 | rh_rostralanteriorcingulate 86 | rh_frontalpole 87 | rh_temporalpole 88 | rh_transversetemporal 89 | rh_insula 90 | rh_caudalmiddlefrontal_div1 91 | rh_caudalmiddlefrontal_div2 92 | rh_fusiform_div1 93 | rh_fusiform_div2 94 | rh_fusiform_div3 95 | rh_inferiorparietal_div1 96 | rh_inferiorparietal_div2 97 | rh_inferiorparietal_div3 98 | rh_inferiortemporal_div1 99 | rh_inferiortemporal_div2 100 | rh_inferiortemporal_div3 101 | rh_lateraloccipital_div1 102 | rh_lateraloccipital_div2 103 | rh_lateralorbitofrontal_div1 104 | rh_lateralorbitofrontal_div2 105 | rh_lingual_div1 106 | rh_lingual_div2 107 | rh_medialorbitofrontal_div1 108 | rh_medialorbitofrontal_div2 109 | rh_middletemporal_div1 110 | rh_middletemporal_div2 111 | rh_middletemporal_div3 112 | rh_paracentral_div1 113 | rh_paracentral_div2 114 | rh_postcentral_div1 115 | rh_postcentral_div2 116 | rh_postcentral_div3 117 | rh_postcentral_div4 118 | rh_precentral_div1 119 | rh_precentral_div2 120 | rh_precentral_div3 121 | rh_precentral_div4 122 | rh_precuneus_div1 123 | rh_precuneus_div2 124 | rh_precuneus_div3 125 | rh_rostralmiddlefrontal_div1 126 | rh_rostralmiddlefrontal_div2 127 | rh_rostralmiddlefrontal_div3 128 | rh_superiorfrontal_div1 129 | rh_superiorfrontal_div2 130 | rh_superiorfrontal_div3 131 | rh_superiorfrontal_div4 132 | rh_superiorfrontal_div5 133 | rh_superiorfrontal_div6 134 | rh_superiorparietal_div1 135 | rh_superiorparietal_div2 136 | rh_superiorparietal_div3 137 | rh_superiorparietal_div4 138 | rh_superiortemporal_div1 139 | rh_superiortemporal_div2 140 | rh_superiortemporal_div3 141 | rh_supramarginal_div1 142 | rh_supramarginal_div2 143 | -------------------------------------------------------------------------------- /cvu/orders/aparc2009_alph.txt: -------------------------------------------------------------------------------- 1 | lh_G_Ins_lg_and_S_cent_ins 2 | lh_G_and_S_cingul-Ant 3 | lh_G_and_S_cingul-Mid-Ant 4 | lh_G_and_S_cingul-Mid-Post 5 | lh_G_and_S_frontomargin 6 | lh_G_and_S_occipital_inf 7 | lh_G_and_S_paracentral 8 | lh_G_and_S_subcentral 9 | lh_G_and_S_transv_frontopol 10 | lh_G_cingul-Post-dorsal 11 | lh_G_cingul-Post-ventral 12 | lh_G_cuneus 13 | lh_G_front_inf-Opercular 14 | lh_G_front_inf-Orbital 15 | lh_G_front_inf-Triangul 16 | lh_G_front_middle 17 | lh_G_front_sup 18 | lh_G_insular_short 19 | lh_G_oc-temp_lat-fusifor 20 | lh_G_oc-temp_med-Lingual 21 | lh_G_oc-temp_med-Parahip 22 | lh_G_occipital_middle 23 | lh_G_occipital_sup 24 | lh_G_orbital 25 | lh_G_pariet_inf-Angular 26 | lh_G_pariet_inf-Supramar 27 | lh_G_parietal_sup 28 | lh_G_postcentral 29 | lh_G_precentral 30 | lh_G_precuneus 31 | lh_G_rectus 32 | lh_G_subcallosal 33 | lh_G_temp_sup-G_T_transv 34 | lh_G_temp_sup-Lateral 35 | lh_G_temp_sup-Plan_polar 36 | lh_G_temp_sup-Plan_tempo 37 | lh_G_temporal_inf 38 | lh_G_temporal_middle 39 | lh_Lat_Fis-ant-Horizont 40 | lh_Lat_Fis-ant-Vertical 41 | lh_Lat_Fis-post 42 | lh_Medial_wall 43 | lh_Pole_occipital 44 | lh_Pole_temporal 45 | lh_S_calcarine 46 | lh_S_central 47 | lh_S_cingul-Marginalis 48 | lh_S_circular_insula_ant 49 | lh_S_circular_insula_inf 50 | lh_S_circular_insula_sup 51 | lh_S_collat_transv_ant 52 | lh_S_collat_transv_post 53 | lh_S_front_inf 54 | lh_S_front_middle 55 | lh_S_front_sup 56 | lh_S_interm_prim-Jensen 57 | lh_S_intrapariet_and_P_trans 58 | lh_S_oc-temp_lat 59 | lh_S_oc-temp_med_and_Lingual 60 | lh_S_oc_middle_and_Lunatus 61 | lh_S_oc_sup_and_transversal 62 | lh_S_occipital_ant 63 | lh_S_orbital-H_Shaped 64 | lh_S_orbital_lateral 65 | lh_S_orbital_med-olfact 66 | lh_S_parieto_occipital 67 | lh_S_pericallosal 68 | lh_S_postcentral 69 | lh_S_precentral-inf-part 70 | lh_S_precentral-sup-part 71 | lh_S_suborbital 72 | lh_S_subparietal 73 | lh_S_temporal_inf 74 | lh_S_temporal_sup 75 | lh_S_temporal_transverse 76 | rh_G_Ins_lg_and_S_cent_ins 77 | rh_G_and_S_cingul-Ant 78 | rh_G_and_S_cingul-Mid-Ant 79 | rh_G_and_S_cingul-Mid-Post 80 | rh_G_and_S_frontomargin 81 | rh_G_and_S_occipital_inf 82 | rh_G_and_S_paracentral 83 | rh_G_and_S_subcentral 84 | rh_G_and_S_transv_frontopol 85 | rh_G_cingul-Post-dorsal 86 | rh_G_cingul-Post-ventral 87 | rh_G_cuneus 88 | rh_G_front_inf-Opercular 89 | rh_G_front_inf-Orbital 90 | rh_G_front_inf-Triangul 91 | rh_G_front_middle 92 | rh_G_front_sup 93 | rh_G_insular_short 94 | rh_G_oc-temp_lat-fusifor 95 | rh_G_oc-temp_med-Lingual 96 | rh_G_oc-temp_med-Parahip 97 | rh_G_occipital_middle 98 | rh_G_occipital_sup 99 | rh_G_orbital 100 | rh_G_pariet_inf-Angular 101 | rh_G_pariet_inf-Supramar 102 | rh_G_parietal_sup 103 | rh_G_postcentral 104 | rh_G_precentral 105 | rh_G_precuneus 106 | rh_G_rectus 107 | rh_G_subcallosal 108 | rh_G_temp_sup-G_T_transv 109 | rh_G_temp_sup-Lateral 110 | rh_G_temp_sup-Plan_polar 111 | rh_G_temp_sup-Plan_tempo 112 | rh_G_temporal_inf 113 | rh_G_temporal_middle 114 | rh_Lat_Fis-ant-Horizont 115 | rh_Lat_Fis-ant-Vertical 116 | rh_Lat_Fis-post 117 | rh_Medial_wall 118 | rh_Pole_occipital 119 | rh_Pole_temporal 120 | rh_S_calcarine 121 | rh_S_central 122 | rh_S_cingul-Marginalis 123 | rh_S_circular_insula_ant 124 | rh_S_circular_insula_inf 125 | rh_S_circular_insula_sup 126 | rh_S_collat_transv_ant 127 | rh_S_collat_transv_post 128 | rh_S_front_inf 129 | rh_S_front_middle 130 | rh_S_front_sup 131 | rh_S_interm_prim-Jensen 132 | rh_S_intrapariet_and_P_trans 133 | rh_S_oc-temp_lat 134 | rh_S_oc-temp_med_and_Lingual 135 | rh_S_oc_middle_and_Lunatus 136 | rh_S_oc_sup_and_transversal 137 | rh_S_occipital_ant 138 | rh_S_orbital-H_Shaped 139 | rh_S_orbital_lateral 140 | rh_S_orbital_med-olfact 141 | rh_S_parieto_occipital 142 | rh_S_pericallosal 143 | rh_S_postcentral 144 | rh_S_precentral-inf-part 145 | rh_S_precentral-sup-part 146 | rh_S_suborbital 147 | rh_S_subparietal 148 | rh_S_temporal_inf 149 | rh_S_temporal_sup 150 | rh_S_temporal_transverse 151 | -------------------------------------------------------------------------------- /cvu/orders/aparc2009_cmplike.txt: -------------------------------------------------------------------------------- 1 | lh_G_orbital 2 | lh_S_orbital-H_Shaped 3 | lh_S_orbital_lateral 4 | lh_G_and_S_frontomargin 5 | lh_G_and_S_transv_frontopol 6 | lh_G_rectus 7 | lh_S_suborbital 8 | lh_S_orbital_med-olfact 9 | lh_G_and_S_cingul-Ant 10 | lh_G_subcallosal 11 | lh_G_and_S_cingul-Mid-Ant 12 | lh_S_pericallosal 13 | lh_G_front_sup 14 | lh_S_front_sup 15 | lh_G_front_middle 16 | lh_S_front_middle 17 | lh_S_front_inf 18 | lh_G_front_inf-Orbital 19 | lh_G_front_inf-Triangul 20 | lh_G_front_inf-Opercular 21 | lh_Lat_Fis-ant-Horizont 22 | lh_Lat_Fis-ant-Vertical 23 | lh_S_circular_insula_ant 24 | lh_S_circular_insula_sup 25 | lh_G_insular_short 26 | lh_S_precentral-inf-part 27 | lh_G_precentral 28 | lh_S_precentral-sup-part 29 | lh_G_and_S_cingul-Mid-Post 30 | lh_Medial_wall 31 | lh_G_and_S_subcentral 32 | lh_S_central 33 | lh_G_postcentral 34 | lh_S_postcentral 35 | lh_S_cingul-Marginalis 36 | lh_G_cingul-Post-dorsal 37 | lh_G_cingul-Post-ventral 38 | lh_G_and_S_paracentral 39 | lh_G_precuneus 40 | lh_S_subparietal 41 | lh_G_pariet_inf-Supramar 42 | lh_S_interm_prim-Jensen 43 | lh_G_pariet_inf-Angular 44 | lh_S_intrapariet_and_P_trans 45 | lh_G_parietal_sup 46 | lh_S_parieto_occipital 47 | lh_G_cuneus 48 | lh_S_calcarine 49 | lh_G_occipital_sup 50 | lh_S_oc_sup_and_transversal 51 | lh_G_oc-temp_med-Lingual 52 | lh_G_occipital_middle 53 | lh_S_oc_middle_and_Lunatus 54 | lh_S_collat_transv_post 55 | lh_Pole_occipital 56 | lh_G_and_S_occipital_inf 57 | lh_S_occipital_ant 58 | lh_G_oc-temp_lat-fusifor 59 | lh_S_oc-temp_lat 60 | lh_S_oc-temp_med_and_Lingual 61 | lh_Lat_Fis-post 62 | lh_G_temp_sup-Plan_tempo 63 | lh_S_temporal_sup 64 | lh_S_temporal_transverse 65 | lh_G_temp_sup-G_T_transv 66 | lh_G_temporal_middle 67 | lh_S_temporal_inf 68 | lh_G_temporal_inf 69 | lh_G_oc-temp_med-Parahip 70 | lh_G_temp_sup-Lateral 71 | lh_G_Ins_lg_and_S_cent_ins 72 | lh_S_collat_transv_ant 73 | lh_S_circular_insula_inf 74 | lh_G_temp_sup-Plan_polar 75 | lh_Pole_temporal 76 | rh_G_orbital 77 | rh_S_orbital-H_Shaped 78 | rh_S_orbital_lateral 79 | rh_G_and_S_frontomargin 80 | rh_G_and_S_transv_frontopol 81 | rh_G_rectus 82 | rh_S_suborbital 83 | rh_S_orbital_med-olfact 84 | rh_G_and_S_cingul-Ant 85 | rh_G_subcallosal 86 | rh_G_and_S_cingul-Mid-Ant 87 | rh_S_pericallosal 88 | rh_G_front_sup 89 | rh_S_front_sup 90 | rh_G_front_middle 91 | rh_S_front_middle 92 | rh_S_front_inf 93 | rh_G_front_inf-Orbital 94 | rh_G_front_inf-Triangul 95 | rh_G_front_inf-Opercular 96 | rh_Lat_Fis-ant-Horizont 97 | rh_Lat_Fis-ant-Vertical 98 | rh_S_circular_insula_ant 99 | rh_S_circular_insula_sup 100 | rh_G_insular_short 101 | rh_S_precentral-inf-part 102 | rh_G_precentral 103 | rh_S_precentral-sup-part 104 | rh_G_and_S_cingul-Mid-Post 105 | rh_Medial_wall 106 | rh_G_and_S_subcentral 107 | rh_S_central 108 | rh_G_postcentral 109 | rh_S_postcentral 110 | rh_S_cingul-Marginalis 111 | rh_G_cingul-Post-dorsal 112 | rh_G_cingul-Post-ventral 113 | rh_G_and_S_paracentral 114 | rh_G_precuneus 115 | rh_S_subparietal 116 | rh_G_pariet_inf-Supramar 117 | rh_S_interm_prim-Jensen 118 | rh_G_pariet_inf-Angular 119 | rh_S_intrapariet_and_P_trans 120 | rh_G_parietal_sup 121 | rh_S_parieto_occipital 122 | rh_G_cuneus 123 | rh_S_calcarine 124 | rh_G_occipital_sup 125 | rh_S_oc_sup_and_transversal 126 | rh_G_oc-temp_med-Lingual 127 | rh_G_occipital_middle 128 | rh_S_oc_middle_and_Lunatus 129 | rh_S_collat_transv_post 130 | rh_Pole_occipital 131 | rh_G_and_S_occipital_inf 132 | rh_S_occipital_ant 133 | rh_G_oc-temp_lat-fusifor 134 | rh_S_oc-temp_lat 135 | rh_S_oc-temp_med_and_Lingual 136 | rh_Lat_Fis-post 137 | rh_G_temp_sup-Plan_tempo 138 | rh_S_temporal_sup 139 | rh_S_temporal_transverse 140 | rh_G_temp_sup-G_T_transv 141 | rh_G_temporal_middle 142 | rh_S_temporal_inf 143 | rh_G_temporal_inf 144 | rh_G_oc-temp_med-Parahip 145 | rh_G_temp_sup-Lateral 146 | rh_G_Ins_lg_and_S_cent_ins 147 | rh_S_collat_transv_ant 148 | rh_S_circular_insula_inf 149 | rh_G_temp_sup-Plan_polar 150 | rh_Pole_temporal 151 | -------------------------------------------------------------------------------- /cvu/graph.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | import bct 20 | import numpy as np 21 | import scipy.io as sio 22 | from collections import OrderedDict 23 | from traits.api import HasTraits,Str,Any,List 24 | from traitsui.api import View,Item,TabularEditor 25 | from traitsui.tabular_adapter import TabularAdapter 26 | 27 | class StatisticsDisplay(HasTraits): 28 | name=Str 29 | stat=Any #np.ndarray 30 | display_chart=Any #np.ndarray 31 | 32 | def __init__(self,name,stat,labels,**kwargs): 33 | super(HasTraits,self).__init__(**kwargs) 34 | self.name=name 35 | if np.size(stat)==1: 36 | self.stat=stat 37 | self.display_chart=np.array((('','%.3f'%stat,),)) 38 | elif np.size(stat)!=len(labels): 39 | #print np.size(stat),len(labels) 40 | raise ValueError('Size of graph statistic inconsistent') 41 | else: 42 | nr_labels=len(labels) 43 | self.stat=stat.reshape((nr_labels,1)) 44 | self.display_chart=np.append( 45 | np.reshape(labels,(nr_labels,1)), 46 | np.reshape(map(lambda nr:'%.3f'%nr,stat),(nr_labels,1)), 47 | axis=1) 48 | #self.stat=np.reshape(stat,(np.size(stat),1)) 49 | 50 | traits_view=View( 51 | #Item('stat',editor=ArrayViewEditor(show_index=False,format='%.4f'), 52 | # height=350,width=225,show_label=False), 53 | Item('display_chart',editor=TabularEditor( 54 | adapter=TabularAdapter(columns=['','']), 55 | editable=False,show_titles=True), 56 | height=300,width=225,show_label=False), 57 | ) 58 | 59 | def calculate_modules(adj): 60 | ci,_ = bct.modularity_louvain_und(adj) 61 | ci2,_ = bct.modularity_finetune_und(adj, ci=ci) 62 | return ci2 63 | 64 | def do_summary(adj,mods,opts): 65 | stats=OrderedDict() 66 | for opt in opts: 67 | #throw an error if modularity calculations were requested but no 68 | #community structure exists 69 | if opt in ('modularity','participation coefficient','within-module ' 70 | 'degree') and mods is None: 71 | import cvu_utils as util 72 | raise util.CVUError('Need Modules') 73 | for opt in opts: 74 | stats.update({opt:do_opt(adj,mods,opt)}) 75 | return stats 76 | 77 | def do_opt(adj,mods,option): 78 | if option=='global efficiency': 79 | return bct.efficiency_wei(adj) 80 | elif option=='local efficiency': 81 | return bct.efficiency_wei(adj,local=True) 82 | elif option=='average strength': 83 | return bct.strengths_und(adj) 84 | elif option=='clustering coefficient': 85 | return bct.clustering_coef_wu(adj) 86 | elif option=='eigenvector centrality': 87 | return bct.eigenvector_centrality_und(adj) 88 | elif option=='binary kcore': 89 | return bct.kcoreness_centrality_bu(adj)[0] 90 | 91 | elif option=='modularity': 92 | return bct.modularity_und(adj,mods)[1] 93 | elif option=='participation coefficient': 94 | return bct.participation_coef(adj,mods) 95 | elif option=='within-module degree': 96 | return bct.module_degree_zscore(adj,mods) 97 | -------------------------------------------------------------------------------- /cvu/directory_dialog.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | 20 | import os 21 | from traits.api import (Directory, Str) 22 | from traitsui.api import (Item, HGroup, VGroup, View, HistoryEditor, 23 | DirectoryEditor) 24 | from traitsui.file_dialog import OpenFileDialog 25 | 26 | #reimplementation of OpenFileDialog for directory selection 27 | 28 | class OpenDirectoryDialog(OpenFileDialog): 29 | file_name = Directory 30 | 31 | id = Str('OpenDirectoryDialog') 32 | 33 | def _get_is_valid_file(self): 34 | if self.is_save_file: 35 | return (os.path.isdir(self.file_name) or (os.path.exists( 36 | self.file_name))) 37 | 38 | return os.path.isdir(self.file_name) or os.path.isfile(self.file_name) 39 | 40 | def open_file_view(self): 41 | item=Item( 'file_name', 42 | id = 'file_tree', 43 | style = 'custom', 44 | show_label = False, 45 | width = 0.5, 46 | editor = DirectoryEditor( filter = self.filter, 47 | allow_dir = True, 48 | reload_name = 'reload', 49 | dclick_name = 'dclick',)) 50 | width=height=0.20 51 | 52 | if len(self.extensions) > 0: 53 | raise Exception('extensions are not supported') 54 | 55 | 56 | return View ( 57 | VGroup( 58 | VGroup( item ), 59 | HGroup( 60 | Item( 'create', 61 | id = 'create', 62 | show_label = False, 63 | style = 'custom', 64 | defined_when = 'is_save_file', 65 | enabled_when = 'can_create_dir', 66 | tooltip = 'Create a new directory' 67 | ), 68 | Item( 'file_name', 69 | id = 'history', 70 | editor = HistoryEditor( entries = self.entries, 71 | auto_set = True ), 72 | springy = True 73 | ), 74 | Item( 'ok', 75 | id = 'ok', 76 | show_label = False, 77 | enabled_when = 'is_valid_file' 78 | ), 79 | Item( 'cancel', 80 | show_label = False 81 | ) 82 | ) 83 | ), 84 | title = self.title, 85 | id = self.id, 86 | kind = 'livemodal', 87 | width = width, 88 | height = height, 89 | close_result = False, 90 | resizable = True 91 | ) 92 | 93 | def open_directory(**traits): 94 | fd=OpenDirectoryDialog(**traits) 95 | if fd.edit_traits( view='open_file_view' ).result: 96 | return fd.file_name 97 | else: 98 | return '' 99 | 100 | -------------------------------------------------------------------------------- /cvu/color_axis.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | 19 | from chaco.api import PlotAxis,LinearMapper 20 | import numpy as np 21 | from traits.api import RGBColor,List,Any,Enum,HasTraits,Instance,Int 22 | 23 | def rcol(): 24 | return tuple(np.random.random(3)).__add__((1,)) 25 | 26 | class ColorfulAxis(PlotAxis): 27 | colors=List(Any) 28 | direction=Enum('x','y',None) 29 | 30 | def __init__(self,component,color_list,direction,**traits): 31 | super(ColorfulAxis,self).__init__(component=component,**traits) 32 | 33 | self.colors=color_list 34 | self.ensure_labels_bounded=True 35 | self.axis_line_visible=False 36 | self.tick_interval=1 37 | self.tick_weight=2 38 | 39 | self.direction=direction 40 | if self.direction=='x': 41 | self.orientation='bottom' 42 | elif self.direction=='y': 43 | self.orientation='left' 44 | 45 | def _draw_ticks(self,gc): 46 | if not self.tick_visible: 47 | return 48 | gc.set_line_width(self.tick_weight) 49 | gc.set_antialias(False) 50 | #tick_in_vector = self._inside_vector*self.tick_in 51 | tick_out_vector = self._inside_vector*self.tick_out*2 52 | #print self._tick_positions 53 | 54 | if self.direction=='x': 55 | self.mapper=self.component.x_mapper 56 | elif self.direction=='y': 57 | self.mapper=self.component.y_mapper 58 | 59 | min_scr=self.mapper.range.low 60 | max_scr=self.mapper.range.high 61 | 62 | #deal with the edge cases 63 | if min_scr-int(min_scr)==0: 64 | #the tick at r is preserved and i'll put at r+.5 65 | min_r=int(min_scr) 66 | elif min_scr-int(min_scr)<=.5: 67 | #i need a tick at r+.5 but i don't have one, take the one from r-1 68 | min_r=int(np.floor(min_scr)) 69 | elif min_scr-int(min_scr)>.5: 70 | #don't need a tick at r+.5, don't have a tick at r, start at r+1 71 | min_r=int(np.ceil(min_scr)) 72 | else: 73 | raise IndexError('Internal error in ColorfulAxis min') 74 | 75 | if max_scr-int(max_scr)<.5: 76 | #i have a superfluous tick at r, get rid of it 77 | max_r=int(np.floor(max_scr)) 78 | elif max_scr-int(max_scr)>=.5: 79 | #the tick at r will be displayed at r+.5, stop at r+1 80 | max_r=int(np.ceil(max_scr)) 81 | else: 82 | raise IndexError('Internal error in ColorfulAxis max') 83 | 84 | moddiv=int(np.ceil(max((max_r-min_r)//75,1))) 85 | inds=xrange(min_r,max_r,moddiv) 86 | nr_ticks=len(inds) 87 | 88 | # add .5 to each tick to place them in the center of the grid 89 | ticks_axis=self.mapper.map_screen(np.array(inds)+.5) 90 | ticks_static=np.tile(48,(nr_ticks,)) 91 | 92 | if self.direction=='x': 93 | ticks=np.vstack((ticks_axis,ticks_static)).T 94 | elif self.direction=='y': 95 | ticks=np.vstack((ticks_static,ticks_axis)).T 96 | 97 | for tick_pos,i in zip(ticks,inds): 98 | if i<0 or i>=len(self.colors): 99 | #gc.set_stroke_color((0,0,0)) 100 | continue 101 | else: 102 | gc.set_stroke_color(self.colors[i]) 103 | gc.begin_path() 104 | gc.move_to(*(tick_pos)) 105 | gc.line_to(*(tick_pos - tick_out_vector)) 106 | gc.stroke_path() 107 | return 108 | 109 | def _draw_labels(self,gc): 110 | pass 111 | -------------------------------------------------------------------------------- /cvu/volume.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | import numpy as np 19 | import os 20 | 21 | FSAVG5_XMIN=-68.7888 22 | FSAVG5_XMAX=69.8464 23 | FSAVG5_YMIN=-104.6920 24 | FSAVG5_YMAX=69.1561 25 | FSAVG5_ZMIN=-48.3923 26 | FSAVG5_ZMAX=79.2110 27 | 28 | LH_CORTEX_ASEGNUM=3 29 | RH_CORTEX_ASEGNUM=42 30 | 31 | #TODO hardcode slightly more softly 32 | aseg_rois={ 'lh_hippocampus':53, 'rh_hippocampus':17, 33 | 'lh_amygdala':54, 'rh_amygdala':18, 34 | 'lh_thalamus':49, 'rh_thalamus':10, 35 | 'lh_caudate':50, 'rh_caudate':11, 36 | 'lh_putamen':51, 'rh_putamen':12, 37 | 'lh_pallidum':52, 'rh_pallidum':13, 38 | 'lh_globus_pallidus':52, 'rh_globus_pallidus':13, 39 | 'lh_insula':55, 'rh_insula':19, 40 | 'lh_nucleus_accumbens':58, 'rh_nucleus_accumbens':26, 41 | 'lh_accumbens':58, 'rh_accumbens':26, 42 | 'lh_accumbens_area':58, 'rh_accumbens_area':26,} 43 | #'brainstem':16, 'brain_stem':16 } 44 | 45 | def surf_properties(use_fsavg5=True,lhsurf=None,rhsurf=None): 46 | if use_fsavg5: 47 | return (FSAVG5_XMIN,FSAVG5_YMIN,FSAVG5_ZMIN, 48 | FSAVG5_XMAX,FSAVG5_YMAX,FSAVG5_ZMAX) 49 | elif lhsurf is None or rhsurf is None: 50 | import cvu_utils 51 | raise cvu_utils.CVUError('Must use fsavg5 surface constants or provide ' 52 | 'an alternate mayavi surface to scrape dimensions') 53 | 54 | xs=np.hstack((lhsurf.mlab_source.x,rhsurf.mlab_source.x)) 55 | ys=np.hstack((lhsurf.mlab_source.y,rhsurf.mlab_source.y)) 56 | zs=np.hstack((lhsurf.mlab_source.z,rhsurf.mlab_source.z)) 57 | 58 | xmin=np.min(xs); xmax=np.max(xs) 59 | ymin=np.min(ys); ymax=np.max(ys) 60 | zmin=np.min(zs); zmax=np.max(zs) 61 | return (xmin,ymin,zmin,xmax,ymax,zmax) 62 | 63 | #the idea here is to provide a mean region location for each of the segmentation 64 | #structures. 65 | 66 | #First find the mean location within the volume, and then translate this 67 | #location to surface/mayavi coordinates. 68 | 69 | def roi_and_vol_properties(asegnum,asegd): 70 | roi_mean=np.mean(np.where(asegd==asegnum),axis=1) 71 | 72 | xc,yc,zc=np.where(np.logical_or(asegd==LH_CORTEX_ASEGNUM, 73 | asegd==RH_CORTEX_ASEGNUM)) 74 | 75 | xmin=np.floor(np.min(xc)); xmax=np.ceil(np.max(xc)) 76 | ymin=np.floor(np.min(yc)); ymax=np.ceil(np.max(yc)) 77 | zmin=np.floor(np.min(zc)); zmax=np.ceil(np.max(zc)) 78 | 79 | return roi_mean,(xmin,ymin,zmin,xmax,ymax,zmax) 80 | 81 | def translate_coords(roi,surf_lims,cortical_vol_lims, 82 | orientation_swap=True): 83 | rx,ry,rz=roi 84 | xmins,ymins,zmins,xmaxs,ymaxs,zmaxs=surf_lims 85 | xminc,yminc,zminc,xmaxc,ymaxc,zmaxc=cortical_vol_lims 86 | 87 | retx=(rx-xminc)*(xmaxs-xmins)/(xmaxc-xminc)+xmins 88 | if orientation_swap: 89 | rety=(rz-zminc)*(ymaxs-ymins)/(zmaxc-zminc)+ymins 90 | retz=(ry-ymaxc)*(zmaxs-zmins)/(yminc-ymaxc)+zmins 91 | # z direction is reversed. -1 automatically cancels out. 92 | else: 93 | rety=(ry-yminc)*(ymaxs-ymins)/(ymaxc-yminc)+ymins 94 | retz=(rz-zminc)*(zmaxs-zmins)/(zmaxc-zminc)+zmins 95 | 96 | return retx,rety,retz 97 | 98 | def roi_coords(roi_name,asegd,subjdir=None,subject='fsavg5',lhsurf=None,rhsurf=None): 99 | #if subject is none, use fsavg5 100 | #import time 101 | #t1=time.clock() 102 | c=surf_properties(use_fsavg5=(subject=='fsavg5' or subject is None), 103 | lhsurf=lhsurf,rhsurf=rhsurf) 104 | #t2=time.clock(); print t2-t1,'bip' 105 | r,v=roi_and_vol_properties(aseg_rois[roi_name],asegd) 106 | #this is the bottleneck. indexing into a large file. cant really fix. 107 | #t3=time.clock(); print t3-t2,'bop' 108 | return translate_coords(r,c,v) 109 | #t4=time.clock(); print t4-t3,'bap' 110 | -------------------------------------------------------------------------------- /cvu/orders/laus125_alph.txt: -------------------------------------------------------------------------------- 1 | lh_bankssts_1 2 | lh_bankssts_2 3 | lh_caudalanteriorcingulate_1 4 | lh_caudalmiddlefrontal_1 5 | lh_caudalmiddlefrontal_2 6 | lh_caudalmiddlefrontal_3 7 | delete 8 | lh_cuneus_1 9 | lh_entorhinal_1 10 | lh_frontalpole_1 11 | lh_fusiform_1 12 | lh_fusiform_2 13 | lh_fusiform_3 14 | lh_fusiform_4 15 | lh_inferiorparietal_1 16 | lh_inferiorparietal_2 17 | lh_inferiorparietal_3 18 | lh_inferiorparietal_4 19 | lh_inferiorparietal_5 20 | lh_inferiortemporal_1 21 | lh_inferiortemporal_2 22 | lh_inferiortemporal_3 23 | lh_inferiortemporal_4 24 | lh_insula_1 25 | lh_insula_2 26 | lh_insula_3 27 | lh_insula_4 28 | lh_isthmuscingulate_1 29 | lh_lateraloccipital_1 30 | lh_lateraloccipital_2 31 | lh_lateraloccipital_3 32 | lh_lateraloccipital_4 33 | lh_lateraloccipital_5 34 | lh_lateralorbitofrontal_1 35 | lh_lateralorbitofrontal_2 36 | lh_lateralorbitofrontal_3 37 | lh_lateralorbitofrontal_4 38 | lh_lingual_1 39 | lh_lingual_2 40 | lh_lingual_3 41 | lh_lingual_4 42 | lh_medialorbitofrontal_1 43 | lh_medialorbitofrontal_2 44 | lh_middletemporal_1 45 | lh_middletemporal_2 46 | lh_middletemporal_3 47 | lh_middletemporal_4 48 | lh_paracentral_1 49 | lh_paracentral_2 50 | lh_parahippocampal_1 51 | lh_parsopercularis_1 52 | lh_parsopercularis_2 53 | lh_parsorbitalis_1 54 | lh_parstriangularis_1 55 | lh_pericalcarine_1 56 | lh_postcentral_1 57 | lh_postcentral_2 58 | lh_postcentral_3 59 | lh_postcentral_4 60 | lh_postcentral_5 61 | lh_postcentral_6 62 | lh_postcentral_7 63 | lh_posteriorcingulate_1 64 | lh_posteriorcingulate_2 65 | lh_precentral_1 66 | lh_precentral_2 67 | lh_precentral_3 68 | lh_precentral_4 69 | lh_precentral_5 70 | lh_precentral_6 71 | lh_precentral_7 72 | lh_precentral_8 73 | lh_precuneus_1 74 | lh_precuneus_2 75 | lh_precuneus_3 76 | lh_precuneus_4 77 | lh_precuneus_5 78 | lh_rostralanteriorcingulate_1 79 | lh_rostralmiddlefrontal_1 80 | lh_rostralmiddlefrontal_2 81 | lh_rostralmiddlefrontal_3 82 | lh_rostralmiddlefrontal_4 83 | lh_rostralmiddlefrontal_5 84 | lh_rostralmiddlefrontal_6 85 | lh_superiorfrontal_1 86 | lh_superiorfrontal_2 87 | lh_superiorfrontal_3 88 | lh_superiorfrontal_4 89 | lh_superiorfrontal_5 90 | lh_superiorfrontal_6 91 | lh_superiorfrontal_7 92 | lh_superiorfrontal_8 93 | lh_superiorfrontal_9 94 | lh_superiorparietal_1 95 | lh_superiorparietal_2 96 | lh_superiorparietal_3 97 | lh_superiorparietal_4 98 | lh_superiorparietal_5 99 | lh_superiorparietal_6 100 | lh_superiorparietal_7 101 | lh_superiortemporal_1 102 | lh_superiortemporal_2 103 | lh_superiortemporal_3 104 | lh_superiortemporal_4 105 | lh_superiortemporal_5 106 | lh_supramarginal_1 107 | lh_supramarginal_2 108 | lh_supramarginal_3 109 | lh_supramarginal_4 110 | lh_supramarginal_5 111 | lh_temporalpole_1 112 | lh_transversetemporal_1 113 | delete 114 | rh_bankssts_1 115 | rh_caudalanteriorcingulate_1 116 | rh_caudalmiddlefrontal_1 117 | rh_caudalmiddlefrontal_2 118 | rh_caudalmiddlefrontal_3 119 | delete 120 | rh_cuneus_1 121 | rh_cuneus_2 122 | rh_entorhinal_1 123 | rh_frontalpole_1 124 | rh_fusiform_1 125 | rh_fusiform_2 126 | rh_fusiform_3 127 | rh_fusiform_4 128 | rh_inferiorparietal_1 129 | rh_inferiorparietal_2 130 | rh_inferiorparietal_3 131 | rh_inferiorparietal_4 132 | rh_inferiorparietal_5 133 | rh_inferiorparietal_6 134 | rh_inferiortemporal_1 135 | rh_inferiortemporal_2 136 | rh_inferiortemporal_3 137 | rh_inferiortemporal_4 138 | rh_insula_1 139 | rh_insula_2 140 | rh_insula_3 141 | rh_isthmuscingulate_1 142 | rh_lateraloccipital_1 143 | rh_lateraloccipital_2 144 | rh_lateraloccipital_3 145 | rh_lateraloccipital_4 146 | rh_lateraloccipital_5 147 | rh_lateralorbitofrontal_1 148 | rh_lateralorbitofrontal_2 149 | rh_lateralorbitofrontal_3 150 | rh_lateralorbitofrontal_4 151 | rh_lingual_1 152 | rh_lingual_2 153 | rh_lingual_3 154 | rh_medialorbitofrontal_1 155 | rh_medialorbitofrontal_2 156 | rh_medialorbitofrontal_3 157 | rh_middletemporal_1 158 | rh_middletemporal_2 159 | rh_middletemporal_3 160 | rh_middletemporal_4 161 | rh_paracentral_1 162 | rh_paracentral_2 163 | rh_paracentral_3 164 | rh_parahippocampal_1 165 | rh_parsopercularis_1 166 | rh_parsopercularis_2 167 | rh_parsorbitalis_1 168 | rh_parstriangularis_1 169 | rh_parstriangularis_2 170 | rh_pericalcarine_1 171 | rh_pericalcarine_2 172 | rh_postcentral_1 173 | rh_postcentral_2 174 | rh_postcentral_3 175 | rh_postcentral_4 176 | rh_postcentral_5 177 | rh_posteriorcingulate_1 178 | rh_posteriorcingulate_2 179 | rh_precentral_1 180 | rh_precentral_2 181 | rh_precentral_3 182 | rh_precentral_4 183 | rh_precentral_5 184 | rh_precentral_6 185 | rh_precuneus_1 186 | rh_precuneus_2 187 | rh_precuneus_3 188 | rh_precuneus_4 189 | rh_precuneus_5 190 | rh_rostralanteriorcingulate_1 191 | rh_rostralmiddlefrontal_1 192 | rh_rostralmiddlefrontal_2 193 | rh_rostralmiddlefrontal_3 194 | rh_rostralmiddlefrontal_4 195 | rh_rostralmiddlefrontal_5 196 | rh_rostralmiddlefrontal_6 197 | rh_superiorfrontal_1 198 | rh_superiorfrontal_2 199 | rh_superiorfrontal_3 200 | rh_superiorfrontal_4 201 | rh_superiorfrontal_5 202 | rh_superiorfrontal_6 203 | rh_superiorfrontal_7 204 | rh_superiorfrontal_8 205 | rh_superiorparietal_1 206 | rh_superiorparietal_2 207 | rh_superiorparietal_3 208 | rh_superiorparietal_4 209 | rh_superiorparietal_5 210 | rh_superiorparietal_6 211 | rh_superiorparietal_7 212 | rh_superiortemporal_1 213 | rh_superiortemporal_2 214 | rh_superiortemporal_3 215 | rh_superiortemporal_4 216 | rh_superiortemporal_5 217 | rh_supramarginal_1 218 | rh_supramarginal_2 219 | rh_supramarginal_3 220 | rh_supramarginal_4 221 | rh_temporalpole_1 222 | rh_transversetemporal_1 223 | delete 224 | -------------------------------------------------------------------------------- /cvu/orders/laus125_fsfast.txt: -------------------------------------------------------------------------------- 1 | delete 2 | lh_bankssts_1 3 | lh_caudalanteriorcingulate_1 4 | lh_caudalmiddlefrontal_1 5 | delete 6 | lh_cuneus_1 7 | lh_entorhinal_1 8 | lh_fusiform_1 9 | lh_inferiorparietal_1 10 | lh_inferiortemporal_1 11 | lh_isthmuscingulate_1 12 | lh_lateraloccipital_1 13 | lh_lateralorbitofrontal_1 14 | lh_lingual_1 15 | lh_medialorbitofrontal_1 16 | lh_middletemporal_1 17 | lh_parahippocampal_1 18 | lh_paracentral_1 19 | lh_parsopercularis_1 20 | lh_parsorbitalis_1 21 | lh_parstriangularis_1 22 | lh_pericalcarine_1 23 | lh_postcentral_1 24 | lh_posteriorcingulate_1 25 | lh_precentral_1 26 | lh_precuneus_1 27 | lh_rostralanteriorcingulate_1 28 | lh_rostralmiddlefrontal_1 29 | lh_superiorfrontal_1 30 | lh_superiorparietal_1 31 | lh_superiortemporal_1 32 | lh_supramarginal_1 33 | lh_frontalpole_1 34 | lh_temporalpole_1 35 | lh_transversetemporal_1 36 | lh_insula_1 37 | lh_bankssts_2 38 | lh_caudalmiddlefrontal_2 39 | lh_caudalmiddlefrontal_3 40 | lh_fusiform_2 41 | lh_fusiform_3 42 | lh_fusiform_4 43 | lh_inferiorparietal_2 44 | lh_inferiorparietal_3 45 | lh_inferiorparietal_4 46 | lh_inferiorparietal_5 47 | lh_inferiortemporal_2 48 | lh_inferiortemporal_3 49 | lh_inferiortemporal_4 50 | lh_lateraloccipital_2 51 | lh_lateraloccipital_3 52 | lh_lateraloccipital_4 53 | lh_lateraloccipital_5 54 | lh_lateralorbitofrontal_2 55 | lh_lateralorbitofrontal_3 56 | lh_lateralorbitofrontal_4 57 | lh_lingual_2 58 | lh_lingual_3 59 | lh_lingual_4 60 | lh_medialorbitofrontal_2 61 | lh_middletemporal_2 62 | lh_middletemporal_3 63 | lh_middletemporal_4 64 | lh_paracentral_2 65 | lh_parsopercularis_2 66 | lh_postcentral_2 67 | lh_postcentral_3 68 | lh_postcentral_4 69 | lh_postcentral_5 70 | lh_postcentral_6 71 | lh_postcentral_7 72 | lh_posteriorcingulate_2 73 | lh_precentral_2 74 | lh_precentral_3 75 | lh_precentral_4 76 | lh_precentral_5 77 | lh_precentral_6 78 | lh_precentral_7 79 | lh_precentral_8 80 | lh_precuneus_2 81 | lh_precuneus_3 82 | lh_precuneus_4 83 | lh_precuneus_5 84 | lh_rostralmiddlefrontal_2 85 | lh_rostralmiddlefrontal_3 86 | lh_rostralmiddlefrontal_4 87 | lh_rostralmiddlefrontal_5 88 | lh_rostralmiddlefrontal_6 89 | lh_superiorfrontal_2 90 | lh_superiorfrontal_3 91 | lh_superiorfrontal_4 92 | lh_superiorfrontal_5 93 | lh_superiorfrontal_6 94 | lh_superiorfrontal_7 95 | lh_superiorfrontal_8 96 | lh_superiorfrontal_9 97 | lh_superiorparietal_2 98 | lh_superiorparietal_3 99 | lh_superiorparietal_4 100 | lh_superiorparietal_5 101 | lh_superiorparietal_6 102 | lh_superiorparietal_7 103 | lh_superiortemporal_2 104 | lh_superiortemporal_3 105 | lh_superiortemporal_4 106 | lh_superiortemporal_5 107 | lh_supramarginal_2 108 | lh_supramarginal_3 109 | lh_supramarginal_4 110 | lh_supramarginal_5 111 | lh_insula_2 112 | lh_insula_3 113 | lh_insula_4 114 | delete 115 | rh_bankssts_1 116 | rh_caudalanteriorcingulate_1 117 | rh_caudalmiddlefrontal_1 118 | delete 119 | rh_cuneus_1 120 | rh_entorhinal_1 121 | rh_fusiform_1 122 | rh_inferiorparietal_1 123 | rh_inferiortemporal_1 124 | rh_isthmuscingulate_1 125 | rh_lateraloccipital_1 126 | rh_lateralorbitofrontal_1 127 | rh_lingual_1 128 | rh_medialorbitofrontal_1 129 | rh_middletemporal_1 130 | rh_parahippocampal_1 131 | rh_paracentral_1 132 | rh_parsopercularis_1 133 | rh_parsorbitalis_1 134 | rh_parstriangularis_1 135 | rh_pericalcarine_1 136 | rh_postcentral_1 137 | rh_posteriorcingulate_1 138 | rh_precentral_1 139 | rh_precuneus_1 140 | rh_rostralanteriorcingulate_1 141 | rh_rostralmiddlefrontal_1 142 | rh_superiorfrontal_1 143 | rh_superiorparietal_1 144 | rh_superiortemporal_1 145 | rh_supramarginal_1 146 | rh_frontalpole_1 147 | rh_temporalpole_1 148 | rh_transversetemporal_1 149 | rh_insula_1 150 | rh_caudalmiddlefrontal_2 151 | rh_caudalmiddlefrontal_3 152 | rh_cuneus_2 153 | rh_fusiform_2 154 | rh_fusiform_3 155 | rh_fusiform_4 156 | rh_inferiorparietal_2 157 | rh_inferiorparietal_3 158 | rh_inferiorparietal_4 159 | rh_inferiorparietal_5 160 | rh_inferiorparietal_6 161 | rh_inferiortemporal_2 162 | rh_inferiortemporal_3 163 | rh_inferiortemporal_4 164 | rh_lateraloccipital_2 165 | rh_lateraloccipital_3 166 | rh_lateraloccipital_4 167 | rh_lateraloccipital_5 168 | rh_lateralorbitofrontal_2 169 | rh_lateralorbitofrontal_3 170 | rh_lateralorbitofrontal_4 171 | rh_lingual_2 172 | rh_lingual_3 173 | rh_medialorbitofrontal_2 174 | rh_medialorbitofrontal_3 175 | rh_middletemporal_2 176 | rh_middletemporal_3 177 | rh_middletemporal_4 178 | rh_paracentral_2 179 | rh_paracentral_3 180 | rh_parsopercularis_2 181 | rh_parstriangularis_2 182 | rh_pericalcarine_2 183 | rh_postcentral_2 184 | rh_postcentral_3 185 | rh_postcentral_4 186 | rh_postcentral_5 187 | rh_posteriorcingulate_2 188 | rh_precentral_2 189 | rh_precentral_3 190 | rh_precentral_4 191 | rh_precentral_5 192 | rh_precentral_6 193 | rh_precuneus_2 194 | rh_precuneus_3 195 | rh_precuneus_4 196 | rh_precuneus_5 197 | rh_rostralmiddlefrontal_2 198 | rh_rostralmiddlefrontal_3 199 | rh_rostralmiddlefrontal_4 200 | rh_rostralmiddlefrontal_5 201 | rh_rostralmiddlefrontal_6 202 | rh_superiorfrontal_2 203 | rh_superiorfrontal_3 204 | rh_superiorfrontal_4 205 | rh_superiorfrontal_5 206 | rh_superiorfrontal_6 207 | rh_superiorfrontal_7 208 | rh_superiorfrontal_8 209 | rh_superiorparietal_2 210 | rh_superiorparietal_3 211 | rh_superiorparietal_4 212 | rh_superiorparietal_5 213 | rh_superiorparietal_6 214 | rh_superiorparietal_7 215 | rh_superiortemporal_2 216 | rh_superiortemporal_3 217 | rh_superiortemporal_4 218 | rh_superiortemporal_5 219 | rh_supramarginal_2 220 | rh_supramarginal_3 221 | rh_supramarginal_4 222 | rh_insula_2 223 | rh_insula_3 224 | -------------------------------------------------------------------------------- /cvu/orders/laus125_cmp.txt: -------------------------------------------------------------------------------- 1 | rh_lateralorbitofrontal_1 2 | rh_lateralorbitofrontal_2 3 | rh_lateralorbitofrontal_3 4 | rh_lateralorbitofrontal_4 5 | rh_parsorbitalis_1 6 | rh_frontalpole_1 7 | rh_medialorbitofrontal_1 8 | rh_medialorbitofrontal_2 9 | rh_medialorbitofrontal_3 10 | rh_parstriangularis_1 11 | rh_parstriangularis_2 12 | rh_parsopercularis_1 13 | rh_parsopercularis_2 14 | rh_rostralmiddlefrontal_1 15 | rh_rostralmiddlefrontal_2 16 | rh_rostralmiddlefrontal_3 17 | rh_rostralmiddlefrontal_4 18 | rh_rostralmiddlefrontal_5 19 | rh_rostralmiddlefrontal_6 20 | rh_superiorfrontal_1 21 | rh_superiorfrontal_2 22 | rh_superiorfrontal_3 23 | rh_superiorfrontal_4 24 | rh_superiorfrontal_5 25 | rh_superiorfrontal_6 26 | rh_superiorfrontal_7 27 | rh_superiorfrontal_8 28 | rh_caudalmiddlefrontal_1 29 | rh_caudalmiddlefrontal_2 30 | rh_caudalmiddlefrontal_3 31 | rh_precentral_1 32 | rh_precentral_2 33 | rh_precentral_3 34 | rh_precentral_4 35 | rh_precentral_5 36 | rh_precentral_6 37 | rh_paracentral_1 38 | rh_paracentral_2 39 | rh_paracentral_3 40 | rh_rostralanteriorcingulate_1 41 | rh_caudalanteriorcingulate_1 42 | rh_posteriorcingulate_1 43 | rh_posteriorcingulate_2 44 | rh_isthmuscingulate_1 45 | rh_postcentral_1 46 | rh_postcentral_2 47 | rh_postcentral_3 48 | rh_postcentral_4 49 | rh_postcentral_5 50 | rh_supramarginal_1 51 | rh_supramarginal_2 52 | rh_supramarginal_3 53 | rh_supramarginal_4 54 | rh_superiorparietal_1 55 | rh_superiorparietal_2 56 | rh_superiorparietal_3 57 | rh_superiorparietal_4 58 | rh_superiorparietal_5 59 | rh_superiorparietal_6 60 | rh_superiorparietal_7 61 | rh_inferiorparietal_1 62 | rh_inferiorparietal_2 63 | rh_inferiorparietal_3 64 | rh_inferiorparietal_4 65 | rh_inferiorparietal_5 66 | rh_inferiorparietal_6 67 | rh_precuneus_1 68 | rh_precuneus_2 69 | rh_precuneus_3 70 | rh_precuneus_4 71 | rh_precuneus_5 72 | rh_cuneus_1 73 | rh_cuneus_2 74 | rh_pericalcarine_1 75 | rh_pericalcarine_2 76 | rh_lateraloccipital_1 77 | rh_lateraloccipital_2 78 | rh_lateraloccipital_3 79 | rh_lateraloccipital_4 80 | rh_lateraloccipital_5 81 | rh_lingual_1 82 | rh_lingual_2 83 | rh_lingual_3 84 | rh_fusiform_1 85 | rh_fusiform_2 86 | rh_fusiform_3 87 | rh_fusiform_4 88 | rh_parahippocampal_1 89 | rh_entorhinal_1 90 | rh_temporalpole_1 91 | rh_inferiortemporal_1 92 | rh_inferiortemporal_2 93 | rh_inferiortemporal_3 94 | rh_inferiortemporal_4 95 | rh_middletemporal_1 96 | rh_middletemporal_2 97 | rh_middletemporal_3 98 | rh_middletemporal_4 99 | rh_bankssts_1 100 | rh_superiortemporal_1 101 | rh_superiortemporal_2 102 | rh_superiortemporal_3 103 | rh_superiortemporal_4 104 | rh_superiortemporal_5 105 | rh_transversetemporal_1 106 | rh_insula_1 107 | rh_insula_2 108 | rh_insula_3 109 | delete 110 | delete 111 | delete 112 | delete 113 | delete 114 | delete 115 | delete 116 | lh_lateralorbitofrontal_1 117 | lh_lateralorbitofrontal_2 118 | lh_lateralorbitofrontal_3 119 | lh_lateralorbitofrontal_4 120 | lh_parsorbitalis_1 121 | lh_frontalpole_1 122 | lh_medialorbitofrontal_1 123 | lh_medialorbitofrontal_2 124 | lh_parstriangularis_1 125 | lh_parsopercularis_1 126 | lh_parsopercularis_2 127 | lh_rostralmiddlefrontal_1 128 | lh_rostralmiddlefrontal_2 129 | lh_rostralmiddlefrontal_3 130 | lh_rostralmiddlefrontal_4 131 | lh_rostralmiddlefrontal_5 132 | lh_rostralmiddlefrontal_6 133 | lh_superiorfrontal_1 134 | lh_superiorfrontal_2 135 | lh_superiorfrontal_3 136 | lh_superiorfrontal_4 137 | lh_superiorfrontal_5 138 | lh_superiorfrontal_6 139 | lh_superiorfrontal_7 140 | lh_superiorfrontal_8 141 | lh_superiorfrontal_9 142 | lh_caudalmiddlefrontal_1 143 | lh_caudalmiddlefrontal_2 144 | lh_caudalmiddlefrontal_3 145 | lh_precentral_1 146 | lh_precentral_2 147 | lh_precentral_3 148 | lh_precentral_4 149 | lh_precentral_5 150 | lh_precentral_6 151 | lh_precentral_7 152 | lh_precentral_8 153 | lh_paracentral_1 154 | lh_paracentral_2 155 | lh_rostralanteriorcingulate_1 156 | lh_caudalanteriorcingulate_1 157 | lh_posteriorcingulate_1 158 | lh_posteriorcingulate_2 159 | lh_isthmuscingulate_1 160 | lh_postcentral_1 161 | lh_postcentral_2 162 | lh_postcentral_3 163 | lh_postcentral_4 164 | lh_postcentral_5 165 | lh_postcentral_6 166 | lh_postcentral_7 167 | lh_supramarginal_1 168 | lh_supramarginal_2 169 | lh_supramarginal_3 170 | lh_supramarginal_4 171 | lh_supramarginal_5 172 | lh_superiorparietal_1 173 | lh_superiorparietal_2 174 | lh_superiorparietal_3 175 | lh_superiorparietal_4 176 | lh_superiorparietal_5 177 | lh_superiorparietal_6 178 | lh_superiorparietal_7 179 | lh_inferiorparietal_1 180 | lh_inferiorparietal_2 181 | lh_inferiorparietal_3 182 | lh_inferiorparietal_4 183 | lh_inferiorparietal_5 184 | lh_precuneus_1 185 | lh_precuneus_2 186 | lh_precuneus_3 187 | lh_precuneus_4 188 | lh_precuneus_5 189 | lh_cuneus_1 190 | lh_pericalcarine_1 191 | lh_lateraloccipital_1 192 | lh_lateraloccipital_2 193 | lh_lateraloccipital_3 194 | lh_lateraloccipital_4 195 | lh_lateraloccipital_5 196 | lh_lingual_1 197 | lh_lingual_2 198 | lh_lingual_3 199 | lh_lingual_4 200 | lh_fusiform_1 201 | lh_fusiform_2 202 | lh_fusiform_3 203 | lh_fusiform_4 204 | lh_parahippocampal_1 205 | lh_entorhinal_1 206 | lh_temporalpole_1 207 | lh_inferiortemporal_1 208 | lh_inferiortemporal_2 209 | lh_inferiortemporal_3 210 | lh_inferiortemporal_4 211 | lh_middletemporal_1 212 | lh_middletemporal_2 213 | lh_middletemporal_3 214 | lh_middletemporal_4 215 | lh_bankssts_1 216 | lh_bankssts_2 217 | lh_superiortemporal_1 218 | lh_superiortemporal_2 219 | lh_superiortemporal_3 220 | lh_superiortemporal_4 221 | lh_superiortemporal_5 222 | lh_transversetemporal_1 223 | lh_insula_1 224 | lh_insula_2 225 | lh_insula_3 226 | lh_insula_4 227 | delete 228 | delete 229 | delete 230 | delete 231 | delete 232 | delete 233 | delete 234 | delete 235 | -------------------------------------------------------------------------------- /cvu/custom_file_editor.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # 3 | # Copyright (c) 2005, Enthought, Inc. 4 | # All rights reserved. 5 | # 6 | # This software is provided without warranty under the terms of the BSD 7 | # license included in enthought/LICENSE.txt and may be redistributed only 8 | # under the conditions described in the aforementioned license. The license 9 | # is also available online at http://www.enthought.com/licenses/BSD.txt 10 | # 11 | # Thanks for using Enthought open source! 12 | # 13 | # Author: David C. Morrill 14 | # Date: 10/21/2004 15 | # 16 | #------------------------------------------------------------------------------ 17 | 18 | """ Defines file editors for the wxPython user interface toolkit. 19 | """ 20 | 21 | #------------------------------------------------------------------------------- 22 | # Imports: 23 | #------------------------------------------------------------------------------- 24 | 25 | import os 26 | from traits.trait_base import ETSConfig 27 | _tk = ETSConfig.toolkit 28 | 29 | if _tk in ('null','',None): 30 | _tk = os.environ['ETS_TOOLKIT'] 31 | else: 32 | print _tk 33 | 34 | from functools import partial 35 | from traits.api import (File, HasTraits, Button, Instance, Any, Callable, 36 | Property, Directory, Bool) 37 | from traitsui.api import (View, Item, CustomEditor, Handler, UIInfo) 38 | from traitsui.file_dialog import open_file 39 | 40 | #from traitsui..custom_editor import CustomEditor as CustomEditorKlass 41 | CustomEditorKlass = __import__('traitsui.%s.custom_editor'%_tk, 42 | fromlist=['CustomEditor'], ).CustomEditor 43 | 44 | from directory_dialog import open_directory 45 | 46 | def mkeditor(*args, **kwargs): 47 | """ Custom editor factory. Must be instantiated on top of an 48 | InteractiveSubwindow instance with an implemented reconstruct(). 49 | """ 50 | #return _editor_factory(*args) 51 | return (getattr(__import__('custom_file_editor'),'%s_editor_factory'%_tk) 52 | (*args,**kwargs)) 53 | 54 | def wx_editor_factory(parent, editor, use_dir=False, *args): 55 | import wx 56 | from traitsui.wx.helper import TraitsUIPanel 57 | 58 | editor.control = panel = TraitsUIPanel( parent, -1 ) 59 | sizer = wx.BoxSizer( wx.HORIZONTAL ) 60 | 61 | editor.use_dir = use_dir 62 | 63 | pad = 8 64 | 65 | bmp = wx.ArtProvider.GetBitmap ( wx.ART_FOLDER_OPEN, size= (15,15)) 66 | button = wx.BitmapButton(panel, -1, bitmap=bmp) 67 | 68 | editor.text_control = text_control = wx.TextCtrl(panel, -1, '', 69 | style=wx.TE_PROCESS_ENTER) 70 | 71 | _do_update_obj = lambda ev:update_file_obj(editor) 72 | 73 | wx.EVT_TEXT_ENTER( panel, text_control.GetId(), _do_update_obj) 74 | wx.EVT_KILL_FOCUS( text_control, _do_update_obj) 75 | 76 | sizer.Add( text_control, 1, wx.EXPAND | wx.ALIGN_CENTER ) 77 | sizer.Add( button, 0, wx.RIGHT | wx.ALIGN_CENTER, pad ) 78 | 79 | wx.EVT_BUTTON( panel, button.GetId(), lambda ev:button_click(editor) ) 80 | panel.SetSizerAndFit( sizer ) 81 | 82 | return panel 83 | 84 | def qt4_editor_factory(parent, editor, use_dir=False, *args): 85 | from pyface.qt import QtCore, QtGui 86 | from traitsui.qt4.helper import IconButton 87 | 88 | editor.control = panel = QtGui.QWidget() 89 | layout = QtGui.QHBoxLayout( panel ) 90 | layout.setContentsMargins(0,0,0,0) 91 | 92 | editor.use_dir = use_dir 93 | 94 | editor.text_control = text_control = QtGui.QLineEdit() 95 | layout.addWidget(text_control) 96 | signal = QtCore.SIGNAL('editingFinished()') 97 | QtCore.QObject.connect(text_control, signal, lambda:update_file_obj(editor)) 98 | 99 | button = IconButton(QtGui.QStyle.SP_DirIcon, lambda:button_click(editor)) 100 | layout.addWidget(button) 101 | 102 | return panel 103 | 104 | def get_text(editor): 105 | if _tk == 'wx': return editor.text_control.GetValue() 106 | elif _tk == 'qt4': return editor.text_control.text() 107 | else: raise NotImplementedError('Attempted to get text from nonexistent editor type') 108 | 109 | def set_text(editor, text): 110 | if _tk == 'wx': return editor.text_control.SetValue(text) 111 | elif _tk == 'qt4': return editor.text_control.setText(text) 112 | else: raise NotImplementedError('Attempted to set text in nonexistent editor type') 113 | 114 | #methods referring to editor factory, which is not a real object 115 | def update_file_obj(editor): 116 | editor.value = get_text(editor) 117 | 118 | def button_click(editor): 119 | if editor.use_dir: 120 | file_selected=open_directory(entries=20) 121 | else: 122 | file_selected=open_file(entries=20) 123 | if file_selected: 124 | editor.value=file_selected 125 | editor.ui.handler.reconstruct() 126 | 127 | #custom editor on traitsui abstraction level 128 | if _tk == 'wx': 129 | class CustomFileEditor(CustomEditor): 130 | '''abstraction layer for Custom File editor. This editor must be 131 | instantiated within a view of an InteractiveSubwindow object with a 132 | correctly implemented reconstruct()''' 133 | factory = Property #Callable 134 | 135 | use_dir = Bool(False) 136 | 137 | def _get_klass(self): 138 | #tell the editor to use this instead of importing from traitsui.wx 139 | return CustomFileEditorKlass 140 | 141 | def _get_factory(self): 142 | return partial(mkeditor, use_dir=self.use_dir) 143 | 144 | class CustomDirectoryEditor(CustomFileEditor): 145 | use_dir = True 146 | elif _tk == 'qt4': 147 | #in qt, the file editor has good default history feature unlike wx 148 | from traitsui.editors.file_editor import FileEditor as CustomFileEditor 149 | from traitsui.editors.directory_editor import DirectoryEditor \ 150 | as CustomDirectoryEditor 151 | else: 152 | raise NotImplementedError('No CustomFileEditor defined for nonexistent toolkit') 153 | 154 | #custom editor on level of toolkit (i.e., wx or qt4) 155 | class CustomFileEditorKlass(CustomEditorKlass): 156 | text_control = Any # Instance( wx._control.TextCtrl or QtGui.QLineEdit ) 157 | 158 | use_dir = Bool(False) 159 | 160 | def update_editor(self): 161 | set_text(self, self.value) 162 | 163 | def update_file_obj(self,event): 164 | self.value = get_text(self) 165 | 166 | #test as main file 167 | if __name__=='__main__': 168 | import signal 169 | signal.signal(signal.SIGINT, signal.SIG_DFL) 170 | 171 | class Farkish(Handler): 172 | f=File('saukish') 173 | b=Button 174 | info=Instance(UIInfo) 175 | 176 | traits_view=View( 177 | Item('f',editor=CustomFileEditor()), 178 | Item('b'), 179 | height=500,width=500) 180 | 181 | def _b_fired(self): 182 | print self.f 183 | 184 | def init_info(self,info): 185 | self.info=info 186 | def reconstruct(self): 187 | self.info.ui.dispose() 188 | self.info.object.edit_traits() 189 | 190 | Farkish().configure_traits() 191 | -------------------------------------------------------------------------------- /cvu/color_map.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | import numpy as np 19 | from matplotlib.colors import LinearSegmentedColormap 20 | from mayavi.core import lut_manager 21 | from pylab import get_cmap 22 | from traits.api import (HasTraits,Enum,Bool,File,Range,Str,Instance,Property,Event, 23 | on_trait_change) 24 | 25 | class CustomColormap(HasTraits): 26 | lut_list=lut_manager.lut_mode_list() 27 | lut_list.remove('black-white') 28 | lut_list.remove('blue-red') 29 | lut_list.append('custom_heat') 30 | 31 | imgs_path = 'cmap_images' 32 | 33 | map_type = Enum('default','scalar','activation','connmat') 34 | cmap = Enum(lut_list) 35 | reverse = Bool 36 | fname = File 37 | label = Str 38 | threshold = Range(0.0,0.5,0.2) 39 | _pl = Property(Instance(LinearSegmentedColormap)) 40 | 41 | def __init__(self,type): 42 | self.map_type=type 43 | 44 | def _cmap_default(self): 45 | if self.map_type=='scalar': return 'BuGn' 46 | elif self.map_type=='activation': return 'YlOrRd' 47 | elif self.map_type=='connmat': return 'RdYlBu' 48 | else: return 'cool' #return default 49 | 50 | def _reverse_default(self): 51 | if self.map_type=='connmat': return True 52 | else: return False 53 | 54 | def _label_default(self): 55 | if self.map_type=='scalar': return 'Scalars Colormap' 56 | elif self.map_type=='activation': return 'Conns Colormap' 57 | elif self.map_type=='connmat': return 'Matrix Colormap' 58 | else: return 'Default Colormap' 59 | 60 | def _get__pl(self): 61 | '''return the LinearSegmentedColormap describing this CustomColormap''' 62 | if self.cmap=='file' and self.fname: 63 | colors = lut_manager.parse_lut_file(self.fname) 64 | if self.reverse: 65 | colors.reverse() 66 | return LinearSegmentedColormap.from_list('file',colors) 67 | elif self.cmap=='custom_heat': 68 | return gen_heatmap(t=self.threshold,reverse=self.reverse) 69 | elif self.reverse: 70 | return get_cmap(self.cmap+'_r') 71 | else: 72 | return get_cmap(self.cmap) 73 | 74 | def gen_heatmap(t=.2,two_tailed=True,reverse=False): 75 | '''Generates a heatmap that has red-to-yellow at the top, blue-to-light-blue 76 | at the bottom, and gray in the middle. If the map is one-tailed, only the red 77 | portion is displayed: 78 | 79 | gen_heatmap(t=.2,two_tailed=True) 80 | t -- the threshold used to start both tails of the heatmap. This should be a 81 | value between 0 and .5. You are responsible for calculating the right value 82 | from your statistics. 83 | 84 | two-tailed -- if false, only the upper (red) part of the heatmap is shown''' 85 | 86 | #a very fancy algorithm to do things correctly when the map is inverted. 87 | #sorry about the readability 88 | def swapif(trip): 89 | if reverse: return ( 1-trip[0], trip[2], trip[1] ) 90 | else: return trip 91 | 92 | def revif(tups): 93 | if reverse: 94 | l=list(tups); l.reverse(); return tuple(l) 95 | else: return tups 96 | 97 | if two_tailed: 98 | cdict = {'red': revif(( swapif((0.0,0.0,0.6)), 99 | swapif((t ,0.2,0.4)), 100 | swapif((1-t,0.4,1.0)), 101 | swapif((1.0,1.0,0.0)))), 102 | 'green':revif(( swapif((0.0,0.0,1.0)), 103 | swapif((t ,0.5,0.4)), 104 | swapif((1-t,0.4,0.0)), 105 | swapif((1.0,1.0,0.0)))), 106 | 'blue': revif(( swapif((0.0,0.0,1.0)), 107 | swapif((t ,1.0,0.4)), 108 | swapif((1-t,0.4,0.0)), 109 | swapif((1.0,0.5,0.0)))),} 110 | else: 111 | cdict = {'red': revif(( swapif((0.0,0.0,0.4)), 112 | swapif((1-t,0.4,1.0)), 113 | swapif((1.0,1.0,0.0)))), 114 | 'green':revif(( swapif((0.0,0.0,0.4)), 115 | swapif((1-t,0.4,0.0)), 116 | swapif((1.0,1.0,0.0)))), 117 | 'blue': revif(( swapif((0.0,0.0,0.4)), 118 | swapif((1-t,0.4,0.0)), 119 | swapif((1.0,0.5,0.0)))),} 120 | 121 | return LinearSegmentedColormap('heatmap_%.3f'%t,cdict,256) 122 | 123 | def map_to_table(cmap,nvals=256): 124 | '''Takes a LinearSegmentedColormap, and returns a table of RGBA values 125 | spanning that colormap. 126 | 127 | arguments: 128 | cmap - the LinearSegmentedColormap instance 129 | nvals- the number of values to span over. The default is 256.''' 130 | 131 | return cmap(xrange(nvals),bytes=True) 132 | 133 | def set_lut(mayavi_obj,map,use_vector_lut=False): 134 | '''Takes a mayavi object and a CustomColormap and sets the color LUT on thatobject to use the colormap referred to by the CustomColormap, handling all 135 | edge cases 136 | 137 | arguments: 138 | mayavi_obj - the mayavi object. This object MUST have a module_manager 139 | trait, which not all mayavi objects do. 140 | map - the CustomColormap instance 141 | use_vector_lut - if True, uses the vector_lut_manager instead of the 142 | scalar_lut_manager on the mayavi object. Defaults to false.''' 143 | 144 | if use_vector_lut: 145 | lut_mgr=mayavi_obj.module_manager.vector_lut_manager 146 | else: 147 | lut_mgr=mayavi_obj.module_manager.scalar_lut_manager 148 | 149 | lut_mgr.number_of_colors = 256 150 | lut_mgr.file_name=map.fname 151 | lut_mgr.reverse_lut=map.reverse 152 | 153 | if map.cmap=='custom_heat': 154 | lut_mgr.lut_mode='black-white' #this mode is not used and will always 155 | #trigger notifications when changed 156 | hmap = gen_heatmap(t=map.threshold,reverse=map.reverse) 157 | lut_mgr.lut.table = map_to_table(hmap) 158 | else: 159 | lut_mgr.lut_mode=map.cmap 160 | 161 | def set_color_range(mayavi_obj, scalars, use_vector_lut=False): 162 | '''Set the data_range trait of a mayavi module manager's scalar LUT. If 163 | use_vector_lut is set, set the range of the vector LUT instead. The range is 164 | set to [min(scalars), max(scalars)]''' 165 | if use_vector_lut: 166 | module_manager = mayavi_obj.module_manager.vector_lut_manager 167 | else: 168 | module_manager = mayavi_obj.module_manager.scalar_lut_manager 169 | module_manager.data_range = (np.min(scalars), np.max(scalars)) 170 | -------------------------------------------------------------------------------- /cvu/cmaps/sample_heat.lut: -------------------------------------------------------------------------------- 1 | LOOKUP_TABLE UnnamedTable 256 2 | 0.6588 0.7843 1.0000 1.0000 3 | 0.6431 0.7686 1.0000 1.0000 4 | 0.6314 0.7490 1.0000 1.0000 5 | 0.6157 0.7333 1.0000 1.0000 6 | 0.6039 0.7176 1.0000 1.0000 7 | 0.5922 0.6980 1.0000 1.0000 8 | 0.5765 0.6824 0.9961 1.0000 9 | 0.5647 0.6667 0.9961 1.0000 10 | 0.5490 0.6471 0.9961 1.0000 11 | 0.5373 0.6314 0.9961 1.0000 12 | 0.5216 0.6157 0.9961 1.0000 13 | 0.5098 0.5961 0.9961 1.0000 14 | 0.4941 0.5804 0.9961 1.0000 15 | 0.4824 0.5647 0.9961 1.0000 16 | 0.4706 0.5451 0.9961 1.0000 17 | 0.4549 0.5294 0.9961 1.0000 18 | 0.4431 0.5137 0.9961 1.0000 19 | 0.4275 0.4941 0.9922 1.0000 20 | 0.4157 0.4784 0.9922 1.0000 21 | 0.4000 0.4627 0.9922 1.0000 22 | 0.3882 0.4431 0.9922 1.0000 23 | 0.3725 0.4275 0.9922 1.0000 24 | 0.3608 0.4118 0.9922 1.0000 25 | 0.3490 0.3922 0.9922 1.0000 26 | 0.3333 0.3765 0.9922 1.0000 27 | 0.3216 0.3608 0.9922 1.0000 28 | 0.3059 0.3412 0.9922 1.0000 29 | 0.2941 0.3255 0.9922 1.0000 30 | 0.2784 0.3098 0.9882 1.0000 31 | 0.2667 0.2902 0.9882 1.0000 32 | 0.2510 0.2745 0.9882 1.0000 33 | 0.2392 0.2588 0.9882 1.0000 34 | 0.2235 0.2392 0.9882 1.0000 35 | 0.2118 0.2235 0.9882 1.0000 36 | 0.2000 0.2078 0.9882 1.0000 37 | 0.1843 0.1922 0.9882 1.0000 38 | 0.1922 0.1961 0.9725 1.0000 39 | 0.2000 0.2039 0.9608 1.0000 40 | 0.2039 0.2118 0.9451 1.0000 41 | 0.2118 0.2157 0.9333 1.0000 42 | 0.2157 0.2235 0.9176 1.0000 43 | 0.2235 0.2314 0.9020 1.0000 44 | 0.2314 0.2353 0.8902 1.0000 45 | 0.2353 0.2431 0.8745 1.0000 46 | 0.2431 0.2510 0.8627 1.0000 47 | 0.2510 0.2549 0.8471 1.0000 48 | 0.2549 0.2627 0.8353 1.0000 49 | 0.2627 0.2706 0.8196 1.0000 50 | 0.2667 0.2745 0.8078 1.0000 51 | 0.2745 0.2824 0.7922 1.0000 52 | 0.2824 0.2902 0.7804 1.0000 53 | 0.2863 0.2941 0.7647 1.0000 54 | 0.2941 0.3020 0.7529 1.0000 55 | 0.3020 0.3098 0.7373 1.0000 56 | 0.3059 0.3176 0.7255 1.0000 57 | 0.3137 0.3216 0.7098 1.0000 58 | 0.3176 0.3294 0.6941 1.0000 59 | 0.3255 0.3373 0.6824 1.0000 60 | 0.3333 0.3412 0.6667 1.0000 61 | 0.3373 0.3490 0.6549 1.0000 62 | 0.3451 0.3569 0.6392 1.0000 63 | 0.3529 0.3608 0.6275 1.0000 64 | 0.3569 0.3686 0.6118 1.0000 65 | 0.3647 0.3765 0.6000 1.0000 66 | 0.3725 0.3804 0.5843 1.0000 67 | 0.3765 0.3882 0.5725 1.0000 68 | 0.3843 0.3961 0.5569 1.0000 69 | 0.3882 0.4000 0.5451 1.0000 70 | 0.3961 0.4078 0.5294 1.0000 71 | 0.4039 0.4157 0.5176 1.0000 72 | 0.4078 0.4196 0.5020 1.0000 73 | 0.4157 0.4275 0.4863 1.0000 74 | 0.4235 0.4353 0.4745 1.0000 75 | 0.4275 0.4392 0.4588 1.0000 76 | 0.4314 0.4431 0.4549 1.0000 77 | 0.4314 0.4431 0.4549 1.0000 78 | 0.4314 0.4431 0.4549 1.0000 79 | 0.4314 0.4431 0.4549 1.0000 80 | 0.4314 0.4431 0.4549 1.0000 81 | 0.4314 0.4431 0.4549 1.0000 82 | 0.4314 0.4431 0.4549 1.0000 83 | 0.4314 0.4431 0.4549 1.0000 84 | 0.4314 0.4431 0.4549 1.0000 85 | 0.4314 0.4431 0.4549 1.0000 86 | 0.4314 0.4431 0.4549 1.0000 87 | 0.4314 0.4431 0.4549 1.0000 88 | 0.4314 0.4431 0.4549 1.0000 89 | 0.4314 0.4431 0.4549 1.0000 90 | 0.4314 0.4431 0.4549 1.0000 91 | 0.4314 0.4431 0.4549 1.0000 92 | 0.4314 0.4431 0.4549 1.0000 93 | 0.4314 0.4431 0.4549 1.0000 94 | 0.4314 0.4471 0.4549 1.0000 95 | 0.4314 0.4471 0.4549 1.0000 96 | 0.4314 0.4471 0.4549 1.0000 97 | 0.4314 0.4471 0.4549 1.0000 98 | 0.4314 0.4471 0.4549 1.0000 99 | 0.4314 0.4471 0.4549 1.0000 100 | 0.4314 0.4471 0.4549 1.0000 101 | 0.4314 0.4471 0.4549 1.0000 102 | 0.4353 0.4471 0.4549 1.0000 103 | 0.4353 0.4471 0.4549 1.0000 104 | 0.4353 0.4471 0.4549 1.0000 105 | 0.4353 0.4471 0.4549 1.0000 106 | 0.4353 0.4471 0.4549 1.0000 107 | 0.4353 0.4471 0.4549 1.0000 108 | 0.4353 0.4471 0.4549 1.0000 109 | 0.4353 0.4471 0.4549 1.0000 110 | 0.4353 0.4471 0.4549 1.0000 111 | 0.4353 0.4471 0.4549 1.0000 112 | 0.4353 0.4471 0.4549 1.0000 113 | 0.4353 0.4471 0.4549 1.0000 114 | 0.4353 0.4471 0.4549 1.0000 115 | 0.4353 0.4471 0.4549 1.0000 116 | 0.4353 0.4471 0.4549 1.0000 117 | 0.4353 0.4471 0.4549 1.0000 118 | 0.4353 0.4471 0.4549 1.0000 119 | 0.4353 0.4471 0.4549 1.0000 120 | 0.4353 0.4471 0.4549 1.0000 121 | 0.4353 0.4471 0.4549 1.0000 122 | 0.4353 0.4471 0.4549 1.0000 123 | 0.4353 0.4471 0.4549 1.0000 124 | 0.4353 0.4471 0.4549 1.0000 125 | 0.4353 0.4471 0.4549 1.0000 126 | 0.4353 0.4471 0.4549 1.0000 127 | 0.4353 0.4471 0.4549 1.0000 128 | 0.4353 0.4471 0.4549 1.0000 129 | 0.4353 0.4510 0.4549 1.0000 130 | 0.4353 0.4510 0.4549 1.0000 131 | 0.4353 0.4510 0.4549 1.0000 132 | 0.4353 0.4510 0.4549 1.0000 133 | 0.4353 0.4510 0.4549 1.0000 134 | 0.4353 0.4510 0.4549 1.0000 135 | 0.4353 0.4510 0.4549 1.0000 136 | 0.4353 0.4510 0.4549 1.0000 137 | 0.4392 0.4510 0.4549 1.0000 138 | 0.4392 0.4510 0.4549 1.0000 139 | 0.4392 0.4510 0.4549 1.0000 140 | 0.4392 0.4510 0.4549 1.0000 141 | 0.4392 0.4510 0.4549 1.0000 142 | 0.4392 0.4510 0.4549 1.0000 143 | 0.4392 0.4510 0.4549 1.0000 144 | 0.4392 0.4510 0.4549 1.0000 145 | 0.4392 0.4510 0.4549 1.0000 146 | 0.4392 0.4510 0.4549 1.0000 147 | 0.4392 0.4510 0.4549 1.0000 148 | 0.4392 0.4510 0.4549 1.0000 149 | 0.4392 0.4510 0.4549 1.0000 150 | 0.4392 0.4510 0.4549 1.0000 151 | 0.4392 0.4510 0.4549 1.0000 152 | 0.4392 0.4510 0.4549 1.0000 153 | 0.4392 0.4510 0.4549 1.0000 154 | 0.4392 0.4510 0.4549 1.0000 155 | 0.4392 0.4510 0.4549 1.0000 156 | 0.4392 0.4510 0.4549 1.0000 157 | 0.4392 0.4510 0.4549 1.0000 158 | 0.4392 0.4510 0.4549 1.0000 159 | 0.4392 0.4510 0.4549 1.0000 160 | 0.4392 0.4510 0.4549 1.0000 161 | 0.4392 0.4510 0.4549 1.0000 162 | 0.4392 0.4510 0.4549 1.0000 163 | 0.4392 0.4549 0.4549 1.0000 164 | 0.4392 0.4549 0.4549 1.0000 165 | 0.4392 0.4549 0.4549 1.0000 166 | 0.4392 0.4549 0.4549 1.0000 167 | 0.4392 0.4549 0.4549 1.0000 168 | 0.4392 0.4549 0.4549 1.0000 169 | 0.4392 0.4549 0.4549 1.0000 170 | 0.4392 0.4549 0.4549 1.0000 171 | 0.4431 0.4549 0.4549 1.0000 172 | 0.4431 0.4549 0.4549 1.0000 173 | 0.4431 0.4549 0.4549 1.0000 174 | 0.4431 0.4549 0.4549 1.0000 175 | 0.4431 0.4549 0.4549 1.0000 176 | 0.4431 0.4549 0.4549 1.0000 177 | 0.4431 0.4549 0.4549 1.0000 178 | 0.4431 0.4549 0.4549 1.0000 179 | 0.4431 0.4549 0.4549 1.0000 180 | 0.4431 0.4549 0.4549 1.0000 181 | 0.4431 0.4549 0.4549 1.0000 182 | 0.4431 0.4549 0.4549 1.0000 183 | 0.4431 0.4549 0.4549 1.0000 184 | 0.4431 0.4549 0.4549 1.0000 185 | 0.4431 0.4549 0.4549 1.0000 186 | 0.4431 0.4549 0.4549 1.0000 187 | 0.4431 0.4549 0.4549 1.0000 188 | 0.4549 0.4471 0.4471 1.0000 189 | 0.4667 0.4353 0.4353 1.0000 190 | 0.4784 0.4235 0.4235 1.0000 191 | 0.4941 0.4118 0.4118 1.0000 192 | 0.5059 0.4000 0.4000 1.0000 193 | 0.5176 0.3922 0.3922 1.0000 194 | 0.5294 0.3804 0.3804 1.0000 195 | 0.5451 0.3686 0.3686 1.0000 196 | 0.5569 0.3569 0.3569 1.0000 197 | 0.5686 0.3490 0.3490 1.0000 198 | 0.5804 0.3373 0.3373 1.0000 199 | 0.5961 0.3255 0.3255 1.0000 200 | 0.6078 0.3137 0.3137 1.0000 201 | 0.6196 0.3020 0.3020 1.0000 202 | 0.6314 0.2941 0.2941 1.0000 203 | 0.6471 0.2824 0.2824 1.0000 204 | 0.6588 0.2706 0.2706 1.0000 205 | 0.6706 0.2588 0.2588 1.0000 206 | 0.6824 0.2510 0.2510 1.0000 207 | 0.6980 0.2392 0.2392 1.0000 208 | 0.7098 0.2275 0.2275 1.0000 209 | 0.7216 0.2157 0.2157 1.0000 210 | 0.7333 0.2039 0.2039 1.0000 211 | 0.7490 0.1961 0.1961 1.0000 212 | 0.7608 0.1843 0.1843 1.0000 213 | 0.7725 0.1725 0.1725 1.0000 214 | 0.7843 0.1608 0.1608 1.0000 215 | 0.8000 0.1529 0.1529 1.0000 216 | 0.8118 0.1412 0.1412 1.0000 217 | 0.8235 0.1294 0.1294 1.0000 218 | 0.8353 0.1176 0.1176 1.0000 219 | 0.8510 0.1059 0.1059 1.0000 220 | 0.8627 0.0980 0.0980 1.0000 221 | 0.8745 0.0863 0.0863 1.0000 222 | 0.8863 0.0745 0.0745 1.0000 223 | 0.9020 0.0627 0.0627 1.0000 224 | 0.9137 0.0549 0.0549 1.0000 225 | 0.9255 0.0431 0.0431 1.0000 226 | 0.9373 0.0314 0.0314 1.0000 227 | 0.9529 0.0196 0.0196 1.0000 228 | 0.9647 0.0078 0.0078 1.0000 229 | 0.9765 0.0039 0.0000 1.0000 230 | 0.9765 0.0392 0.0000 1.0000 231 | 0.9765 0.0745 0.0000 1.0000 232 | 0.9765 0.1059 0.0000 1.0000 233 | 0.9765 0.1412 0.0000 1.0000 234 | 0.9804 0.1765 0.0000 1.0000 235 | 0.9804 0.2118 0.0000 1.0000 236 | 0.9804 0.2431 0.0000 1.0000 237 | 0.9804 0.2784 0.0000 1.0000 238 | 0.9843 0.3137 0.0000 1.0000 239 | 0.9843 0.3451 0.0000 1.0000 240 | 0.9843 0.3804 0.0000 1.0000 241 | 0.9843 0.4157 0.0000 1.0000 242 | 0.9882 0.4510 0.0000 1.0000 243 | 0.9882 0.4824 0.0000 1.0000 244 | 0.9882 0.5176 0.0000 1.0000 245 | 0.9882 0.5529 0.0000 1.0000 246 | 0.9882 0.5843 0.0000 1.0000 247 | 0.9922 0.6196 0.0000 1.0000 248 | 0.9922 0.6549 0.0000 1.0000 249 | 0.9922 0.6902 0.0000 1.0000 250 | 0.9922 0.7216 0.0000 1.0000 251 | 0.9961 0.7569 0.0000 1.0000 252 | 0.9961 0.7922 0.0000 1.0000 253 | 0.9961 0.8235 0.0000 1.0000 254 | 0.9961 0.8588 0.0000 1.0000 255 | 1.0000 0.8941 0.0000 1.0000 256 | 1.0000 0.9294 0.0000 1.0000 257 | 1.0000 0.9608 0.0000 1.0000 258 | -------------------------------------------------------------------------------- /cvu/mpleditor.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | from traits.trait_base import ETSConfig 19 | _tk = ETSConfig.toolkit 20 | 21 | if (_tk is None) or (_tk == 'null'): 22 | raise NotImplementedError("We must independently set the toolkit") 23 | 24 | from traits.api import Any, Int, Bool, Instance, Either 25 | from traitsui.basic_editor_factory import BasicEditorFactory 26 | from matplotlib.figure import Figure 27 | 28 | 29 | #import wx 30 | #from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg 31 | #from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg 32 | # this import is not portable. But that is ok because currently the number of options 33 | # is exactly 2 34 | FigureCanvas = getattr(__import__('matplotlib.backends.backend_%sagg'%_tk, 35 | fromlist=['FigureCanvas']), 'FigureCanvas%sAgg'%('Wx' if _tk=='wx' else 'QT')) 36 | 37 | #from traitsui..editor import Editor 38 | Editor = __import__('traitsui.%s.editor'%_tk,fromlist=['Editor']).Editor 39 | 40 | import numpy as np 41 | import time 42 | 43 | #This code is extensively adapted from Gael Varoquax's example code for 44 | #hacking a traited matplotlib editor 45 | 46 | class _MPLFigureEditor(Editor): 47 | 48 | scrollable = True 49 | parent = Any 50 | canvas = Instance(FigureCanvas) 51 | tooltip = Any #Either(Instance(wx._misc.ToolTip), Instance(QtGui.QWidget)) 52 | 53 | # define some callbacks that need to be added and removed on the fly. 54 | # these callbacks can't be passed around easily 55 | release_cid = Int 56 | motion_cid = Int 57 | 58 | waiting_for_tooltip = Bool(False) 59 | 60 | def init(self,parent): 61 | self.parent=parent 62 | self.control=self._create_canvas(parent) 63 | 64 | def update_editor(self): 65 | pass 66 | 67 | def _create_canvas(self, *args): 68 | return getattr(self,'_create_canvas_%s'%_tk)(*args) 69 | 70 | def _create_canvas_wx(self, parent): 71 | import wx 72 | #unsure if there is a way to avoid hard coding these function names 73 | fig=self.object.circ 74 | panel=wx.Panel(parent,-1) 75 | self.canvas = canvas = FigureCanvas(panel,-1,fig) 76 | sizer=wx.BoxSizer(wx.VERTICAL) 77 | sizer.Add(self.canvas,1,wx.EXPAND|wx.ALL,1) 78 | #toolbar=NavigationToolbar2Wx(self.canvas) 79 | #toolbar.Realize() 80 | #sizer.Add(toolbar,0,wx.EXPAND|wx.ALL,1) 81 | panel.SetSizer(sizer) 82 | 83 | #for the panning process the id of the callback must be stored 84 | #self.motion_cid=self.canvas.mpl_connect('motion_notify_event', 85 | # lambda ev:self.object.circ_mouseover(ev,self)) 86 | 87 | canvas.mpl_connect('button_press_event',self.object.circle_click) 88 | canvas.mpl_connect('motion_notify_event', 89 | lambda ev:self.object.circle_mouseover(ev, self._update_tooltip_wx)) 90 | 91 | self.tooltip=wx.ToolTip(tip='') 92 | self.tooltip.SetDelay(2000) 93 | canvas.SetToolTip(self.tooltip) 94 | return panel 95 | 96 | def _update_tooltip_wx(self, tooltip_on, text=''): 97 | if tooltip_on: 98 | self.tooltip.Enable(True) 99 | self.tooltip.SetTip(text) 100 | else: 101 | self.tooltip.Enable(False) 102 | 103 | def _create_canvas_qt4(self, parent): 104 | import matplotlib 105 | #matplotlib.use('Qt4Agg') 106 | #matplotlib.rcParams['backend.qt4']='PySide' 107 | 108 | from pyface.qt import QtCore, QtGui 109 | 110 | self.tooltip = panel = QtGui.QWidget() 111 | 112 | fig = self.object.circ 113 | self.canvas = canvas = FigureCanvas(fig) 114 | #self.canvas.setParent(panel) 115 | 116 | layout = QtGui.QVBoxLayout( panel ) 117 | layout.addWidget(canvas) 118 | 119 | canvas.mpl_connect('button_press_event', self.object.circle_click) 120 | canvas.mpl_connect('motion_notify_event', 121 | lambda ev: self.object.circle_mouseover(ev, self._update_tooltip_qt)) 122 | 123 | return panel 124 | 125 | def _update_tooltip_qt(self, tooltip_on, text=''): 126 | if tooltip_on: 127 | self.tooltip.setToolTip(text) 128 | else: 129 | self.tooltip.setToolTip(None) 130 | pass 131 | 132 | ###################################################################################### 133 | ###################################################################################### 134 | #FIXME all remaining code in this class is not used. but it is left untouched to 135 | #show how to do the panning. 136 | #if we ever actually do the panning, which is unlikely, obviously it should be 137 | #modernized. 138 | def _process_circ_click(self,event,cvu): 139 | # if the user right clicked, just display all 140 | if event.button==3: 141 | cvu.display_all() 142 | return 143 | elif event.button==2: 144 | self.object.mpleditor=self 145 | return 146 | # the user left clicked, lets wait and see if he wants to pan 147 | self.release_cid=self.canvas.mpl_connect('button_release_event', 148 | lambda ignore:self._single_click(event,cvu)) 149 | # use the existing event coordinates; theres probably no difference 150 | # but if there were the originals would be more reliable 151 | #self.motion_cid=self.canvas.mpl_connect('motion_notify_event', 152 | # self._pan_decide) 153 | 154 | def _single_click(self,event,cvu): 155 | self._clear_callbacks() 156 | #this event has xdata and ydata in reverse polar coordinates (theta,r) 157 | #do some algebra to figure out which ROI based on the angle 158 | if event.button==1 and event.ydata>=7 and event.ydata<=8: 159 | nod=cvu.nr_labels*event.xdata/(np.pi*2)+.5*np.pi/cvu.nr_labels 160 | #the formula for the correct node, assuming perfect clicking, 161 | #is floor(n*theta/2pi). however, matplotlib seems to not do great 162 | #with this, the clicking is often too high, so i add this correction 163 | cvu.display_node(int(np.floor(nod))) 164 | 165 | def _possibly_show_tooltip(self,event,cvu): 166 | self._clear_callbacks() 167 | if event.ydata>=7 and event.ydata<=8: 168 | nod=int(np.floor(cvu.nr_labels*event.xdata/(np.pi*2) 169 | +.5*np.pi/cvu.nr_labels)) 170 | self.tooltip.Enable(True) 171 | self.tooltip.SetTip(cvu.labnam[nod]) 172 | else: 173 | self.tooltip.Enable(False) 174 | 175 | #if and when panning is also done, this logic needs to become a bit 176 | #more complex to respond only to novel mouse events and constantly 177 | #clear old callbacks. 178 | 179 | #self.waiting_for_tooltip=True 180 | #self.motion_cid=self.canvas.mpl_connect('motion_notify_event', 181 | # self._move_unset_tooltip) 182 | #time.sleep(1) 183 | 184 | def _move_unset_tooltip(self,ignore): 185 | self.waiting_for_tooltip=False 186 | 187 | def _clear_callbacks(self): 188 | self.canvas.mpl_disconnect(self.release_cid) 189 | #self.canvas.mpl_disconnect(self.motion_cid) 190 | 191 | def _pan_decide(self,event): 192 | ax=self.canvas.figure.get_axes()[0] 193 | ax.set_navigate_mode('PAN') 194 | ax.start_pan(event.x,event.y,1) 195 | self._pan(event) 196 | self._clear_callbacks() 197 | self.release_cid=self.canvas.mpl_connect('button_release_event', 198 | self._end_pan) 199 | self.motion_cid=self.canvas.mpl_connect('motion_notify_event', 200 | self._pan) 201 | 202 | def _pan(self,event): 203 | ax = self.canvas.figure.get_axes()[0] 204 | ax.drag_pan(1,event.key,event.x,event.y) 205 | self.canvas.draw() 206 | 207 | def _end_pan(self,event): 208 | ax = self.canvas.figure.get_axes()[0] 209 | ax.end_pan() 210 | self._clear_callbacks() 211 | 212 | class MPLFigureEditor(BasicEditorFactory): 213 | klass = _MPLFigureEditor 214 | -------------------------------------------------------------------------------- /cvu/viewport.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | from traits.api import (HasTraits,Int,Instance,Range,List,Str,Range,Property, 19 | Enum,Any,DelegatesTo,Bool,on_trait_change) 20 | from traitsui.api import (View,Item,Group,VSplit,HSplit,NullEditor,Handler, 21 | InstanceEditor,UIInfo) 22 | 23 | from mayavi.core.ui.api import (MayaviScene,SceneEditor,MlabSceneModel) 24 | from dialogs import InteractiveSubwindow 25 | from enable.component_editor import ComponentEditor 26 | from mpleditor import MPLFigureEditor 27 | from utils import CVUError 28 | from chaco.api import Plot 29 | from matplotlib.figure import Figure 30 | 31 | class Viewport(Handler): 32 | ds=Any 33 | 34 | #FIXME there is no reason to have modular viewports anymore since as 35 | #it turns out the viewport has to be rebuilt in order to update the view. 36 | #this is something that could be modularly managed. 37 | #The benefit of changing what now works is however low. It is basically 38 | #a very weak form of static type checking, and a way to save a miniscule 39 | #amount of time and space on managing pointers. 40 | 41 | 42 | 43 | 44 | #by keeping these views on the viewport object itself, we can change 45 | #the dataset without making traitsui think that the view is inaccessible 46 | #and it is time to be thrown away immediately upon loading a new dataset 47 | scene=Instance(MlabSceneModel) 48 | conn_mat=Instance(Plot) 49 | circ=Instance(Figure) 50 | 51 | view_type=Enum('dummy','3D Brain','Connection Matrix','Circular plot') 52 | 53 | dummy_view=View( 54 | Item(editor=NullEditor(),height=500,width=500,label='empty')) 55 | 56 | mayavi_view=View( 57 | Item(name='scene', 58 | editor=SceneEditor(scene_class=MayaviScene), 59 | height=500,width=500,show_label=False,resizable=True)) 60 | 61 | matrix_view=View( 62 | Item(name='conn_mat', 63 | editor=ComponentEditor(), 64 | height=500,width=500,show_label=False,resizable=True)) 65 | 66 | circle_view=View( 67 | Item(name='circ', 68 | editor=MPLFigureEditor(), 69 | height=500,width=500,show_label=False,resizable=True)) 70 | 71 | def __init__(self,ds,**kwargs): 72 | super(Viewport,self).__init__(**kwargs) 73 | self.ds=ds 74 | 75 | #it is ok to assign the editors while initializing the viewport 76 | self.scene=ds.dv_3d.scene 77 | self.conn_mat=ds.dv_mat.conn_mat 78 | self.circ=ds.dv_circ.circ 79 | 80 | #MPLEditor wants its interactions to be on the model object 81 | #this is the "fake" model object so we forward them to the real model object 82 | def circle_click(self,event): 83 | self.ds.dv_circ.circle_click(event) 84 | def circle_mouseover(self,event,tooltip): 85 | self.ds.dv_circ.circle_mouseover(event,tooltip) 86 | 87 | #more general port layout 88 | 89 | #class ViewPanelPortList(HasTraits): 90 | # ports=List(Instance(Viewport)) 91 | # 92 | # def __getattr__(self,attr): 93 | # try: 94 | # if attr[0]=='p': 95 | # return self.ports[int(attr[1:])] 96 | # else: 97 | # raise ValueError 98 | # except (AttributeError,ValueError,TypeError,IndexError): 99 | # return self.__getattribute__(attr) 100 | 101 | class DatasetViewportInterface(HasTraits): 102 | mayavi_port,matrix_port,circle_port = (Instance(Viewport),)*3 103 | panel_name = Str 104 | 105 | class DatasetViewportLayout(DatasetViewportInterface): 106 | def mkitems(dummies=False): 107 | if dummies: view_order=('dummy','dummy','dummy') 108 | else: view_order=('mayavi','matrix','circle') 109 | for it in view_order: 110 | yield Item(name='%s_port'%it,style='custom',show_label=False, 111 | editor=InstanceEditor(view='%s_view'%it),height=500,width=500) 112 | 113 | single_view = View(HSplit(content=[it for it in mkitems()],columns=3), 114 | height=500,width=1500) 115 | square_view = View(VSplit(HSplit(content=[it for it in mkitems()][:-1], 116 | columns=2),HSplit(content=[it for it in mkitems()][-1:],columns=2)), 117 | height=1000,width=1000) 118 | 119 | class ViewPanel(InteractiveSubwindow): 120 | panel_name=Str('Extra View 1') 121 | layout=Enum('single','double','square') 122 | #configurations allowed: 2x3, 1x3, 2x2 (like main window) 123 | 124 | group_1,group_2 = 2*(Instance(DatasetViewportLayout),) 125 | 126 | def __repr__(self): return self.panel_name 127 | 128 | def is_full(self,group=None): 129 | if group is None and self.layout=='double': 130 | return self.group_1 is not None and self.group_2 is not None 131 | elif group in (None,1): 132 | return self.group_1 is not None 133 | elif group=='2': 134 | return self.group_2 is not None 135 | else: raise ValueError('Invalid value of group') 136 | 137 | #TODO determine based on self.layout 138 | def populate_dummies(self,two_groups=True): 139 | grps=(self.group_1,self.group_2) if two_groups else (self.group_1,) 140 | for group in grps: 141 | group=DatasetViewportLayout() 142 | group.mayavi_port=Viewport(ds=None) 143 | group.matrix_port=Viewport(ds=None) 144 | group.circle_port=Viewport(ds=None) 145 | 146 | #TODO determine based on self.layout 147 | def populate(self,ds,ds2=None,group=None,force=False): 148 | if ds2 is not None: grps=('group_1','group_2') 149 | elif group==1 or group is None: grps=('group_1',) 150 | elif group==2: grps=('group_2',) 151 | elif self.is_full(): raise CVUError('Panel is full') 152 | else: raise ValueError('Cannot populate ViewPanel with group >=2') 153 | 154 | if not force: 155 | for group in grps: 156 | if self.__getattribute__(group) is not None: 157 | raise CVUError('Group specified is full, overwrite with ' 158 | 'force=True') 159 | 160 | datasets=( (ds,ds2) if (ds2 is not None) else (ds,) ) 161 | 162 | for group,d in zip(grps,datasets): 163 | dvl=DatasetViewportLayout() 164 | dvl.mayavi_port=Viewport(ds=d) 165 | dvl.matrix_port=Viewport(ds=d) 166 | dvl.circle_port=Viewport(ds=d) 167 | self.__setattr__(group,dvl) 168 | 169 | def produce_view(self,layout=None): 170 | produce_item=(lambda ht,wd,grp,lb,vw: 171 | Item(name=lb,style='custom',show_label=False,#height=ht,width=wd, 172 | editor=InstanceEditor(view=vw))) 173 | 174 | if layout=='double' or (layout is None and self.layout=='double'): 175 | return View( 176 | produce_item(500,1500,self.group_1,'group_1','single_view'), 177 | produce_item(500,1500,self.group_2,'group_2','single_view'), 178 | resizable=True,height=1000,width=1500) 179 | elif layout=='single' or (layout is None and self.layout=='single'): 180 | return View( 181 | produce_item(500,1500,self.group_1,'group_1','single_view'), 182 | resizable=True,height=500,width=1500,title=self.panel_name) 183 | elif layout=='square' or (layout is None and self.layout=='square'): 184 | return View( 185 | produce_item(1000,1000,self.group_1,'group_1','square_view'), 186 | resizable=True,height=1000,width=1000) 187 | else: raise ValueError('Invalid layout') 188 | 189 | #handler methods 190 | def init_info(self,info): 191 | self.info=info 192 | self.window_active=True 193 | self._change_title() 194 | 195 | def conditionally_dispose(self): 196 | if self.window_active: 197 | self.info.ui.dispose() 198 | self.window_active=False 199 | 200 | @on_trait_change('panel_name') 201 | def _change_title(self): 202 | try: 203 | self.info.ui.title=self.panel_name 204 | #if the panel is renamed when not shown 205 | #this also occurs on initialization 206 | except AttributeError: pass 207 | 208 | #this is code written that in principle, permits a maximally generic 209 | #infrastructure for what viewports should go where on the extra window. 210 | # 211 | #in the end allowing maximally generic viewports is not really possible or 212 | #strictly necessary. this is a complex problem that might draw slightly 213 | #from the weirdnesses with scene editor and recreating windows, but mostly 214 | #from how damn hard it is to deal with tables in traitsui 215 | # 216 | #instead, i am going to implement it so that there are a small number of 217 | #allowed possible configurations showing 3 or 6 views. The following 218 | #function tries to do this as well, but doesn't do a great job at it -- 219 | #it is complex, clunky, and requires several arguments to do everything 220 | #correctly in a few cases. Which is not the worst thing ever, but is 221 | #too silly to manage when it is just fine to hardcode the three reasonable 222 | #possibilities 223 | # 224 | #so don't use this function 225 | # def produce_view(self,nr_groups,cols,dummies=False): 226 | # 227 | # def generate_items(self,second_group=False,dummies=False): 228 | # if not dummies: 229 | # view_order=('mayavi_view','matrix_view','circle_view') 230 | # else: 231 | # view_order=('dummy_view','dummy_view','dummy_view') 232 | # for i,(port,view) in enumerate(zip(self.ports.ports,view_order)): 233 | # yield Item(name='p%i'%(i+second_group*3), 234 | # object='object.ports',style='custom', 235 | # show_label=False,editor=InstanceEditor(view=view), 236 | # height=500,width=500) 237 | # 238 | # items=[] 239 | # for i in xrange(nr_groups): 240 | # items.extend([j for j in self.generate_items(i,dummies)]) 241 | # return View(Group(content=items,columns=cols)) 242 | -------------------------------------------------------------------------------- /cvu/orders/laus250_alph.txt: -------------------------------------------------------------------------------- 1 | lh_bankssts_1 2 | lh_bankssts_2 3 | lh_bankssts_3 4 | lh_caudalanteriorcingulate_1 5 | lh_caudalanteriorcingulate_2 6 | lh_caudalmiddlefrontal_1 7 | lh_caudalmiddlefrontal_2 8 | lh_caudalmiddlefrontal_3 9 | lh_caudalmiddlefrontal_4 10 | lh_caudalmiddlefrontal_5 11 | lh_caudalmiddlefrontal_6 12 | delete 13 | lh_cuneus_1 14 | lh_cuneus_2 15 | lh_cuneus_3 16 | lh_entorhinal_1 17 | lh_frontalpole_1 18 | lh_fusiform_1 19 | lh_fusiform_2 20 | lh_fusiform_3 21 | lh_fusiform_4 22 | lh_fusiform_5 23 | lh_fusiform_6 24 | lh_fusiform_7 25 | lh_fusiform_8 26 | lh_inferiorparietal_1 27 | lh_inferiorparietal_10 28 | lh_inferiorparietal_2 29 | lh_inferiorparietal_3 30 | lh_inferiorparietal_4 31 | lh_inferiorparietal_5 32 | lh_inferiorparietal_6 33 | lh_inferiorparietal_7 34 | lh_inferiorparietal_8 35 | lh_inferiorparietal_9 36 | lh_inferiortemporal_1 37 | lh_inferiortemporal_2 38 | lh_inferiortemporal_3 39 | lh_inferiortemporal_4 40 | lh_inferiortemporal_5 41 | lh_inferiortemporal_6 42 | lh_inferiortemporal_7 43 | lh_inferiortemporal_8 44 | lh_insula_1 45 | lh_insula_2 46 | lh_insula_3 47 | lh_insula_4 48 | lh_insula_5 49 | lh_insula_6 50 | lh_insula_7 51 | lh_isthmuscingulate_1 52 | lh_isthmuscingulate_2 53 | lh_isthmuscingulate_3 54 | lh_lateraloccipital_1 55 | lh_lateraloccipital_10 56 | lh_lateraloccipital_11 57 | lh_lateraloccipital_2 58 | lh_lateraloccipital_3 59 | lh_lateraloccipital_4 60 | lh_lateraloccipital_5 61 | lh_lateraloccipital_6 62 | lh_lateraloccipital_7 63 | lh_lateraloccipital_8 64 | lh_lateraloccipital_9 65 | lh_lateralorbitofrontal_1 66 | lh_lateralorbitofrontal_2 67 | lh_lateralorbitofrontal_3 68 | lh_lateralorbitofrontal_4 69 | lh_lateralorbitofrontal_5 70 | lh_lateralorbitofrontal_6 71 | lh_lateralorbitofrontal_7 72 | lh_lingual_1 73 | lh_lingual_2 74 | lh_lingual_3 75 | lh_lingual_4 76 | lh_lingual_5 77 | lh_lingual_6 78 | lh_lingual_7 79 | lh_lingual_8 80 | lh_medialorbitofrontal_1 81 | lh_medialorbitofrontal_2 82 | lh_medialorbitofrontal_3 83 | lh_medialorbitofrontal_4 84 | lh_medialorbitofrontal_5 85 | lh_middletemporal_1 86 | lh_middletemporal_2 87 | lh_middletemporal_3 88 | lh_middletemporal_4 89 | lh_middletemporal_5 90 | lh_middletemporal_6 91 | lh_middletemporal_7 92 | lh_paracentral_1 93 | lh_paracentral_2 94 | lh_paracentral_3 95 | lh_paracentral_4 96 | lh_paracentral_5 97 | lh_parahippocampal_1 98 | lh_parahippocampal_2 99 | lh_parahippocampal_3 100 | lh_parsopercularis_1 101 | lh_parsopercularis_2 102 | lh_parsopercularis_3 103 | lh_parsopercularis_4 104 | lh_parsorbitalis_1 105 | lh_parsorbitalis_2 106 | lh_parstriangularis_1 107 | lh_parstriangularis_2 108 | lh_parstriangularis_3 109 | lh_pericalcarine_1 110 | lh_pericalcarine_2 111 | lh_pericalcarine_3 112 | lh_postcentral_1 113 | lh_postcentral_10 114 | lh_postcentral_11 115 | lh_postcentral_12 116 | lh_postcentral_13 117 | lh_postcentral_14 118 | lh_postcentral_2 119 | lh_postcentral_3 120 | lh_postcentral_4 121 | lh_postcentral_5 122 | lh_postcentral_6 123 | lh_postcentral_7 124 | lh_postcentral_8 125 | lh_postcentral_9 126 | lh_posteriorcingulate_1 127 | lh_posteriorcingulate_2 128 | lh_posteriorcingulate_3 129 | lh_posteriorcingulate_4 130 | lh_precentral_1 131 | lh_precentral_10 132 | lh_precentral_11 133 | lh_precentral_12 134 | lh_precentral_13 135 | lh_precentral_14 136 | lh_precentral_15 137 | lh_precentral_16 138 | lh_precentral_2 139 | lh_precentral_3 140 | lh_precentral_4 141 | lh_precentral_5 142 | lh_precentral_6 143 | lh_precentral_7 144 | lh_precentral_8 145 | lh_precentral_9 146 | lh_precuneus_1 147 | lh_precuneus_10 148 | lh_precuneus_11 149 | lh_precuneus_2 150 | lh_precuneus_3 151 | lh_precuneus_4 152 | lh_precuneus_5 153 | lh_precuneus_6 154 | lh_precuneus_7 155 | lh_precuneus_8 156 | lh_precuneus_9 157 | lh_rostralanteriorcingulate_1 158 | lh_rostralanteriorcingulate_2 159 | lh_rostralmiddlefrontal_1 160 | lh_rostralmiddlefrontal_10 161 | lh_rostralmiddlefrontal_11 162 | lh_rostralmiddlefrontal_12 163 | lh_rostralmiddlefrontal_2 164 | lh_rostralmiddlefrontal_3 165 | lh_rostralmiddlefrontal_4 166 | lh_rostralmiddlefrontal_5 167 | lh_rostralmiddlefrontal_6 168 | lh_rostralmiddlefrontal_7 169 | lh_rostralmiddlefrontal_8 170 | lh_rostralmiddlefrontal_9 171 | lh_superiorfrontal_1 172 | lh_superiorfrontal_10 173 | lh_superiorfrontal_11 174 | lh_superiorfrontal_12 175 | lh_superiorfrontal_13 176 | lh_superiorfrontal_14 177 | lh_superiorfrontal_15 178 | lh_superiorfrontal_16 179 | lh_superiorfrontal_17 180 | lh_superiorfrontal_18 181 | lh_superiorfrontal_2 182 | lh_superiorfrontal_3 183 | lh_superiorfrontal_4 184 | lh_superiorfrontal_5 185 | lh_superiorfrontal_6 186 | lh_superiorfrontal_7 187 | lh_superiorfrontal_8 188 | lh_superiorfrontal_9 189 | lh_superiorparietal_1 190 | lh_superiorparietal_10 191 | lh_superiorparietal_11 192 | lh_superiorparietal_12 193 | lh_superiorparietal_13 194 | lh_superiorparietal_14 195 | lh_superiorparietal_2 196 | lh_superiorparietal_3 197 | lh_superiorparietal_4 198 | lh_superiorparietal_5 199 | lh_superiorparietal_6 200 | lh_superiorparietal_7 201 | lh_superiorparietal_8 202 | lh_superiorparietal_9 203 | lh_superiortemporal_1 204 | lh_superiortemporal_10 205 | lh_superiortemporal_11 206 | lh_superiortemporal_2 207 | lh_superiortemporal_3 208 | lh_superiortemporal_4 209 | lh_superiortemporal_5 210 | lh_superiortemporal_6 211 | lh_superiortemporal_7 212 | lh_superiortemporal_8 213 | lh_superiortemporal_9 214 | lh_supramarginal_1 215 | lh_supramarginal_10 216 | lh_supramarginal_2 217 | lh_supramarginal_3 218 | lh_supramarginal_4 219 | lh_supramarginal_5 220 | lh_supramarginal_6 221 | lh_supramarginal_7 222 | lh_supramarginal_8 223 | lh_supramarginal_9 224 | lh_temporalpole_1 225 | lh_transversetemporal_1 226 | lh_transversetemporal_2 227 | delete 228 | rh_bankssts_1 229 | rh_bankssts_2 230 | rh_bankssts_3 231 | rh_caudalanteriorcingulate_1 232 | rh_caudalanteriorcingulate_2 233 | rh_caudalanteriorcingulate_3 234 | rh_caudalmiddlefrontal_1 235 | rh_caudalmiddlefrontal_2 236 | rh_caudalmiddlefrontal_3 237 | rh_caudalmiddlefrontal_4 238 | rh_caudalmiddlefrontal_5 239 | delete 240 | rh_cuneus_1 241 | rh_cuneus_2 242 | rh_cuneus_3 243 | rh_cuneus_4 244 | rh_entorhinal_1 245 | rh_frontalpole_1 246 | rh_fusiform_1 247 | rh_fusiform_2 248 | rh_fusiform_3 249 | rh_fusiform_4 250 | rh_fusiform_5 251 | rh_fusiform_6 252 | rh_fusiform_7 253 | rh_fusiform_8 254 | rh_inferiorparietal_1 255 | rh_inferiorparietal_10 256 | rh_inferiorparietal_11 257 | rh_inferiorparietal_12 258 | rh_inferiorparietal_2 259 | rh_inferiorparietal_3 260 | rh_inferiorparietal_4 261 | rh_inferiorparietal_5 262 | rh_inferiorparietal_6 263 | rh_inferiorparietal_7 264 | rh_inferiorparietal_8 265 | rh_inferiorparietal_9 266 | rh_inferiortemporal_1 267 | rh_inferiortemporal_2 268 | rh_inferiortemporal_3 269 | rh_inferiortemporal_4 270 | rh_inferiortemporal_5 271 | rh_inferiortemporal_6 272 | rh_inferiortemporal_7 273 | rh_insula_1 274 | rh_insula_2 275 | rh_insula_3 276 | rh_insula_4 277 | rh_insula_5 278 | rh_insula_6 279 | rh_insula_7 280 | rh_isthmuscingulate_1 281 | rh_isthmuscingulate_2 282 | rh_lateraloccipital_1 283 | rh_lateraloccipital_10 284 | rh_lateraloccipital_2 285 | rh_lateraloccipital_3 286 | rh_lateraloccipital_4 287 | rh_lateraloccipital_5 288 | rh_lateraloccipital_6 289 | rh_lateraloccipital_7 290 | rh_lateraloccipital_8 291 | rh_lateraloccipital_9 292 | rh_lateralorbitofrontal_1 293 | rh_lateralorbitofrontal_2 294 | rh_lateralorbitofrontal_3 295 | rh_lateralorbitofrontal_4 296 | rh_lateralorbitofrontal_5 297 | rh_lateralorbitofrontal_6 298 | rh_lateralorbitofrontal_7 299 | rh_lingual_1 300 | rh_lingual_2 301 | rh_lingual_3 302 | rh_lingual_4 303 | rh_lingual_5 304 | rh_lingual_6 305 | rh_lingual_7 306 | rh_medialorbitofrontal_1 307 | rh_medialorbitofrontal_2 308 | rh_medialorbitofrontal_3 309 | rh_medialorbitofrontal_4 310 | rh_medialorbitofrontal_5 311 | rh_middletemporal_1 312 | rh_middletemporal_2 313 | rh_middletemporal_3 314 | rh_middletemporal_4 315 | rh_middletemporal_5 316 | rh_middletemporal_6 317 | rh_middletemporal_7 318 | rh_middletemporal_8 319 | rh_middletemporal_9 320 | rh_paracentral_1 321 | rh_paracentral_2 322 | rh_paracentral_3 323 | rh_paracentral_4 324 | rh_paracentral_5 325 | rh_paracentral_6 326 | rh_parahippocampal_1 327 | rh_parahippocampal_2 328 | rh_parahippocampal_3 329 | rh_parsopercularis_1 330 | rh_parsopercularis_2 331 | rh_parsopercularis_3 332 | rh_parsopercularis_4 333 | rh_parsorbitalis_1 334 | rh_parsorbitalis_2 335 | rh_parstriangularis_1 336 | rh_parstriangularis_2 337 | rh_parstriangularis_3 338 | rh_parstriangularis_4 339 | rh_pericalcarine_1 340 | rh_pericalcarine_2 341 | rh_pericalcarine_3 342 | rh_pericalcarine_4 343 | rh_postcentral_1 344 | rh_postcentral_10 345 | rh_postcentral_11 346 | rh_postcentral_12 347 | rh_postcentral_2 348 | rh_postcentral_3 349 | rh_postcentral_4 350 | rh_postcentral_5 351 | rh_postcentral_6 352 | rh_postcentral_7 353 | rh_postcentral_8 354 | rh_postcentral_9 355 | rh_posteriorcingulate_1 356 | rh_posteriorcingulate_2 357 | rh_posteriorcingulate_3 358 | rh_posteriorcingulate_4 359 | rh_precentral_1 360 | rh_precentral_10 361 | rh_precentral_11 362 | rh_precentral_12 363 | rh_precentral_13 364 | rh_precentral_14 365 | rh_precentral_15 366 | rh_precentral_16 367 | rh_precentral_2 368 | rh_precentral_3 369 | rh_precentral_4 370 | rh_precentral_5 371 | rh_precentral_6 372 | rh_precentral_7 373 | rh_precentral_8 374 | rh_precentral_9 375 | rh_precuneus_1 376 | rh_precuneus_10 377 | rh_precuneus_2 378 | rh_precuneus_3 379 | rh_precuneus_4 380 | rh_precuneus_5 381 | rh_precuneus_6 382 | rh_precuneus_7 383 | rh_precuneus_8 384 | rh_precuneus_9 385 | rh_rostralanteriorcingulate_1 386 | rh_rostralanteriorcingulate_2 387 | rh_rostralmiddlefrontal_1 388 | rh_rostralmiddlefrontal_10 389 | rh_rostralmiddlefrontal_11 390 | rh_rostralmiddlefrontal_12 391 | rh_rostralmiddlefrontal_13 392 | rh_rostralmiddlefrontal_2 393 | rh_rostralmiddlefrontal_3 394 | rh_rostralmiddlefrontal_4 395 | rh_rostralmiddlefrontal_5 396 | rh_rostralmiddlefrontal_6 397 | rh_rostralmiddlefrontal_7 398 | rh_rostralmiddlefrontal_8 399 | rh_rostralmiddlefrontal_9 400 | rh_superiorfrontal_1 401 | rh_superiorfrontal_10 402 | rh_superiorfrontal_11 403 | rh_superiorfrontal_12 404 | rh_superiorfrontal_13 405 | rh_superiorfrontal_14 406 | rh_superiorfrontal_15 407 | rh_superiorfrontal_16 408 | rh_superiorfrontal_17 409 | rh_superiorfrontal_2 410 | rh_superiorfrontal_3 411 | rh_superiorfrontal_4 412 | rh_superiorfrontal_5 413 | rh_superiorfrontal_6 414 | rh_superiorfrontal_7 415 | rh_superiorfrontal_8 416 | rh_superiorfrontal_9 417 | rh_superiorparietal_1 418 | rh_superiorparietal_10 419 | rh_superiorparietal_11 420 | rh_superiorparietal_12 421 | rh_superiorparietal_13 422 | rh_superiorparietal_2 423 | rh_superiorparietal_3 424 | rh_superiorparietal_4 425 | rh_superiorparietal_5 426 | rh_superiorparietal_6 427 | rh_superiorparietal_7 428 | rh_superiorparietal_8 429 | rh_superiorparietal_9 430 | rh_superiortemporal_1 431 | rh_superiortemporal_10 432 | rh_superiortemporal_11 433 | rh_superiortemporal_2 434 | rh_superiortemporal_3 435 | rh_superiortemporal_4 436 | rh_superiortemporal_5 437 | rh_superiortemporal_6 438 | rh_superiortemporal_7 439 | rh_superiortemporal_8 440 | rh_superiortemporal_9 441 | rh_supramarginal_1 442 | rh_supramarginal_2 443 | rh_supramarginal_3 444 | rh_supramarginal_4 445 | rh_supramarginal_5 446 | rh_supramarginal_6 447 | rh_supramarginal_7 448 | rh_supramarginal_8 449 | rh_supramarginal_9 450 | rh_temporalpole_1 451 | rh_transversetemporal_1 452 | delete 453 | -------------------------------------------------------------------------------- /cvu/orders/laus250_cmp.txt: -------------------------------------------------------------------------------- 1 | rh_lateralorbitofrontal_1 2 | rh_lateralorbitofrontal_2 3 | rh_lateralorbitofrontal_3 4 | rh_lateralorbitofrontal_4 5 | rh_lateralorbitofrontal_5 6 | rh_lateralorbitofrontal_6 7 | rh_lateralorbitofrontal_7 8 | rh_parsorbitalis_1 9 | rh_parsorbitalis_2 10 | rh_frontalpole_1 11 | rh_medialorbitofrontal_1 12 | rh_medialorbitofrontal_2 13 | rh_medialorbitofrontal_3 14 | delete 15 | rh_medialorbitofrontal_5 16 | rh_parstriangularis_1 17 | rh_parstriangularis_2 18 | rh_parstriangularis_3 19 | rh_parstriangularis_4 20 | rh_parsopercularis_1 21 | rh_parsopercularis_2 22 | rh_parsopercularis_3 23 | rh_parsopercularis_4 24 | rh_rostralmiddlefrontal_1 25 | rh_rostralmiddlefrontal_2 26 | rh_rostralmiddlefrontal_3 27 | rh_rostralmiddlefrontal_4 28 | rh_rostralmiddlefrontal_5 29 | rh_rostralmiddlefrontal_6 30 | rh_rostralmiddlefrontal_7 31 | rh_rostralmiddlefrontal_8 32 | rh_rostralmiddlefrontal_9 33 | rh_rostralmiddlefrontal_10 34 | rh_rostralmiddlefrontal_11 35 | rh_rostralmiddlefrontal_12 36 | rh_rostralmiddlefrontal_13 37 | rh_superiorfrontal_1 38 | rh_superiorfrontal_2 39 | delete 40 | rh_superiorfrontal_4 41 | rh_superiorfrontal_5 42 | rh_superiorfrontal_6 43 | rh_superiorfrontal_7 44 | rh_superiorfrontal_8 45 | rh_superiorfrontal_9 46 | rh_superiorfrontal_10 47 | rh_superiorfrontal_11 48 | rh_superiorfrontal_12 49 | rh_superiorfrontal_13 50 | rh_superiorfrontal_14 51 | rh_superiorfrontal_15 52 | rh_superiorfrontal_16 53 | rh_superiorfrontal_17 54 | rh_caudalmiddlefrontal_1 55 | rh_caudalmiddlefrontal_2 56 | rh_caudalmiddlefrontal_3 57 | rh_caudalmiddlefrontal_4 58 | rh_caudalmiddlefrontal_5 59 | rh_precentral_1 60 | rh_precentral_2 61 | delete 62 | rh_precentral_4 63 | rh_precentral_5 64 | rh_precentral_6 65 | rh_precentral_7 66 | rh_precentral_8 67 | rh_precentral_9 68 | rh_precentral_10 69 | rh_precentral_11 70 | rh_precentral_12 71 | rh_precentral_13 72 | rh_precentral_14 73 | rh_precentral_15 74 | rh_precentral_16 75 | rh_paracentral_1 76 | rh_paracentral_2 77 | rh_paracentral_3 78 | rh_paracentral_4 79 | rh_paracentral_5 80 | rh_paracentral_6 81 | rh_rostralanteriorcingulate_1 82 | rh_rostralanteriorcingulate_2 83 | rh_caudalanteriorcingulate_1 84 | rh_caudalanteriorcingulate_2 85 | rh_caudalanteriorcingulate_3 86 | rh_posteriorcingulate_1 87 | rh_posteriorcingulate_2 88 | rh_posteriorcingulate_3 89 | rh_posteriorcingulate_4 90 | rh_isthmuscingulate_1 91 | rh_isthmuscingulate_2 92 | rh_postcentral_1 93 | rh_postcentral_2 94 | rh_postcentral_3 95 | rh_postcentral_4 96 | rh_postcentral_5 97 | rh_postcentral_6 98 | rh_postcentral_7 99 | rh_postcentral_8 100 | rh_postcentral_9 101 | rh_postcentral_10 102 | rh_postcentral_11 103 | rh_postcentral_12 104 | rh_supramarginal_1 105 | rh_supramarginal_2 106 | rh_supramarginal_3 107 | rh_supramarginal_4 108 | rh_supramarginal_5 109 | rh_supramarginal_6 110 | rh_supramarginal_7 111 | rh_supramarginal_8 112 | rh_supramarginal_9 113 | rh_superiorparietal_1 114 | rh_superiorparietal_2 115 | rh_superiorparietal_3 116 | rh_superiorparietal_4 117 | rh_superiorparietal_5 118 | rh_superiorparietal_6 119 | rh_superiorparietal_7 120 | rh_superiorparietal_8 121 | rh_superiorparietal_9 122 | rh_superiorparietal_10 123 | rh_superiorparietal_11 124 | rh_superiorparietal_12 125 | rh_superiorparietal_13 126 | rh_inferiorparietal_1 127 | rh_inferiorparietal_2 128 | rh_inferiorparietal_3 129 | rh_inferiorparietal_4 130 | rh_inferiorparietal_5 131 | rh_inferiorparietal_6 132 | rh_inferiorparietal_7 133 | rh_inferiorparietal_8 134 | rh_inferiorparietal_9 135 | rh_inferiorparietal_10 136 | rh_inferiorparietal_11 137 | rh_inferiorparietal_12 138 | rh_precuneus_1 139 | rh_precuneus_2 140 | rh_precuneus_3 141 | rh_precuneus_4 142 | rh_precuneus_5 143 | rh_precuneus_6 144 | rh_precuneus_7 145 | rh_precuneus_8 146 | rh_precuneus_9 147 | rh_precuneus_10 148 | rh_cuneus_1 149 | delete 150 | rh_cuneus_3 151 | rh_cuneus_4 152 | rh_pericalcarine_1 153 | rh_pericalcarine_2 154 | rh_pericalcarine_3 155 | rh_pericalcarine_4 156 | rh_lateraloccipital_1 157 | rh_lateraloccipital_2 158 | rh_lateraloccipital_3 159 | rh_lateraloccipital_4 160 | rh_lateraloccipital_5 161 | rh_lateraloccipital_6 162 | rh_lateraloccipital_7 163 | rh_lateraloccipital_8 164 | rh_lateraloccipital_9 165 | rh_lateraloccipital_10 166 | rh_lingual_1 167 | rh_lingual_2 168 | rh_lingual_3 169 | delete 170 | rh_lingual_5 171 | rh_lingual_6 172 | rh_lingual_7 173 | rh_fusiform_1 174 | rh_fusiform_2 175 | rh_fusiform_3 176 | rh_fusiform_4 177 | rh_fusiform_5 178 | rh_fusiform_6 179 | rh_fusiform_7 180 | rh_fusiform_8 181 | rh_parahippocampal_1 182 | rh_parahippocampal_2 183 | rh_parahippocampal_3 184 | rh_entorhinal_1 185 | rh_temporalpole_1 186 | rh_inferiortemporal_1 187 | rh_inferiortemporal_2 188 | rh_inferiortemporal_3 189 | rh_inferiortemporal_4 190 | rh_inferiortemporal_5 191 | rh_inferiortemporal_6 192 | rh_inferiortemporal_7 193 | rh_middletemporal_1 194 | rh_middletemporal_2 195 | rh_middletemporal_3 196 | rh_middletemporal_4 197 | rh_middletemporal_5 198 | rh_middletemporal_6 199 | rh_middletemporal_7 200 | rh_middletemporal_8 201 | rh_middletemporal_9 202 | rh_bankssts_1 203 | rh_bankssts_2 204 | rh_bankssts_3 205 | rh_superiortemporal_1 206 | rh_superiortemporal_2 207 | rh_superiortemporal_3 208 | rh_superiortemporal_4 209 | rh_superiortemporal_5 210 | rh_superiortemporal_6 211 | rh_superiortemporal_7 212 | rh_superiortemporal_8 213 | rh_superiortemporal_9 214 | rh_superiortemporal_10 215 | rh_superiortemporal_11 216 | rh_transversetemporal_1 217 | rh_insula_1 218 | rh_insula_2 219 | rh_insula_3 220 | rh_insula_4 221 | rh_insula_5 222 | rh_insula_6 223 | rh_insula_7 224 | delete 225 | delete 226 | delete 227 | delete 228 | delete 229 | delete 230 | delete 231 | lh_lateralorbitofrontal_1 232 | lh_lateralorbitofrontal_2 233 | lh_lateralorbitofrontal_3 234 | lh_lateralorbitofrontal_4 235 | lh_lateralorbitofrontal_5 236 | lh_lateralorbitofrontal_6 237 | lh_lateralorbitofrontal_7 238 | lh_parsorbitalis_1 239 | lh_parsorbitalis_2 240 | lh_frontalpole_1 241 | lh_medialorbitofrontal_1 242 | lh_medialorbitofrontal_2 243 | lh_medialorbitofrontal_3 244 | lh_medialorbitofrontal_4 245 | lh_medialorbitofrontal_5 246 | lh_parstriangularis_1 247 | lh_parstriangularis_2 248 | lh_parstriangularis_3 249 | lh_parsopercularis_1 250 | lh_parsopercularis_2 251 | lh_parsopercularis_3 252 | lh_parsopercularis_4 253 | lh_rostralmiddlefrontal_1 254 | lh_rostralmiddlefrontal_2 255 | lh_rostralmiddlefrontal_3 256 | lh_rostralmiddlefrontal_4 257 | lh_rostralmiddlefrontal_5 258 | lh_rostralmiddlefrontal_6 259 | lh_rostralmiddlefrontal_7 260 | lh_rostralmiddlefrontal_8 261 | lh_rostralmiddlefrontal_9 262 | lh_rostralmiddlefrontal_10 263 | lh_rostralmiddlefrontal_11 264 | lh_rostralmiddlefrontal_12 265 | lh_superiorfrontal_1 266 | lh_superiorfrontal_2 267 | lh_superiorfrontal_3 268 | lh_superiorfrontal_4 269 | lh_superiorfrontal_5 270 | lh_superiorfrontal_6 271 | lh_superiorfrontal_7 272 | lh_superiorfrontal_8 273 | lh_superiorfrontal_9 274 | lh_superiorfrontal_10 275 | lh_superiorfrontal_11 276 | lh_superiorfrontal_12 277 | lh_superiorfrontal_13 278 | lh_superiorfrontal_14 279 | lh_superiorfrontal_15 280 | lh_superiorfrontal_16 281 | lh_superiorfrontal_17 282 | lh_superiorfrontal_18 283 | lh_caudalmiddlefrontal_1 284 | lh_caudalmiddlefrontal_2 285 | lh_caudalmiddlefrontal_3 286 | lh_caudalmiddlefrontal_4 287 | lh_caudalmiddlefrontal_5 288 | lh_caudalmiddlefrontal_6 289 | lh_precentral_1 290 | lh_precentral_2 291 | lh_precentral_3 292 | lh_precentral_4 293 | lh_precentral_5 294 | lh_precentral_6 295 | lh_precentral_7 296 | lh_precentral_8 297 | lh_precentral_9 298 | lh_precentral_10 299 | lh_precentral_11 300 | lh_precentral_12 301 | lh_precentral_13 302 | lh_precentral_14 303 | lh_precentral_15 304 | lh_precentral_16 305 | lh_paracentral_1 306 | lh_paracentral_2 307 | lh_paracentral_3 308 | lh_paracentral_4 309 | lh_paracentral_5 310 | lh_rostralanteriorcingulate_1 311 | lh_rostralanteriorcingulate_2 312 | lh_caudalanteriorcingulate_1 313 | lh_caudalanteriorcingulate_2 314 | lh_posteriorcingulate_1 315 | lh_posteriorcingulate_2 316 | lh_posteriorcingulate_3 317 | lh_posteriorcingulate_4 318 | lh_isthmuscingulate_1 319 | lh_isthmuscingulate_2 320 | lh_isthmuscingulate_3 321 | lh_postcentral_1 322 | lh_postcentral_2 323 | lh_postcentral_3 324 | lh_postcentral_4 325 | lh_postcentral_5 326 | lh_postcentral_6 327 | lh_postcentral_7 328 | lh_postcentral_8 329 | lh_postcentral_9 330 | lh_postcentral_10 331 | lh_postcentral_11 332 | lh_postcentral_12 333 | lh_postcentral_13 334 | lh_postcentral_14 335 | lh_supramarginal_1 336 | lh_supramarginal_2 337 | lh_supramarginal_3 338 | lh_supramarginal_4 339 | lh_supramarginal_5 340 | lh_supramarginal_6 341 | lh_supramarginal_7 342 | lh_supramarginal_8 343 | lh_supramarginal_9 344 | lh_supramarginal_10 345 | lh_superiorparietal_1 346 | lh_superiorparietal_2 347 | lh_superiorparietal_3 348 | lh_superiorparietal_4 349 | lh_superiorparietal_5 350 | lh_superiorparietal_6 351 | lh_superiorparietal_7 352 | lh_superiorparietal_8 353 | lh_superiorparietal_9 354 | lh_superiorparietal_10 355 | lh_superiorparietal_11 356 | lh_superiorparietal_12 357 | lh_superiorparietal_13 358 | lh_superiorparietal_14 359 | lh_inferiorparietal_1 360 | lh_inferiorparietal_2 361 | lh_inferiorparietal_3 362 | lh_inferiorparietal_4 363 | lh_inferiorparietal_5 364 | lh_inferiorparietal_6 365 | lh_inferiorparietal_7 366 | lh_inferiorparietal_8 367 | lh_inferiorparietal_9 368 | lh_inferiorparietal_10 369 | lh_precuneus_1 370 | lh_precuneus_2 371 | lh_precuneus_3 372 | lh_precuneus_4 373 | lh_precuneus_5 374 | lh_precuneus_6 375 | lh_precuneus_7 376 | lh_precuneus_8 377 | lh_precuneus_9 378 | lh_precuneus_10 379 | lh_precuneus_11 380 | lh_cuneus_1 381 | lh_cuneus_2 382 | lh_cuneus_3 383 | delete 384 | lh_pericalcarine_2 385 | lh_pericalcarine_3 386 | lh_lateraloccipital_1 387 | lh_lateraloccipital_2 388 | lh_lateraloccipital_3 389 | lh_lateraloccipital_4 390 | lh_lateraloccipital_5 391 | lh_lateraloccipital_6 392 | lh_lateraloccipital_7 393 | lh_lateraloccipital_8 394 | lh_lateraloccipital_9 395 | lh_lateraloccipital_10 396 | lh_lateraloccipital_11 397 | lh_lingual_1 398 | lh_lingual_2 399 | lh_lingual_3 400 | lh_lingual_4 401 | lh_lingual_5 402 | lh_lingual_6 403 | lh_lingual_7 404 | lh_lingual_8 405 | lh_fusiform_1 406 | lh_fusiform_2 407 | lh_fusiform_3 408 | lh_fusiform_4 409 | lh_fusiform_5 410 | lh_fusiform_6 411 | lh_fusiform_7 412 | lh_fusiform_8 413 | lh_parahippocampal_1 414 | lh_parahippocampal_2 415 | lh_parahippocampal_3 416 | lh_entorhinal_1 417 | lh_temporalpole_1 418 | lh_inferiortemporal_1 419 | lh_inferiortemporal_2 420 | lh_inferiortemporal_3 421 | lh_inferiortemporal_4 422 | lh_inferiortemporal_5 423 | lh_inferiortemporal_6 424 | lh_inferiortemporal_7 425 | lh_inferiortemporal_8 426 | lh_middletemporal_1 427 | lh_middletemporal_2 428 | lh_middletemporal_3 429 | lh_middletemporal_4 430 | lh_middletemporal_5 431 | lh_middletemporal_6 432 | lh_middletemporal_7 433 | lh_bankssts_1 434 | lh_bankssts_2 435 | lh_bankssts_3 436 | lh_superiortemporal_1 437 | lh_superiortemporal_2 438 | lh_superiortemporal_3 439 | lh_superiortemporal_4 440 | lh_superiortemporal_5 441 | lh_superiortemporal_6 442 | lh_superiortemporal_7 443 | lh_superiortemporal_8 444 | delete 445 | lh_superiortemporal_10 446 | lh_superiortemporal_11 447 | lh_transversetemporal_1 448 | lh_transversetemporal_2 449 | lh_insula_1 450 | lh_insula_2 451 | lh_insula_3 452 | lh_insula_4 453 | lh_insula_5 454 | lh_insula_6 455 | lh_insula_7 456 | delete 457 | delete 458 | delete 459 | delete 460 | delete 461 | delete 462 | delete 463 | delete 464 | -------------------------------------------------------------------------------- /cvu/options_struct.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | from traits.api import (HasTraits,Instance,Int,Range,Bool,Float,Property,Enum, 19 | Str,List,Either,Directory,Any,File,on_trait_change,cached_property) 20 | from color_map import CustomColormap 21 | from color_legend import ColorLegend 22 | from graph import StatisticsDisplay 23 | import os 24 | import numpy as np 25 | 26 | class OptionsDatabase(HasTraits): 27 | def __init__(self,ds_orig,**kwargs): 28 | super(OptionsDatabase,self).__init__(**kwargs) 29 | self.parcellation_chooser_parameters=( 30 | ParcellationChooserParameters(ds_orig)) 31 | self.adjmat_chooser_parameters=( 32 | AdjmatChooserParameters(ds_orig)) 33 | self.tractography_chooser_parameters=( 34 | TractographyChooserParameters(ds_orig)) 35 | self.general_matrix_chooser_parameters=( 36 | GeneralMatrixChooserParameters(ds_orig)) 37 | self.node_chooser_parameters=( 38 | NodeChooserParameters(ds_orig)) 39 | self.calculate_parameters=( 40 | CalculateParameters(ds_orig)) 41 | self.module_chooser_parameters=( 42 | ModuleChooserParameters(ds_orig)) 43 | self.module_customizer_parameters=( 44 | ModuleCustomizerParameters(ds_orig)) 45 | self.color_legend_parameters=( 46 | ColorLegendParameters(ds_orig)) 47 | self.snapshot_parameters=( 48 | SnapshotParameters(ds_orig)) 49 | self.make_movie_parameters=( 50 | MakeMovieParameters(ds_orig)) 51 | self.graph_theory_parameters=( 52 | GraphTheoryParameters(ds_orig)) 53 | 54 | #GUI INTERACTION PARAMETER CLASSES 55 | 56 | #the idea is to separate GUI construction and the location of the data referred 57 | #to by GUI editors. The idea of having data specified directly in GUI window 58 | #makes it difficult to appropriately designate that data to the proper target 59 | #dataset. For some targets this is not an issue (e.g., AboutWindow) but having 60 | #the data in the GUI component itself is still a bit kludgy (even if traits 61 | #expects this). 62 | 63 | #So, I'll just have everything out in an OptionsStructure whether it really 64 | #needs it or not, except stuff like AboutWindow which literally has no data. 65 | 66 | ####################################################################### 67 | # OPTIONS STRUCTURES 68 | ####################################################################### 69 | 70 | #having the reference to the dataset is not needed by most of the structs, 71 | #but having the bidirectional access is very helpful to avoid copying data in 72 | #a number of cases 73 | class DatasetReferenceOptionsStructure(HasTraits): 74 | ds_ref=Any #symbolic reference to a dataset 75 | 76 | def __init__(self,ds_ref,**kwargs): 77 | super(DatasetReferenceOptionsStructure,self).__init__(**kwargs) 78 | self.ds_ref=ds_ref 79 | 80 | class DisplayOptions(DatasetReferenceOptionsStructure): 81 | #THE DISPLAY OPTIONS SHOULD BE DISPLAYED IN NUMEROUS TABS 82 | # **MISCELLANEOUS, **COLORMAPS, **GRAPH STATISTICS 83 | #* should be moved to a non-display-related tab if there are enough items 84 | #miscellaneous tab 85 | surface_visibility = Range(0.0,1.0,.15) 86 | circ_size = Range(7,20,10,mode='spinner') 87 | circ_symmetry = Enum('bilateral','radial') 88 | circ_bilateral_symmetry=Property(depends_on='circ_symmetry') 89 | def _get_circ_bilateral_symmetry(self): 90 | return self.circ_symmetry=='bilateral' 91 | conns_colorbar=Bool(False) 92 | scalar_colorbar=Bool(False) 93 | pthresh = Range(0.,1.,.95) 94 | athresh = Float 95 | thresh_type = Enum('prop','abs') 96 | prune_modules = Bool(True) 97 | show_floating_text = Bool(True) 98 | module_view_style = Enum('intramodular','intermodular','both') 99 | modules_on_surface = Bool(False) 100 | render_style=Enum('glass','cracked_glass','contours','wireframe','speckled') 101 | interhemi_conns_on = Bool(True) 102 | lh_conns_on = Bool(True) 103 | rh_conns_on = Bool(True) 104 | lh_nodes_on = Bool(True) 105 | rh_nodes_on = Bool(True) 106 | lh_surfs_on = Bool(True) 107 | rh_surfs_on = Bool(True) 108 | conns_width = Float(2.) 109 | tube_conns = Bool(False) 110 | circle_render = Enum('singlethreaded', 'asynchronous', 'disabled') 111 | conns_colors_on = Bool(True) 112 | 113 | #colormap tab 114 | default_map= Instance(CustomColormap) 115 | def _default_map_default(self): return CustomColormap('default') 116 | scalar_map= Instance(CustomColormap) 117 | def _scalar_map_default(self): return CustomColormap('scalar') 118 | activation_map= Instance(CustomColormap) 119 | def _activation_map_default(self): return CustomColormap('activation') 120 | connmat_map= Instance(CustomColormap) 121 | def _connmat_map_default(self): return CustomColormap('connmat') 122 | 123 | #graph statistics tab 124 | intermediate_graphopts_list=List(Str) 125 | 126 | def _intermediate_graphopts_list_default(self): 127 | return ['global efficiency', 'clustering coefficient', 128 | 'average strength','eigenvector centrality','binary kcore'] 129 | 130 | class ScalarDisplaySettings(DatasetReferenceOptionsStructure): 131 | node_color=Either(Str,None) 132 | surf_color=Either(Str,None) 133 | node_size=Either(Str,None) 134 | circle=Either(Str,None) 135 | connmat=Either(Str,None) 136 | #scalar_sets=List(Str) 137 | scalar_sets=Property(List(Either(Str,None))) 138 | def _get_scalar_sets(self): 139 | return [None]+self.ds_ref.node_scalars.keys() 140 | #def update_scalars(self): 141 | # self.scalar_sets=self.ds_ref.node_scalars.keys() 142 | 143 | def reset_configuration(self): 144 | self.node_color=''; self.surf_color=''; self.node_size=''; 145 | self.circle=''; self.connmat=''; 146 | 147 | class ParcellationChooserParameters(DatasetReferenceOptionsStructure): 148 | new_dataset=Bool(False) 149 | new_dataset_name=Str 150 | subjects_dir=Directory('./') 151 | subject=Str('fsavg5') 152 | ordering_file=File 153 | surface_type=Str('pial') 154 | 155 | parcellation_type=Enum('surface', 'volume file', 'coordinates file') 156 | parcellation_name=Str #surface 157 | parcellation_volume=File #volume 158 | volume_ordering=File #volume 159 | parcellation_coords=File #coordinates 160 | registration_matrix=File #volume and coordinates 161 | 162 | class AdjmatChooserParameters(DatasetReferenceOptionsStructure): 163 | adjmat=Either(File, np.ndarray, np.matrix) 164 | adjmat_order=Either(File, None, list) 165 | max_edges=Int 166 | field_name=Either(Str, None) 167 | ignore_deletes=Bool 168 | require_ls=List(Str) 169 | suppress_extra_rois=Bool 170 | 171 | def _adjmat_default(self): 172 | return '' 173 | 174 | def _adjmat_order_default(self): 175 | return '' 176 | 177 | class TractographyChooserParameters(DatasetReferenceOptionsStructure): 178 | track_file=File 179 | b0_volume=File 180 | subjects_dir=Directory 181 | subject=Str 182 | fs_setup=File('/usr/local/freesurfer/nmr-stable53-env') 183 | 184 | class GeneralMatrixChooserParameters(DatasetReferenceOptionsStructure): 185 | mat=File 186 | mat_order=File 187 | field_name=Str 188 | ignore_deletes=Bool 189 | whichkind=Enum('modules','scalars') 190 | #scalar_name=Enum 191 | 192 | measure_nr=Int(1) 193 | measure_name=Property(Str) 194 | measure_has_custom_name=Bool(False) 195 | measure_custom_name=Str 196 | def _get_measure_name(self): 197 | return (self.measure_custom_name if self.measure_has_custom_name else 198 | 'scalars%i'%self.measure_nr) 199 | def _set_measure_name(self,new_val): 200 | self.measure_has_custom_name=True 201 | self.measure_custom_name=new_val 202 | def _increment_scalar_count(self): 203 | self.measure_nr+=1 204 | self.measure_has_custom_name=False 205 | 206 | class NodeChooserParameters(DatasetReferenceOptionsStructure): 207 | cur_node=Int(-1) 208 | node_list=Property(List(Str)) 209 | def _get_node_list(self): 210 | return self.ds_ref.labnam 211 | 212 | class CalculateParameters(DatasetReferenceOptionsStructure): 213 | calculation_type=Enum('modules','statistics') 214 | athresh=Float 215 | pthresh=Range(0.,1.,.8) 216 | thresh_type=Enum('prop','abs') 217 | 218 | class ModuleChooserParameters(DatasetReferenceOptionsStructure): 219 | cur_mod=Int(-1) 220 | module_list=Property(List(Str),depends_on='ds_ref.modules') 221 | @cached_property 222 | def _get_module_list(self): 223 | return ['Module %i'%i for i,m in enumerate(self.ds_ref.modules)] 224 | 225 | class ModuleCustomizerParameters(DatasetReferenceOptionsStructure): 226 | initial_node_list=Property(List(Str)) 227 | def _get_initial_node_list(self): 228 | return self.ds_ref.labnam 229 | intermediate_node_list=List(Str) 230 | return_module=List(Int) 231 | 232 | #index_convert may return a ValueError, it should be contained in try/except 233 | def _index_convert(self): 234 | self.return_module=[self.initial_node_list.index(i) 235 | for i in self.intermediate_node_list] 236 | 237 | class ColorLegendParameters(DatasetReferenceOptionsStructure): 238 | skaabbl=Str('skaabll') 239 | legend=Property(Instance(ColorLegend)) 240 | def _get_legend(self): return self.ds_ref.color_legend 241 | 242 | class SnapshotParameters(DatasetReferenceOptionsStructure): 243 | savefile=Str(os.path.expanduser('~')) 244 | whichplot=Enum('3D brain','connection matrix','circle plot') 245 | dpi=Int(300) 246 | 247 | class MakeMovieParameters(DatasetReferenceOptionsStructure): 248 | savefile=Str(os.path.expanduser('~')) 249 | framerate=Int(20) 250 | bitrate=Int(4000) 251 | samplerate=Int(8) 252 | anim_style=Bool(True) 253 | anim_rate=Int(8) 254 | rotate_deg=Int(10) 255 | debug=Bool(False) 256 | 257 | class GraphTheoryParameters(DatasetReferenceOptionsStructure): 258 | from traitsui.api import View,Item,ListEditor 259 | 260 | graph_stats=Property(List(StatisticsDisplay), 261 | depends_on='ds_ref:graph_stats') #this is a *display* list 262 | #each dataset has its own dictionary of stats from which this is created 263 | current_stat=Instance(StatisticsDisplay) 264 | scalar_savename=File 265 | 266 | @cached_property 267 | def _get_graph_stats(self): 268 | return list( StatisticsDisplay(k,v,self.ds_ref.labnam) for k,v in 269 | self.ds_ref.graph_stats.iteritems() ) 270 | 271 | def _current_stat_changed(self): 272 | self.scalar_savename=self.current_stat.name 273 | 274 | def _proc_export_to_scalar(self): 275 | from traitsui.file_dialog import save_file 276 | filename = save_file() 277 | if filename.endswith('.mat'): 278 | from scipy import io 279 | io.savemat(filename, mdict={self.current_stat.name: 280 | self.current_stat.stat}) 281 | elif filename.endswith('.npy'): 282 | np.save(filename, self.current_stat.stat) 283 | else: 284 | np.savetxt(filename, self.current_stat.stat) 285 | 286 | def _proc_save_to_scalar(self): 287 | self.ds_ref.save_scalar(self.scalar_savename,self.current_stat.stat) 288 | 289 | def _proc_recalculate(self): 290 | self.ds_ref.calculate_graph_stats() 291 | 292 | #before version 4.4.1 of traitsui there was a bug such that list editors 293 | #in notebook mode crash when the model object is specified in extended 294 | #name notation. so instead we create a view with a local model object 295 | old_traitsui_view = View( 296 | Item(name='graph_stats',style='custom', 297 | editor=ListEditor(use_notebook=True,page_name='.name', 298 | selected='current_stat'), 299 | show_label=False,),) 300 | -------------------------------------------------------------------------------- /cvu/controller.py: -------------------------------------------------------------------------------- 1 | # (C) Roan LaPlante 2013 rlaplant@nmr.mgh.harvard.edu 2 | # 3 | # This file is part of cvu, the Connectome Visualization Utility. 4 | # 5 | # cvu is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | from traits.api import (HasTraits,Any,List,Str,Enum,Dict,Instance,Either, 19 | Property,Button,on_trait_change) 20 | from traitsui.api import (Item,Handler,View,ButtonEditor,InstanceEditor, 21 | TextEditor) 22 | from options_struct import OptionsDatabase 23 | from utils import DatasetMetadataElement,CVUError,DisplayMetadata 24 | from viewport import ViewPanel 25 | 26 | class ViewportManagerEntry(HasTraits): 27 | window_name=Str 28 | window_group=Enum('1','2') 29 | all_datasets=List 30 | 31 | class ViewportManager(Handler): 32 | #TODO make this a dialog 33 | from traitsui.api import (Item,View,ObjectColumn,TableEditor,RangeEditor, 34 | CheckListEditor,OKButton) 35 | 36 | ctl=Any 37 | selected_col=Any 38 | 39 | def __init__(self,ctl,**kwargs): 40 | super(Handler,self).__init__(**kwargs) 41 | self.ctl = ctl 42 | 43 | traits_view=View( 44 | Item(name='metadata_list',object='object.ctl', 45 | editor=TableEditor(columns= [ 46 | ObjectColumn(label='Window',name='panel_scratch', 47 | editor=TextEditor(enter_set=True, auto_set=False)), 48 | ObjectColumn(label='Dataset',name='ds_name_scratch', 49 | editor=TextEditor(enter_set=True, auto_set=False))], 50 | edit_view='tabular_view'), 51 | show_label=False,height=200,width=700, 52 | ), 53 | kind='nonmodal',buttons=[OKButton], 54 | title='If it were up to me it would all be in Swahili', 55 | ) 56 | 57 | class DatasetUIMetadata(DatasetMetadataElement): 58 | controller = Any 59 | panel,panel_scratch = 2*(Str,) 60 | ds_name,ds_name_scratch = 2*(Str,) 61 | 62 | display_metadata = Instance(DisplayMetadata) 63 | 64 | rebuild_button = Button 65 | rebuild_label = Property(Str) 66 | def _get_rebuild_label(self): return 'Rebuild %s'%self.panel 67 | 68 | delete_button = Button 69 | delete_label = Property(Str) 70 | def _get_delete_label(self): return 'Delete %s'%self.ds_name 71 | 72 | def __init__(self,controller,panel,name,display_metadata,**kwargs): 73 | self.panel = self.panel_scratch = panel 74 | self.ds_name = self.ds_name_scratch = name 75 | super(DatasetUIMetadata,self).__init__(controller,**kwargs) 76 | self.controller = controller 77 | self.display_metadata = display_metadata 78 | 79 | def _rebuild_button_fired(self): 80 | if self.panel == 'base_gui': 81 | self.controller.error_dialog( 82 | 'Rebuilding the base GUI is not allowed'); return 83 | self.controller.rebuild_panel(self.panel) 84 | def _delete_button_fired(self): 85 | if (self.controller.ds_instances[self.ds_name] is 86 | self.controller.ds_orig): 87 | self.controller.error_dialog( 88 | "Removal of the sample data is not allowed"); return 89 | self.controller.remove_dataset(self.ds_name) 90 | 91 | @on_trait_change('panel_scratch') 92 | def _rename_panel(self): 93 | if self.panel == 'base_gui': 94 | self.controller.warning_dialog( 95 | 'Renaming the base gui window is not allowed'); return 96 | old_name = self.controller.panel_instances[self.panel].panel_name 97 | new_name = self.panel_scratch 98 | self.controller.rename_panel(old_name,new_name) 99 | self.panel = self.panel_scratch 100 | 101 | @on_trait_change('ds_name_scratch') 102 | def _rename_ds(self): 103 | old_name = self.controller.ds_instances[self.ds_name].name 104 | new_name = self.ds_name_scratch 105 | self.controller.rename_dataset(old_name,new_name) 106 | self.ds_name = self.ds_name_scratch 107 | 108 | tabular_view = View( 109 | Item(name='rebuild_button', 110 | editor=ButtonEditor(label_value='rebuild_label'),show_label=False), 111 | Item(name='delete_button', 112 | editor=ButtonEditor(label_value='delete_label'),show_label=False), 113 | #Item(name='rename_button', 114 | # editor=ButtonEditor(label_value='rename_label')), 115 | Item(name='display_metadata',style='custom',show_label=False, 116 | editor=InstanceEditor(),), 117 | ) 118 | 119 | class Controller(HasTraits): 120 | gui=Any #handle to the gui 121 | options_db=Instance(OptionsDatabase) 122 | 123 | ds_orig = Any #convenience reference to the original dataset 124 | 125 | ds_instances = Dict #map: dataset name -> metadata 126 | ds_metadatae = Dict #map: panel name -> metadata 127 | panel_instances = Dict #map: dataset name -> DS instance 128 | panel_metadatae = Dict #map: panel name -> panel instance 129 | #metadata_list = List #all instances of metadata elements 130 | metadata_list = Property(List) 131 | def _get_metadata_list(self): 132 | return self.ds_metadatae.values() 133 | #def _set_metadata_list(self,val): pass 134 | 135 | viewport_manager=Instance(ViewportManager) 136 | 137 | #HASHING STRATEGY 138 | # 139 | # 4 hash tables 140 | # dataset name -> associated metadata 141 | # panel name -> associated metadata 142 | # dataset name -> Dataset Instance 143 | # panel name -> Panel Instance 144 | 145 | def __init__(self,gui,sample_data,sample_metadata): 146 | super(Controller,self).__init__() 147 | self.gui=gui 148 | 149 | self.ds_orig = sample_data 150 | 151 | ds_meta = DatasetUIMetadata(self,'base_gui',sample_data.name, 152 | sample_metadata) 153 | self.ds_instances = {sample_data.name : sample_data} 154 | self.panel_instances = {'base_gui' : self.gui} 155 | self.ds_metadatae = {sample_data.name : ds_meta} 156 | self.panel_metadatae = {'base_gui' : ds_meta} 157 | 158 | self.options_db=OptionsDatabase(sample_data) 159 | self.viewport_manager=ViewportManager(self) 160 | 161 | #listen to the GUI for changes in the current dataset and set the control 162 | #accordingly for the unstable windows 163 | @on_trait_change('gui:options_window:current_dataset') 164 | def options_window_ctl_listener(self): 165 | self.gui.options_window.ctl=self.gui.options_window.current_dataset.opts 166 | @on_trait_change('gui:configure_scalars_window:current_dataset') 167 | def configure_scalars_window_ctl_listener(self): 168 | csw=self.gui.configure_scalars_window 169 | csw.ctl=csw.current_dataset.scalar_display_settings 170 | 171 | ########################################################## 172 | #viewport allocation 173 | def add_dataset(self,ds,display_metadata,panel=None,group=None): 174 | '''Given a dataset, add it to the controller. If panel and group 175 | are specified, add it to that panel, otherwise any panel will do''' 176 | if ds.name in self.ds_instances: 177 | raise CVUError('A dataset with this name already exists') 178 | 179 | if panel is None and group is None: 180 | panel_ref = self._create_new_panel(ds.name) 181 | panel = panel_ref.panel_name 182 | group = 2 if panel_ref.is_full(group=1) else 1 183 | elif group is not None: 184 | raise CVUError('Cannot specify group without panel') 185 | elif panel is not None: 186 | panel_ref = self.get_named_panel(panel) 187 | if panel_ref.is_full(): 188 | raise CVUError('That panel is full') 189 | group = 2 if panel_ref.is_full(group=1) else 1 190 | else: 191 | panel_ref = self.get_named_panel(panel) 192 | 193 | panel_ref.populate(ds,group=group) #group can be none, doesnt matter 194 | 195 | ds_meta = DatasetUIMetadata(self,panel,ds.name,display_metadata) 196 | self.ds_instances.update({ds.name:ds}) 197 | self.ds_metadatae.update({ds.name:ds_meta}) 198 | self.panel_instances.update({panel_ref.panel_name:panel_ref}) 199 | self.panel_metadatae.update({panel_ref.panel_name:ds_meta}) 200 | 201 | self.show_panel(panel_ref) 202 | 203 | def show_panel(self,panel): 204 | panel.edit_traits(panel.produce_view()) 205 | 206 | def rebuild_panel(self,panel_name): 207 | '''we havent actually destroyed the editor here. 208 | have to destroy the panel and create a new one. 209 | otherwise the panel still refers to the wrong editor''' 210 | 211 | panel=self.panel_instances[panel_name] 212 | 213 | #have the panel dispose of itself if necessary 214 | panel.conditionally_dispose() 215 | 216 | #find the associated dataset and reset its DataViews 217 | ds=self._get_dataset_from_panel(panel) 218 | ds.reset_dataviews() 219 | 220 | #actually ask the panel to drop the old references to the editor 221 | panel.populate(ds,force=True) 222 | 223 | #then show the panel 224 | self.show_panel(panel) 225 | 226 | def rename_panel(self,old_name,new_name): 227 | try: 228 | panel = self.panel_instances[old_name] 229 | ds_meta = self.panel_metadatae[old_name] 230 | except KeyError: 231 | raise CVUError('No such panel') 232 | del self.panel_instances[old_name] 233 | del self.panel_metadatae[old_name] 234 | self.panel_instances.update({new_name:panel}) 235 | self.panel_metadatae.update({new_name:ds_meta}) 236 | panel.panel_name = new_name 237 | 238 | def rename_dataset(self,old_name,new_name): 239 | try: 240 | ds = self.ds_instances[old_name] 241 | ds_meta = self.ds_metadatae[old_name] 242 | except KeyError: 243 | raise CVUError('No such dataset') 244 | del self.ds_instances[old_name] 245 | del self.ds_metadatae[old_name] 246 | self.ds_instances.update({new_name:ds}) 247 | self.ds_metadatae.update({new_name:ds_meta}) 248 | ds.name = new_name 249 | 250 | def find_dataset_views(self,ds): 251 | '''Given a dataset, return the three viewports that refer to it''' 252 | ds_meta = self.ds_metadatae[ds.name] 253 | panel=self.panel_instances[ds_meta.panel] 254 | 255 | from viewport import DatasetViewportInterface 256 | #if panel is base gui, return it 257 | if isinstance(panel,DatasetViewportInterface): layout_obj=panel 258 | #otherwise, return its group 259 | else: layout_obj = panel.group_1 260 | return layout_obj 261 | 262 | def update_display_metadata(self,ds_name,subject_name=None,parc_name=None, 263 | adj_filename=None): 264 | ds_meta=self.ds_metadatae[ds_name] 265 | if subject_name is not None: 266 | ds_meta.display_metadata.subject_name=subject_name 267 | if parc_name is not None: 268 | ds_meta.display_metadata.parc_name=parc_name 269 | if adj_filename is not None: 270 | ds_meta.display_metadata.adj_filename=adj_filename 271 | 272 | def remove_dataset(self,ds_name): 273 | #remove the metadata elements associated with this dataset 274 | ds_meta = self.ds_metadatae[ds_name] 275 | panel_name = ds_meta.panel 276 | 277 | #dispose of the window if necessary 278 | panel = self.panel_instances[panel_name] 279 | panel.conditionally_dispose() 280 | 281 | ds = self.ds_instances[ds_name] 282 | self.gui.reset_controls(ds) 283 | 284 | try: 285 | del self.ds_instances[ds_name] 286 | del self.ds_metadatae[ds_name] 287 | del self.panel_instances[panel_name] 288 | del self.panel_metadatae[panel_name] 289 | except KeyError as e: 290 | raise CVUError('Inconsistent metadata') 291 | 292 | #internal methods for panel manipulation 293 | def _get_named_panel(self,panel_name): 294 | try: 295 | return self.panel_instances[panel_name] 296 | except KeyError as e: 297 | raise CVUError('No such panel') 298 | 299 | def _get_dataset_from_panel(self,panel): 300 | ds_meta = self.panel_metadatae[panel.panel_name] 301 | return self._get_named_dataset(ds_meta.ds_name) 302 | 303 | def _get_named_dataset(self,ds_name): 304 | try: 305 | return self.ds_instances[ds_name] 306 | except KeyError as e: 307 | raise CVUError('No such dataset') 308 | 309 | #panel creation 310 | def __ctr_generate(): 311 | i=0 312 | while True: 313 | i+=1 314 | yield i 315 | __ctr_generator = Any(__ctr_generate()) 316 | def _panel_counter(self): 317 | return self.__ctr_generator.next() 318 | 319 | def _create_new_panel(self,ds_name): 320 | panel_name='Extra View %i'%self._panel_counter() 321 | #panel = ViewPanel(panel_name=panel_name) 322 | #self.panel_instances[panel_name]=panel 323 | panel = ViewPanel(panel_name=ds_name) 324 | self.panel_instances[ds_name]=panel 325 | return panel 326 | 327 | def _destroy_panel(self,name): 328 | del self.panel_instances[name] 329 | 330 | #error messages 331 | def error_dialog(self,message): 332 | return self.gui.error_dialog(message) 333 | def warning_dialog(self,message): 334 | return self.gui.warning_dialog(message) 335 | def verbose_msg(self,message): 336 | return self.gui.verbose_msg(message) 337 | --------------------------------------------------------------------------------