-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKP_2PVR_generate_outliers_mask_v3_singleTrialRes.m
More file actions
executable file
·73 lines (72 loc) · 3.66 KB
/
Copy pathKP_2PVR_generate_outliers_mask_v3_singleTrialRes.m
File metadata and controls
executable file
·73 lines (72 loc) · 3.66 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
function [sMask, sOrg1, sOrg0, sMaskInputStruct] = KP_2PVR_generate_outliers_mask_v3_singleTrialRes(neuHistInputStruct, in_sOrg, dataCat, maskID, threshold, direction, fieldHistInputStruct, inputStruct, postProcess)
if postProcess == "none"
sMaskInputStruct.outpath = sprintf('%strialSuperMasks\\%s\\%s\\', inputStruct.outpath,dataCat,maskID);
elseif postProcess == "SensitiveIDs"
sMaskInputStruct.outpath = sprintf('%strialSuperMasks_projectSensitiveIDs\\%s\\%s\\', inputStruct.outpath,dataCat,maskID);
end
sMaskInputStruct.expID = inputStruct.expID;
sMaskInputStruct.neuHistID = inputStruct.neuHistID;
sMaskInputStruct.fineQuantID = inputStruct.fineQuantID;
sMaskInputStruct.fieldHistID = inputStruct.fieldHistID;
sMaskInputStruct.trialResID = inputStruct.trialResID;
if postProcess == "SensitiveIDs"
sMaskInputStruct.interpretID = inputStruct.interpretID;
end
sMaskInputStruct.fieldProperty = dataCat;
sMaskInputStruct.maskID = maskID;
sMaskInputStruct.maskFun = 'KP_2PVR_generate_outliers_mask_v3_singleTrialRes';
sMaskInputStruct.direction = direction;
sMaskInputStruct.theshold = threshold;
KP_2PVR_save_maskInputStruct(sMaskInputStruct);
transfGroups = fieldnames(neuHistInputStruct.Transformations);
for g = 1:length(transfGroups)
group = transfGroups{g};
fprintf('Processing %s\n', group)
fprintf('Processing %s\n', group)
dataVec = [];
neurons = fieldnames(in_sOrg.(group));
numNeurons = length(neurons);
for n = 1:numNeurons
neuron = neurons{n};
sMask.(group).(neuron) = zeros(size(in_sOrg.(group).(neuron),1), size(in_sOrg.(group).(neuron),2), size(in_sOrg.(group).(neuron),3));
sOrg1.(group).(neuron) = NaN(size(in_sOrg.(group).(neuron),1), size(in_sOrg.(group).(neuron),2), size(in_sOrg.(group).(neuron),3));
sOrg0.(group).(neuron) = in_sOrg.(group).(neuron);
dataVec = [dataVec, transpose(in_sOrg.(group).(neuron)(:))];
if ~(all(all(all(isnan(in_sOrg.(group).(neuron))))))
fprintf('Processing %s\n', neuron)
for t = 1:size(in_sOrg.(group).(neuron),3)
dataMat = in_sOrg.(group).(neuron)(:,:,t);
if ~all(all(isnan(dataMat)))
if direction == "smallerThan"
[row, col] = find(dataMat < threshold);
elseif direction == "smallerOrEqualTo"
[row, col] = find(dataMat <= threshold);
elseif direction == "greaterThan"
[row, col] = find(dataMat > threshold);
end
for found = 1:length(row)
sMask.(group).(neuron)(row(found),col(found),t) = 1;
sOrg1.(group).(neuron)(row(found),col(found),t) = in_sOrg.(group).(neuron)(row(found),col(found),t);
sOrg0.(group).(neuron)(row(found),col(found),t) = NaN;
end
end
end
end
end
if ~all(isnan(dataVec))
fig_filepath = sprintf('%s%s\\',sMaskInputStruct.outpath,group);
mkdir(fig_filepath);
minDataVec = min(dataVec);
maxDataVec = max(dataVec);
edges = minDataVec:fieldHistInputStruct.bin_height:maxDataVec + fieldHistInputStruct.bin_height;
fig = figure;
histogram(dataVec, edges)
xline(threshold,'Color','red','LineStyle','--','LineWidth',1)
title(sprintf('All neurons %s', dataCat))
fig_filename = sprintf('thresh_%s.pdf',string(threshold));
saveas(fig,[fig_filepath,fig_filename])
end
end
filenameMask = 'sMasked';
save([sMaskInputStruct.outpath,filenameMask],'sMask', 'sOrg1', 'sOrg0')
end