Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions specparam/bands/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from collections import OrderedDict

from specparam.reports.strings import gen_bands_str

###################################################################################################
###################################################################################################

Expand Down Expand Up @@ -126,6 +128,18 @@ def add_band(self, label, band_definition):
self.bands[label] = tuple(band_definition)


def print(self, concise=False):
"""Print out the current band definitions.

Parameters
----------
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
"""

print(gen_bands_str(self, concise))


def remove_band(self, label):
"""Remove a previously defined oscillation band.

Expand Down
31 changes: 16 additions & 15 deletions specparam/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,32 @@ def get_data(self, component='full', space='log'):
return output


def print_settings(self, description=False, concise=False):
"""Print out the current settings.
def print(self, info, description=False, concise=False):
"""Print out requested information.

Parameters
----------
info : {'algorithm', 'settings', 'data', 'modes', 'issue'}
Which information to print:
'algorithm' or 'settings: print information on the fit algorithm & settings
'data' : print a description of the data
'modes' : print a description of the fit modes
'issue' : print instructions on how to report bugs and/or problematic fits
description : bool, optional, default: False
Whether to print out a description with current settings.
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
Whether to print the report in a concise mode.
"""

self.algorithm.print()
# Special case - treat 'settings' as request to print algorithm info
if info == 'settings':
info = 'algorithm'

if info in ['algorithm', 'data', 'modes']:
getattr(self, info).print(concise=concise)

@staticmethod
def print_report_issue(concise=False):
"""Prints instructions on how to report bugs and/or problematic fits.

Parameters
----------
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
"""

print(gen_issue_str(concise))
if info == 'issue':
print(gen_issue_str(concise))


def _add_from_dict(self, data):
Expand Down
11 changes: 8 additions & 3 deletions specparam/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,24 @@ def report(self, freqs=None, spectrograms=None, freq_range=None,

self.fit(freqs, spectrograms, freq_range, bands, n_jobs, progress)
self.plot()
self.print_results()
self.print('results')


def print_results(self, concise=False):
def print(self, info='results', concise=False):
"""Print out SpectralTimeEventModel results.

Parameters
----------
info : {'results', ...}
XX
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
"""

print(gen_event_results_str(self, concise))
if info == 'results':
print(gen_event_results_str(self, concise=concise))
else:
super().print(info, concise=concise)


@copy_doc_func_to_method(plot_event_model)
Expand Down
13 changes: 9 additions & 4 deletions specparam/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def report(self, freqs=None, power_spectra=None, freq_range=None, n_jobs=1,

self.fit(freqs, power_spectra, freq_range, n_jobs=n_jobs, progress=progress)
self.plot(**plot_kwargs)
self.print_results(False)
self.print('results')


@copy_doc_func_to_method(plot_group_model)
Expand Down Expand Up @@ -331,16 +331,21 @@ def save_report(self, file_name, file_path=None, add_settings=True):
save_group_report(self, file_name, file_path, add_settings)


def print_results(self, concise=False):
"""Print out the group results.
def print(self, info='results', concise=False):
"""Print out requested information.

Parameters
----------
info : {'results', ...}
xx
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
"""

print(gen_group_results_str(self, concise))
if info == 'results':
print(gen_group_results_str(self, concise=concise))
else:
super().print(info, concise=concise)


def save_model_report(self, index, file_name, file_path=None,
Expand Down
13 changes: 9 additions & 4 deletions specparam/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,24 @@ def report(self, freqs=None, power_spectrum=None, freq_range=None,
plot_full_range else plot_kwargs.pop('plot_power_spectrum', None),
freq_range=plot_kwargs.pop('plot_freq_range', None),
**plot_kwargs)
self.print_results(concise=False)
self.print('results')


def print_results(self, concise=False):
"""Print out model fitting results.
def print(self, info='results', concise=False):
"""Print out requested information.

Parameters
----------
info : {'results', ...}
xx
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
"""

print(gen_model_results_str(self, concise))
if info == 'results':
print(gen_model_results_str(self, concise))
else:
super().print(info, concise=concise)


@copy_doc_func_to_method(plot_model)
Expand Down
25 changes: 16 additions & 9 deletions specparam/models/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def report(self, freqs=None, spectrogram=None, freq_range=None,
bands : Bands or dict or int, optional
How to organize peaks into bands.
If Bands or dict, uses band definitions. If int, extracts the first 'n' peaks.
TODOXX:results_format :
xx
n_jobs : int, optional, default: 1
Number of jobs to run in parallel.
1 is no parallelization. -1 uses all available cores.
Expand All @@ -132,24 +134,29 @@ def report(self, freqs=None, spectrogram=None, freq_range=None,

self.fit(freqs, spectrogram, freq_range, bands, n_jobs=n_jobs, progress=progress)
self.plot(report_type)
self.print_results(report_type)
self.print('results', report_type)


def print_results(self, print_type='time', concise=False):
"""Print out SpectralTimeModel results.
def print(self, info='results', report_type='time', concise=False):
"""Print out requested information.

Parameters
----------
print_type : {'time', 'group'}
Which format to print results out in.
info : {'results', ...}
xxx
report_type : {'time', 'group'}
Which report type to print results in. Only used if 'info' is 'results'.
concise : bool, optional, default: False
Whether to print the report in a concise mode, or not.
"""

if print_type == 'time':
print(gen_time_results_str(self, concise))
if print_type == 'group':
super().print_results(concise)
if info == 'results':
if report_type == 'time':
print(gen_time_results_str(self, concise=concise))
if report_type == 'group':
super().print('results', concise=concise)
else:
super().print(info, concise=concise)


@copy_doc_func_to_method(plot_time_model)
Expand Down
Loading