Skip to content

Commit

Permalink
more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabi committed Aug 9, 2024
1 parent f017f89 commit e462006
Show file tree
Hide file tree
Showing 5 changed files with 504 additions and 181 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Contributions to PyRASA are welcome! Whether it's raising issues, improving docu

If you are using IRASA please cite the smart people who came up with the algorithm:

Wen, H., & Liu, Z. (2016). Separating fractal and oscillatory components in the power spectrum of neurophysiological signal. Brain topography, 29, 13-26.
Wen, H., & Liu, Z. (2016). Separating fractal and oscillatory components in the power spectrum of neurophysiological signal. Brain topography, 29, 13-26. https://doi.org/10.1007/s10548-015-0448-0

If you are using PyRASA it would be nice, if you could additionally cite us (whenever the paper is finally ready):

Expand Down
135 changes: 107 additions & 28 deletions examples/basic_functionality.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 27,
"metadata": {},
"outputs": [
{
Expand All @@ -645,9 +645,6 @@
}
],
"source": [
"import seaborn as sns\n",
"sns.set_style('ticks')\n",
"sns.set_context('talk')\n",
"f, axes = plt.subplots(ncols=2, figsize=(8, 4))\n",
"axes[0].plot(irasa_out.freqs, irasa_out.periodic[0,:])\n",
"axes[0].set_ylabel('Power (a.u.)')\n",
Expand All @@ -661,51 +658,133 @@
"axes[1].set_xlabel('Frequency (Hz)')\n",
"axes[1].set_title('Original + \\n Aperiodic Spectrum')\n",
"\n",
"f.tight_layout()\n",
"f.savefig('../simulations/example_knee.png')\n"
"f.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"| ch_name | cf | bw | pw |\n",
"|----------:|-----:|--------:|-------:|\n",
"| 0 | 9.5 | 1.44337 | 0.4146 |\n"
]
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>ch_name</th>\n",
" <th>cf</th>\n",
" <th>bw</th>\n",
" <th>pw</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>9.5</td>\n",
" <td>1.443373</td>\n",
" <td>0.4146</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" ch_name cf bw pw\n",
"0 0 9.5 1.443373 0.4146"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# %% get periodic stuff\n",
"peaks = irasa_out.get_peaks()\n",
"md = peaks.to_markdown(index=False)\n",
"print(md)"
"irasa_out.get_peaks()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"| mse | r_squared | BIC | AIC | fit_type | ch_name |\n",
"|------------:|------------:|---------:|---------:|:-----------|----------:|\n",
"| 3.02402e-05 | 0.999894 | -2049.69 | -2062.86 | knee | 0 |\n"
]
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Offset</th>\n",
" <th>Knee</th>\n",
" <th>Exponent_1</th>\n",
" <th>Exponent_2</th>\n",
" <th>fit_type</th>\n",
" <th>Knee Frequency (Hz)</th>\n",
" <th>ch_name</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1.380983</td>\n",
" <td>532.909784</td>\n",
" <td>0.511999</td>\n",
" <td>1.894478</td>\n",
" <td>knee</td>\n",
" <td>8.59554</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Offset Knee Exponent_1 Exponent_2 fit_type Knee Frequency (Hz) \\\n",
"0 1.380983 532.909784 0.511999 1.894478 knee 8.59554 \n",
"\n",
" ch_name \n",
"0 0 "
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ap = irasa_out.fit_aperiodic_model(fit_func='knee').gof\n",
"md = ap.to_markdown(index=False)\n",
"print(md)"
"irasa_out.fit_aperiodic_model(fit_func='knee').aperiodic_params"
]
},
{
Expand Down
Loading

0 comments on commit e462006

Please sign in to comment.