code: def switch(self, time=None):
          
          stag_to_int = {'NREM1': 1, 'NREM2': 2, 'NREM3': 3, 'REM': 5, 'Wake': 0}
          hypno = [stag_to_int[x['stage']] for x in self.get_epochs(time=time) \
                   if x['stage'] in stag_to_int.keys()]
          
          return sum(asarray(diff(hypno), dtype=bool))
docs: Obtain switch parameter, ie number of times the stage shifts.