forked from abhishekde95/Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTuningDistribution.jl
36 lines (29 loc) · 1.56 KB
/
TuningDistribution.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using NeuroAnalysis,Statistics,FileIO,Plots,VegaLite,Interact
dataroot = "../Data"
dataexportroot = "../DataExport"
resultroot = "../Result"
subject = "AF5";recordsession = "HLV1";recordsite = "ODL3"
siteid = join(filter(!isempty,[subject,recordsession,recordsite]),"_")
resultsitedir = joinpath(resultroot,subject,siteid)
## Tuning Properties in layers
layer = load(joinpath(resultsitedir,"layer.jld2"),"layer")
testids = ["$(siteid)_OriSF_$i" for i in 1:5]
ds = load.(joinpath.(resultsitedir,testids,"factorresponse.jld2"))
testtitles = ["$(i["color"])" for i in ds]
spikes = load.(joinpath.(resultsitedir,testids,"spike.jld2"),"spike")
f = :Ori
p=plot(layout=(1,testn),link=:all,legend=false,grid=false,xlims=(10,60))
for i in 1:testn
vi = spikes[i]["unitgood"].&ds[i]["responsive"].&ds[i]["modulative"]
if f in [:Ori,:Ori_Final]
color = map((i,j)->j ? HSV(i.oo,1-i.ocv/1.5,1) : RGBA(0.5,0.5,0.5,0.1),ds[i]["factorstats"][:Ori_Final],vi)
elseif f==:Dir
color = map((i,j)->j ? HSV(i.od,1-i.dcv/1.5,1) : RGBA(0.5,0.5,0.5,0.1),ds[i]["factorstats"][:Ori_Final],vi)
end
scatter!(p,subplot=i,spikes[i]["unitposition"][:,1],spikes[i]["unitposition"][:,2],color=color,markerstrokewidth=0,markersize=2,title=testtitles[i],titlefontsize=8)
if !isnothing(layer)
hline!(p,subplot=i,[layer[k][1] for k in keys(layer)],linestyle=:dash,annotations=[(17,layer[k][1],text(k,5,:gray20,:bottom)) for k in keys(layer)],linecolor=:gray30,legend=false)
end
end
p
foreach(i->savefig(joinpath(resultsitedir,"Layer_UnitPosition_$(f)_Tuning$i")),[".png",".svg"])