Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BatchVerMo #20

Open
wants to merge 371 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
371 commits
Select commit Hold shift + click to select a range
3ef1883
new input “manual”
shijiegu Jul 5, 2017
a1497e1
use central A to merge
shijiegu Jul 6, 2017
38e3d71
gt not lt…stupid
shijiegu Jul 6, 2017
caaa148
chucked version faster
shijiegu Jul 6, 2017
b12fddb
New Merging strategy: quit using original functions from C++
shijiegu Jul 6, 2017
7e4084f
Splitting added, viewTraces added. More robust input/output parser.
shijiegu Jul 6, 2017
3599c91
changing the trunked version
shijiegu Jul 6, 2017
2b88da3
stupid mistake
shijiegu Jul 6, 2017
fe4f5f4
something about std
shijiegu Jul 6, 2017
b797468
some ind error. now fixed.
shijiegu Jul 6, 2017
13204af
debugging display added :(
shijiegu Jul 7, 2017
c5c6b67
more display
shijiegu Jul 7, 2017
18b1aa8
added isempty(…)
shijiegu Jul 7, 2017
b175125
shoji’s own merging function’s debug
shijiegu Jul 7, 2017
01cbd86
sequence change
shijiegu Jul 7, 2017
f6fec03
mergeAC adding debugging information newIDs
shijiegu Jul 7, 2017
fe9dbec
some unnecessary changes revert
shijiegu Jul 7, 2017
827a2a8
having new changes in upstream
shijiegu Jul 7, 2017
1b53d9b
debugging MergeAC
shijiegu Jul 7, 2017
dc48652
cat(dim,….)
shijiegu Jul 7, 2017
2ef09a4
min_pixel included as a user defined parameter in BatchVer
shijiegu Jul 7, 2017
0a9aed6
debugging the problematic peeling off process. chasing ci to ci_raw
shijiegu Jul 7, 2017
9e27119
c_raw seems to be fine!
shijiegu Jul 7, 2017
f072be4
higher PNR; median to mean
shijiegu Jul 8, 2017
23b0ed4
(1) Make sure c’s are the same. (2) Only have neurons that are merged.
shijiegu Jul 8, 2017
fb29d81
typo
shijiegu Jul 8, 2017
5c816d1
typo
shijiegu Jul 8, 2017
bdf7864
Full version, using bout files.
shijiegu Jul 8, 2017
b05919b
after merging, some files may have zero neurons. This update take int…
shijiegu Jul 9, 2017
8613d4d
display
shijiegu Jul 9, 2017
dc35e27
many check point for empty results added!
shijiegu Jul 9, 2017
c6a7b48
more check points
shijiegu Jul 9, 2017
945c629
bout1 and bout115 has different character number!!!
shijiegu Jul 9, 2017
085cda8
selectedTraces added here
shijiegu Jul 9, 2017
73603e9
small changes but might be important!
shijiegu Jul 10, 2017
e8dea45
before pull request
shijiegu Jul 10, 2017
4425319
not allowing massive mode to deconvolve
shijiegu Jul 12, 2017
5d73822
allow deletion in spatial
shijiegu Jul 12, 2017
af75d15
for deconvolving
shijiegu Jul 13, 2017
502fd64
add Afinal saving as well as ColoredA for each batch for moBatchVer
shijiegu Jul 18, 2017
212cf47
Afinal, not Amask
shijiegu Jul 19, 2017
1588d97
“normcorre” forBatch underdevelopment
shijiegu Jul 19, 2017
f42f2d2
moBatchVer cluster part starting!
shijiegu Jul 22, 2017
1345bab
motion correction included. Basic version cluster part changed.
shijiegu Jul 23, 2017
327d85c
Changed ColorAllNeurons so it doesn't autosave
emackev Jul 23, 2017
d0dd70a
colorallneurons pushed by git
shijiegu Jul 25, 2017
b75e123
Merge branch 'BatchVer' of ssh://bitbucket.org/feelab/cnmf_e into Bat…
shijiegu Jul 25, 2017
33a60b4
BatchVerMotion Cluster1 is shortened and these cut are put in Cluster2
shijiegu Jul 26, 2017
704f8dc
renaming cluster part1
shijiegu Jul 26, 2017
250ed71
commit changes before renaming
shijiegu Jul 26, 2017
1f460fb
renaming cluster part2
shijiegu Jul 26, 2017
4311f24
BatchVerMo
shijiegu Jul 27, 2017
5382e4b
demo update
shijiegu Jul 27, 2017
c6aca9d
BatchVerBasic
shijiegu Jul 27, 2017
7353cee
add ending note
shijiegu Jul 27, 2017
32c97d4
outputdirDetails
shijiegu Jul 27, 2017
1ca8a1e
dir issues
shijiegu Jul 27, 2017
99702f2
cd
shijiegu Jul 27, 2017
b0786c6
BatchVerMotionSection
shijiegu Jul 27, 2017
6a1cb95
new version
shijiegu Jul 27, 2017
8874c95
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Jul 27, 2017
0652d16
one file is small the other is bigger
shijiegu Jul 27, 2017
ec633a7
some changes before
shijiegu Jul 28, 2017
c76331d
some for BatchVerMo
shijiegu Jul 28, 2017
811835e
MergeACforMo will only calculate index but do not the actual merge. T…
shijiegu Jul 28, 2017
8c3185c
Some update for Merging in BatchVerMo. Office is too noisy Going to L…
shijiegu Jul 28, 2017
8c00351
Merge for cnmfeMoBatchVer
shijiegu Jul 28, 2017
00ef980
NewVersion of Motion Correction- 1) limited update 2) Nuerons out of …
shijiegu Jul 29, 2017
691ea26
wrong name specification
shijiegu Jul 29, 2017
21d2c33
folder problem again
shijiegu Jul 29, 2017
d066ef9
new version format change
shijiegu Jul 29, 2017
4edc43e
Structure concat change
shijiegu Jul 29, 2017
13bac6f
Some structures are concated in the other direction
shijiegu Jul 29, 2017
05fef37
M was saved as M_final not M in MotionCorrection Section...
shijiegu Jul 29, 2017
576d859
Merging debug1
shijiegu Jul 30, 2017
a83c578
Trunked Version for testing stage
shijiegu Jul 30, 2017
df0a706
typo
shijiegu Jul 30, 2017
f94ce65
some index stupid typo
shijiegu Jul 30, 2017
f586f6a
mergeAC typo. some new normcorre_BatchVer debug
shijiegu Jul 31, 2017
f69d2f8
Using consecutive day’s relative shifts to infer all shifts among days
shijiegu Jul 31, 2017
328a8a2
reducing the memory use
shijiegu Jul 31, 2017
823bb66
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Jul 31, 2017
b41cdbf
Looks like in our design, only keeping neurons that are found in at l…
shijiegu Aug 1, 2017
aafb75b
before my computer goes to repair. Here is new inter-day registration
shijiegu Aug 1, 2017
e47f4a8
This commit is the debugged-version of updating pics to register rath…
shijiegu Aug 2, 2017
87d4c5d
This version uses overlapping information between days to align.
shijiegu Aug 2, 2017
67a575a
motionGUI
shijiegu Aug 3, 2017
d276cdb
magnifying, indexing, automatic aligning one neuron pair
shijiegu Aug 4, 2017
e6d03ea
Making GUI nicer, ready to move neurons tmr
shijiegu Aug 5, 2017
0bbda5c
added text in GUI, fixing some bugs in reverse
shijiegu Aug 6, 2017
d4a8c8e
neuron recognition in process
shijiegu Aug 6, 2017
c52ea86
Basic GUI complete
shijiegu Aug 7, 2017
57a8581
use the middle M
shijiegu Aug 7, 2017
95a2012
...the missing one
shijiegu Aug 8, 2017
050d36f
Trunked has some changes important changes
shijiegu Aug 8, 2017
dc844d8
MotionBasicDone
shijiegu Aug 8, 2017
b82403c
Merge commit '9ecacc94592e1bd0d7557f01e171a81fcb78023e' into BatchVerMo
shijiegu Aug 9, 2017
c428b7f
merging BatchVer and MoBatchVer
shijiegu Aug 9, 2017
e3e112d
Merging all motion correction scripts into GUI
shijiegu Aug 10, 2017
ae9b2ea
This GUI version includes NormCorr "auto tune", grid drawing, and par…
shijiegu Aug 10, 2017
bd6b4f2
missing d1 and d2
shijiegu Aug 11, 2017
ed3e6d0
some missing variables
shijiegu Aug 11, 2017
a738c5d
some missing variables
shijiegu Aug 11, 2017
e0a3a36
Whatever I can do on Motion Correction
shijiegu Aug 11, 2017
f727782
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Aug 11, 2017
c60dede
Making raw video's background subtracted video for each day.
shijiegu Aug 15, 2017
d897314
Making movies, some changes on my mac
shijiegu Aug 15, 2017
9a42a84
maybe the dot
shijiegu Aug 15, 2017
a883453
checking
shijiegu Aug 15, 2017
7364dc2
making movies name diff
shijiegu Aug 15, 2017
03429d5
double
shijiegu Aug 15, 2017
e3b8782
adding raw data in File
shijiegu Aug 15, 2017
eeed026
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Aug 15, 2017
3385e64
Making videos; adding raw data in save.
shijiegu Aug 15, 2017
d9e340c
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 15, 2017
0e459a0
some bugs in making movies, also making raw data movies for reference.
shijiegu Aug 16, 2017
764c0d4
Size change of GUI
shijiegu Aug 16, 2017
21f2a00
annoying video making
shijiegu Aug 16, 2017
f498389
stupid typo
shijiegu Aug 16, 2017
2a36077
typo
shijiegu Aug 16, 2017
a7149af
Using C_raw for merging neurons
shijiegu Aug 16, 2017
e5b498d
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Aug 16, 2017
d5b879b
typo in comments
shijiegu Aug 16, 2017
7798c72
I forgot some changes in the format
shijiegu Aug 16, 2017
7ebe0ef
Added try and catch for movie making
shijiegu Aug 16, 2017
04cc573
shortened version
shijiegu Aug 16, 2017
6fac420
Fixing deconvolutuion
shijiegu Aug 16, 2017
e076589
Merging
shijiegu Aug 16, 2017
02c8625
making better videos and deconvolution fix
shijiegu Aug 16, 2017
4cc6225
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 16, 2017
4b33a90
Last debuging before running
shijiegu Aug 16, 2017
39277a5
Use updated A for merging
shijiegu Aug 16, 2017
47c93c0
video bugs 3
shijiegu Aug 16, 2017
ee6fcb6
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 16, 2017
bb024d4
Important typo
shijiegu Aug 17, 2017
0bb6bd3
changing the way to extract c from a. Now back to PC’s original method.
shijiegu Aug 17, 2017
513abad
typo
shijiegu Aug 17, 2017
aaf5801
index issue/typo
shijiegu Aug 17, 2017
1e9fa51
corr image making
shijiegu Aug 17, 2017
1e604ae
function’s missing input
shijiegu Aug 17, 2017
a3ce2d3
some small bugs
shijiegu Aug 17, 2017
dc2de6f
size and nan
shijiegu Aug 17, 2017
9ab0fa3
use weighted version
shijiegu Aug 17, 2017
f97a0d2
something not important now
shijiegu Aug 17, 2017
8ec197b
merging
shijiegu Aug 17, 2017
d7e8d4e
Filtering out some neurons
shijiegu Aug 18, 2017
bb386be
some index typo
shijiegu Aug 18, 2017
6414111
updating some changes made in Part1 in Part2.
shijiegu Aug 18, 2017
fc8b52f
day typo
shijiegu Aug 18, 2017
4e294b7
added raw traces
shijiegu Aug 18, 2017
15c4e07
typo
shijiegu Aug 18, 2017
00d566c
part2
shijiegu Aug 19, 2017
6993786
merging branches
shijiegu Aug 19, 2017
319de64
get back to normal
shijiegu Aug 20, 2017
ee3e5a0
temp to C
shijiegu Aug 20, 2017
d3bca0a
some changes
shijiegu Aug 21, 2017
5d3b4eb
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 21, 2017
6a31c5e
debugging
shijiegu Aug 21, 2017
8686bc6
merge branches
shijiegu Aug 21, 2017
a9e5a9a
some small changes
shijiegu Aug 21, 2017
249b382
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 21, 2017
6527857
more efficient.
shijiegu Aug 21, 2017
c7351fa
merging branches
shijiegu Aug 21, 2017
f080032
more changes regarding to variables.
shijiegu Aug 21, 2017
b836ca6
Adding cnacel deletion option
shijiegu Aug 21, 2017
f631375
more debugging information included
shijiegu Aug 21, 2017
1317f8a
missing part
shijiegu Aug 21, 2017
d27f06e
small trick
shijiegu Aug 22, 2017
3ade2f7
some mistakes I made in Columbia
shijiegu Aug 22, 2017
728a149
some tricks for global variables Hope it will work
shijiegu Aug 22, 2017
ae226a8
weird matlab parfor
shijiegu Aug 23, 2017
6b6f98a
parfor nightmare
shijiegu Aug 23, 2017
986b9a3
smaller data set
shijiegu Aug 23, 2017
4858d51
adding display line
shijiegu Aug 23, 2017
5de6f83
debug
shijiegu Aug 23, 2017
97a5197
try object copy rather than equation
shijiegu Aug 23, 2017
28f97e5
final changes
shijiegu Aug 24, 2017
9a4e85f
final code cleaning/commenting---1
shijiegu Aug 24, 2017
756d589
more cleaning
shijiegu Aug 24, 2017
f1bfb16
cleaner DEMO!
shijiegu Aug 24, 2017
110d407
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 24, 2017
2ff52e7
DEMO more concise
shijiegu Aug 25, 2017
62ea3c8
Merge commit '098c6b3a408fc363d907322c1d61a1bcedbafb15' into BatchVerMo
shijiegu Aug 25, 2017
530816c
cleaning code
shijiegu Aug 25, 2017
5c2c311
merging branches
shijiegu Aug 25, 2017
2c23fed
changes some video making
shijiegu Aug 25, 2017
f240e73
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 25, 2017
3d40d73
A2C2A
shijiegu Aug 25, 2017
c31d8d8
raming A2C2A to A2C
shijiegu Aug 25, 2017
50431ab
some cleaning
shijiegu Aug 25, 2017
5c459a2
missing line
shijiegu Aug 26, 2017
fa026a5
a small bug
shijiegu Aug 26, 2017
9221e21
merging branches
shijiegu Aug 26, 2017
2d56ebe
more cleaning
shijiegu Aug 26, 2017
fd2a6c0
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 26, 2017
feddbbb
cleaning the “filelist” and “sample list”
shijiegu Aug 26, 2017
081c21a
using previous version
shijiegu Aug 27, 2017
6e86bf9
back to before
shijiegu Aug 27, 2017
788e98b
more cleaning
shijiegu Aug 28, 2017
c20be5c
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 28, 2017
1e41169
more cleaning
shijiegu Aug 28, 2017
0e20068
just to make life easier
shijiegu Aug 28, 2017
2bdbb3a
move some of the contents of the script to the shell script.
shijiegu Aug 28, 2017
64cb28d
missing changes
shijiegu Aug 28, 2017
76df364
trunked
shijiegu Aug 29, 2017
6c03fef
new DEMO
shijiegu Aug 29, 2017
9350108
move it here
shijiegu Aug 29, 2017
e91e0ce
final cleaning
shijiegu Aug 30, 2017
6f2b7ba
small changes
shijiegu Aug 30, 2017
fa6d785
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Aug 30, 2017
9b7e3de
shijiegu Aug 30, 2017
9b20298
some older version cleaning
shijiegu Aug 30, 2017
e93d4e6
merging branches
shijiegu Aug 30, 2017
01ce8bc
something I messed up during the last cleaning...
shijiegu Sep 2, 2017
d477e57
new version did not update in the outside
shijiegu Sep 3, 2017
c5193af
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Sep 3, 2017
c08c71d
… folder problems…
shijiegu Sep 3, 2017
96d7623
Add a function for getting giff from M3 in NicerA
shijiegu Oct 2, 2017
3457dee
1) Only use neurons that appear in each day.
shijiegu Oct 2, 2017
84450ad
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Oct 2, 2017
11bcd6a
Some changes in saving format
shijiegu Oct 16, 2017
f0e0e90
part traces returns deconv spike times
shijiegu Oct 16, 2017
84513eb
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Oct 16, 2017
2329893
minor changes
shijiegu Oct 28, 2017
9dddc23
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Oct 28, 2017
b93f834
part traces, don't divide deconvolved S by pnr
shijiegu Oct 28, 2017
aaa48c3
including spike
shijiegu Oct 30, 2017
c92a9d2
newer version
shijiegu Oct 31, 2017
e3cfdea
….matlab version issue
shijiegu Oct 31, 2017
c7716b9
some minor changes!
shijiegu Nov 1, 2017
eb475cc
Merge branch 'BatchVerMo' of https://bitbucket.org/feelab/cnmf_e into…
shijiegu Nov 1, 2017
f51d1cc
some version issue
shijiegu Nov 1, 2017
6729e3c
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Nov 1, 2017
d6aa1e4
pic name change
shijiegu Nov 8, 2017
a84a41e
sometimes the noise estimator leads to failure. This should be caught…
shijiegu Nov 26, 2017
2ba3747
for 6938
shijiegu Nov 27, 2017
8149ef7
trunked for the long 6938 dataset
shijiegu Nov 27, 2017
077b678
For the bug in noise estimation. estimate_baseline_noise sometimes cr…
shijiegu Dec 3, 2017
c6bb86c
typo
shijiegu Dec 3, 2017
00a024d
Some files have inherent defects in them, estimate_baseline_noise see…
shijiegu Dec 5, 2017
b17dcaa
return, not break
shijiegu Dec 5, 2017
78a100b
Corrupted files are considered to have frame-drop. Noise estimation i…
shijiegu Dec 6, 2017
2b54214
I do not know matlab changed this.
shijiegu Dec 9, 2017
19a463f
Merge commit '088afc143f84d384c38c50e7c3cda6f040e5f57a' into BatchVerMo
shijiegu Dec 26, 2017
d799e1c
Shijie wrote this on Emily's computer: greedyROI initiation now inclu…
emackev Jan 11, 2018
30c310e
merging new changes from PC
emackev Jan 11, 2018
c0d9f2f
Shijie: using PC's code
emackev Jan 15, 2018
088c627
Adding Transformation as the output.
shijiegu Jan 20, 2018
844fe83
empty nam
shijiegu Jan 20, 2018
b7c68d3
Merge branch 'BatchVerMo' of ssh://bitbucket.org/feelab/cnmf_e into B…
shijiegu Jan 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .Rhistory
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**.png

