code: def test_modelgen1(tmpdir):
      filename1 = tmpdir.join("test1.nii").strpath
      filename2 = tmpdir.join("test2.nii").strpath
      Nifti1Image(
          np.random.rand(10, 10, 10, 200), np.eye(4)
      ).to_filename(filename1)
      Nifti1Image(
          np.random.rand(10, 10, 10, 200), np.eye(4)
      ).to_filename(filename2)
      s = SpecifyModel()
      s.inputs.input_units = "scans"
      set_output_units = lambda: setattr(
          s.inputs, "output_units", "scans"
      )
      with pytest.raises(TraitError):
          set_output_units()
      s.inputs.functional_runs = [filename1, filename2]
      s.inputs.time_repetition = 6
      s.inputs.high_pass_filter_cutoff = 128.0
      info = [
          Bunch(
              conditions=["cond1"],
              onsets=[[2, 50, 100, 180]],
              durations=[[1]],
              amplitudes=None,
              pmod=None,
              regressors=None,
              regressor_names=None,
              tmod=None,
          ),
          Bunch(
              conditions=["cond1"],
              onsets=[[30, 40, 100, 150]],
              durations=[[1]],
              amplitudes=None,
              pmod=None,
              regressors=None,
              regressor_names=None,
              tmod=None,
          ),
      ]
      s.inputs.subject_info = info
      res = s.run()
      assert len(res.outputs.session_info) == 2
      assert len(res.outputs.session_info[0]["regress"]) == 0
      assert len(res.outputs.session_info[0]["cond"]) == 1
      npt.assert_almost_equal(
          np.array(res.outputs.session_info[0]["cond"][0]["onset"]),
          np.array([12, 300, 600, 1080]),
      )
      info = [
          Bunch(conditions=["cond1"], onsets=[[2]], durations=[[1]]),
          Bunch(conditions=["cond1"], onsets=[[3]], durations=[[1]]),
      ]
      s.inputs.subject_info = deepcopy(info)
      res = s.run()
      npt.assert_almost_equal(
          np.array(res.outputs.session_info[0]["cond"][0]["duration"]),
          np.array([6.0]),
      )
      npt.assert_almost_equal(
          np.array(res.outputs.session_info[1]["cond"][0]["duration"]),
          np.array([6.0]),
      )
      info = [
          Bunch(
              conditions=["cond1", "cond2"],
              onsets=[[2, 3], [2]],
              durations=[[1, 1], [1]],
          ),
          Bunch(
              conditions=["cond1", "cond2"],
              onsets=[[2, 3], [2, 4]],
              durations=[[1, 1], [1, 1]],
          ),
      ]
      s.inputs.subject_info = deepcopy(info)
      s.inputs.input_units = "scans"
      res = s.run()
      npt.assert_almost_equal(
          np.array(res.outputs.session_info[0]["cond"][0]["duration"]),
          np.array([6.0, 6.0]),
      )
      npt.assert_almost_equal(
          np.array(res.outputs.session_info[0]["cond"][1]["duration"]),
          np.array([6.0]),
      )
      npt.assert_almost_equal(
          np.array(res.outputs.session_info[1]["cond"][1]["duration"]),
          np.array([6.0, 6.0]),
      )
  
file_path: nipype/nipype/algorithms/tests/test_modelgen.py
imports: from copy import deepcopy
  import os
  from nibabel import Nifti1Image
  import numpy
  import pytest
  import numpy.testing
  from nipype.testing import example_data
  from nipype.interfaces.base import Bunch, TraitError
  from nipype.algorithms.modelgen import bids_gen_info, SpecifyModel, SpecifySparseModel, SpecifySPMModel
label_desc: Use image node_id 2 for calling a global function with example usage: test_modelgen1(tmpdir) without return types