-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] - Plotting updates #343
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c8c8758
add prepare multi plot func
TomDonoghue b1190f5
use prep multi plot for spectral
TomDonoghue 417f4dd
use prep multi plot in ts plots
TomDonoghue 8965c75
tweak prep multi plot name
TomDonoghue 63048b6
add plot_autocorr func
TomDonoghue 905b1df
add plot_autocorr to API list
TomDonoghue 6fa2811
use new plot autocorr func in tutorial
TomDonoghue 4976524
tweaks & lints
TomDonoghue da60bcf
add plot_spectra_3d
TomDonoghue a6f3234
add 3d plot to API list
TomDonoghue 17ab4e8
fix list input to _check_times
TomDonoghue 778bd30
Merge branch 'main' into mlplts
TomDonoghue 5fc3944
Merge branch 'main' into mlplts
TomDonoghue 4d3f956
review updates / fixes
TomDonoghue f688202
add check_ax_3d
TomDonoghue af23327
update plot spectra 3d
TomDonoghue fee9757
tweak 3d naming
TomDonoghue 5470350
fix doctest
TomDonoghue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Plotting functions for neurodsp.aperiodic.""" | ||
|
||
from neurodsp.plts.style import style_plot | ||
from neurodsp.plts.utils import check_ax, savefig, prepare_multi_plot | ||
|
||
#################################################################################################### | ||
#################################################################################################### | ||
|
||
@savefig | ||
@style_plot | ||
def plot_autocorr(timepoints, autocorrs, labels=None, colors=None, ax=None, **kwargs): | ||
"""Plot autocorrelation results. | ||
|
||
Parameters | ||
---------- | ||
timepoints : 1d array | ||
Time points, in samples, at which autocorrelations are computed. | ||
autocorrs : array | ||
Autocorrelation values, across time lags. | ||
labels : str or list of str, optional | ||
Labels for each time series. | ||
colors : str or list of str | ||
Colors to use to plot lines. | ||
ax : matplotlib.Axes, optional | ||
Figure axes upon which to plot. | ||
**kwargs | ||
Keyword arguments for customizing the plot. | ||
""" | ||
|
||
ax = check_ax(ax, figsize=kwargs.pop('figsize', (6, 5))) | ||
|
||
for time, ac, label, color in zip(*prepare_multi_plot(timepoints, autocorrs, labels, colors)): | ||
ax.plot(time, ac, label=label, color=color) | ||
|
||
ax.set(xlabel='Lag (Samples)', ylabel='Autocorrelation') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Tests for neurodsp.plts.aperiodic.""" | ||
|
||
from neurodsp.aperiodic.autocorr import compute_autocorr | ||
|
||
from neurodsp.tests.settings import TEST_PLOTS_PATH, FS | ||
from neurodsp.tests.tutils import plot_test | ||
|
||
from neurodsp.plts.aperiodic import * | ||
|
||
################################################################################################### | ||
################################################################################################### | ||
|
||
def tests_plot_autocorr(tsig, tsig_comb): | ||
|
||
times1, acs1 = compute_autocorr(tsig, max_lag=150) | ||
times2, acs2 = compute_autocorr(tsig_comb, max_lag=150) | ||
|
||
plot_autocorr(times1, acs1, | ||
save_fig=True, file_path=TEST_PLOTS_PATH, | ||
file_name='test_plot_autocorr-1.png') | ||
|
||
plot_autocorr([times1, times2], [acs1, acs2], | ||
labels=['first', 'second'], colors=['k', 'r'], | ||
save_fig=True, file_path=TEST_PLOTS_PATH, | ||
file_name='test_plot_autocorr-2.png') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only thought here is whether to include it in aperiodic.py or somewhere else, since acf isn't restricted to aperiodic signals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh.... agreed. I wasn't sure where to put it, but since we already have
neurodsp/aperiodic/autocorr
as the home of the function to compute autocorrelation, this seemed like the most consistent spot for the plot function. I don't know what a better name / place for these things is - so unless we want to re-org, move both I think this works best for now?