*.mat
cvx/
*.avi
Expand Down
110 changes: 110 additions & 0 deletions BatchVerMO/A2C.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
function ACS_temp=A2C(Ysignal, A, options)
% ACS=A2C2A(ACS, File, A, options)
% General Description:
% This function is designed to extract C in background-subtracted signal
% from A(not Amask) in Ysignal.
% The method relies on CNMF-E's conference script.
% For each successful ai extraction, peel A*C off Ysignal.
% Iterate for all the neurons indicated by A.
% Input:
% Ysignal(background-subtracted), with dimenstion of [d1*d2,T];
% A is also used for center calculation(for subtraction previous signal).
% options: struct data of paramters/options
% d1: number of rows
% d2: number of columns
% gSiz: maximum size of a neuron
% nb: left-over from the previous version, number of knots in
% modeling background,=1.
% min_corr: minimum threshold of correlation for segementing neurons
% deconv_options
% deconv_flag
% Output:
% ACS_temp is a structure with three fields: A,C,and C's
% standard deviation(STD). This structure is used for merging in later steps in cnmf_e-BatchVer.

% Modified from "greedyROI_endoscope"
% Main dependences are "extract_a", "extract_c" in CNMF-E BatchVer, and "com" for neuron center by Pengcheng Zhou.

% Shijie Gu, [email protected]

