Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Fix rendering of explanatory text #3972

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 15 additions & 15 deletions examples/06_manipulating_images/plot_mask_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

"""

###############################################################################
# %%
# Computing a mask from the background
###############################################################################
# ------------------------------------
#
# The default strategy to compute a mask, eg in NiftiMasker is to try to
# detect the background.
Expand All @@ -44,7 +44,7 @@
miyawaki_filename = miyawaki_dataset.func[0]
miyawaki_mean_img = image.mean_img(miyawaki_filename)
plot_epi(miyawaki_mean_img, title="Mean EPI image")
###############################################################################
# %%
# A NiftiMasker with the default strategy
masker = NiftiMasker()
masker.fit(miyawaki_filename)
Expand All @@ -54,15 +54,15 @@
masker.mask_img_, miyawaki_mean_img, title="Mask from already masked data"
)

###############################################################################
# %%
# Plot the generated mask using the .generate_report method
report = masker.generate_report()
report


###############################################################################
# %%
# Computing a mask from raw EPI data
###############################################################################
# ----------------------------------
#
# From raw EPI data, there is no uniform background, and a different
# strategy is necessary
Expand All @@ -80,15 +80,15 @@
mean_img = image.mean_img(epi_img)
plot_epi(mean_img, title="Mean EPI image")

###############################################################################
# %%
# Simple mask extraction from EPI images
# We need to specify an 'epi' mask_strategy, as this is raw EPI data
masker = NiftiMasker(mask_strategy="epi")
masker.fit(epi_img)
report = masker.generate_report()
report

###############################################################################
# %%
# Generate mask with strong opening
#
# We can fine-tune the outline of the mask by increasing the number of
Expand All @@ -102,7 +102,7 @@
report = masker.generate_report()
report

###############################################################################
# %%
# Generate mask with a high lower cutoff
#
# The NiftiMasker calls the nilearn.masking.compute_epi_mask function to
Expand All @@ -121,9 +121,9 @@
report = masker.generate_report()
report

###############################################################################
# %%
# Computing the mask from the MNI template
###############################################################################
# ----------------------------------------
#
# A mask can also be computed from the MNI template. In this case, it is
# resampled to the target image. Three options are available:
Expand All @@ -135,9 +135,9 @@
report = masker.generate_report()
report

###############################################################################
# %%
# Compute and resample a mask
###############################################################################
# ---------------------------
#
# NiftiMasker also allows passing parameters directly to `image.resample_img`.
# We can specify a `target_affine`, a `target_shape`, or both.
Expand All @@ -154,9 +154,9 @@
report = masker.generate_report()
report

###############################################################################
# %%
# After mask computation: extracting time series
###############################################################################
# ----------------------------------------------
#
# Extract time series

Expand Down