Skip to content

[NF] Orientation extraction and script for angular error between peaks images - #1343

Open
CHrlS98 wants to merge 14 commits into
scilus:masterfrom
CHrlS98:oct-tractography-paper
Open

[NF] Orientation extraction and script for angular error between peaks images#1343
CHrlS98 wants to merge 14 commits into
scilus:masterfrom
CHrlS98:oct-tractography-paper

Conversation

@CHrlS98

@CHrlS98 CHrlS98 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Quick description

Code for my OCT tractography paper (in preparation).

  • Renamed module denoise to feature for "feature extraction".
  • Added module scilpy.feature.orientation implementing Frangi filters for orientation extraction (taken from https://github.com/lens-biophotonics/Foa3D)
  • Added script scil_volume_local_orientation for estimating principal orientation of structures in a grayscale image using Frangi filters or structure tensor analysis.
  • Added script scil_peak_angular_error to compute angular error between estimated and reference peaks.
  • Added script for reconstructing ODF from local orientations.

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.84713% with 214 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.11%. Comparing base (31cf4e5) to head (3e99aa2).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1343      +/-   ##
==========================================
- Coverage   72.59%   72.11%   -0.49%     
==========================================
  Files         301      305       +4     
  Lines       26283    26594     +311     
  Branches     3700     3721      +21     
==========================================
+ Hits        19080    19178      +98     
- Misses       5651     5864     +213     
  Partials     1552     1552              
Flag Coverage Δ
smoketests 69.30% <31.84%> (-0.45%) ⬇️
unittests 14.05% <0.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Scripts 74.84% <40.00%> (-0.49%) ⬇️
Library 68.82% <17.54%> (-0.50%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CHrlS98
CHrlS98 marked this pull request as ready for review July 2, 2026 19:15
Copilot AI review requested due to automatic review settings July 2, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds OCT-oriented feature extraction tooling (Frangi/structure-tensor local orientation, peak angular error, and peak→ODF reconstruction), while migrating the former denoise asymmetric filtering code into a new scilpy.feature module and wiring new CLI entry points + tests.

Changes:

  • Introduces scilpy.feature.orientation (Frangi-based orientation extraction) and related unit tests.
  • Adds new CLIs: scil_volume_local_orientation, scil_peak_angular_error, scil_peak_to_odf, plus CLI smoke tests.
  • Adds SH apodized delta-kernel generation and moves asymmetric ODF filtering into scilpy.feature (including OpenCL kernel file).

Reviewed changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/scilpy/reconst/sh.py Adds apodized delta-kernel generation used by peak→ODF conversion.
src/scilpy/feature/orientation.py New Frangi/orientation extraction implementation.
src/scilpy/feature/tests/test_orientation.py Unit tests for Frangi/orientation helpers.
src/scilpy/feature/asym_filtering.py Migrated asymmetric filtering implementation (CPU/OpenCL paths).
src/scilpy/feature/aodf_filter.cl New OpenCL kernel for unified asymmetric filtering.
src/scilpy/feature/tests/test_asym_filtering.py Updates tests to import from scilpy.feature.
src/scilpy/feature/init.py New module package init.
src/scilpy/cli/scil_volume_local_orientation.py New CLI for local orientation estimation from grayscale volumes.
src/scilpy/cli/tests/test_volume_local_orientation.py CLI smoke tests for local orientation script.
src/scilpy/cli/scil_peak_angular_error.py New CLI to compute angular error between peak images + JSON metrics.
src/scilpy/cli/tests/test_peak_angular_error.py CLI smoke tests for peak angular error script.
src/scilpy/cli/scil_peak_to_odf.py New CLI converting peaks to SH ODFs (optional apodization + smoothing).
src/scilpy/cli/tests/test_peak_to_odf.py CLI smoke tests for peak→ODF script.
src/scilpy/cli/scil_sh_to_aodf.py Updates imports to new scilpy.feature module path.
pyproject.toml Registers new CLI entry points.
docs/source/modules/scilpy.rst Updates modules index to reference scilpy.feature.
docs/source/modules/scilpy.denoise.rst Updates automodule target text to scilpy.feature.asym_filtering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/scilpy/feature/orientation.py Outdated
Comment thread src/scilpy/reconst/sh.py Outdated
Comment on lines +813 to +815
mask_theta_0 = np.abs(sphere.vertices.dot([0, 0, 1])) == 1

p_n = Q[mask_theta_0].reshape((-1, 1))
p.add_argument('out_probability', help='Output probability nifti image.')
p.add_argument('--method', default='frangi', choices=['frangi', 'structure_tensor'],
help='Method to use for local orientation estimation. [%(default)s]')
p.add_argument('--sigma', nargs='+', type=float, default=1.0,
Comment on lines 7 to 9
scilpy.connectivity
scilpy.denoise
scilpy.feature
scilpy.dwi
Comment on lines +98 to +103
# THIS LINE IS VERY MEMORY INTENSIVE: OOM ON LARGE IMAGES
sh = sh_to_sf_mat.T[peaks1d_to_sph_ind]
if apodize_kernel is not None:
sh = sh * apodize_kernel

out_sh[mask] = sh
CHrlS98 and others added 4 commits July 2, 2026 15:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@CHrlS98 CHrlS98 changed the title [WIP] Orientation extraction and script for angular error between peaks images [NF] Orientation extraction and script for angular error between peaks images Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants