Skip to content

Commit 1d5e7dc

Browse files
tvcastillodguaje
andauthored
ODF actor implemented with Ray Tracing (#869)
* added file for experimentation * added SH implementation with 2 parameters * adjusted script * added coefficients to experimental implementation * deleted unused variables * added files for experimentation on each issue * added file for experimentation with textures * updated files * passing coefficients through texture with few glyphs * comparison of passing coefficients with uniforms vs texture * Pruning duplicate coeffs. * Refactoring FS declaration code. * Added temp call to Fury's Central Differences Normals calculation. * Added new file with changes. * Restored texture_coefficients.py * organized files * adjusted uv vals * Added minor changes. * added new file for SH efficient implementation * Minor changes in shader code. * Added first version of Peters' paper. * Added difinitions for constants. * Added first functions of main shaders. * All functions added. * clear * Removed rotation code and resolution dependent code. * Renamed folder spherical_harmonics as rt_odfs. * Organized main code. * Created ray_traced_3.py to simplify ray_traced_1.py content. Removed BRDF functions. * added SH efficient implementation to the base impl with texture * Added minor changes to base Ray Tracing implementation (ray_traced_1.py). * Minor changes on ray_traced_3.py. * Minor changes in ray_traced_1.py * Forwarded camera right and up vectors. * Used 3D point as frag_coord for uv mapping. * Tournier first implementation * updated files * added Tournier impl * Improved description of ray_traced_3.py * Prep for new ray_traced file. * Minor changes to ray_traced3.py * Created ray_traced_6.py to fix scalability. * Minor changes to ray_traced_6.py * Added README and renamed ray_traced files. * Added ray_traced_4.0.py as an analogous version of ray_traced_2.0.py. Updated README. * Removed ray_traced_6.0.py from PR. * implementation with a slice * made adjustments on odf slice example * updated README * Removed unused black tags. * Minor changes in several ray_traced experiments. * Improved multiplatform compatibility of ray_traced_6.0.py. Changed illumination model. * fixed scaling * Fixed merge. * added odf actor implementation * adjusted scaling * Added ray_traced_7.0.py which includes an argument parser. * Added DIPY's ODF slicer python script with argument parser for profiling tool. * Minor changes to ray_traced_7.0.py * Renamed experimental folder. * Changed basis to Tournier's. * reorganized files * Added folders for Descoteaux and Tournier basis. * Updated ray_traced scripts to use spherical harmonics basis. * Added ray_traced_6.5.py to debug performance issues. * added degree param * adjusted the degree setting * Changed first uniform. * Added ray_traced_3.5.py to take single ODF screenshot. * added tests * adjustments on tests and parameter validation * Added Min-Max Normalization function. * Added composed eval sh. * Moved newton_bisection.frag to root_finding folder. * reorganized and refactored odf actor * Re-added newton_bisection.frag to rt_odfs. * Fixed uniform and flats data type. Added numCoeffs param to rayGlyphInteresctions function. * Moved dipy_slicer.py script to personal repo. Renamed as odf_slicer_cli.py * Minor fix on uncertainty cone actor. * Replaced SH_DEGREE with shDegree in rayGlyphIntersections function. * Added extra arguments to rayGlyphIntersections function. * Renamed variables in rayGlyphIntersections finction. * Added new eval_sh.frag. * Added dynamic evalSH function. * Refactored eval_sh_x functions. * Refactored getInvVandermonde function. * Removed unnecessary eval_sh.frag file. * added odf actor implementation * adjusted scaling * reorganized files * added degree param * adjusted the degree setting * added tests * adjustments on tests and parameter validation * reorganized and refactored odf actor * added odf actor implementation * adjusted scaling * reorganized files * added degree param * adjusted the degree setting * added tests * adjustments on tests and parameter validation * reorganized and refactored odf actor * added odf actor implementation * adjusted scaling * reorganized files * added degree param * adjusted the degree setting * added tests * adjustments on tests and parameter validation * reorganized and refactored odf actor * adjusted odf actor and added example * adjustments on variables name and handle degree with uniform * made suggested changes * adjusted odf actor test * fixed format * made adjustments to the format * fixed format * fixed codespell and docs ci's --------- Co-authored-by: Javier Guaje <jrguajeg@iu.edu>
1 parent a09d2ce commit 1d5e7dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5927
-1
lines changed

.codespellrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
skip = .git,*.pdf,*.svg,*.bib,*.html
33
# ue,lod,ans,lastr,numer,lamda,PrIs -- variable names
44
# Hart,Flagg -- name
5-
ignore-words-list = IST,nd,te,ue,lod,hart,ans,lastr,numer,lamda,flagg,pris,lod,IST,tese
5+
ignore-words-list = IST,nd,te,ue,lod,hart,ans,lastr,numer,lamda,flagg,pris,lod,IST,tese,shs

fury/actor.py

+65
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import numpy as np
88

99
from fury import layout as lyt
10+
from fury.actors.odf import sh_odf
1011
from fury.actors.odf_slicer import OdfSlicerActor
1112
from fury.actors.peak import PeakActor
1213
from fury.actors.tensor import (
@@ -4019,3 +4020,67 @@ def uncertainty_cone(
40194020
angles = main_dir_uncertainty(evals, evecs, signal, sigma, b_matrix)
40204021

40214022
return double_cone(centers, evecs, angles, colors, scales, opacity)
4023+
4024+
4025+
def odf(centers, coeffs, sh_basis="descoteaux", scales=1.0, opacity=1.0):
4026+
"""
4027+
FURY actor for visualizing Orientation Distribution Functions (ODFs) given
4028+
an array of Spherical Harmonics (SH) coefficients.
4029+
4030+
Parameters
4031+
----------
4032+
centers : ndarray(N, 3)
4033+
ODFs positions.
4034+
coeffs : (N, M) or (N, 6) or (N, 15) or (N, 28) or (N, 45) or (N, 66) or
4035+
(N, 91) ndarray.
4036+
Corresponding SH coefficients for the ODFs.
4037+
sh_basis: str, optional
4038+
Type of basis (descoteaux, tournier)
4039+
'descoteaux' for the default ``descoteaux07`` DIPY basis.
4040+
'tournier' for the default ``tournier07`` DIPY basis.
4041+
scales : float or ndarray (N, ), optional
4042+
ODFs size.
4043+
opacity : float, optional
4044+
Takes values from 0 (fully transparent) to 1 (opaque).
4045+
4046+
Returns
4047+
-------
4048+
odf: Actor
4049+
4050+
"""
4051+
4052+
if not isinstance(centers, np.ndarray):
4053+
centers = np.array(centers)
4054+
if centers.ndim == 1:
4055+
centers = np.array([centers])
4056+
4057+
if not isinstance(coeffs, np.ndarray):
4058+
coeffs = np.array(coeffs)
4059+
if coeffs.ndim != 2:
4060+
if coeffs.ndim == 1:
4061+
coeffs = np.array([coeffs])
4062+
else:
4063+
raise ValueError("coeffs should be a 2D array.")
4064+
if coeffs.shape[0] != centers.shape[0]:
4065+
raise ValueError(
4066+
"number of odf glyphs defined does not match with number of centers"
4067+
)
4068+
4069+
coeffs_given = coeffs.shape[-1]
4070+
degree = int((np.sqrt(8 * coeffs_given + 1) - 3) / 2)
4071+
if degree % 2 != 0:
4072+
degree -= 1
4073+
coeffs = coeffs[:, : int(((degree + 1) * (degree + 2)) / 2)]
4074+
if not isinstance(scales, np.ndarray):
4075+
scales = np.array(scales)
4076+
if scales.size == 1:
4077+
scales = np.repeat(scales, centers.shape[0])
4078+
elif scales.size != centers.shape[0]:
4079+
scales = np.concatenate(
4080+
(scales, np.ones(centers.shape[0] - scales.shape[0])), axis=None
4081+
)
4082+
4083+
total = np.sum(abs(coeffs), axis=1)
4084+
coeffs = np.dot(np.diag(1 / total * scales), coeffs) * 1.7
4085+
4086+
return sh_odf(centers, coeffs, degree, sh_basis, scales, opacity)

0 commit comments

Comments
 (0)