%% parameters and preparations

d1 = options.d1; % image height
d2 = options.d2; % image width
gSiz = options.gSiz; % average size of neurons

Acenter = round(com(A, d1, d2)); %nr x 2 matrix, with the center of mass coordinates

Ysignal(isnan(Ysignal)) = 0; % remove nan values
Ysignal = double(Ysignal);
T = size(Ysignal, 2);

deconv_options_0= options.deconv_options;
deconv_flag = options.deconv_flag;

K = size(A,2);
Cin = zeros(K, T); % temporal components
Cin_raw = zeros(K, T); % temporal components
STD = zeros(1,K); % standard deviation

%% start initialization
for k = 1:K
r=Acenter(k,1);
c=Acenter(k,2);

% Use center point data to roughly check whether this is a good starting point
% ind_p=sub2ind([d1 d2], r, c);
% y0 = Ysignal(ind_p, :);
% y0_std = std(diff(y0));
% if max(diff(y0))< y0_std % signal is weak
% Ain(:,k)=A(:,k); % If it is a "poor" ci, no problem, low STD will let not it contribute much to finalA.
% Cin(k,:)=y0; % Since poor ci will get poor A that has bad shapes. Use normal A to fill in the place.
% STD(k)=std(y0);
% continue;
% end

% extract ci
[ci_raw,ind_success_ci] = extract_c(Ysignal,[],A(:,k));
Cin_raw(k,:)=ci_raw;

