Skip to content

Commit

Permalink
Added cdm entropy code to be run in octave
Browse files Browse the repository at this point in the history
  • Loading branch information
TenzinCHW committed May 3, 2024
1 parent 897bba1 commit 4c810ff
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/compute_all_cdmentropy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
addpath("~/Documents/CDMentropy/src")
addpath("~/Documents/CDMentropy/lib/PYMentropy/src")
pkg load statistics
pkg load parallel


basedir = "../data/exp_pro/matrix_old/joost_long/full/cdmentropy";
dirs = readdir(basedir)(3:end);
for i = 1:length(dirs)
sdp = fullfile(basedir, dirs(i)){1};
files = readdir(sdp);
files = files(3:length(files));
fps = cell(length(files), 1);
for j = 1:length(files)
fps{j} = fullfile(sdp, files(j, 1));
end
[Hbs, Hvs] = pararrayfun(nproc-1, @compute_cdmentropy, fps);
savepath = fullfile(basedir, strcat(dirs(i), ".mat")){1};
save(savepath, "files", "Hbs", "Hvs", "-v6")
end

9 changes: 9 additions & 0 deletions scripts/compute_cdmentropy.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function [Hb, Hv] = parcompute_cdmentropy(filepath)
load(filepath{1,1}{1,1});
% for some reason cells is a matrix, so have to extract
counts = double(counts);
spike_counts = double(spike_counts);
cells = double(cells(1));
[Hb, Hv] = computeH_CDM(counts, spike_counts, cells(1));
end

0 comments on commit 4c810ff

Please sign in to comment.