code: def test_invalid_filetype(tmp_path, rng):
      """Invalid file types/associated files for load method."""
      bad_nii, bad_conf = create_tmp_filepath(
          tmp_path, copy_confounds=True, fmriprep_version="1.4.x"
      )
      _, _ = load_confounds(bad_nii)
  
      # more than one legal filename for confounds
      add_conf = "sub-14x_task-test_desc-confounds_regressors.tsv"
      legal_confounds, _ = get_legal_confound()
      legal_confounds.to_csv(tmp_path / add_conf, sep="\t", index=False)
      with pytest.raises(ValueError) as info:
          load_confounds(bad_nii)
      assert "more than one" in str(info.value)
      (
          tmp_path / add_conf
      ).unlink()  # Remove for the rest of the tests to run
  
      # invalid fmriprep version: confound file with no header (<1.0)
      fake_confounds = rng.random((30, 20))
      np.savetxt(bad_conf, fake_confounds, delimiter="\t")
      with pytest.raises(ValueError) as error_log:
          load_confounds(bad_nii)
      assert "The confound file contains no header." in str(
          error_log.value
      )
  
      # invalid fmriprep version: old camel case header (<1.2)
      legal_confounds, _ = get_legal_confound()
      camel_confounds = legal_confounds.copy()
      camel_confounds.columns = [
          to_camel_case(col_name)
          for col_name in legal_confounds.columns
      ]
      camel_confounds.to_csv(bad_conf, sep="\t", index=False)
      with pytest.raises(ValueError) as error_log:
          load_confounds(bad_nii)
      assert "contains header in camel case." in str(error_log.value)
  
      # create a empty nifti file with no associated confound file
      # We only need the path to check this
      no_conf = "no_confound_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz"
      no_confound = tmp_path / no_conf
      no_confound.touch()
      with pytest.raises(ValueError):
          load_confounds(bad_nii)
  
imports: import re
  import numpy
  import pandas
  import pytest
  from nibabel import Nifti1Image
  from scipy.stats import pearsonr
  from sklearn.preprocessing import scale
  from nilearn._utils.data_gen import create_fake_bids_dataset
  from nilearn._utils.fmriprep_confounds import to_camel_case
  from nilearn.conftest import _rng
  from nilearn.interfaces.bids import get_bids_files
  from nilearn.interfaces.fmriprep import load_confounds
  from nilearn.interfaces.fmriprep.load_confounds import _check_strategy, _load_single_confounds_file
  from nilearn.interfaces.fmriprep.tests._testing import create_tmp_filepath, get_legal_confound
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 21 for calling a global function with example usage: test_invalid_filetype(tmp_path, rng) without return types