if ~ind_success_ci % If it is a "poor" ci, no need to subtract it before next neuron.
Cin(k,:)=ci_raw;
STD(k)=std(ci_raw);
continue;
end

if and(ind_success_ci,deconv_flag)
try
% deconv the temporal trace
[ci, ~, ~] = deconvolveCa(ci_raw, deconv_options_0);
% save this initialization
Cin(k, :) = ci;
STD(k)=std(ci);
ci=ci';
catch
Cin(k, :)=ci_raw;
STD(k)=std(ci_raw);
ci=ci_raw;
end
end

% select its neighbours to subtract some data, the box size is
%[2*gSiz+1, 2*gSiz+1]
% if the c is poor
ci_std = std(diff(ci));
if max(diff(ci))< ci_std % signal is weak
continue
end
rsub = max(1, -gSiz+r):min(d1, gSiz+r);
csub = max(1, -gSiz+c):min(d2, gSiz+c);
[cind, rind] = meshgrid(csub, rsub);
ind_nhood = sub2ind([d1, d2], rind(:), cind(:));
HY_box = Ysignal(ind_nhood, :);
Ysignal(ind_nhood, :) = HY_box - A(ind_nhood,k)*ci_raw; % update data
end
ACS_temp=struct('Cin',[],'Cin_raw',[],'STD',[]);
ACS_temp.Cin = Cin;
ACS_temp.Cin_raw=Cin_raw;
ACS_temp.STD = STD;

