-
Notifications
You must be signed in to change notification settings - Fork 0
/
boutongui.txt
110 lines (91 loc) · 5.5 KB
/
boutongui.txt
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
todo:
make sure each function is properly outputting all required data
axon/bouton entry should be based on currAxon/currBouton -- increment at end of thing, but overwrite if you return
clear axon function
clear bouton function
all positioning things lag behind by one, probably due to the way keypressfcn triggers and events.Key works
make sure it is logging the right position during this time (what it logs is what you see)
%enter and log mouse ID and file name
%enter and log stacks and stack names
%convert stacks into usable files
%create flattened z projection of stack
%randomly order stack, make sure to save to appropriate output
%create figure with starting stack
%mousewheel function navigates between stacks at different timepoints,
%place a flattened stack in the middle
%button function to navigate between z planes within single timepoint,
%perform all analysis from best plane for given local axon or bouton
%button function to toggle all displays
%zoon, brightness, home location, etc, should all be saved per timepoint
%stack
%for each timepoint
%for each axon
%create mode for single axon registry -- requires click functions for add
%point, remove point, save, delete. Saved data is axon points and total
%length. convert backbone to pixels and find/save average
%brightness and backbone intensity profile
%create mode for single exclude axon registry -- same requirements as above
%key function to toggle between active axons
%for each bouton
%mode to label alpha, beta, absent certain, absent uncertain (exclude)
%create mode for single bouton tracing -- requires click function
%to add point, remove point, save, and delete. Save will assume
%last point and first point connect to form complete polygon.
%convert polygon into mask. Mask will be used to calculate average
%brightness, as well as size using lines along primary and
%secondary axes of bouton. assign numeric value. Saved data is
%border points, mask, mask area, bouton mas brightness, bouton
%average brightness
%create mode for bouton primary axis tracing -- requires click
%function to add point, remove point, save, and delete. trace
%along backbone, through bouton, and along backbone again, without including other boutons.
%save original points, convert to pixels, save brightness profile
%of axon backbone and bouton using bouton boundary mask. Save
%average/peak backbone brighntess and average/peak bouton
%brightness
%create mode for bouton secondary axis tracing -- requires click
%function to add point, remove point, save, and delete. trace
%perpendicular to bouton to measure representative width. avoid
%including other boutons / axons, instead try to include blank
%space (doesn't have to be perpendicular until crossing bouton)save
%points, convert to pixels, save brightness profile as well as average/peak
%background and average/peak bouton. convert pixels overlapping bouton
%to length and save
%button function to toggle between active boutons
%save image of axon and exclusion with numbers for boutons, coded
%points for bouton formation and elimination timepoints, overlay on
%first timepoint
if length(xi)>3
boutonX=mean(xi);
boutonY=mean(yi);
imageMasked=figData.stackData{figData.cs}(:,:,figData.currentZ(currFig)); %copy the image
imageMasked(mask==0)=0; %in the copy, everything outisde the ROI converted to NaN;
%Make a rectangular matrix including all pixels inside the drawn ROI
imageROI=imageMasked(round(min(yi)):round(max(yi)),round(min(xi)):round(max(xi)));
figData.boutonMorphRaw{figData.morphEntry,currFig}=imageROI;
figData.boutonMorphX{figData.morphEntry,currFig}=xi;
figData.boutonMorphY{figData.morphEntry,currFig}=yi;
figData.boutonMorphCoordinates(end+1,1:3)=[mean(xi) mean(yi) figData.currentZ(currFig)];
end
figData.centers{i} = [256 1024];
figData.range{i} = [300 1024];
xlim([figData.centers{figData.cs}(figData.cs,1)-(figData.range{figData.cs}(1)-1) figData.centers{figData.cs}(figData.cs,1)+figData.range{figData.cs}(1)])
ylim([figData.centers{figData.cs}(figData.cs,2)-(figData.range{figData.cs}(2)-1) figData.centers{figData.cs}(figData.cs,2)+figData.range{figData.cs}(2)])
%ENTER HOME CALIBRATION 'H'
if strcmp(events.Key,'h')
set(hfig,'Name','Click to Set Home','NumberTitle','off')
set(hfig,'WindowButtonDownFcn',{@calibrationClick,figData.stackData{cs}});
end
function calibrationClick(hfig,events,stack)
%Call back for calibrating the home point for each stack
figData = guidata(hfig);
currPoint = get(gca,'CurrentPoint');
currPointX=currPoint(1,1);
currPointY=currPoint(1,2);
%Normalize to entire figure
figData.home(figData.cs,:)=[currPointX currPointY figData.currentZ(figData.cs)];
figData.centers(figData.cs,:)=figData.home(figData.cs,1:2);
figData.currentZ(figData.cs)=figData.home(figData.cs,3);
fullReplot(hfig)
guidata(gcbf,figData)
end