From 4c810ff4743a8505222b0bfd1cbdaf126bd3d4d7 Mon Sep 17 00:00:00 2001 From: Tenzin Chan Date: Thu, 2 May 2024 20:40:14 -0700 Subject: [PATCH] Added cdm entropy code to be run in octave --- scripts/compute_all_cdmentropy.m | 21 +++++++++++++++++++++ scripts/compute_cdmentropy.m | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 scripts/compute_all_cdmentropy.m create mode 100644 scripts/compute_cdmentropy.m diff --git a/scripts/compute_all_cdmentropy.m b/scripts/compute_all_cdmentropy.m new file mode 100644 index 0000000..b50ced4 --- /dev/null +++ b/scripts/compute_all_cdmentropy.m @@ -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 + diff --git a/scripts/compute_cdmentropy.m b/scripts/compute_cdmentropy.m new file mode 100644 index 0000000..7b5c16a --- /dev/null +++ b/scripts/compute_cdmentropy.m @@ -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 +