Closed wingillis closed 6 years ago
The only thing I do custom is load in the index file in my own notebook, then I run the function as is
can you post the index loading code? You need to use the second output returned from the function.
(I didn't make this clear at all)
with open(index_path, 'r') as f:
index = yaml.load(f, Loader=yaml.Loader)
Try the parse_index
function per the notebook linked above.
OK - I didn't know that existed, my bad
Not your fault. Wasn't super clear. I'll try to add some safeguards so others don't get tripped up as well (maybe a warning if we detect that someone loaded the yaml directly).
thanks - unfortunately now I'm getting a new error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-27-f3aef73b56c2> in <module>
----> 1 dists = get_behavioral_distance(sorted_index, mdl_path, distances=['pca[dtw]'], dist_options=dict(pca={'normalize': 'mean'}))
~/code/moseq2/moseq2-viz/moseq2_viz/model/dist.py in get_behavioral_distance(index, model_file, whiten, distances, max_syllable, resample_idx, dist_options, sort_labels_by_usage, count)
101 pc_slices = []
102 for syllable in tqdm.tqdm(range(max_syllable)):
--> 103 pc_slice = retrieve_pcs_from_slices(slice_fun(syllable),
104 pca_scores,
105 **use_options)
~/code/moseq2/moseq2-viz/moseq2_viz/model/util.py in get_syllable_slices(syllable, labels, label_uuids, index, trim_nans)
129 score_idx = h5_to_dict(f, 'scores_idx')
130
--> 131 sorted_h5s = [h5s[h5_uuids.index(uuid)] for uuid in label_uuids]
132 syllable_slices = []
133
~/code/moseq2/moseq2-viz/moseq2_viz/model/util.py in <listcomp>(.0)
129 score_idx = h5_to_dict(f, 'scores_idx')
130
--> 131 sorted_h5s = [h5s[h5_uuids.index(uuid)] for uuid in label_uuids]
132 syllable_slices = []
133
ValueError: '822c577d-974d-4176-90eb-618328867e15' is not in list
I just checked that my model and the pca score file share the same keys exactly, so this must be a bug, or some issue in how moseq2-viz
is finding where the scores file lives
ah okay. This one's an easier fix hopefully. Use the following now (I'll add code to automatically do this soon).
Try this
tmp = parse_model_results(model_file)
sorted_index['files'] = {k:v for k,v in sorted_index['files'].items() if k in tmp['train_list']}
It turns out that this key doesn't exist in my moseq2-index
file
Try the latest commit.
hm something's not quite right, I received like a billion of this: /home/wg41/code/moseq2/moseq2-viz/moseq2_viz/model/util.py:144: UserWarning: Index length 80963 and label array length 55146 in /n/groups/datta/win/1pimaging_dls_moseq2/_vae_data/2017-12-03_t11:33:03_a2a-cre-cre-dep_c15_results_00.h5
hmm this might also be related to another issue - I need to select the last iteration of the resampled data. This might be the cause of the issue. One thing that leads me to that conclusion is that each warning that is generated has the same label array length, but different index lengths
Considering this resolved.
When I try to run
get_behavioral_distance
I run into this error