diff --git a/cortex/anat.py b/cortex/anat.py index 835e60f01..abeda8c68 100644 --- a/cortex/anat.py +++ b/cortex/anat.py @@ -5,7 +5,6 @@ import subprocess as sp import numpy as np -import nibabel #from . import utils from .database import db @@ -28,6 +27,7 @@ def whitematter(outfile, subject, do_voxelize=False): else: voxelize(outfile, subject, surf="wm") except IOError: + import nibabel bet = db.get_anat(subject, type='brainmask').get_filename() try: cache = tempfile.mkdtemp() @@ -56,6 +56,7 @@ def whitematter(outfile, subject, do_voxelize=False): def voxelize(outfile, subject, surf='wm', mp=True): '''Voxelize the whitematter surface to generate the white matter mask''' + import nibabel from . import polyutils nib = db.get_anat(subject, "raw") shape = nib.get_shape() diff --git a/cortex/dataset/views.py b/cortex/dataset/views.py index 638abd261..515dfd940 100644 --- a/cortex/dataset/views.py +++ b/cortex/dataset/views.py @@ -125,7 +125,7 @@ def to_json(self, simple=False): sdict = dict( state=self.state, attrs=self.attrs.copy(), - desc=self.description) + desc=self.description.decode()) try: sdict.update(dict( cmap=[self.cmap], diff --git a/cortex/openctm.pyx b/cortex/openctm.pyx index 7ab93a396..209dd7c0c 100644 --- a/cortex/openctm.pyx +++ b/cortex/openctm.pyx @@ -28,7 +28,7 @@ attrmaps = [ cdef class CTMfile: cdef CTMcontext ctx - cdef public bytes filename + cdef public object filename cdef public str mode cdef unsigned int length @@ -38,7 +38,7 @@ cdef class CTMfile: cdef public dict attribs cdef public dict uvs - def __cinit__(self, bytes filename, str mode='r'): + def __cinit__(self, object filename, str mode='r'): cdef openctm.CTMenum err cdef char* name self.filename = filename @@ -145,7 +145,7 @@ cdef class CTMfile: return pts, polys, norms - def save(self, str method='mg2', int level=9): + def save(self, method='mg2', int level=9): cdef char* cname = NULL cdef float* cnorms = NULL cdef openctm.CTMenum err diff --git a/cortex/quickflat/composite.py b/cortex/quickflat/composite.py index 6226baf15..138796ef0 100644 --- a/cortex/quickflat/composite.py +++ b/cortex/quickflat/composite.py @@ -3,7 +3,6 @@ from .. import dataset from ..database import db from ..options import config -from ..svgoverlay import get_overlay from .utils import _get_height, _get_extents, _convert_svg_kwargs, _has_cmap, _get_images, _parse_defaults from .utils import make_flatmap_image, _make_hatch_image @@ -194,6 +193,7 @@ def add_rois(fig, dataview, extents=None, height=None, with_labels=True, roi_lis img : matplotlib.image.AxesImage matplotlib axes image object for plotted data """ + from ..svgoverlay import get_overlay if extents is None: extents = _get_extents(fig) if height is None: @@ -240,6 +240,7 @@ def add_sulci(fig, dataview, extents=None, height=1024, with_labels=True, **kwar img : matplotlib.image.AxesImage matplotlib axes image object for plotted data """ + from ..svgoverlay import get_overlay svgobject = db.get_overlay(dataview.subject) svg_kws = _convert_svg_kwargs(kwargs) layer_kws = _parse_defaults('sulci_paths') @@ -292,6 +293,7 @@ def add_hatch(fig, hatch_data, extents=None, height=None, hatch_space=4, hatch_c ----- Possibly to add: add hatch_width, hatch_offset arguments. """ + from ..svgoverlay import get_overlay if extents is None: extents = _get_extents(fig) if height is None: @@ -370,6 +372,7 @@ def add_custom(fig, dataview, svgfile, layer, extents=None, height=None, with_la matplotlib axes image object for plotted data """ + from ..svgoverlay import get_overlay if height is None: height = _get_height(fig) if extents is None: @@ -417,6 +420,7 @@ def add_cutout(fig, name, dataview, layers=None, height=None, extents=None): ------- """ + from ..svgoverlay import get_overlay if layers is None: layers = _get_images(fig) if height is None: diff --git a/cortex/quickflat/utils.py b/cortex/quickflat/utils.py index 0f62559d1..da218c978 100644 --- a/cortex/quickflat/utils.py +++ b/cortex/quickflat/utils.py @@ -11,7 +11,6 @@ from .. import dataset from ..database import db from ..options import config -from ..svgoverlay import get_overlay def make_flatmap_image(braindata, height=1024, recache=False, **kwargs): diff --git a/cortex/utils.py b/cortex/utils.py index 095a0c097..074978000 100644 --- a/cortex/utils.py +++ b/cortex/utils.py @@ -11,7 +11,6 @@ from .database import db from .volume import anat2epispace from .options import config -from .freesurfer import fs_aseg_dict class DocLoader(object): def __init__(self, func, mod, package): @@ -416,6 +415,7 @@ def get_aseg_mask(subject, aseg_name, xfmname=None, order=1, threshold=None, **k See also get_anat(subject, type='aseg') """ + from .freesurfer import fs_aseg_dict aseg = db.get_anat(subject, type="aseg").get_data().T if not isinstance(aseg_name, (list, tuple)):