def METHOD_NAME(self, in_file, mask_file=None):
    stem, ext = split_ext(in_file)
    self.stem, self.ext = stem, ext
    if mask_file is None:
        mask_file = self.inputs.mask
    self.mask = None
    if ext in [".nii", ".nii.gz"]:
        in_img = nib.loadsave.load(in_file)
        self.in_img = in_img
        ndim = np.asanyarray(in_img.dataobj).ndim
        if ndim == 3:
            volumes = [in_img]
        elif ndim == 4:
            volumes = nib.funcs.four_to_three(in_img)
        else:
            raise ValueError(
                f'Unexpect number of dimensions {ndim:d} in "{in_file}"'
            )
        volume_shape = volumes[0].shape
        n_voxels = np.prod(volume_shape)
        if (
            isdefined(mask_file)
            and isinstance(mask_file, str)
            and Path(mask_file).is_file()
        ):
            mask_img = nib.funcs.squeeze_image(nib.loadsave.load(mask_file))
            assert nvol(mask_img) == 1
            assert np.allclose(mask_img.affine, in_img.affine)
            mask_fdata = mask_img.get_fdata(dtype=np.float64)
            mask_bin = np.logical_not(
                np.logical_or(mask_fdata <= 0, np.isclose(mask_fdata, 0, atol=1e-2))
            )
            self.mask = mask_bin
            n_voxels = np.count_nonzero(mask_bin)
        n_volumes = len(volumes)
        array = np.zeros((n_volumes, n_voxels))
        for i, volume in enumerate(volumes):
            volume_data = volume.get_fdata()
            if self.mask is not None:
                array[i, :] = volume_data[self.mask]
            else:
                array[i, :] = np.ravel(volume_data)
    else:  # a text file
        in_df = read_spreadsheet(in_file)
        self.in_df = in_df
        array = in_df.to_numpy().astype(np.float64)
    return array