Closed mjin1812 closed 6 months ago
Hi Michelle, did you happen to not run the notebooks linearly? For now, the fix could be running kpms.label_syllables(project_dir, model_name, moseq_df)
before you run the visualize bigram.
Dear Sherry,
No I didn't try that! I didn't realize that kpms.label_syllables()
needed to be run prior. Based on the documentation, I thought that was an optional step.
After trying that, I have now run into a different error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[36], line 1
----> 1 kpms.plot_syll_stats_with_sem(
2 stats_df, project_dir, model_name,
3 plot_sig=True, # whether to mark statistical significance with a star
4 thresh=0.05, # significance threshold
5 stat='frequency', # statistic to be plotted (e.g. 'duration' or 'velocity_px_s_mean')
6 order='stat', # order syllables by overall frequency ("stat") or degree of difference ("diff")
7 ctrl_group='sundown_ctrl_male_24', # name of the control group for statistical testing
8 exp_group='sundown_AD_male_24', # name of the experimental group for statistical testing
9 figsize=(8, 4), # figure size
10 groups=['sundown_ctrl_male_24','sundown_AD_male_24'], # groups to be plotted
11 );
File ~\.conda\envs\keypoint_moseq\lib\site-packages\keypoint_moseq\analysis.py:1210, in plot_syll_stats_with_sem(stats_df, project_dir, model_name, save_dir, plot_sig, thresh, stat, order, groups, ctrl_group, exp_group, colors, join, figsize)
1207 plt.scatter(markings, [-0.005] * len(markings), color="r", marker="*")
1209 # manually define a new patch
-> 1210 patch = Line2D(
1211 [],
1212 [],
1213 color="red",
1214 marker="*",
1215 linestyles="None",
1216 markersize=9,
1217 label="Significant Syllable",
1218 )
1219 handles.append(patch)
1221 # add legend and axis labels
File ~\.conda\envs\keypoint_moseq\lib\site-packages\matplotlib\lines.py:407, in Line2D.__init__(self, xdata, ydata, linewidth, linestyle, color, gapcolor, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)
403 self.set_markeredgewidth(markeredgewidth)
405 # update kwargs before updating data to give the caller a
406 # chance to init axes (and hence unit support)
--> 407 self._internal_update(kwargs)
408 self.pickradius = pickradius
409 self.ind_offset = 0
File ~\.conda\envs\keypoint_moseq\lib\site-packages\matplotlib\artist.py:1219, in Artist._internal_update(self, kwargs)
1212 def _internal_update(self, kwargs):
1213 """
1214 Update artist properties without prenormalizing them, but generating
1215 errors as if calling `set`.
1216
1217 The lack of prenormalization is to maintain backcompatibility.
1218 """
-> 1219 return self._update_props(
1220 kwargs, "{cls.__name__}.set() got an unexpected keyword argument "
1221 "{prop_name!r}")
File ~\.conda\envs\keypoint_moseq\lib\site-packages\matplotlib\artist.py:1193, in Artist._update_props(self, props, errfmt)
1191 func = getattr(self, f"set_{k}", None)
1192 if not callable(func):
-> 1193 raise AttributeError(
1194 errfmt.format(cls=type(self), prop_name=k))
1195 ret.append(func(v))
1196 if ret:
AttributeError: Line2D.set() got an unexpected keyword argument 'linestyles'
To give more context, this is when I run
kpms.plot_syll_stats_with_sem(
stats_df, project_dir, model_name,
plot_sig=True, # whether to mark statistical significance with a star
thresh=0.05, # significance threshold
stat='frequency', # statistic to be plotted (e.g. 'duration' or 'velocity_px_s_mean')
order='stat', # order syllables by overall frequency ("stat") or degree of difference ("diff")
ctrl_group='sundown_ctrl_male_24', # name of the control group for statistical testing
exp_group='sundown_AD_male_24', # name of the experimental group for statistical testing
figsize=(8, 4), # figure size
groups=['sundown_ctrl_male_24','sundown_AD_male_24'], # groups to be plotted
);
Not when I run the original transition matrix plotting function. The transition matrices plotting function is now working great! Sorry I should have opened a different error thread for this.
Did you accidentally update seaborn or Matplotlib? If yes, you can downgrade the seaborn version to 0.13.0 for now to fix this error.
Hi Sherry,
Below are my version outputs for matplotlib and seaborn.
matplotlib.__version__
'3.8.2'
seaborn.__version__
'0.13.0'
Hi Michelle,
Can you try installing this version the code and let me know if the error persists?
pip install -U git+https://github.com/dattalab/keypoint-moseq@linestyles_hotfix
Dear Caleb,
Thanks for the response. After installing your hotfix, the issue has been fixed!
Michelle
Hi Caleb,
I'm following the statistical analysis functions documented on the KPMS tutorial. However, when I try to plot a transition matrix of my data, I'm getting an UnboundLocalError in the analysis.py file.
Error Message
Best, Michelle