Skip to content

Commit

Permalink
sty: ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
celprov committed May 17, 2024
1 parent 9bf54fb commit 56d1e84
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions docs/notebooks/Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"source": [
"# Silence warnings\n",
"import warnings\n",
"warnings.simplefilter(action='ignore', category=UserWarning)\n",
"\n",
"warnings.simplefilter(action=\"ignore\", category=UserWarning)\n",
"\n",
"# Load data\n",
"import glob\n",
Expand All @@ -40,7 +41,7 @@
"\n",
"# Load functional connectivity matrices\n",
"fc_matrices = []\n",
"connectivity_files = glob.glob(op.join(output, '**', '*connectivity.tsv'), recursive=True)\n",
"connectivity_files = glob.glob(op.join(output, \"**\", \"*connectivity.tsv\"), recursive=True)\n",
"for idx, connectivity_file in enumerate(connectivity_files):\n",
" fc_matrix = np.loadtxt(connectivity_file, delimiter=\"\\t\")\n",
" flattened = fc_matrix.reshape(-1)\n",
Expand Down Expand Up @@ -73,7 +74,8 @@
"source": [
"# Silence futureWarnings\n",
"import warnings\n",
"warnings.simplefilter(action='ignore', category=FutureWarning)\n",
"\n",
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)\n",
"\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
Expand All @@ -84,6 +86,7 @@
"FC_FIGURE_SIZE: tuple = (70, 45)\n",
"LABELSIZE: int = 60\n",
"\n",
"\n",
"def group_reportlet_fc_dist(fc_matrices: list[np.ndarray], output: str) -> None:\n",
" \"\"\"Plot and save the functional connectivity density distributions.\n",
"\n",
Expand All @@ -96,7 +99,7 @@
" \"\"\"\n",
" _, ax = plt.subplots(figsize=FC_FIGURE_SIZE)\n",
" ax.tick_params(labelsize=LABELSIZE)\n",
" mpl.rcParams['legend.fontsize'] = LABELSIZE\n",
" mpl.rcParams[\"legend.fontsize\"] = LABELSIZE\n",
"\n",
" fc_df = pd.DataFrame(fc_matrices, columns=[\"value\", \"session\"])\n",
"\n",
Expand All @@ -111,8 +114,8 @@
" )\n",
"\n",
" plt.tick_params(labelsize=LABELSIZE)\n",
" plt.xlabel('Value', fontsize=LABELSIZE+4)\n",
" plt.ylabel('Density', fontsize=LABELSIZE+4)\n",
" plt.xlabel(\"Value\", fontsize=LABELSIZE + 4)\n",
" plt.ylabel(\"Density\", fontsize=LABELSIZE + 4)\n",
"\n",
" # Ensure the labels are within the figure\n",
" plt.tight_layout()\n",
Expand All @@ -122,6 +125,8 @@
"\n",
" plt.savefig(op.join(output, savename))\n",
" plt.close()\n",
"\n",
"\n",
"group_reportlet_fc_dist(fc_matrices, output)"
]
},
Expand Down Expand Up @@ -157,6 +162,8 @@
"\n",
"# The literature indicates that less than 5 minutes of fMRI signal after censoring is not enough to reliably estimate functional connectivity.\n",
"DURATION_CUT_OFF = 300\n",
"\n",
"\n",
"# Generate each reportlets\n",
"def group_report_censoring(good_timepoints_df, output) -> None:\n",
" \"\"\"\n",
Expand Down Expand Up @@ -233,6 +240,8 @@
" filename=op.join(output, \"reportlets\", \"group_desc-censoring_bold.html\"),\n",
" auto_open=False,\n",
" )\n",
"\n",
"\n",
"group_report_censoring(good_timepoints_df, output)"
]
},
Expand Down Expand Up @@ -356,7 +365,7 @@
" out_filename=\"group_report.html\",\n",
" bootstrap_file=op.join(\"data\", \"reports-spec.yml\"),\n",
")\n",
"robj.generate_report()\n"
"robj.generate_report()"
]
},
{
Expand Down

0 comments on commit 56d1e84

Please sign in to comment.