Advertisement
Guest User

Untitled

a guest
May 20th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import numpy as np
  2. import cPickle as pickle
  3. import joblib
  4. from moseq.train import ARHMM, train_model
  5. from moseq.train.util import whiten_all
  6. from collections import OrderedDict
  7. from syllables import analysis
  8.  
  9. # Load the data
  10. with open("/data/efs/drugs/alldoses/dataset.pkl","r") as f:
  11. dataset = pickle.load(f)
  12. mouse_names = dataset.keys()
  13.  
  14. # Load the labels
  15. with open('/data/efs/drugs/alldoses/syllablelabels-kappa=18036000-niter=1000-nstates=160.pkl','r') as f:
  16. syllable_labels = pickle.load(f)
  17. syllable_labels = analysis.relabel_by_usage(syllable_labels)
  18.  
  19. # Load the labels into our dataset array
  20. split_points = np.cumsum([len(v['data']) for v in dataset.values()])[:-1]
  21. split_syllable_labels = np.array_split(syllable_labels,split_points)
  22. for mouse_name,_syllable_labels in zip(mouse_names,split_syllable_labels):
  23. dataset[mouse_name]['syllable_labels'] = _syllable_labels
  24.  
  25.  
  26. # Make a dictionary data structure that the ARHMM expects
  27. data_dict = OrderedDict((k,v['data']) for k,v in dataset.items())
  28.  
  29. # Whiten the data
  30. data_dict = whiten_all(data_dict)
  31.  
  32. # Build AR matrices from labels and data.
  33. # either scott linderman or matt johnson have code for this
  34. # I went diving, and didn't find it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement