Skip to content

Commit 2950298

Browse files
committed
Add latency to the "all data table" - also some fix on how latency is
calculated on single flies. This closes #11
1 parent 740f184 commit 2950298

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

panels/2_alldata.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ def __init__(self, parent):
1717

1818
PanelProportion = [2,6]
1919

20-
sfLabels = ['Genotype', 'Day', 'Mon', 'Ch', 'alive', 'totSleep', 'rDS', 'rNS', 'AI', 'rD aLSE', 'rD aNSE', 'rN aLSE', 'rN aNSE']
21-
sfdataTypes = [gridlib.GRID_VALUE_STRING] * 4 + [gridlib.GRID_VALUE_NUMBER] *1 + [gridlib.GRID_VALUE_FLOAT + ':6,2'] * 8
20+
sfLabels = ['Genotype', 'Day', 'Mon', 'Ch', 'alive', 'totSleep', 'rDS', 'rNS', 'AI', 'rD aLSE', 'rD aNSE', 'rN aLSE', 'rN aNSE', 'latency']
21+
sfdataTypes = [gridlib.GRID_VALUE_STRING] * 4 + [gridlib.GRID_VALUE_NUMBER] *1 + [gridlib.GRID_VALUE_FLOAT + ':6,2'] * 10
2222

23-
AVGLabels = ['Genotype', 'Day', 'Mon', 'n(tot)','n(a)' , 'DaySleep', 'stdDV' ,'rDS', 'stdDV' ,'rNS', 'stdDV' , 'AI', 'stdDV']
24-
AVGdataTypes = [gridlib.GRID_VALUE_STRING] * 3 + [gridlib.GRID_VALUE_NUMBER] *2 + [gridlib.GRID_VALUE_FLOAT + ':6,2'] * 8
23+
AVGLabels = ['Genotype', 'Day', 'Mon', 'n(tot)','n(a)' , 'DaySleep', 'stdDV' ,'rDS', 'stdDV' ,'rNS', 'stdDV' , 'AI', 'stdDV', 'latency', 'stdDV']
24+
AVGdataTypes = [gridlib.GRID_VALUE_STRING] * 3 + [gridlib.GRID_VALUE_NUMBER] *2 + [gridlib.GRID_VALUE_FLOAT + ':6,2'] * 10
2525

2626
GridGrid.__init__(self, parent, PanelProportion, [AVGLabels, sfLabels], [AVGdataTypes, sfdataTypes])
2727
self.name = 'All Data'
@@ -75,6 +75,7 @@ def Refresh(self):
7575
len_sleep_episodes_night = all_sleep_episodes (s5_t[dc,fc], 721, 1440)
7676
num_sleep_episodes_day = number_sleep_episodes (s5_t[dc,fc], 0, 720)
7777
num_sleep_episodes_night = number_sleep_episodes (s5_t[dc,fc], 721, 1440)
78+
latency = sleep_latency(s5_t[dc,fc], lightsoff=720)
7879

7980
single_fly_data.append([gen_t, day_sl, mon_sl, ch_sl, alive,
8081
s5_t[dc,fc].sum(),
@@ -84,7 +85,8 @@ def Refresh(self):
8485
average( len_sleep_episodes_day ),
8586
average( num_sleep_episodes_day ),
8687
average( len_sleep_episodes_night ),
87-
average( num_sleep_episodes_night )
88+
average( num_sleep_episodes_night ),
89+
latency
8890
])
8991

9092
#Here we add data to the pool in case we are dealing with multiple selections
@@ -105,14 +107,16 @@ def Refresh(self):
105107
dist_day_sleep_by_fly = average (SleepAmountByFly (s5, t0=0, t1=720), axis=0)
106108
dist_night_sleep_by_fly = average (SleepAmountByFly (s5, t0=720, t1=1440), axis=0)
107109
dist_AI_by_fly = average (ActivityIndexByFly(ax, s5), axis=0)
110+
latency = sleep_latency(s5, 720)
108111

109112
AVGdata = ( [list2str(genotype_set), list2str(day_set), list2str(mon_set),
110113
num_flies, num_alive,
111114
average(dist_tot_sleep_by_fly), std(dist_tot_sleep_by_fly),
112115
average(dist_day_sleep_by_fly), std(dist_day_sleep_by_fly),
113116
average(dist_night_sleep_by_fly), std(dist_night_sleep_by_fly),
114117
average(dist_AI_by_fly), std(dist_AI_by_fly),
115-
0,0,0,0,0,0
118+
average(latency),std(latency),
119+
0,0,0,0
116120
] )
117121

118122
#this places the data in the table

panels/7_sleepepisodes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def Refresh(self):
8282
len_sleep_episodes_night = all_sleep_episodes (s5, 721, 1440)
8383
num_sleep_episodes_day = number_sleep_episodes (s5, 0, 720)
8484
num_sleep_episodes_night = number_sleep_episodes (s5, 721, 1440)
85-
latency = sleep_latency(s5, 720)
85+
latency = sleep_latency(s5, lightsoff=720)
8686

8787
longest_sleep_episode = max( len_sleep_episodes_night )
8888
frag_factor = 1

pysolo_sleep_fun.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ def sleep_latency(s5, lightsoff=720):
149149
"""
150150
returns sleep latency in minutes, that is time between lights off and first recorded sleep episode of at least 5 minutes
151151
"""
152-
grid = np.indices(s5.shape)[2] # compile a grid containing the indices of the array
152+
grid = np.indices(s5.shape)[-1] # compile a grid containing the indices of the array
153153
k = grid * s5 # keep only the indices where s5 is 1
154154

155-
sl = np.argmax(k > lightsoff, axis=2) - lightsoff
155+
sl = np.argmax(k > lightsoff, axis=-1) - lightsoff
156156
return np.ma.masked_less(sl, 0)
157157

158158

0 commit comments

Comments
 (0)