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

ENH: add test for FBTractMeasure with scalar-only polydata #91

Merged
merged 2 commits into from Nov 28, 2017

Conversation

ihnorton
Copy link
Member

@ihnorton ihnorton commented Nov 21, 2017

Adds test for FiberTractMeasurements CLI module with scalar-only polydata.

@ihnorton ihnorton force-pushed the add_fbtractmsr_scalaronly_test branch from 2f819a3 to 84448c0 Compare November 21, 2017 23:36
@ihnorton ihnorton force-pushed the add_fbtractmsr_scalaronly_test branch from 84448c0 to 9845ab2 Compare November 21, 2017 23:39
@ihnorton
Copy link
Member Author

Data is a single-strand fiberbundle from UKF.

Added random scalar array in Python (assuming pd points to the polydata already):

In [75]: randarr = np.random.rand(60)

In [76]: vrandarr = dsa.numpyTovtkDataArray(randarr)

In [77]: vrandarr
Out[77]: (vtkDoubleArray)0x110ddc350

In [78]: np.mean(randarr)
Out[78]: 0.57747233392019237

In [79]: vrandarr.SetName("RANDARRAY")

In [80]: pd.GetPointData().AddArray(vrandarr)
Out[80]: 1

In [81]: wr = vtk.vtkPolyDataWriter()

In [82]: wr.SetFileName("/tmp/fbt/littlerandbundle.vtk")

In [83]: wr.SetInputData(pd)

In [84]: wr.Update()

In [85]: wr.Write()

@ihnorton ihnorton changed the title ENH: add test for FBTractMeasure with scalar only polydata ENH: add test for FBTractMeasure with scalar-only polydata Nov 21, 2017
@ihnorton
Copy link
Member Author

ihnorton commented Nov 21, 2017

Manual verification of figures in baseline output file:

# RANDARRAY values from `fiber_notensor_randscalar.vtk`
julia> v = [0.81787 0.595397 0.197063 0.991127 0.976741 0.804367 0.346301 0.100142 0.193635 0.0378677 0.444774 0.780073 0.426525 0.774192 0.765277 0.968237 0.069852 0.287893 0.0604638 0.340746 0.98026 0.611797 0.963014 0.878509 0.91017 0.721776 0.0652108 0.789717 0.639065 0.673024 0.0148516 0.923146 0.388264 0.920742 0.485409 0.99897 0.414107 0.562507 0.474771 0.182289 0.621647 0.737416 0.96598 0.627021 0.463968 0.928957 0.518274 0.79058 0.99335 0.396943 0.27392 0.0251089 0.995054 0.46926 0.0960025 0.301948 0.319466 0.878315 0.772408 0.896582 ]
julia> minimum(v)
0.0148516

julia> maximum(v)
0.99897

julia> mean(v)
0.5774723883333334

julia> median(v)
0.616722

julia> minimum(v)
0.0148516

julia> var(v)
0.09934554264379902

vs

Max Mean Median Min NAN Variance
0.998970 0.577472 0.621647 0.014852 0.000000 0.099346

@ihnorton
Copy link
Member Author

ihnorton commented Nov 22, 2017

After putting the numbers in the table above, I noticed variance median was incorrect. This was because the calculation did not take in to account the possibility of even numbers of points. Proposed fix added to this PR in eed6624.

Corrected table after fix:

Max Mean Median Min NAN Variance
0.998970 0.577472 0.616722 0.014852 0.000000 0.099346

@ihnorton
Copy link
Member Author

I noticed variance median was incorrect. This was because the calculation did not take in to account the possibility of even numbers of points. Proposed fix added to this PR in eed6624.

cc @zhangfanmark since you wrote this code (I think), can you take a look at this change?

@zhangfanmark
Copy link
Member

Hi @ihnorton, thanks for the update. The changes look good to me.

@ihnorton ihnorton merged commit d4ff725 into SlicerDMRI:master Nov 28, 2017
@ihnorton ihnorton deleted the add_fbtractmsr_scalaronly_test branch November 28, 2017 19:46
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.

None yet

2 participants