Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.

nilearn.reporting.make_glm_report

nilearn.reporting.make_glm_report(model, contrasts=None, first_level_contrast=None, title=None, bg_img='MNI152TEMPLATE', threshold=3.09, alpha=0.001, cluster_threshold=0, height_control='fpr', two_sided=False, min_distance=8.0, plot_type='slice', cut_coords=None, display_mode=None, report_dims=(800, 800))[source]

Return HTMLReport object for a report which shows all important aspects of a fitted GLM.

The object can be opened in a browser, displayed in a notebook, or saved to disk as a standalone HTML file.

Parameters:
modelFirstLevelModel or SecondLevelModel object

A fitted first or second level model object. Must have the computed design matrix(ces).

contrastsdict with str - ndarray key-value pairs or str or list of str or ndarray or list of ndarray, Default=None

Contrasts information for a first or second level model.

Example:

Dict of contrast names and coefficients, or list of contrast names or list of contrast coefficients or contrast name or contrast coefficient

Each contrast name must be a string. Each contrast coefficient must be a list or numpy array of ints.

Contrasts are passed to contrast_def for FirstLevelModel (nilearn.glm.first_level.FirstLevelModel.compute_contrast) & second_level_contrast for SecondLevelModel (nilearn.glm.second_level.SecondLevelModel.compute_contrast)

first_level_contraststr or numpy.ndarray of shape (n_col) with respect to FirstLevelModel or None, default=None

When the model is a SecondLevelModel:

  • in case a list of FirstLevelModel was provided as second_level_input, we have to provide a contrast to apply to the first level models to get the corresponding list of images desired, that would be tested at the second level,

  • in case a DataFrame was provided as second_level_input this is the map name to extract from the DataFrame map_name column. (it has to be a ‘t’ contrast).

This parameter is ignored for all other cases.

Added in version 0.12.0.

titlestr, default=None

If string, represents the web page’s title and primary heading, model type is sub-heading. If None, page titles and headings are autogenerated using contrast names.

bg_imgNiimg-like object, default=’MNI152TEMPLATE’

See Input and output: neuroimaging data representation. The background image for mask and stat maps to be plotted on upon. To turn off background image, just pass “bg_img=None”.

thresholdfloat, default=3.09

Cluster forming threshold in same scale as stat_img (either a t-scale or z-scale value). Used only if height_control is None.

Note

  • When two_sided is True:

    'threshold' cannot be negative.

    The given value should be within the range of minimum and maximum intensity of the input image. All intensities in the interval [-threshold, threshold] will be set to zero.

  • When two_sided is False:

    • If the threshold is negative:

      It should be greater than the minimum intensity of the input data. All intensities greater than or equal to the specified threshold will be set to zero. All other intensities keep their original values.

    • If the threshold is positive:

      It should be less than the maximum intensity of the input data. All intensities less than or equal to the specified threshold will be set to zero. All other intensities keep their original values.

alphafloat, default=0.001

Number controlling the thresholding (either a p-value or q-value). Its actual meaning depends on the height_control parameter. This function translates alpha to a z-scale threshold.

cluster_thresholdint, default=0

Cluster size threshold, in voxels.

height_controlstr, default=’fpr’

false positive control meaning of cluster forming threshold: ‘fpr’ or ‘fdr’ or ‘bonferroni’ or None.

two_sidedbool, default=False

Whether to employ two-sided thresholding or to evaluate positive values only.

min_distancefloat, default=8.0

For display purposes only. Minimum distance between subpeaks in mm.

plot_typestr, {‘slice’, ‘glass’}, default=’slice’

Specifies the type of plot to be drawn for the statistical maps.

cut_coordsNone, a tuple of float, or int, optional

The MNI coordinates of the point where the cut is performed.

  • If display_mode is ‘ortho’ or ‘tiled’, this should be a 3-tuple: (x, y, z)

  • For display_mode == “x”, “y”, or “z”, then these are the coordinates of each cut in the corresponding direction.

  • If None is given, the cuts are calculated automatically.

  • If display_mode is ‘mosaic’, and the number of cuts is the same for all directions, cut_coords can be specified as an integer. It can also be a length 3 tuple specifying the number of cuts for every direction if these are different.

Note

If display_mode is “x”, “y” or “z”, cut_coords can be an integer, in which case it specifies the number of cuts to perform.

display_modestr, default=None

Default is ‘z’ if plot_type is ‘slice’; ‘ ortho’ if plot_type is ‘glass’.

Choose the direction of the cuts: ‘x’ - sagittal, ‘y’ - coronal, ‘z’ - axial, ‘l’ - sagittal left hemisphere only, ‘r’ - sagittal right hemisphere only, ‘ortho’ - three cuts are performed in orthogonal directions.

Possible values are: ‘ortho’, ‘x’, ‘y’, ‘z’, ‘xz’, ‘yx’, ‘yz’, ‘l’, ‘r’, ‘lr’, ‘lzr’, ‘lyr’, ‘lzry’, ‘lyrz’.

report_dimsSequence[int, int], default=(1600, 800)

Specifies width, height (in pixels) of report window within a notebook. Only applicable when inserting the report into a Jupyter notebook. Can be set after report creation using report.width, report.height.

Returns:
report_textHTMLReport Object

Contains the HTML code for the GLM Report.

Examples

report = make_glm_report(model, contrasts) report.open_in_browser() report.save_as_html(destination_path)