Skip to content

Commit

Permalink
MNT, FIX require cython<3.0 to avoid breaking install, and other fixes (
Browse files Browse the repository at this point in the history
#491)

* MNT require cython<3.0 to avoid breaking install

* MNT also fix github actions

* FIX test for write/read gii

* FIX use Delaunay.simplices instead of vertices to make it work with new scipy
  • Loading branch information
mvdoc authored Jul 20, 2023
1 parent 9c1958b commit 57e5f9c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y inkscape
pip install --upgrade pip
pip install wheel numpy cython pillow
pip install wheel numpy "cython<3.0" pillow
pip install -q ipython Sphinx sphinx-gallery numpydoc
pip install -e . --no-build-isolation
python -c 'import cortex; print(cortex.__full_version__)'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/install_from_wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y inkscape
pip install --upgrade pip
pip install wheel numpy cython
pip install wheel numpy "cython<3.0"
- name: Create the wheel
run: python setup.py bdist_wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y inkscape
pip install --upgrade pip
pip install wheel numpy cython
pip install wheel numpy "cython<3.0"
# force using latest nibabel
pip install -U nibabel
pip install -e . --no-build-isolation
Expand Down
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
5 changes: 5 additions & 0 deletions cortex/tests/test_formats.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import os
import tempfile

import numpy as np

import cortex
from cortex.formats import read_gii, write_gii

from numpy.testing import assert_array_equal

def test_write_read_gii():
wm, polys = cortex.db.get_surf("S1", "wm", "lh")
# make sure they are int32 or nibabel will complain
wm = wm.astype(np.int32)
polys = wm.astype(np.int32)
with tempfile.TemporaryDirectory() as tmpdir:
fnout = os.path.join(tmpdir, "out.gii")
write_gii(fnout, wm, polys)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[build-system]
# Minimum requirements for the build system to execute, according to PEP518
# specification.
requires = ["numpy", "cython", "setuptools", "wheel"]
requires = ["numpy", "cython<3.0", "setuptools", "wheel"]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ lxml
html5lib
h5py
numexpr
cython
cython<3.0
matplotlib
pillow
nibabel>=2.1
Expand Down

0 comments on commit 57e5f9c

Please sign in to comment.