-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36072de
commit 2964903
Showing
3 changed files
with
85 additions
and
35 deletions.
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
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,36 @@ | ||
""" | ||
This spript includes the implementation of cone of uncertainty using matrix | ||
perturbation analysis | ||
""" | ||
from fury import actor, window | ||
|
||
from dipy.io.image import load_nifti | ||
from dipy.io.gradients import read_bvals_bvecs | ||
|
||
from dipy.data import get_fnames | ||
|
||
|
||
def test_uncertainty(): | ||
hardi_fname, hardi_bval_fname, hardi_bvec_fname = get_fnames('stanford_hardi') | ||
|
||
data, affine = load_nifti(hardi_fname) | ||
|
||
bvals, bvecs = read_bvals_bvecs(hardi_bval_fname, hardi_bvec_fname) | ||
|
||
from dipy.segment.mask import median_otsu | ||
|
||
maskdata, mask = median_otsu(data, vol_idx=range(10, 50), median_radius=3, | ||
numpass=1, autocrop=True, dilate=2) | ||
|
||
uncertainty_cones = actor.dti_uncertainty( | ||
data=maskdata[13:43, 44:74, 28:29], bvals=bvals, bvecs=bvecs) | ||
|
||
scene = window.Scene() | ||
scene.background([255, 255, 255]) | ||
|
||
scene.add(uncertainty_cones) | ||
|
||
scene.reset_camera() | ||
scene.reset_clipping_range() | ||
|
||
window.show(scene, reset_camera=False) |
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 |
---|---|---|
@@ -1,5 +1,15 @@ | ||
float sdCone( vec3 p, vec2 c, float h ) | ||
{ | ||
float q = length(p.xz); | ||
return max(dot(c.xy,vec2(q,p.y)),-h-p.y); | ||
// c is the sin/cos of the angle, h is height | ||
// Alternatively pass q instead of (c,h), | ||
// which is the point at the base in 2D | ||
vec2 q = h*vec2(c.x/c.y,-1.0); | ||
|
||
vec2 w = vec2( length(p.xz), p.y ); | ||
vec2 a = w - q*clamp( dot(w,q)/dot(q,q), 0.0, 1.0 ); | ||
vec2 b = w - q*vec2( clamp( w.x/q.x, 0.0, 1.0 ), 1.0 ); | ||
float k = sign( q.y ); | ||
float d = min(dot( a, a ),dot(b, b)); | ||
float s = max( k*(w.x*q.y-w.y*q.x),k*(w.y-q.y) ); | ||
return sqrt(d)*sign(s); | ||
} |