end
62 changes: 62 additions & 0 deletions BatchVerMO/A2image.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function image=A2image(A,d1,d2,textOrNot,color,PoporNOt,handle)

if nargin<4
textOrNot=false;
end

if nargin<5
color=[];
end

if nargin<6
PoporNOt=false;
end

A=A(:,any(A,1));
k = size(A,2);
sA = sum(A,1);
A = bsxfun(@rdivide, A, sA)*prctile(sA, 5);
C=ones(k,1);

if isempty(color)==false
if or(strcmp(color,'magenta'),strcmp(color,'red'))
color_palet = 1-[1 0 1];
elseif strcmp(color,'green')
color_palet = 1-[0 1 0];
end
nColors = repmat(color_palet,size(A,2),1);
Ir = diag(nColors(:,1));
Ig = diag(nColors(:,2));
Ib = diag(nColors(:,3));

Brainbow = 1-cat(3, A*Ir*C, A*Ig*C, A*Ib*C);
Brainbow = reshape(Brainbow,d1,d2,3);
else
Brainbow = 1-A*C;
Brainbow(Brainbow<0)=0;
Brainbow = reshape(Brainbow,d1,d2);
%image=imshow(Brainbow);
end
image=Brainbow;
if PoporNOt==true
if nargin<7
figure
else
axes(handle)
end
imshow(Brainbow)
end

