-
Notifications
You must be signed in to change notification settings - Fork 4
/
classifyPS.m
executable file
·62 lines (50 loc) · 1.93 KB
/
classifyPS.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
51
52
53
54
55
56
57
58
59
60
function PS=classifyPS(varargin)
%classifyPS takes an input pointStats structure from a single volume and
%adds the trackIdx for each of the neurons and the track weights.
% Inputs:
% classifyPS(PS,dataFolder)
% PS-pointStats file for a single volume, this is the output of the
% WormStraightening codes.
% dataFolder - dataFolder (normally BrainScanner) that contains a
% PS_ref.mat file and PointsStats2_info.mat file.
% classifyPS(PS,PS_ref,masterVec);
% PS_ref - the PS_ref file containg the pointstats data for the reference
% volumes. Normally made form the makePointStatsRef.m program.
% masterVec - the centers of each of the identified clusters, normally
% from clusterWormTrackCompiler code, saved in the _info.mat file.
% classifyPS(PS,PS_ref,masterVec,hitCutoff)
% hitCutoff - threshold used for definiing membership to cluster,
%parse inputs
if nargin==2
dataFolder=varargin{2};
PS_ref=load([dataFolder filesep 'pointStatsRef.mat']);
PS_ref=PS_ref.PS_ref;
PSref_info=load([dataFolder filesep 'PointsStats2_info.mat']);
masterVec=PSref_info.masterVec;
if isfield(PSref_info,'hitCutoff')
hitCutoff=PSref_info.hitCutoff;
else
hitCutoff=0.2;
end
elseif nargin>=3
PS_ref=varargin{2};
masterVec=varargin{3};
if nargin==4
hitCutoff=varargin{4};
else
hitCutoff=0.2;
end
end
PS=varargin{1};
%make track_matrix by doing the registration between the points in PS and
%the points in PS_ref
track_matrix=compareWithRef(PS,PS_ref);
% count max number of neurons
n_ref_neurons=cellfun(@(x) size(x,1),{PS_ref.straightPoints});
% do one hot encoding to turn matches into binary matrix
track_matrix_bin=oneHotNeuron(track_matrix,n_ref_neurons);
%classify points based on distance to centers in the masterVec
output=distanceClassify(masterVec,track_matrix_bin,hitCutoff);
%save outputs back into pointStats structure
PS.trackIdx=output{1};
PS.trackWeights=output{2};