Skip to content

Commit 1a03d33

Browse files
committed
dev docs: nilearn/nilearn@5de9169 : [MAINT] clean up architecture restriction (#5890)
1 parent cecd7e1 commit 1a03d33

File tree

832 files changed

+51712
-48998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

832 files changed

+51712
-48998
lines changed
Binary file not shown.

dev/_downloads/034e4a0d5c805cf4938eba117765c0ee/plot_predictions_residuals.ipynb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"cell_type": "markdown",
6666
"metadata": {},
6767
"source": [
68-
"## Extract the largest clusters\n\n"
68+
"## Extract the largest clusters\nWe can extract the 6 largest clusters surviving our threshold.\nand get the x, y, and z coordinates of their peaks.\nWe then extract the time series from a sphere around each coordinate.\n\n\n"
6969
]
7070
},
7171
{
@@ -76,7 +76,25 @@
7676
},
7777
"outputs": [],
7878
"source": [
79-
"from nilearn.maskers import NiftiSpheresMasker\nfrom nilearn.reporting import get_clusters_table\n\ntable = get_clusters_table(\n z_map, stat_threshold=threshold, cluster_threshold=20\n)\ntable.set_index(\"Cluster ID\", drop=True)\ntable.head()\n\n# get the 6 largest clusters' max x, y, and z coordinates\ncoords = table.loc[range(1, 7), [\"X\", \"Y\", \"Z\"]].to_numpy()\n\n# extract time series from each coordinate\nmasker = NiftiSpheresMasker(coords)\nreal_timeseries = masker.fit_transform(fmri_img)\npredicted_timeseries = masker.fit_transform(fmri_glm.predicted[0])"
79+
"from nilearn.maskers import NiftiSpheresMasker\nfrom nilearn.reporting import get_clusters_table\n\ntable = get_clusters_table(\n z_map, stat_threshold=threshold, cluster_threshold=20\n)\ntable.set_index(\"Cluster ID\", drop=True)\nprint(table)\n\ncoords = table.loc[range(1, 7), [\"X\", \"Y\", \"Z\"]].to_numpy()\nprint(coords)\n\nmasker = NiftiSpheresMasker(coords)\nreal_timeseries = masker.fit_transform(fmri_img)\npredicted_timeseries = masker.fit_transform(fmri_glm.predicted[0])"
80+
]
81+
},
82+
{
83+
"cell_type": "markdown",
84+
"metadata": {},
85+
"source": [
86+
"Let's have a look at the report to make sure\nthe spheres are well placed.\n\n"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": null,
92+
"metadata": {
93+
"collapsed": false
94+
},
95+
"outputs": [],
96+
"source": [
97+
"report = masker.generate_report()\nreport"
8098
]
8199
},
82100
{
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

dev/_downloads/1020ea2b51f8e38daf607e192d4bdc5d/plot_oasis.py

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -166,47 +166,23 @@
166166
# gray matter density on that dataset.
167167

168168
# %%
169-
# Saving model outputs to disk
170-
# ----------------------------
171-
# It can be useful to quickly generate a portable, ready-to-view report with
172-
# most of the pertinent information.
173-
# We can do this by saving the output of the GLM to disk
174-
# including an HTML report.
175-
# This is easy to do if you have a fitted model and the list of contrasts,
176-
# which we do here.
177-
from pathlib import Path
178-
179-
from nilearn.glm import save_glm_to_bids
180-
181-
output_dir = Path.cwd() / "results" / "plot_oasis"
182-
output_dir.mkdir(exist_ok=True, parents=True)
169+
# Generate a report for the GLM
170+
# -----------------------------
171+
#
172+
# Generate a report and view it.
173+
#
183174

184175
icbm152_2009 = fetch_icbm152_2009()
185176

186-
second_level_model = save_glm_to_bids(
187-
second_level_model,
188-
contrasts=["age", "sex"],
189-
out_dir=output_dir / "derivatives" / "nilearn_glm",
190-
prefix="ageEffectOnGM",
191-
bg_img=icbm152_2009["t1"],
192-
alpha=0.05,
193-
height_control="fdr",
194-
)
195-
196-
# %%
197-
# View the generated files
198-
files = sorted((output_dir / "derivatives" / "nilearn_glm").glob("**/*"))
199-
print("\n".join([str(x.relative_to(output_dir)) for x in files]))
200-
201-
# %%
202-
# Generate a report and view it.
203-
# If no new contrast is passed to ``generate_report``,
204-
# the results saved to disk will be reused to generate the report.
205-
206177
report = second_level_model.generate_report(
207178
bg_img=icbm152_2009["t1"],
208179
plot_type="glass",
209180
alpha=0.05,
210181
height_control=None,
211182
)
212-
report.save_as_html(output_dir / "report.html")
183+
184+
# %%
185+
#
186+
# .. include:: ../../../examples/report_note.rst
187+
#
188+
report

0 commit comments

Comments
 (0)