forked from cortex-lab/Suite2P
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_Fall.m
51 lines (42 loc) · 1.26 KB
/
convert_Fall.m
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
% python to matlab suite2p
% python version saves Fall file, this converts Fall to a format compatible
% with the matlab GUI
dat = load('Fall.mat');
%%
Fcell = {dat.F};
FcellNeu = {dat.Fneu};
ops = dat.ops;
ops.Ly = single(dat.ops.Ly);
ops.Lx = single(dat.ops.Lx);
ops.mimg1 = ops.meanImg;
if isfield(ops, 'meanImg_chan2')
ops.mimgRED = ops.meanImg_chan2;
end
sp = {dat.spks};
clear stat
flds = fieldnames(dat.stat{1});
for n = 1:length(dat.stat)
for j = 1:length(flds)
stat(n).(flds{j}) = dat.stat{n}.(flds{j});
end
stat(n).ipix = int64(ops.Ly)*(stat(n).xpix) + stat(n).ypix + 1;
stat(n).ipix = stat(n).ipix(:);
stat(n).mimgProjAbs = 0;
stat(n).cmpct = stat(n).compact;
stat(n).aspect_ratio = double(stat(n).aspect_ratio);
%stat(n) = dat.stat{n};
end
ops.yrange = [1:dat.ops.Ly];
ops.xrange = [1:dat.ops.Lx];
ops.yrange_crop = dat.ops.yrange(1)+1:dat.ops.yrange(end);
ops.xrange_crop = dat.ops.xrange(1)+1:dat.ops.xrange(end);
ops.Vcorr = zeros(dat.ops.Ly, dat.ops.Lx);
ops.Vcorr(ops.yrange_crop, ops.xrange_crop) = dat.ops.Vcorr;
save('F.mat','-v7.3','Fcell','FcellNeu','ops','sp','stat');
%%
%% convert back to a python format
load('F_proc.mat');
icell = [dat.stat.iscell];
cellProb = [dat.stat.cellProb];
iscell=[icell(:) cellProb(:)];
writeNPY(iscell, 'iscell.npy')