code: def test_convert_dtype(tmp_path, data_dtype):
      infile = get_test_data(fname="anatomical.nii")
      outfile = tmp_path / "output.nii.gz"
  
      orig = nib.load(infile)
      assert not outfile.exists()
  
      # np.dtype() will give us the dtype for the system endianness if that
      # mismatches the data file, we will fail equality, so get the dtype that
      # matches the requested precision but in the endianness of the file
      expected_dtype = np.dtype(data_dtype).newbyteorder(
          orig.header.endianness
      )
  
      convert.main(
          [str(infile), str(outfile), "--out-dtype", data_dtype]
      )
      assert outfile.is_file()
  
      converted = nib.load(outfile)
      assert np.allclose(converted.affine, orig.affine)
      assert converted.shape == orig.shape
      assert converted.get_data_dtype() == expected_dtype
  
file_path: nibabel/nibabel/cmdline/tests/test_convert.py
imports: import numpy
  import pytest
  import nibabel
  from nibabel.cmdline import convert
  from nibabel.testing import get_test_data
label_desc: Use image node_id 2 for calling a global function with example usage: test_convert_dtype(tmp_path, data_dtype) without return types