Module Expr Str Import alias Import alias Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Num If Call NameLoad NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign NameStore NameLoad orelse AugAssignMult NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr If CompareIsNot NameLoad NameLoad body If CompareEq Call AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr Str Assign NameStore BinOpAdd Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign TupleStore NameStore NameStore NameStore NameLoad Return Call AttributeLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad Call AttributeLoad NameLoad attr attr Assign TupleStore NameStore NameStore NameStore SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad AugAssignMult NameStore NameLoad AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr If BoolOpAnd CompareEq Call AttributeLoad NameLoad attr Num CompareEq Call AttributeLoad NameLoad attr Num body Return BinOpMult Num Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad Call AttributeLoad SubscriptLoad NameLoad Index CompareNotEq NameLoad Num attr Num Assign NameStore CompareGt Call AttributeLoad NameLoad attr NameLoad BinOpSub NameLoad Num If CompareEq Call AttributeLoad NameLoad attr Num body Return BinOpMult Num Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign TupleStore NameStore NameStore NameStore SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad AugAssignMult NameStore NameLoad AugAssignAdd NameStore ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad Assign NameStore CompareGt Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareGt Call AttributeLoad NameLoad attr Num body AugAssignMult NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign TupleStore NameStore NameStore NameStore BinOpAdd NameLoad NameLoad Return Call AttributeLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad NameLoad Call AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr If Call NameLoad NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num SubscriptLoad NameLoad Index TupleLoad Num Num Num AugAssignDiv NameStore Num Assign NameStore CompareGt Call AttributeLoad NameLoad attr BinOpSub NameLoad NameLoad BinOpMult Num Call AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore Call NameLoad Call NameLoad NameLoad NameLoad NameLoad Return TupleLoad TupleLoad NameLoad NameLoad TupleLoad NameLoad NameLoad TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Str attr NameLoad Assign NameStore Dict For NameStore Str body Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign SubscriptStore NameLoad Index Str NameLoad Assign NameStore SubscriptLoad Call NameLoad NameLoad Index NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Str Num Str body Expr Str If UnaryOpNot CompareIn NameLoad Str body Raise Call NameLoad BinOpMod Str NameLoad Assign NameStore Call AttributeLoad Str attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad If UnaryOpNot Call NameLoad NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str NameLoad If CompareGt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Return Call NameLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr If CompareEq AttributeLoad AttributeLoad NameLoad attr attr Str body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad NameLoad keyword Str Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr attr Assign NameStore Call NameLoad BinOpSub Call NameLoad NameLoad NameLoad If BoolOpOr CompareLt Call NameLoad NameLoad Num CompareGt NameLoad NameLoad body Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad Raise Call NameLoad NameLoad orelse Assign NameStore Call NameLoad Call NameLoad NameLoad If CompareEq NameLoad Str body Assign NameStore Call NameLoad Call NameLoad BinOpMult BinOpDiv Num NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Num Assign NameStore ListLoad Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad Assign NameStore Call NameLoad For NameStore Call NameLoad NameLoad body Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr AttributeLoad NameLoad attr Index NameLoad Assign NameStore Call NameLoad Num BinOpSub NameLoad NameLoad Assign NameStore BinOpAdd NameLoad NameLoad Assign SubscriptStore NameLoad Index NameLoad Call NameLoad NameLoad NameLoad AugAssignMult SubscriptStore NameLoad Index NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr While CompareLt Call NameLoad NameLoad NameLoad body Assign NameStore BinOpSub Call NameLoad NameLoad Num Assign NameStore BinOpAdd Call NameLoad NameLoad Num Assign NameStore ListLoad NameLoad If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad BinOpMult Num BinOpAdd SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index BinOpAdd NameLoad Num If UnaryOpNot CompareIn NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareGtE NameLoad Num body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Num For NameStore NameLoad body If CompareGtE NameLoad NameLoad body Assign NameStore Num orelse Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad Call AttributeLoad NameLoad attr NameLoad NameLoad Index NameLoad If CompareGt NameLoad NameLoad body Assign NameStore NameLoad Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Return Call NameLoad NameLoad NameLoad NameLoad decorator_list
N/A N/A 
Tools to find activations and cut on maps
 N/A warnings N/A numbers N/A numpy np scipy ndimage _utils.ndimage largest_connected_component image new_img_like _utils.extmath fast_abs_percentile _utils.numpy_conversions as_ndarray _utils check_niimg_3d _utils.niimg _safe_get_data image.resampling get_mask_bounds coord_transform image.image _smooth_array find_xyz_cut_coords N/A N/A img mask activation_threshold N/A None None N/A N/A  Find the center of the largest activation connected component.

        Parameters
        -----------
        img : 3D Nifti1Image
            The brain map.
        mask : 3D ndarray, boolean, optional
            An optional brain mask.
        activation_threshold : float, optional
            The lower threshold to the positive activation. If None, the
            activation threshold is computed using the 80% percentile of
            the absolute value of the map.

        Returns
        -------
        x : float
            the x world coordinate.
        y : float
            the y world coordinate.
        z : float
            the z world coordinate.
     N/A img N/A check_niimg_3d img N/A data N/A _safe_get_data img N/A offset N/A N/A np zeros 3 N/A N/A hasattr data mask N/A N/A not_mask N/A N/A np logical_not N/A data mask N/A N/A mask None N/A N/A mask not_mask N/A N/A mask not_mask N/A data N/A N/A np asarray data N/A data N/A as_ndarray data N/A my_map N/A N/A data copy N/A N/A mask None N/A N/A N/A N/A N/A mask sum 0.0 N/A N/A N/A N/A warnings warn Provided mask is empty. Returning center of mass instead. N/A cut_coords N/A N/A N/A ndimage center_of_mass N/A N/A np abs my_map offset N/A N/A x_map y_map z_map cut_coords N/A N/A N/A N/A N/A np asarray N/A coord_transform x_map y_map z_map N/A N/A img get_affine tolist N/A N/A slice_x slice_y slice_z N/A N/A N/A ndimage find_objects mask N/A 0 N/A my_map N/A my_map N/A N/A slice_x slice_y slice_z N/A mask N/A mask N/A N/A slice_x slice_y slice_z N/A my_map mask N/A offset N/A N/A slice_x start N/A slice_y start N/A slice_z start N/A N/A N/A N/A N/A my_map max 0 N/A N/A N/A my_map min 0 N/A N/A N/A 0.5 N/A N/A np array N/A data shape N/A N/A activation_threshold None N/A N/A activation_threshold N/A fast_abs_percentile N/A N/A N/A my_map N/A N/A my_map 0 ravel 80 N/A mask N/A N/A N/A np abs my_map N/A activation_threshold 1e-15 N/A N/A N/A N/A mask max 0 N/A N/A N/A 0.5 N/A N/A np array N/A data shape N/A mask N/A largest_connected_component mask N/A N/A slice_x slice_y slice_z N/A N/A N/A ndimage find_objects mask N/A 0 N/A my_map N/A my_map N/A N/A slice_x slice_y slice_z N/A mask N/A mask N/A N/A slice_x slice_y slice_z N/A my_map mask N/A offset N/A N/A slice_x start N/A slice_y start N/A slice_z start N/A second_threshold N/A N/A np abs N/A N/A np mean N/A my_map N/A mask N/A second_mask N/A N/A N/A np abs my_map second_threshold N/A N/A N/A N/A second_mask sum 50 N/A N/A my_map N/A largest_connected_component second_mask N/A cut_coords N/A N/A ndimage center_of_mass N/A N/A np abs my_map N/A N/A x_map y_map z_map N/A cut_coords offset N/A N/A N/A N/A N/A np asarray N/A coord_transform x_map y_map z_map N/A N/A img get_affine tolist N/A _get_auto_mask_bounds N/A N/A img N/A N/A N/A  Compute the bounds of the data with an automaticaly computed mask
     N/A data N/A _safe_get_data img N/A affine N/A N/A img get_affine N/A N/A hasattr data mask N/A N/A mask N/A N/A np logical_not N/A data mask N/A data N/A N/A np asarray data N/A N/A edge_value N/A float N/A N/A N/A N/A N/A N/A N/A N/A data N/A N/A 0 0 0 N/A data N/A N/A 0 -1 0 N/A data N/A N/A -1 0 0 N/A data N/A N/A 0 0 -1 N/A data N/A N/A -1 -1 0 N/A data N/A N/A -1 0 -1 N/A data N/A N/A 0 -1 -1 N/A data N/A N/A -1 -1 -1 N/A edge_value 6 N/A mask N/A N/A N/A np abs N/A data edge_value N/A 0.005 N/A N/A data ptp N/A N/A xmin xmax ymin ymax zmin zmax N/A get_mask_bounds N/A new_img_like img mask affine N/A N/A N/A xmin xmax N/A ymin ymax N/A zmin zmax N/A _transform_cut_coords N/A N/A cut_coords direction affine N/A N/A N/A Transforms cut_coords back in image space

    Parameters
    ----------
    cut_coords: 1D array of length n_cuts
        The coordinates to be transformed.

    direction: string, optional (default "z")
        sectional direction; possible values are "x", "y", or "z"

    affine: 2D array of shape (4, 4)
        The affine for the image.

    Returns
    -------
    cut_coords: 1D array of length n_cuts
       The original cut_coords transformed image space.
     N/A axis N/A N/A xyz index direction N/A kwargs N/A N/A name xyz N/A N/A N/A kwargs N/A name N/A N/A np zeros N/A len cut_coords N/A N/A kwargs N/A direction cut_coords N/A N/A kwargs N/A affine affine N/A cut_coords N/A N/A coord_transform kwargs N/A axis N/A N/A N/A np atleast_1d cut_coords N/A find_cut_slices N/A N/A img direction n_cuts spacing N/A z 7 auto N/A N/A  Find 'good' cross-section slicing positions along a given axis.

    Parameters
    ----------
    img: 3D Nifti1Image
        the brain map
    direction: string, optional (default "z")
        sectional direction; possible values are "x", "y", or "z"
    n_cuts: int, optional (default 7)
        number of cuts in the plot
    spacing: 'auto' or int, optional (default 'auto')
        minimum spacing between cuts (in voxels, not milimeters)
        if 'auto', the spacing is .5 / n_cuts * img_length

    Returns
    -------
    cut_coords: 1D array of length n_cuts
        the computed cut_coords

    Notes
    -----
    This code works by iteratively locating peak activations that are
    separated by a distance of at least 'spacing'. If n_cuts is very
    large and all the activated regions are covered, cuts with a spacing
    less than 'spacing' will be returned.
     N/A N/A N/A direction xyz N/A N/A N/A ValueError N/A 'direction' must be one of 'x', 'y', or 'z'. Got '%s' direction N/A axis N/A N/A xyz index direction N/A affine N/A N/A img get_affine N/A orig_data N/A N/A np abs N/A _safe_get_data img N/A this_shape N/A N/A orig_data shape N/A axis N/A N/A N/A isinstance n_cuts N/A numbers Number N/A N/A N/A ValueError N/A The number of cuts (n_cuts) must be an integer greater than or equal to 1. You provided a value of n_cuts=%s.  n_cuts N/A N/A n_cuts this_shape N/A N/A N/A N/A warnings warn N/A Too many cuts requested for the data: n_cuts=%i, data size=%i N/A n_cuts this_shape N/A N/A _transform_cut_coords N/A N/A np arange this_shape direction affine N/A data N/A N/A orig_data copy N/A N/A N/A N/A data dtype kind i N/A N/A data N/A N/A data astype N/A np float N/A data N/A _smooth_array data affine fwhm fast N/A epsilon N/A N/A N/A np finfo N/A np float32 eps N/A difference N/A abs N/A N/A round n_cuts n_cuts N/A N/A N/A N/A round n_cuts 1.0 N/A difference epsilon N/A N/A message N/A Image has %d slices in direction %s. Therefore, the number of cuts must be between 1 and %d. You provided n_cuts=%s  N/A this_shape direction this_shape n_cuts N/A N/A ValueError message N/A N/A n_cuts N/A int N/A round n_cuts N/A N/A spacing auto N/A N/A spacing N/A max N/A int N/A N/A 0.5 n_cuts N/A N/A data shape N/A axis 1 N/A slices N/A N/A slice None None N/A slice None None N/A slice None None N/A cut_coords N/A list N/A _ N/A range n_cuts N/A N/A max_along_axis N/A N/A N/A np unravel_index N/A N/A N/A N/A np abs data argmax N/A data shape N/A axis N/A start N/A max 0 N/A max_along_axis spacing N/A stop N/A max_along_axis spacing N/A N/A slices N/A axis N/A slice start stop N/A N/A data N/A slices 0.001 N/A N/A N/A cut_coords append max_along_axis N/A cut_coords N/A N/A N/A N/A np unique cut_coords tolist N/A N/A N/A len cut_coords n_cuts N/A N/A slice_below N/A N/A min cut_coords 2 N/A slice_above N/A N/A max cut_coords 2 N/A candidates N/A slice_above N/A N/A N/A len cut_coords 1 N/A N/A middle_idx N/A N/A np argmax N/A N/A np diff cut_coords N/A slice_middle N/A int N/A 0.5 N/A N/A cut_coords N/A middle_idx N/A cut_coords N/A N/A middle_idx 1 N/A N/A N/A slice_middle cut_coords N/A N/A N/A N/A candidates append slice_middle N/A N/A slice_below 0 N/A N/A N/A N/A candidates append slice_below N/A best_weight -10 N/A candidate candidates N/A N/A N/A candidate this_shape N/A N/A this_weight 0 N/A N/A this_weight N/A N/A np sum N/A N/A N/A np rollaxis orig_data axis N/A candidate N/A N/A this_weight best_weight N/A N/A best_candidate candidate N/A best_weight this_weight N/A N/A N/A cut_coords append best_candidate N/A cut_coords N/A N/A N/A N/A np unique cut_coords tolist N/A cut_coords N/A N/A np array cut_coords N/A N/A N/A cut_coords sort N/A N/A _transform_cut_coords cut_coords direction affine N/A