Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiuliren committed Oct 31, 2019
1 parent 695525f commit e6f19dd
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
5 changes: 3 additions & 2 deletions src/NBLASTs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ function nblast(target::Matrix{T}, query::Matrix{T};
targetNodeIndex = nodeIndexList[1]
# physical distance
dist = dists[i][1]

queryVector = query[4:6, i]
targetVector = target[4:6, targetNodeIndex]
# absolute dot product
adp = abs( dot( queryVector, targetVector ) )


#@show i, targetNodeIndex, dist, adp, ria[dist, adp]
totalScore += ria[dist, adp]
end
totalScore
Expand Down
81 changes: 44 additions & 37 deletions test/NBLASTs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ const k = 20

println("\ncompute nblast score...")
@time score = NBLASTs.nblast(vectorCloud2, vectorCloud1; ria=ria)
@time score = NBLASTs.nblast(vectorCloud2, vectorCloud1; ria=ria)
println("query $(NEURON_ID1) against target $(NEURON_ID2): ", score)
@test isapprox(score, Float32(50887.82f0))
@time score = NBLASTs.nblast(vectorCloud1, vectorCloud1; ria=ria)
println("query $(NEURON_ID1) against itself: ", score)
@test isapprox(score, Float32(86507.24f0))

println("\ncompute nblast score...")
@time score = NBLASTs.nblast(vectorCloud1, vectorCloud2; ria=ria)
println("query $(NEURON_ID1) against target $(NEURON_ID2): ", score)
@test isapprox(score, Float32(53697.95f0))

#@time score = NBLASTs.nblast(vectorCloud1, vectorCloud1; ria=ria)
#println("query $(NEURON_ID1) against itself: ", score)
#@test isapprox(score, Float32(86507.24f0))


neuronList = [neuron1, neuron2]
Expand All @@ -55,40 +62,40 @@ const k = 20
@test isapprox.(rawSimilarityMatrix, RNBLAST_RESULT) |> all


println("\ncompute normalised similarity matrix...")
RNBLAST_RESULT = Float32[1.0 0.5315924; 0.5883275 1.0]
@show normalizedSimilarityMatrix
@test isapprox.(normalizedSimilarityMatrix, RNBLAST_RESULT) |> all

RNBLAST_RESULT = Float32[1.0 0.5599599; 0.5599599 1.0]
println("\ncompute mean similarity matrix...")
@show meanSimilarityMatrix
@test isapprox.(meanSimilarityMatrix, RNBLAST_RESULT) |> all

vectorCloudList = [vectorCloud1, vectorCloud2]
RNBLAST_RESULT = Float32[86501.20 53696.72; 50891.03 101011.08]
@time rawSimilarityMatrix = NBLASTs.nblast_allbyall(vectorCloudList; ria=ria)
@show rawSimilarityMatrix
@test isapprox.(rawSimilarityMatrix, RNBLAST_RESULT) |> all
#println("\ncompute normalised similarity matrix...")
#RNBLAST_RESULT = Float32[1.0 0.5315924; 0.5883275 1.0]
#@show normalizedSimilarityMatrix
#@test isapprox.(normalizedSimilarityMatrix, RNBLAST_RESULT) |> all
#
#RNBLAST_RESULT = Float32[1.0 0.5599599; 0.5599599 1.0]
#println("\ncompute mean similarity matrix...")
#@show meanSimilarityMatrix
#@test isapprox.(meanSimilarityMatrix, RNBLAST_RESULT) |> all
#
#vectorCloudList = [vectorCloud1, vectorCloud2]
#RNBLAST_RESULT = Float32[86501.20 53696.72; 50891.03 101011.08]
#@time rawSimilarityMatrix = NBLASTs.nblast_allbyall(vectorCloudList; ria=ria)
#@show rawSimilarityMatrix
#@test isapprox.(rawSimilarityMatrix, RNBLAST_RESULT) |> all


println("\ncompute nblast score using default zfish score table ...")
# this test will not work since neuron reading from swc/swc.bin
# do not support node class yet
vectorCloud1 = NBLASTs.VectorCloud(neuron1; class=Segments.DENDRITE_CLASS)
vectorCloud2 = NBLASTs.VectorCloud(neuron2; class=Segments.DENDRITE_CLASS)
@time score = NBLASTs.nblast(vectorCloud2, vectorCloud1;)
println("query $(NEURON_ID1) against target $(NEURON_ID2): ", score)
# @test isapprox(score, -63722.48f0)

println("\ntest similarity measurement for dendrites...")
@time rawSimilarityMatrix, normalizedSimilarityMatrix, meanSimilarityMatrix =
NBLASTs.nblast_allbyall(neuronList; ria=ria, k=k, downscaleFactor=1000)
@show rawSimilarityMatrix
#println("similarity matrix of dendrites: ", similarityMatrix)

println("compute similarity score with semantic small-to-big...")
semanticSmall2bigSimilarityMatrix =
NBLASTs.nblast_allbyall_small2big(neuronList; k=k, ria=ria, semantic=true);
#
#println("\ncompute nblast score using default zfish score table ...")
## this test will not work since neuron reading from swc/swc.bin
## do not support node class yet
#vectorCloud1 = NBLASTs.VectorCloud(neuron1; class=Segments.DENDRITE_CLASS)
#vectorCloud2 = NBLASTs.VectorCloud(neuron2; class=Segments.DENDRITE_CLASS)
#@time score = NBLASTs.nblast(vectorCloud2, vectorCloud1;)
#println("query $(NEURON_ID1) against target $(NEURON_ID2): ", score)
## @test isapprox(score, -63722.48f0)
#
#println("\ntest similarity measurement for dendrites...")
#@time rawSimilarityMatrix, normalizedSimilarityMatrix, meanSimilarityMatrix =
# NBLASTs.nblast_allbyall(neuronList; ria=ria, k=k, downscaleFactor=1000)
#@show rawSimilarityMatrix
##println("similarity matrix of dendrites: ", similarityMatrix)

#println("compute similarity score with semantic small-to-big...")
#semanticSmall2bigSimilarityMatrix =
# NBLASTs.nblast_allbyall_small2big(neuronList; k=k, ria=ria, semantic=true);

end # end of test module

0 comments on commit e6f19dd

Please sign in to comment.