Skip to content

Commit

Permalink
Merge pull request #1101 from CHrlS98/cythonization
Browse files Browse the repository at this point in the history
Cythonization warnings
  • Loading branch information
arnaudbore authored Jan 9, 2025
2 parents 0ff0900 + 45493c3 commit 0ac4461
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 88 deletions.
9 changes: 0 additions & 9 deletions docs/source/fake_files/quick_tools.py

This file was deleted.

8 changes: 0 additions & 8 deletions docs/source/modules/scilpy.tractanalysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ scilpy.tractanalysis.json\_utils module
:undoc-members:
:show-inheritance:

scilpy.tractanalysis.quick\_tools module
------------------------------------------------------

.. automodule:: scilpy.tractanalysis.quick_tools
:members:
:undoc-members:
:show-inheritance:

scilpy.tractanalysis.reproducibility\_measures module
------------------------------------------------------

Expand Down
50 changes: 0 additions & 50 deletions scilpy/tractanalysis/quick_tools.pyx

This file was deleted.

2 changes: 1 addition & 1 deletion scilpy/tractanalysis/streamlines_metrics.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: utf-8
#cython: profile=False
# cython: profile=False, language_level=3

# http://www.cse.yorku.ca/~amana/research/grid.pdf
# http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_4_Spatial_Subdivisions.shtml
Expand Down
4 changes: 1 addition & 3 deletions scilpy/tractanalysis/voxel_boundary_intersection.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: utf-8
#cython: profile=False
# cython: profile=False, language_level=3

from libc.math cimport ceil, fabs, floor, sqrt
from libc.math cimport fmin as cfmin
Expand Down Expand Up @@ -27,7 +27,6 @@ cdef struct Pointers:


@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
def subdivide_streamlines_at_voxel_faces(streamlines):
"""
Expand Down Expand Up @@ -140,7 +139,6 @@ cdef inline void copypoint_d2f(double * a, float * b) nogil:


@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
cdef cnp.npy_intp _grid_intersections(
Pointers* pointers,
Expand Down
7 changes: 2 additions & 5 deletions scilpy/tractograms/streamline_and_mask_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from scilpy.tractograms.streamline_operations import \
resample_streamlines_step_size

from scilpy.tractanalysis.quick_tools import (get_next_real_point,
get_previous_real_point)
from scilpy.tractograms.streamline_operations import \
filter_streamlines_by_length, _get_point_on_line, _get_streamline_pt_index

Expand Down Expand Up @@ -596,7 +594,7 @@ def compute_streamline_segment(orig_strl, inter_vox, in_vox_idx, out_vox_idx,
# If not, find the next real streamline point
if in_strl_point is None:
# Find the index of the next real streamline point
in_strl_point = get_next_real_point(points_to_indices, in_vox_idx)
in_strl_point = np.searchsorted(points_to_indices, in_vox_idx)
# Generate an artificial point on the line between the previous
# real point and the next real point
additional_start_pt = _get_point_on_line(orig_strl[in_strl_point - 1],
Expand All @@ -612,8 +610,7 @@ def compute_streamline_segment(orig_strl, inter_vox, in_vox_idx, out_vox_idx,
# If not, find the previous real streamline point
if out_strl_point is None:
# Find the index of the previous real streamline point
out_strl_point = get_previous_real_point(points_to_indices,
out_vox_idx)
out_strl_point = np.searchsorted(points_to_indices, out_vox_idx) - 1
# Generate an artificial point on the line between the previous
# real point and the next real point
additional_exit_pt = _get_point_on_line(orig_strl[out_strl_point],
Expand Down
5 changes: 1 addition & 4 deletions scilpy/tractograms/uncompress.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# encoding: utf-8
#cython: profile=False
#cython: language_level=3
# cython: profile=False, language_level=3

from libc.math cimport ceil, fabs, floor, sqrt
from libc.math cimport fmin as cfmin
Expand Down Expand Up @@ -32,7 +31,6 @@ cdef struct Pointers:


@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
def uncompress(streamlines, return_mapping=False):
"""
Expand Down Expand Up @@ -148,7 +146,6 @@ cdef inline void c_get_closest_edge(double *p,


@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
cdef cnp.npy_intp _uncompress(
Pointers* pointers,
Expand Down
3 changes: 2 additions & 1 deletion scripts/tests/test_tractogram_cut_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from scilpy.io.fetcher import fetch_data, get_testing_files_dict

# If they already exist, this only takes 5 seconds (check md5sum)
fetch_data(get_testing_files_dict(), keys=['filtering.zip'])
fetch_data(get_testing_files_dict(),
keys=['filtering.zip', 'tractograms.zip', 'connectivity.zip'])
tmp_dir = tempfile.TemporaryDirectory()


Expand Down
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@


def get_extensions():
define_macros = [('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')]
uncompress = Extension('scilpy.tractograms.uncompress',
['scilpy/tractograms/uncompress.pyx'])
quick_tools = Extension('scilpy.tractanalysis.quick_tools',
['scilpy/tractanalysis/quick_tools.pyx'])
['scilpy/tractograms/uncompress.pyx'],
define_macros=define_macros)
voxel_boundary_intersection =\
Extension('scilpy.tractanalysis.voxel_boundary_intersection',
['scilpy/tractanalysis/voxel_boundary_intersection.pyx'])
['scilpy/tractanalysis/voxel_boundary_intersection.pyx'],
define_macros=define_macros)
streamlines_metrics =\
Extension('scilpy.tractanalysis.streamlines_metrics',
['scilpy/tractanalysis/streamlines_metrics.pyx'])
return [uncompress, quick_tools,
voxel_boundary_intersection, streamlines_metrics]
['scilpy/tractanalysis/streamlines_metrics.pyx'],
define_macros=define_macros)
return [uncompress, voxel_boundary_intersection, streamlines_metrics]


class CustomBuildExtCommand(build_ext):
Expand Down

0 comments on commit 0ac4461

Please sign in to comment.