Skip to content

Commit

Permalink
FIX use Delaunay.simplices instead of vertices to make it work with n…
Browse files Browse the repository at this point in the history
…ew scipy
  • Loading branch information
mvdoc committed Jul 20, 2023
1 parent 2845730 commit a86f17b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cortex/quickflat/utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Makes flattened views of volumetric data on the cortical surface.
"""
from functools import reduce
import os
import numpy as np
import string
import warnings
from functools import reduce

import numpy as np

from .. import utils
from .. import dataset
from .. import dataset, utils
from ..database import db
from ..options import config

Expand Down Expand Up @@ -354,8 +354,9 @@ def _make_hatch_image(hatch_data, height, sampler='nearest', hatch_space=4, reca
return hatchim

def _make_flatmask(subject, height=1024):
from .. import polyutils
from PIL import Image, ImageDraw

from .. import polyutils
pts, polys = db.get_surf(subject, "flat", merge=True, nudge=True)
left, right = polyutils.trace_poly(polyutils.boundary_edges(polys))

Expand Down Expand Up @@ -423,8 +424,8 @@ def _make_pixel_cache(subject, xfmname, height=1024, thick=32, depth=0.5, sample
try:
pia, polys = db.get_surf(subject, "pia", merge=True, nudge=False)
wm, polys = db.get_surf(subject, "wm", merge=True, nudge=False)
piacoords = xfm((pia[valid][dl.vertices][simps] * ll[np.newaxis].T).sum(1))
wmcoords = xfm((wm[valid][dl.vertices][simps] * ll[np.newaxis].T).sum(1))
piacoords = xfm((pia[valid][dl.simplices][simps] * ll[np.newaxis].T).sum(1))
wmcoords = xfm((wm[valid][dl.simplices][simps] * ll[np.newaxis].T).sum(1))

valid_p = np.array([np.all((0 <= piacoords), axis=1),
piacoords[:,0] < xfm.shape[2],
Expand Down Expand Up @@ -455,7 +456,7 @@ def _make_pixel_cache(subject, xfmname, height=1024, thick=32, depth=0.5, sample

except IOError:
fid, polys = db.get_surf(subject, "fiducial", merge=True)
fidcoords = xfm((fid[valid][dl.vertices][simps] * ll[np.newaxis].T).sum(1))
fidcoords = xfm((fid[valid][dl.simplices][simps] * ll[np.newaxis].T).sum(1))

valid = reduce(np.logical_and,
[reduce(np.logical_and, (0 <= fidcoords).T),
Expand Down

0 comments on commit a86f17b

Please sign in to comment.