-
Notifications
You must be signed in to change notification settings - Fork 181
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
tvcastillod
wants to merge
144
commits into
fury-gl:master
Choose a base branch
from
tvcastillod:shodfimpl
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 141 commits
Commits
Show all changes
144 commits
Select commit
Hold shift + click to select a range
5ec815e
added file for experimentation
tvcastillod 4464ee4
added SH implementation with 2 parameters
tvcastillod dffb17c
adjusted script
tvcastillod 508f8cc
Merge branch 'fury-gl:master' into SH-for-ODF-impl
tvcastillod b61aaf5
added coefficients to experimental implementation
tvcastillod f33930d
Merge remote-tracking branch 'origin/SH-for-ODF-impl' into SH-for-ODF…
tvcastillod 06d933e
Merge branch 'fury-gl:master' into SH-for-ODF-impl
tvcastillod 91f5ea5
deleted unused variables
tvcastillod 7ad49f1
added files for experimentation on each issue
tvcastillod 5c72691
added file for experimentation with textures
tvcastillod 67c231c
updated files
tvcastillod fb1f6e2
passing coefficients through texture with few glyphs
tvcastillod 0e0c1d7
comparison of passing coefficients with uniforms vs texture
tvcastillod 63e2886
Pruning duplicate coeffs.
guaje a451eee
Merge branch 'fury-master' into sh_odf
guaje df3b9ca
Refactoring FS declaration code.
guaje 6346117
Added temp call to Fury's Central Differences Normals calculation.
guaje 54b2b3a
Added new file with changes.
guaje 321bab2
Merge branch 'tania-sh_odf' into sh_odf
guaje 1f455c0
Restored texture_coefficients.py
guaje 5793fd1
Merge pull request #2 from guaje/sh_odf
tvcastillod ed6d9ab
organized files
tvcastillod 31900bb
adjusted uv vals
tvcastillod f747107
Added minor changes.
guaje d0ab18c
added new file for SH efficient implementation
tvcastillod feee339
Minor changes in shader code.
guaje 1b1546a
Merge branch 'tania-sh_odf' into sh_odf
guaje f3c3490
Added first version of Peters' paper.
guaje 2f93d36
Added difinitions for constants.
guaje 80f5682
Added first functions of main shaders.
guaje ec69820
All functions added.
guaje c94cb7a
clear
guaje d255964
Removed rotation code and resolution dependent code.
guaje 99908e5
Renamed folder spherical_harmonics as rt_odfs.
guaje 2dfde0b
Organized main code.
guaje e19ff42
Merge pull request #3 from guaje/sh_odf
tvcastillod d604060
Merge branch 'fury-master' into sh_odf
guaje 4057e41
Created ray_traced_3.py to simplify ray_traced_1.py content. Removed …
guaje a3ac454
added SH efficient implementation to the base impl with texture
tvcastillod b973e65
Added minor changes to base Ray Tracing implementation (ray_traced_1.…
guaje 02915dc
Minor changes on ray_traced_3.py.
guaje 4880e45
Minor changes in ray_traced_1.py
guaje cc483cd
Forwarded camera right and up vectors.
guaje 6420487
Merge branch 'tania-sh_odf' into sh_odf
guaje a9a6ffd
Used 3D point as frag_coord for uv mapping.
guaje ae9e554
Tournier first implementation
tvcastillod f87a985
updated files
tvcastillod 39d429c
Merge branch 'tania-sh_odf' into sh_odf
guaje 1598f0e
added Tournier impl
tvcastillod 07beada
Merge branch 'tania-sh_odf' into sh_odf
guaje d5a387b
Improved description of ray_traced_3.py
guaje dd7ab4c
Prep for new ray_traced file.
guaje a3c861d
Minor changes to ray_traced3.py
guaje 6a1516a
Created ray_traced_6.py to fix scalability.
guaje 1fac9ad
Minor changes to ray_traced_6.py
guaje 305b848
Added README and renamed ray_traced files.
guaje 6b682d3
Added ray_traced_4.0.py as an analogous version of ray_traced_2.0.py.…
guaje f960c5b
Removed ray_traced_6.0.py from PR.
guaje 50d6425
Merge pull request #4 from guaje/sh_odf
tvcastillod c95e435
implementation with a slice
tvcastillod 07252e0
made adjustments on odf slice example
tvcastillod 2d41c30
updated README
tvcastillod 175d03d
Removed unused black tags.
guaje dc18604
Minor changes in several ray_traced experiments.
guaje 10c185d
Improved multiplatform compatibility of ray_traced_6.0.py. Changed il…
guaje fdd25cf
fixed scaling
tvcastillod 89c7f76
Merge branch 'tania-sh_odf' into sh_odf
guaje f73d7d0
Fixed merge.
guaje 247d811
Merge pull request #5 from guaje/sh_odf
tvcastillod a7724d7
added odf actor implementation
tvcastillod fbe7ed5
adjusted scaling
tvcastillod 8c6b8fd
Added ray_traced_7.0.py which includes an argument parser.
guaje bfd4b01
Added DIPY's ODF slicer python script with argument parser for profil…
guaje 1438b84
Minor changes to ray_traced_7.0.py
guaje 644b4fe
Renamed experimental folder.
guaje fc85cd6
Changed basis to Tournier's.
guaje 97f1d93
reorganized files
tvcastillod ef09453
Added folders for Descoteaux and Tournier basis.
guaje 0b5c75f
Updated ray_traced scripts to use spherical harmonics basis.
guaje dc1b8da
Merge branch 'fury-master' into sh_odf_exp
guaje 8f71a14
Added ray_traced_6.5.py to debug performance issues.
guaje 66dda5d
added degree param
tvcastillod badb5a9
adjusted the degree setting
tvcastillod d9c3323
Merge branch 'master' into shodfimpl
tvcastillod 290b330
Changed first uniform.
guaje ecef0ff
Added ray_traced_3.5.py to take single ODF screenshot.
guaje dc41684
added tests
tvcastillod f4824f6
adjustments on tests and parameter validation
tvcastillod a17222e
Added Min-Max Normalization function.
guaje a4e9fde
Added composed eval sh.
guaje 9f4a515
Moved newton_bisection.frag to root_finding folder.
guaje a580355
reorganized and refactored odf actor
tvcastillod 4ccced9
Re-added newton_bisection.frag to rt_odfs.
guaje 4c66c81
Fixed uniform and flats data type. Added numCoeffs param to rayGlyphI…
guaje 00c069a
Moved dipy_slicer.py script to personal repo. Renamed as odf_slicer_c…
guaje c33c4d6
Minor fix on uncertainty cone actor.
guaje de817ab
Replaced SH_DEGREE with shDegree in rayGlyphIntersections function.
guaje 64a0789
Added extra arguments to rayGlyphIntersections function.
guaje 9742ca9
Merge branch 'fury-gl-master' into SH-for-ODF-impl
tvcastillod 8ee28ff
Merge branch 'fury-gl:master' into SH-for-ODF-impl
tvcastillod 326c77f
Renamed variables in rayGlyphIntersections finction.
guaje 44e35a7
Merge branch 'SH-for-ODF-impl' of https://github.com/tvcastillod/fury…
tvcastillod f5b91f3
Merge branch 'SH-for-ODF-impl' into sh_odf_exp
tvcastillod 283446d
Added new eval_sh.frag.
guaje 9321cf7
Added dynamic evalSH function.
guaje a5d1ff1
Refactored eval_sh_x functions.
guaje 86c7613
Refactored getInvVandermonde function.
guaje e150d06
Removed unnecessary eval_sh.frag file.
guaje 668a7c3
Merge branch 'fury-master' into sh_odf_exp
guaje c491e75
Merge pull request #6 from guaje/sh_odf_exp
tvcastillod f68991b
added odf actor implementation
tvcastillod 0e6dc18
adjusted scaling
tvcastillod 54fbd0d
reorganized files
tvcastillod 23c53df
added degree param
tvcastillod 236d809
adjusted the degree setting
tvcastillod ecd1d75
added tests
tvcastillod 3a375d9
adjustments on tests and parameter validation
tvcastillod c56920b
reorganized and refactored odf actor
tvcastillod 904c698
solved conflicts
tvcastillod c149861
added odf actor implementation
tvcastillod 18dc83a
adjusted scaling
tvcastillod e259713
reorganized files
tvcastillod dd16653
added degree param
tvcastillod 59971b7
adjusted the degree setting
tvcastillod 390ce01
added tests
tvcastillod ecca0f6
adjustments on tests and parameter validation
tvcastillod 8006581
reorganized and refactored odf actor
tvcastillod 2ddb43f
Merge branch 'shodfimpl' of https://github.com/tvcastillod/fury into …
tvcastillod 5a6d1f6
Merge branch 'shodfimpl' of https://github.com/tvcastillod/fury into …
tvcastillod a57c158
added odf actor implementation
tvcastillod a0d8ecc
adjusted scaling
tvcastillod 0fa1db8
reorganized files
tvcastillod 49aeeda
added degree param
tvcastillod a2539d2
adjusted the degree setting
tvcastillod 6f95e7a
added tests
tvcastillod f2204f0
adjustments on tests and parameter validation
tvcastillod 2ee1422
reorganized and refactored odf actor
tvcastillod 933ae32
odf actor change
tvcastillod 6b2e4e7
Merge branch 'fury-gl:master' into shodfimpl
tvcastillod 0c6351d
adjusted odf actor and added example
tvcastillod fc30cd9
adjustments on variables name and handle degree with uniform
tvcastillod 95aa9eb
made suggested changes
tvcastillod ca9ec16
adjusted odf actor test
tvcastillod 69f3819
fixed format
tvcastillod File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
|
||
import numpy as np | ||
from dipy.data.fetcher import dipy_home | ||
from dipy.io.image import load_nifti | ||
|
||
from fury import actor, window | ||
|
||
if __name__ == "__main__": | ||
show_man = window.ShowManager(size=(1280, 720)) | ||
|
||
dataset_dir = os.path.join(dipy_home, "stanford_hardi") | ||
|
||
coeffs, affine = load_nifti("docs\experimental\SH-ODF_experimental\odf_debug_sh_coeffs_9x11x45(8).nii") | ||
|
||
valid_mask = np.abs(coeffs).max(axis=(-1)) > 0 | ||
indices = np.nonzero(valid_mask) | ||
|
||
centers = np.asarray(indices).T | ||
|
||
x, y, z, s = coeffs.shape | ||
coeffs = coeffs[:, :, :].reshape((x * y * z, s)) | ||
|
||
#''' | ||
coeffs = np.array([ | ||
[ | ||
-0.2739740312099, 0.2526670396328, 1.8922271728516, 0.2878578901291, | ||
-0.5339795947075, -0.2620058953762, 0.1580424904823, 0.0329004973173, | ||
-0.1322413831949, -0.1332057565451, 1.0894461870193, -0.6319401264191, | ||
-0.0416776277125, -1.0772529840469, 0.1423762738705, 0.7941166162491, | ||
0.7490307092667, -0.3428381681442, 0.1024847552180, -0.0219132602215, | ||
0.0499043911695, 0.2162453681231, 0.0921059995890, -0.2611238956451, | ||
0.2549301385880, -0.4534865319729, 0.1922748684883, -0.6200597286224, | ||
-0.0532187558711, -0.3569841980934, 0.0293972902000, -0.1977960765362, | ||
-0.1058669015765, 0.2372217923403, -0.1856198310852, -0.3373193442822, | ||
-0.0750469490886, 0.2146576642990, -0.0490148440003, 0.1288588196039, | ||
0.3173974752426, 0.1990085393190, -0.1736343950033, -0.0482443645597, | ||
0.1749017387629 | ||
] | ||
]) | ||
centers= np.array([0, 0, 0]) | ||
#''' | ||
|
||
odf_actor = actor.odf(centers=centers, coeffs=coeffs, scales=1.0, | ||
sh_basis='descoteaux') | ||
show_man.scene.add(odf_actor) | ||
show_man.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -4019,3 +4020,70 @@ def uncertainty_cone( | |
angles = main_dir_uncertainty(evals, evecs, signal, sigma, b_matrix) | ||
|
||
return double_cone(centers, evecs, angles, colors, scales, opacity) | ||
|
||
|
||
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, ) | ||
ODFs size. | ||
opacity : float | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, optional
to add