Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODF actor implemented with Ray Tracing #869

Open
wants to merge 144 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
5ec815e
added file for experimentation
tvcastillod Jul 25, 2023
4464ee4
added SH implementation with 2 parameters
tvcastillod Aug 8, 2023
dffb17c
adjusted script
tvcastillod Aug 9, 2023
508f8cc
Merge branch 'fury-gl:master' into SH-for-ODF-impl
tvcastillod Aug 15, 2023
b61aaf5
added coefficients to experimental implementation
tvcastillod Aug 16, 2023
f33930d
Merge remote-tracking branch 'origin/SH-for-ODF-impl' into SH-for-ODF…
tvcastillod Aug 16, 2023
06d933e
Merge branch 'fury-gl:master' into SH-for-ODF-impl
tvcastillod Aug 24, 2023
91f5ea5
deleted unused variables
tvcastillod Aug 24, 2023
7ad49f1
added files for experimentation on each issue
tvcastillod Aug 24, 2023
5c72691
added file for experimentation with textures
tvcastillod Oct 4, 2023
67c231c
updated files
tvcastillod Oct 6, 2023
fb1f6e2
passing coefficients through texture with few glyphs
tvcastillod Oct 10, 2023
0e0c1d7
comparison of passing coefficients with uniforms vs texture
tvcastillod Oct 13, 2023
63e2886
Pruning duplicate coeffs.
guaje Oct 13, 2023
a451eee
Merge branch 'fury-master' into sh_odf
guaje Oct 13, 2023
df3b9ca
Refactoring FS declaration code.
guaje Oct 13, 2023
6346117
Added temp call to Fury's Central Differences Normals calculation.
guaje Oct 13, 2023
54b2b3a
Added new file with changes.
guaje Oct 31, 2023
321bab2
Merge branch 'tania-sh_odf' into sh_odf
guaje Oct 31, 2023
1f455c0
Restored texture_coefficients.py
guaje Oct 31, 2023
5793fd1
Merge pull request #2 from guaje/sh_odf
tvcastillod Nov 1, 2023
ed6d9ab
organized files
tvcastillod Nov 7, 2023
31900bb
adjusted uv vals
tvcastillod Nov 10, 2023
f747107
Added minor changes.
guaje Nov 17, 2023
d0ab18c
added new file for SH efficient implementation
tvcastillod Dec 2, 2023
feee339
Minor changes in shader code.
guaje Dec 4, 2023
1b1546a
Merge branch 'tania-sh_odf' into sh_odf
guaje Dec 4, 2023
f3c3490
Added first version of Peters' paper.
guaje Dec 4, 2023
2f93d36
Added difinitions for constants.
guaje Dec 4, 2023
80f5682
Added first functions of main shaders.
guaje Dec 5, 2023
ec69820
All functions added.
guaje Dec 5, 2023
c94cb7a
clear
guaje Dec 5, 2023
d255964
Removed rotation code and resolution dependent code.
guaje Dec 5, 2023
99908e5
Renamed folder spherical_harmonics as rt_odfs.
guaje Dec 5, 2023
2dfde0b
Organized main code.
guaje Dec 6, 2023
e19ff42
Merge pull request #3 from guaje/sh_odf
tvcastillod Dec 8, 2023
d604060
Merge branch 'fury-master' into sh_odf
guaje Dec 19, 2023
4057e41
Created ray_traced_3.py to simplify ray_traced_1.py content. Removed …
guaje Dec 19, 2023
a3ac454
added SH efficient implementation to the base impl with texture
tvcastillod Dec 19, 2023
b973e65
Added minor changes to base Ray Tracing implementation (ray_traced_1.…
guaje Dec 19, 2023
02915dc
Minor changes on ray_traced_3.py.
guaje Dec 19, 2023
4880e45
Minor changes in ray_traced_1.py
guaje Dec 19, 2023
cc483cd
Forwarded camera right and up vectors.
guaje Dec 19, 2023
6420487
Merge branch 'tania-sh_odf' into sh_odf
guaje Dec 19, 2023
a9a6ffd
Used 3D point as frag_coord for uv mapping.
guaje Dec 22, 2023
ae9e554
Tournier first implementation
tvcastillod Jan 26, 2024
f87a985
updated files
tvcastillod Jan 26, 2024
39d429c
Merge branch 'tania-sh_odf' into sh_odf
guaje Jan 27, 2024
1598f0e
added Tournier impl
tvcastillod Feb 6, 2024
07beada
Merge branch 'tania-sh_odf' into sh_odf
guaje Feb 6, 2024
d5a387b
Improved description of ray_traced_3.py
guaje Feb 6, 2024
dd7ab4c
Prep for new ray_traced file.
guaje Feb 8, 2024
a3c861d
Minor changes to ray_traced3.py
guaje Feb 8, 2024
6a1516a
Created ray_traced_6.py to fix scalability.
guaje Feb 8, 2024
1fac9ad
Minor changes to ray_traced_6.py
guaje Feb 9, 2024
305b848
Added README and renamed ray_traced files.
guaje Feb 9, 2024
6b682d3
Added ray_traced_4.0.py as an analogous version of ray_traced_2.0.py.…
guaje Feb 9, 2024
f960c5b
Removed ray_traced_6.0.py from PR.
guaje Feb 9, 2024
50d6425
Merge pull request #4 from guaje/sh_odf
tvcastillod Feb 9, 2024
c95e435
implementation with a slice
tvcastillod Feb 14, 2024
07252e0
made adjustments on odf slice example
tvcastillod Feb 14, 2024
2d41c30
updated README
tvcastillod Feb 14, 2024
175d03d
Removed unused black tags.
guaje Feb 15, 2024
dc18604
Minor changes in several ray_traced experiments.
guaje Feb 15, 2024
10c185d
Improved multiplatform compatibility of ray_traced_6.0.py. Changed il…
guaje Feb 15, 2024
fdd25cf
fixed scaling
tvcastillod Feb 15, 2024
89c7f76
Merge branch 'tania-sh_odf' into sh_odf
guaje Feb 17, 2024
f73d7d0
Fixed merge.
guaje Feb 17, 2024
247d811
Merge pull request #5 from guaje/sh_odf
tvcastillod Feb 17, 2024
a7724d7
added odf actor implementation
tvcastillod Feb 23, 2024
fbe7ed5
adjusted scaling
tvcastillod Feb 23, 2024
8c6b8fd
Added ray_traced_7.0.py which includes an argument parser.
guaje Feb 26, 2024
bfd4b01
Added DIPY's ODF slicer python script with argument parser for profil…
guaje Feb 26, 2024
1438b84
Minor changes to ray_traced_7.0.py
guaje Feb 26, 2024
644b4fe
Renamed experimental folder.
guaje Feb 26, 2024
fc85cd6
Changed basis to Tournier's.
guaje Feb 27, 2024
97f1d93
reorganized files
tvcastillod Feb 27, 2024
ef09453
Added folders for Descoteaux and Tournier basis.
guaje Feb 27, 2024
0b5c75f
Updated ray_traced scripts to use spherical harmonics basis.
guaje Feb 27, 2024
dc1b8da
Merge branch 'fury-master' into sh_odf_exp
guaje Feb 29, 2024
8f71a14
Added ray_traced_6.5.py to debug performance issues.
guaje Mar 1, 2024
66dda5d
added degree param
tvcastillod Mar 1, 2024
badb5a9
adjusted the degree setting
tvcastillod Mar 6, 2024
d9c3323
Merge branch 'master' into shodfimpl
tvcastillod Mar 6, 2024
290b330
Changed first uniform.
guaje Mar 12, 2024
ecef0ff
Added ray_traced_3.5.py to take single ODF screenshot.
guaje Mar 12, 2024
dc41684
added tests
tvcastillod Mar 18, 2024
f4824f6
adjustments on tests and parameter validation
tvcastillod Mar 29, 2024
a17222e
Added Min-Max Normalization function.
guaje Mar 29, 2024
a4e9fde
Added composed eval sh.
guaje Mar 29, 2024
9f4a515
Moved newton_bisection.frag to root_finding folder.
guaje Apr 9, 2024
a580355
reorganized and refactored odf actor
tvcastillod Apr 16, 2024
4ccced9
Re-added newton_bisection.frag to rt_odfs.
guaje Apr 23, 2024
4c66c81
Fixed uniform and flats data type. Added numCoeffs param to rayGlyphI…
guaje Apr 23, 2024
00c069a
Moved dipy_slicer.py script to personal repo. Renamed as odf_slicer_c…
guaje Apr 24, 2024
c33c4d6
Minor fix on uncertainty cone actor.
guaje Apr 26, 2024
de817ab
Replaced SH_DEGREE with shDegree in rayGlyphIntersections function.
guaje May 30, 2024
64a0789
Added extra arguments to rayGlyphIntersections function.
guaje May 30, 2024
9742ca9
Merge branch 'fury-gl-master' into SH-for-ODF-impl
tvcastillod May 31, 2024
8ee28ff
Merge branch 'fury-gl:master' into SH-for-ODF-impl
tvcastillod May 31, 2024
326c77f
Renamed variables in rayGlyphIntersections finction.
guaje May 31, 2024
44e35a7
Merge branch 'SH-for-ODF-impl' of https://github.com/tvcastillod/fury…
tvcastillod Jun 1, 2024
f5b91f3
Merge branch 'SH-for-ODF-impl' into sh_odf_exp
tvcastillod Jun 1, 2024
283446d
Added new eval_sh.frag.
guaje Jun 6, 2024
9321cf7
Added dynamic evalSH function.
guaje Jun 7, 2024
a5d1ff1
Refactored eval_sh_x functions.
guaje Jun 7, 2024
86c7613
Refactored getInvVandermonde function.
guaje Jun 7, 2024
e150d06
Removed unnecessary eval_sh.frag file.
guaje Jun 13, 2024
668a7c3
Merge branch 'fury-master' into sh_odf_exp
guaje Jun 13, 2024
c491e75
Merge pull request #6 from guaje/sh_odf_exp
tvcastillod Jun 13, 2024
f68991b
added odf actor implementation
tvcastillod Feb 23, 2024
0e6dc18
adjusted scaling
tvcastillod Feb 23, 2024
54fbd0d
reorganized files
tvcastillod Feb 27, 2024
23c53df
added degree param
tvcastillod Mar 1, 2024
236d809
adjusted the degree setting
tvcastillod Mar 6, 2024
ecd1d75
added tests
tvcastillod Mar 18, 2024
3a375d9
adjustments on tests and parameter validation
tvcastillod Mar 29, 2024
c56920b
reorganized and refactored odf actor
tvcastillod Apr 16, 2024
904c698
solved conflicts
tvcastillod Aug 26, 2024
c149861
added odf actor implementation
tvcastillod Feb 23, 2024
18dc83a
adjusted scaling
tvcastillod Feb 23, 2024
e259713
reorganized files
tvcastillod Feb 27, 2024
dd16653
added degree param
tvcastillod Mar 1, 2024
59971b7
adjusted the degree setting
tvcastillod Mar 6, 2024
390ce01
added tests
tvcastillod Mar 18, 2024
ecca0f6
adjustments on tests and parameter validation
tvcastillod Mar 29, 2024
8006581
reorganized and refactored odf actor
tvcastillod Apr 16, 2024
2ddb43f
Merge branch 'shodfimpl' of https://github.com/tvcastillod/fury into …
tvcastillod Aug 26, 2024
5a6d1f6
Merge branch 'shodfimpl' of https://github.com/tvcastillod/fury into …
tvcastillod Aug 26, 2024
a57c158
added odf actor implementation
tvcastillod Feb 23, 2024
a0d8ecc
adjusted scaling
tvcastillod Feb 23, 2024
0fa1db8
reorganized files
tvcastillod Feb 27, 2024
49aeeda
added degree param
tvcastillod Mar 1, 2024
a2539d2
adjusted the degree setting
tvcastillod Mar 6, 2024
6f95e7a
added tests
tvcastillod Mar 18, 2024
f2204f0
adjustments on tests and parameter validation
tvcastillod Mar 29, 2024
2ee1422
reorganized and refactored odf actor
tvcastillod Apr 16, 2024
933ae32
odf actor change
tvcastillod Aug 26, 2024
6b2e4e7
Merge branch 'fury-gl:master' into shodfimpl
tvcastillod Aug 26, 2024
0c6351d
adjusted odf actor and added example
tvcastillod Aug 26, 2024
fc30cd9
adjustments on variables name and handle degree with uniform
tvcastillod Aug 28, 2024
95aa9eb
made suggested changes
tvcastillod Sep 13, 2024
ca9ec16
adjusted odf actor test
tvcastillod Sep 13, 2024
69f3819
fixed format
tvcastillod Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions fury/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
main_dir_uncertainty,
tensor_ellipsoid,
)
from fury.actors.odf import sh_odf
from fury.colormap import colormap_lookup_table
from fury.decorators import warn_on_args_to_kwargs
from fury.io import load_image
Expand Down Expand Up @@ -4019,3 +4020,73 @@ def uncertainty_cone(
angles = main_dir_uncertainty(evals, evecs, signal, sigma, b_matrix)

return double_cone(centers, evecs, angles, colors, scales, opacity)


@warn_on_args_to_kwargs()
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed since this is a new function

def odf(
centers,
coeffs,
*,
sh_basis='descoteaux',
scales=1.0,
opacity=1.0
):
"""
FURY actor for visualizing Orientation Distribution Functions (ODFs) given
an array of Spherical Harmonics (SH) coefficients.

Parameters
----------
centers : ndarray(N, 3)
ODFs positions.
coeffs : (N, M) or (N, 6) or (N, 15) or (N, 28) or (N, 45) or (N, 66) or
(N, 91) ndarray.
Corresponding SH coefficients for the ODFs.
sh_basis: str, optional
Type of basis (descoteaux, tournier)
'descoteaux' for the default ``descoteaux07`` DYPY basis.
'tournier' for the default ``tournier07` DYPY basis.
scales : float or ndarray (N, )
Copy link
Contributor

Choose a reason for hiding this comment

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

, optional to add

ODFs size.
opacity : float
Copy link
Contributor

Choose a reason for hiding this comment

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

, optional to add

Takes values from 0 (fully transparent) to 1 (opaque).

Returns
-------
odf: Actor

"""

if not isinstance(centers, np.ndarray):
centers = np.array(centers)
if centers.ndim == 1:
centers = np.array([centers])

if not isinstance(coeffs, np.ndarray):
coeffs = np.array(coeffs)
if coeffs.ndim != 2:
if coeffs.ndim == 1:
coeffs = np.array([coeffs])
else:
raise ValueError('coeffs should be a 2D array.')
if coeffs.shape[0] != centers.shape[0]:
raise ValueError('number of odf glyphs defined does not match with '
'number of centers')

coeffs_given = coeffs.shape[-1]
tvcastillod marked this conversation as resolved.
Show resolved Hide resolved
degree = int((np.sqrt(8 * coeffs_given + 1) - 3) / 2)
if (degree%2 != 0):
degree -= 1
coeffs = coeffs[:, :int(((degree + 1) * (degree + 2)) / 2)]
if not isinstance(scales, np.ndarray):
scales = np.array(scales)
if scales.size == 1:
scales = np.repeat(scales, centers.shape[0])
elif scales.size != centers.shape[0]:
scales = np.concatenate(
(scales, np.ones(centers.shape[0] - scales.shape[0])), axis=None)

total = np.sum(abs(coeffs), axis=1)
coeffs = np.dot(np.diag(1 / total * scales), coeffs) * 1.7

return sh_odf(centers, coeffs, degree, sh_basis, scales, opacity)
Loading
Loading