if textOrNot==true
Atemp=reshape(A,d1,d2,k);
Position=zeros(2,k);
for i=1:k
Atemp_=Atemp(:,:,i);
[row_ind,col_ind] = find(Atemp_>0);
Position(2,i)=mean(row_ind);
Position(1,i)=mean(col_ind);
end
text(Position(1,:),Position(2,:),cellstr(num2str((1:k)'))','Color','black')
F = getframe(gca);
image=F.cdata;
end
27 changes: 27 additions & 0 deletions BatchVerMO/AllTraces.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function [AllC, boundary]=AllTraces(neuron_batch,type)
if nargin<2||isempty(type);
type='rawsignal';
end

AllC=[];
boundary=[];
if strcmp(type,'rawsignal')
for i=1:length(neuron_batch)
AllC=[AllC neuron_batch(i).rawsignal];
boundary=[boundary size(neuron_batch(i).rawsignal,2)];
end
elseif strcmp(type,'signal')
for i=1:length(neuron_batch)
AllC=[AllC neuron_batch(i).signal];
boundary=[boundary size(neuron_batch(i).signal,2)];
end
end
boundary=cumsum(boundary);
end
% %%
% framesize=[];
% framesizeC=[];
% for i=1:length(neuron_batch)
% framesize=[framesize size(neuron_batch(i).signal,2)];
% framesizeC=[framesizeC size(neuron_batch(i).neuron.C,2)];
% end
19 changes: 19 additions & 0 deletions BatchVerMO/AllTracesfromACS.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function [AllC, boundary]=AllTracesfromACS(ACS,rawOrNot)
if nargin<2
rawOrNot=false;
end
AllC=[];
boundary=[];
for i=1:length(ACS)
if rawOrNot
AllC=[AllC ACS(i).Cin_raw];
boundary=[boundary size(ACS(i).Cin_raw,2)];
else
AllC=[AllC ACS(i).Cin];
boundary=[boundary size(ACS(i).Cin,2)];
end
boundary=cumsum(boundary);
end


end
18 changes: 18 additions & 0 deletions BatchVerMO/BackgroundSub.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rr = ceil(neuron.options.gSiz * bg_neuron_ratio);
active_px = []; %(sum(IND, 2)>0); %If some missing neurons are not covered by active_px, use [] to replace IND
[Ybg, Ybg_weights] = neuron.localBG(Y, spatial_ds_factor, rr, active_px, neuron.P.sn, thresh); % estiamte local background.
% subtract the background from the raw data.
Ysignal = Y - Ybg;

%% estimate noise
if ~isfield(neuron.P, 'sn') || isempty(neuron.P.sn)
%% estimate the noise for all pixels
b0 =zeros(size(Ysignal,1), 1);
sn = b0;
parfor m=1:size(neuron.A,1)
[b0(m), sn(m)] = estimate_baseline_noise(Ysignal(m, :));
end
Ysignal = bsxfun(@minus, Ysignal, b0);
neuron.P.sn = sn;
%Ysignal = bsxfun(@minus, Ysignal, sn);
end
14 changes: 14 additions & 0 deletions BatchVerMO/BatchVer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

#SBATCH -n 1
#SBATCH --cpus-per-task=8
#SBATCH --mem=20000
#SBATCH -t 0-2:00
#SBATCH --time-min=0-01:00
#SBATCH -o /net/feevault/data0/shared/EmilyShijieShared/BatchResultTest/job_%A.out
#SBATCH -e /net/feevault/data0/shared/EmilyShijieShared/BatchResultTest/job_%A.err

cd /net/feevault/data0/shared/EmilyShijieShared/BatchResultTest/
module add mit/matlab/2016b
matlab -nodisplay -singleCompThread -r "addpath(genpath('/home/shijiegu/cnmf_e/'));\
BatchVerScript"
13 changes: 13 additions & 0 deletions BatchVerMO/BatchVerSLURM.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

#SBATCH -n 1
#SBATCH --cpus-per-task=8
#SBATCH --mem=150000
#SBATCH -t 0-10:00
#SBATCH --time-min=0-01:00
#SBATCH -o /net/feevault/data0/shared/EmilyShijieShared/BatchResult/6922FirstFewDaysForBatchNewMerging/job_%A.out
#SBATCH -e /net/feevault/data0/shared/EmilyShijieShared/BatchResult/6922FirstFewDaysForBatchNewMerging/job_%A.err
cd /net/feevault/data0/shared/EmilyShijieShared/BatchResult/6922FirstFewDaysForBatchNewMerging/
module add mit/matlab/2016b
matlab -nodisplay -singleCompThread -r "addpath(genpath('/home/shijiegu/cnmf_e/'));\
load(fullfile('/net/feevault/data0/shared/EmilyShijieShared/BatchResult/6922FirstFewDaysForBatchNewMerging/','PartOneOFcnmfeBatchVer.mat')); BatchVerTestVer "
3 changes: 3 additions & 0 deletions BatchVerMO/BatchVerScript.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load(fullfile('/net/feevault/data0/shared/EmilyShijieShared/BatchResult/7030FirstFewDaysForBatch/','LogisticscnmfeBatchVer.mat'))
addpath(genpath(codeDir));
cnmfeBatchVer_ClusterPart
77 changes: 77 additions & 0 deletions BatchVerMO/BatchVerTestVer.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
%% 2 Merge similar neurons
%%% Merge similar neurons based on spatial AND temporal correlation
C_all=cat(2,ACS.Cin);

Amask_temp=cat(2,A0s{1:2})>0;
C_temp=C_all(1:size(Amask_temp,2),:);
[Amask_temp,C_temp,ACS] = mergeAC(Amask_temp,C_temp,ACS,merge_thr);

merge2start=1+size(A0s{1},2)+size(A0s{2},2);
for i=3:length(samplelist_reduced)
Amask_temp=cat(2,Amask_temp,A0s{i})>0;

C_temp=[C_temp;C_all(merge2start:merge2start+size(A0s{i},2)-1,:)];

[Amask_temp,C_temp,ACS] = mergeAC(Amask_temp,C_temp,ACS,merge_thr);
merge2start=merge2start+size(A0s{i},2);
end

save([outputdir 'commonAcnmfeBatchVer.mat'],'-v7.3')
%% 3 Determine uniqueA's
As=cell(1,length(samplelist));
STDs=cell(1,length(samplelist));
parfor i=1:length(samplelist)
As{i}=ACS(i).Ain;
STDs{i}=ACS(i).STD;
end
Afinal=ReducingA(As,STDs);
save([outputdir 'uniqueAcnmfeBatchVer.mat'],'-v7.3')
%% 5 Determine Afinal that will be used to extract C's in each file.

%%% Some processes making Afinal nicer, modified from Pengcheng Zhou's
%%% idea.
for i=1:size(Afinal,2)
ai=Afinal(:,i);
temp = full(ai>quantile(ai, 0.5, 1));
ai(~temp(:)) = 0;
Afinal(:,i)=ai;
end

% Just in case some all zero A's got passed to this stage.
nz_ind=any(Afinal);
Afinal=Afinal(:,nz_ind);
save([outputdir 'AfinalcnmfeBatchVer.mat'],'-v7.3')
%% 6 "massive" procedure: Extract A from each file
neuron_batch(length(filelist)) = struct('ind_del',[],'signal',[],'FileOrigin',[],'neuron',[]);

parfor i= 1:length(filelist)
mode='massive';
nam=fullfile(datadir,filelist(i).name);
[~,neuron_batch(i)]=demo_endoscope2(gSig,gSiz,min_corr,min_pnr,FS,SSub,TSub,bg_neuron_ratio,nam,mode,[],Afinal,neuron_batch(i),convolveType);
neuron_batch(i).FileOrigin=filelist(i); % save origin(filelist)
end
fprintf('Massive extraction done.');
save([outputdir 'MassivecnmfeBatchVer.mat'],'-v7.3')

%neuron(length(filelist)) = struct('signal',[],'filelist',[]);
%%% Partition between those neurons found in each file and those not.
ind_del_final_cat=cat(2,neuron_batch.ind_del);
ind_del_final=any(ind_del_final_cat,2);
parfor i= 1:length(filelist)
neuron_batch(i).neuron.A=[neuron_batch(i).neuron.A(:,~ind_del_final) neuron_batch(i).neuron.A(:,ind_del_final)];
fprintf('A extraction done\n');
neuron_batch(i).neuron.C=[neuron_batch(i).neuron.C(~ind_del_final,:);neuron_batch(i).neuron.C(ind_del_final,:)];
neuron_batch(i).neuron.C_raw=[neuron_batch(i).neuron.C_raw(~ind_del_final,:);neuron_batch(i).neuron.C_raw(ind_del_final,:)];
fprintf('C extraction done\n');
%%% save each data i's signal into neuron(i).signal and
for j=1:size(neuron_batch(i).neuron.A,2)
jA=neuron_batch(i).neuron.A(:,j);
jC=neuron_batch(i).neuron.C(j,:);
neuron_batch(i).signal(j,:)=median(jA(jA>0)*jC);
end
fprintf('neuron_batch %.0f extraction done\n', i);
end
fprintf('First %.0f neurons are successfully deconvolved in each files while those after that are missing in some files\n', sum(~ind_del_final));
fprintf('ALL extractions done.\n');
eval(sprintf('save %sCNMFE_BatchVer.mat %s -v7.3', outputdir, 'neuron_batch'));
fprintf('ALL data saved, check them out!');
16 changes: 16 additions & 0 deletions BatchVerMO/CTraceTestbed.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[AllC,boundary]=AllTraces(neuron_batch);
%Boundary=boundary;

figure;
plot(AllC(1,:))
hold on
plot(boundary'*ones(1,2), [0 max(AllC(1,:),[],2)], 'k:')

PartC{ni}=C;
boundary{ni}=cumsum(bound);


figure;
plot(PartC{14})
hold on
plot(boundary{14}'*ones(1,2), [0 max(PartC{14},[],2)], 'k:')
Loading