def to_matrix(self, smooth_fwhm=<NUM_LIT:0>, outdtype=None):
if not self.all_compatible:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if not outdtype:<EOL><INDENT>outdtype = self.items[<NUM_LIT:0>].dtype<EOL><DEDENT>n_voxels     = None<EOL>mask_indices = None<EOL>mask_shape   = self.items[<NUM_LIT:0>].shape[:<NUM_LIT:3>]<EOL>if self.has_mask:<EOL><INDENT>mask_arr     = self.mask.get_data()<EOL>mask_indices = np.nonzero(mask_arr)<EOL>mask_shape   = self.mask.shape<EOL>n_voxels     = np.count_nonzero(mask_arr)<EOL><DEDENT>if n_voxels is None:<EOL><INDENT>log.debug('<STR_LIT>'.format(self.mask))<EOL>n_voxels     = np.prod(mask_shape)<EOL>mask_indices = None<EOL><DEDENT>ndims = self.items[<NUM_LIT:0>].ndim<EOL>if ndims == <NUM_LIT:3>:<EOL><INDENT>subj_flat_shape = (n_voxels, )<EOL><DEDENT>elif ndims == <NUM_LIT:4>:<EOL><INDENT>subj_flat_shape = (n_voxels, self.items[<NUM_LIT:0>].shape[<NUM_LIT:3>])<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError('<STR_LIT>'<EOL>'<STR_LIT>'.format(ndims))<EOL><DEDENT>outmat = np.zeros((self.n_subjs, ) + subj_flat_shape, dtype=outdtype)<EOL>try:<EOL><INDENT>for i, image in enumerate(self.items):<EOL><INDENT>if smooth_fwhm > <NUM_LIT:0>:<EOL><INDENT>image.fwhm = smooth_fwhm<EOL><DEDENT>if self.has_mask:<EOL><INDENT>image.set_mask(self.mask)<EOL><DEDENT>outmat[i, :], _, _ = image.mask_and_flatten()<EOL>image.clear_data()<EOL><DEDENT><DEDENT>except Exception as exc:<EOL><INDENT>raise Exception('<STR_LIT>'.format(image)) from exc<EOL><DEDENT>else:<EOL><INDENT>return outmat, mask_indices, mask_shape<EOL><DEDENT>
Return numpy.ndarray with the masked or flatten image data and
           the relevant information (mask indices and volume shape).

        Parameters
        ----------
        smooth__fwhm: int
            Integer indicating the size of the FWHM Gaussian smoothing kernel
            to smooth the subject volumes before creating the data matrix

        outdtype: dtype
            Type of the elements of the array, if None will obtain the dtype from
            the first nifti file.

        Returns
        -------
        outmat, mask_indices, vol_shape

        outmat: Numpy array with shape N x prod(vol.shape)
                containing the N files as flat vectors.

        mask_indices: matrix with indices of the voxels in the mask

        vol_shape: Tuple with shape of the volumes, for reshaping.