neurosynth/base/mask.py
def unmask(self, data, layers=None, output='array'):
        """ Reconstruct a masked vector into the original 3D volume.
        Args:
            data: The 1D vector to reconstruct. (Can also be a 2D vector where
                the second dimension is time, but then output will always
                be set to 'array'--i.e., a 4D image will be returned.)
            layers: Which mask layers to use (specified as int, string, or list
                of ints and strings). When None, applies the conjunction of all
                layers. Note that the layers specified here must exactly match
                the layers used in the mask() operation, otherwise the shape of
                the mask will be incorrect and bad things will happen.
            output: What kind of object to return. See options in get_image().
                By default, returns an N-dimensional array of reshaped data.
        """
        self.set_mask(layers)
        if data.ndim == 2:
            n_volumes = data.shape[1]
            # Assume 1st dimension is voxels, 2nd is time
            # but we generate x,y,z,t volume
            image = np.zeros(self.full.shape + (n_volumes,))
            image[self.current_mask, :] = data
            image = np.reshape(image, self.volume.shape + (n_volumes,))
        else:
            # img = self.full.copy()
            image = np.zeros(self.full.shape)
            image[self.current_mask] = data
        return self.get_image(image, output)
def unmask(self, data, layers=None, output='array'):
        """ Reconstruct a masked vector into the original 3D volume.
        Args:
            data: The 1D vector to reconstruct. (Can also be a 2D vector where
                the second dimension is time, but then output will always
                be set to 'array'--i.e., a 4D image will be returned.)
            layers: Which mask layers to use (specified as int, string, or list
                of ints and strings). When None, applies the conjunction of all
                layers. Note that the layers specified here must exactly match
                the layers used in the mask() operation, otherwise the shape of
                the mask will be incorrect and bad things will happen.
            output: What kind of object to return. See options in get_image().
                By default, returns an N-dimensional array of reshaped data.
        """
        self.set_mask(layers)
        if data.ndim == 2:
            n_volumes = data.shape[1]
            # Assume 1st dimension is voxels, 2nd is time
            # but we generate x,y,z,t volume
            image = np.zeros(self.full.shape + (n_volumes,))
            image[self.current_mask, :] = data
            image = np.reshape(image, self.volume.shape + (n_volumes,))
        else:
            # img = self.full.copy()
            image = np.zeros(self.full.shape)
            image[self.current_mask] = data
        return self.get_image(image, output)
Reconstruct a masked vector into the original 3D volume.
        Args:
            data: The 1D vector to reconstruct. (Can also be a 2D vector where
                the second dimension is time, but then output will always
                be set to 'array'--i.e., a 4D image will be returned.)
            layers: Which mask layers to use (specified as int, string, or list
                of ints and strings). When None, applies the conjunction of all
                layers. Note that the layers specified here must exactly match
                the layers used in the mask() operation, otherwise the shape of
                the mask will be incorrect and bad things will happen.
            output: What kind of object to return. See options in get_image().
                By default, returns an N-dimensional array of reshaped data.