88import numpy as np
99
1010from specparam .models .base import BaseModel
11- from specparam .objs .data import BaseData
12- from specparam .objs .results import BaseResults
11+ from specparam .objs .data import Data
12+ from specparam .objs .results import Results
1313from specparam .algorithms .spectral_fit import SpectralFitAlgorithm , SPECTRAL_FIT_SETTINGS
1414from specparam .reports .save import save_model_report
1515from specparam .reports .strings import gen_model_results_str
@@ -47,49 +47,25 @@ class SpectralModel(BaseModel):
4747
4848 Attributes
4949 ----------
50- freqs : 1d array
51- Frequency values for the power spectrum.
52- power_spectrum : 1d array
53- Power values, stored internally in log10 scale.
54- freq_range : list of [float, float]
55- Frequency range of the power spectrum, as [lowest_freq, highest_freq].
56- freq_res : float
57- Frequency resolution of the power spectrum.
58- modeled_spectrum_ : 1d array
59- The full model fit of the power spectrum, in log10 scale.
60- aperiodic_params_ : 1d array
61- Fitted parameter values that define the aperiodic fit. As [Offset, (Knee), Exponent].
62- The knee parameter is only included if aperiodic component is fit with a knee.
63- peak_params_ : 2d array
64- Fitted parameter values for the peaks. Each row is a peak, as [CF, PW, BW].
65- gaussian_params_ : 2d array
66- Fitted parameter values that define the gaussian fit(s).
67- Each row is a gaussian, as [mean, height, standard deviation].
68- r_squared_ : float
69- R-squared of the fit between the input power spectrum and the full model fit.
70- error_ : float
71- Error of the full model fit.
72- n_peaks_ : int
73- The number of peaks fit in the model.
74- has_data : bool
75- Whether data is loaded to the object.
76- has_model : bool
77- Whether model results are available in the object.
78- _debug : bool
79- Whether the object is set in debug mode.
80- If in debug mode, an error is raised if model fitting is unsuccessful.
81- This should be controlled by using the `set_debug` method.
50+ algorithm : Algorithm
51+ Algorithm object with model fitting settings and procedures.
52+ modes : Modes
53+ Modes object with fit mode definitions.
54+ data : Data
55+ Data object with spectral data and metadata.
56+ results : Results
57+ Results object with model fit results and metrics.
8258
8359 Notes
8460 -----
85- - Commonly used abbreviations used in this module include:
86- CF: center frequency, PW: power, BW: Bandwidth, AP: aperiodic
8761 - Input power spectra must be provided in linear scale.
8862 Internally they are stored in log10 scale, as this is what the model operates upon.
8963 - Input power spectra should be smooth, as overly noisy power spectra may lead to bad fits.
9064 For example, raw FFT inputs are not appropriate. Where possible and appropriate, use
9165 longer time segments for power spectrum calculation to get smoother power spectra,
9266 as this will give better model fits.
67+ - Commonly used abbreviations used in this module include:
68+ CF: center frequency, PW: power, BW: Bandwidth, AP: aperiodic
9369 - The gaussian params are those that define the gaussian of the fit, where as the peak
9470 params are a modified version, in which the CF of the peak is the mean of the gaussian,
9571 the PW of the peak is the height of the gaussian over and above the aperiodic component,
@@ -106,9 +82,9 @@ def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_h
10682 periodic_mode = periodic_mode ,
10783 verbose = verbose )
10884
109- self .data = BaseData ()
85+ self .data = Data ()
11086
111- self .results = BaseResults (modes = self .modes , metrics = metrics , bands = bands )
87+ self .results = Results (modes = self .modes , metrics = metrics , bands = bands )
11288
11389 self .algorithm = SpectralFitAlgorithm (
11490 peak_width_limits = peak_width_limits , max_n_peaks = max_n_peaks ,
@@ -117,8 +93,8 @@ def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_h
11793 debug = debug , ** model_kwargs )
11894
11995
120- @replace_docstring_sections ([docs_get_section (BaseData .add_data .__doc__ , 'Parameters' ),
121- docs_get_section (BaseData .add_data .__doc__ , 'Notes' )])
96+ @replace_docstring_sections ([docs_get_section (Data .add_data .__doc__ , 'Parameters' ),
97+ docs_get_section (Data .add_data .__doc__ , 'Notes' )])
12298 def add_data (self , freqs , power_spectrum , freq_range = None , clear_results = True ):
12399 """Add data (frequencies, and power spectrum values) to the current object.
124100
@@ -311,7 +287,7 @@ def load(self, file_name, file_path=None, regenerate=True):
311287 self .results ._regenerate_model (self .data .freqs )
312288
313289
314- @copy_doc_func_to_method (BaseResults .get_params )
290+ @copy_doc_func_to_method (Results .get_params )
315291 def get_params (self , name , field = None ):
316292
317293 return self .results .get_params (name , field )
0 commit comments