# Path: brainiak/image.py
# def mask_images(images: Iterable[SpatialImage], mask: np.ndarray,
#                 image_type: type = None) -> Iterable[np.ndarray]:
#     """Mask images.
# 
#     Parameters
#     ----------
#     images:
#         Images to mask.
#     mask:
#         Mask to apply.
#     image_type:
#         Type to cast images to.
# 
#     Yields
#     ------
#     np.ndarray
#         Masked image.
#     """
#     for images in multimask_images(images, (mask,), image_type):
#         yield images[0]
# 
# def multimask_images(images: Iterable[SpatialImage],
#                      masks: Sequence[np.ndarray], image_type: type = None
#                      ) -> Iterable[Sequence[np.ndarray]]:
#     """Mask images with multiple masks.
# 
#     Parameters
#     ----------
#     images:
#         Images to mask.
#     masks:
#         Masks to apply.
#     image_type:
#         Type to cast images to.
# 
#     Yields
#     ------
#     Sequence[np.ndarray]
#         For each mask, a masked image.
#     """
#     for image in images:
#         yield [mask_image(image, mask, image_type) for mask in masks]


import math
import time
import numpy as np
import logging
from scipy.stats.mstats import zscore
from mpi4py import MPI
from enum import Enum
from ..image import mask_images, multimask_images
                    epoch_info.append((cond, sid, start, start + r))
    time2 = time.time()
    logger.debug(
        'epoch separation done, takes %.2f s' %
        (time2 - time1)
    )
    return epoch_info


def prepare_mvpa_data(images, conditions, mask):
    """Prepare data for activity-based model training and prediction.

    Average the activity within epochs and z-scoring within subject.

    Parameters
    ----------
    images: Iterable[SpatialImage]
        Data.
    conditions: List[UniqueLabelConditionSpec]
        Condition specification.
    mask: np.ndarray
        Mask to apply to each image.

    Returns
    -------
    processed_data: 2D array in shape [num_voxels, num_epochs]
        averaged epoch by epoch processed data
    labels: 1D array
        contains labels of the data
    """

# Path: brainiak/image.py
# def mask_images(images: Iterable[SpatialImage], mask: np.ndarray,
#                 image_type: type = None) -> Iterable[np.ndarray]:
#     """Mask images.
# 
#     Parameters
#     ----------
#     images:
#         Images to mask.
#     mask:
#         Mask to apply.
#     image_type:
#         Type to cast images to.
# 
#     Yields
#     ------
#     np.ndarray
#         Masked image.
#     """
#     for images in multimask_images(images, (mask,), image_type):
#         yield images[0]
# 
# def multimask_images(images: Iterable[SpatialImage],
#                      masks: Sequence[np.ndarray], image_type: type = None
#                      ) -> Iterable[Sequence[np.ndarray]]:
#     """Mask images with multiple masks.
# 
#     Parameters
#     ----------
#     images:
#         Images to mask.
#     masks:
#         Masks to apply.
#     image_type:
#         Type to cast images to.
# 
#     Yields
#     ------
#     Sequence[np.ndarray]
#         For each mask, a masked image.
#     """
#     for image in images:
#         yield [mask_image(image, mask, image_type) for mask in masks]


# Path: brainiak/fcma/preprocessing.py
import math
import time
import numpy as np
import logging
from scipy.stats.mstats import zscore
from mpi4py import MPI
from enum import Enum
from ..image import mask_images, multimask_images

                    epoch_info.append((cond, sid, start, start + r))
    time2 = time.time()
    logger.debug(
        'epoch separation done, takes %.2f s' %
        (time2 - time1)
    )
    return epoch_info


def prepare_mvpa_data(images, conditions, mask):
    """Prepare data for activity-based model training and prediction.

    Average the activity within epochs and z-scoring within subject.

    Parameters
    ----------
    images: Iterable[SpatialImage]
        Data.
    conditions: List[UniqueLabelConditionSpec]
        Condition specification.
    mask: np.ndarray
        Mask to apply to each image.

    Returns
    -------
    processed_data: 2D array in shape [num_voxels, num_epochs]
        averaged epoch by epoch processed data
    labels: 1D array
        contains labels of the data
    """

    activity_data = list(mask_images(images, mask, np.float32))