code: def test_nan():
      """Check that the masker handles NaNs appropriately."""
      data = np.ones((9, 9, 9))
      data[0] = np.nan
      data[:, 0] = np.nan
      data[:, :, 0] = np.nan
      data[-1] = np.nan
      data[:, -1] = np.nan
      data[:, :, -1] = np.nan
      data[3:-3, 3:-3, 3:-3] = 10
      img = nibabel.Nifti1Image(data, np.eye(4))
      masker = NiftiMasker(mask_args=dict(opening=0))
      masker.fit(img)
      mask = get_data(masker.mask_img_)
      assert mask[1:-1, 1:-1, 1:-1].all()
      assert not mask[0].any()
      assert not mask[:, 0].any()
      assert not mask[:, :, 0].any()
      assert not mask[-1].any()
      assert not mask[:, -1].any()
      assert not mask[:, :, -1].any()
  
imports: import os
  import shutil
  import warnings
  from tempfile import mkdtemp
  import nibabel
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from nilearn._utils import data_gen, exceptions, testing
  from nilearn._utils.class_inspect import get_params
  from nilearn.image import get_data, index_img
  from nilearn.maskers import NiftiMasker
  from nilearn.maskers.nifti_masker import _filter_and_mask
label_desc: Use image node_id 8 for calling a global function with example usage: test_nan() without return types