3939
4040############################################################
4141# as always we can look view some interesting information about the
42- # metadata and structure of a file just by printing the reader and
42+ # metadata and structure of a file just by printing the reader and
4343# it's header
4444print (reader )
4545print (f"Header information: { reader .header } " )
4949# Now let's make a function that we want to apply to
5050# look at lazy vs eager uses of the API
5151
52+
5253def apply_my_fancy_average (sig_list ):
5354 """basic average along triggers and then channels
5455 here we go back to numpy with magnitude
5556 to be able to use np.stack.
56-
57+
5758 Because neo uses quantities to keep track of units
58- we can always get just the magnitude of an array
59+ we can always get just the magnitude of an array
5960 with `.magnitude`
6061 """
6162 sig_list = [s .magnitude for s in sig_list ]
6263 sigs = np .stack (sig_list , axis = 0 )
6364 return np .mean (np .mean (sigs , axis = 0 ), axis = 1 )
6465
66+
6567#################################################
6668# Let's set our limits for both cases. We will
67- # use quantities to include time dimensions.
69+ # use quantities to include time dimensions.
6870
69- lim_start = - 20 * pq .ms # 20 milliseconds before
70- lim_end = + 20 * pq .ms # 20 milliseconds after
71+ lim_start = - 20 * pq .ms # 20 milliseconds before
72+ lim_end = + 20 * pq .ms # 20 milliseconds after
7173
7274##################################################
7375# We start with eager (where `lazy=False`.) Everything
7476# is loaded into memory. We will read a segment of data.
75- # This includes analog signal data and events data
76- # (final contents of a segment are dependent on the
77+ # This includes analog signal data and events data
78+ # (final contents of a segment are dependent on the
7779# underlying IO being used)
7880
7981
@@ -86,7 +88,7 @@ def apply_my_fancy_average(sig_list):
8688 anasig_chunk = anasig .time_slice (t0 , t1 )
8789 all_sig_chunks .append (anasig_chunk )
8890
89- # After pulling all data into memory and then iterating through triggers
91+ # After pulling all data into memory and then iterating through triggers
9092# we end by doing our average
9193m1 = apply_my_fancy_average (all_sig_chunks )
9294
@@ -111,7 +113,7 @@ def apply_my_fancy_average(sig_list):
111113m2 = apply_my_fancy_average (all_sig_chunks )
112114
113115##########################################################
114- # We see that either way the result is the same, but
116+ # We see that either way the result is the same, but
115117# we do not exhaust our RAM/memory
116118print (f"Eagerly loading data and averaging: { m1 } " )
117119print (f"Lazy loading data and average { m2 } " )
0 commit comments