Skip to content

Commit

Permalink
Moved saving inside loop
Browse files Browse the repository at this point in the history
  • Loading branch information
TenzinCHW committed May 2, 2024
1 parent b6b300a commit 897bba1
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions scripts/export_jl2mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ end

"""Gets all pattern counts and spike counts for each unique pattern and pattern dimension"""
function cntspikecell(dirpath, datapath, extractfn)
inp = Dict()
out = Dict()
null = Dict()
for f in readdir(joinpath(dirpath, "complete"))
println(f)
modeldata = DrWatson.wload(joinpath(dirpath, "complete", f))
# extract model
model = MEFK.MEF2T(modeldata["1"]["net"], CUDA.cu)
Expand All @@ -56,6 +54,7 @@ function cntspikecell(dirpath, datapath, extractfn)
windowedspikes, counts = window(data_split[1], winsz)
spkcnt = sum(windowedspikes, dims=2)
# get outputs for data
println(size(windowedspikes))
output = convergedynamics(model, windowedspikes |> CUDA.cu) |> Array
# combine output count
output, outcounts = combine_counts(output, counts)
Expand All @@ -69,11 +68,10 @@ function cntspikecell(dirpath, datapath, extractfn)
o = Dict("cells"=>model.n, "counts"=>outcounts, "spike_counts"=>outspkcnt)
i = Dict("cells"=>model.n, "counts"=>counts, "spike_counts"=>spkcnt)
nl = Dict("cells"=>model.n, "counts"=>nullcnts, "spike_counts"=>nullspkcnt)
out[f] = o
inp[f] = i
null[f] = nl
MAT.matwrite(joinpath(dirpath, "cdmentropy", "input", "$(f).mat"), i)
MAT.matwrite(joinpath(dirpath, "cdmentropy", "complete", "$(f).mat"), o)
MAT.matwrite(joinpath(dirpath, "cdmentropy", "null", "$(f).mat"), nl)
end
inp, out, null
end


Expand All @@ -99,9 +97,9 @@ if abspath(PROGRAM_FILE) == @__FILE__
# writemat(outvals, basedir, subdir)
#end

inp, out, null = cntspikecell(basedir, datapath, extractfn)
subdirs = Dict("input"=>inp, "complete"=>out, "null"=>null)
for (dn, v) in subdirs
writemat(v, basedir, dn)
end
cntspikecell(basedir, datapath, extractfn)
#subdirs = Dict("input"=>inp, "complete"=>out, "null"=>null)
#for (dn, v) in subdirs
# writemat(v, basedir, dn)
#end
end

0 comments on commit 897bba1

Please sign in to comment.