def test_exists_gracefully_if_filter_not_float(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['--high-pass'] = '******' settings = ciftify_clean_img.UserSettings(arguments) assert False
def test_proper_output_returned_for_cifti(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/myfunc.dtseries.nii' settings = ciftify_clean_img.UserSettings(arguments) assert settings.output_func == '/path/to/input/myfunc_clean_s0.dtseries.nii'
def test_bandpass_filter_returns_float_if_float(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['--high-pass'] = '******' settings = ciftify_clean_img.UserSettings(arguments) assert settings.high_pass == 3.14
def test_exists_gracefully_if_output_not_writable(self): wrong_func = '/wrong/path/to/input/myfunc.nii.gz' arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = wrong_func settings = ciftify_clean_img.UserSettings(arguments) assert False
def test_exists_gracefully_if_input_is_gifti(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/func.L.func.gii' with pytest.raises(SystemExit): settings = ciftify_clean_img.UserSettings(arguments)
def test_dtseries_input_returned(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/myfunc.dtseries.nii' settings = ciftify_clean_img.UserSettings(arguments) assert settings.func.type == "cifti" assert settings.func.path == '/path/to/input/myfunc.dtseries.nii'
def test_list_arg_returns_list_for_one_item(self, mock_readable, mock_writable, mock_pdread): arguments = copy.deepcopy(self.docopt_args) arguments['--cf-cols'] = 'one' arguments['--confounds-tsv'] = '/path/to/confounds.tsv' settings = ciftify_clean_img.UserSettings(arguments) assert settings.cf_cols == ['one']
def test_exits_when_confounds_tsv_not_given(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['--cf-cols'] = 'one,two,three' arguments['--confounds-tsv'] = None with pytest.raises(SystemExit): settings = ciftify_clean_img.UserSettings(arguments)
def test_fwhm_is_0_if_not_smoothing(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/myfunc.nii.gz' arguments['--smooth-fwhm'] = None settings = ciftify_clean_img.UserSettings(arguments) assert settings.smooth.fwhm == 0
def test_proper_output_returned_for_nifti(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/myfunc.nii.gz' arguments['--smooth-fwhm'] = 8 settings = ciftify_clean_img.UserSettings(arguments) assert settings.output_func == '/path/to/input/myfunc_clean_s8.nii.gz'
def test_that_updated_arg_is_present(self, mock_readable, mock_writable, mock_json): arguments = copy.deepcopy(self.docopt_args) arguments['--clean-config'] = self.json_config settings = ciftify_clean_img.UserSettings(arguments) assert settings.high_pass == 0.01, "high_pass not set to config val" assert settings.detrend == True, "detrend not set to config val"
def test_exists_gracefully_if_surfaces_not_present(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/myfunc.dtseries.nii' arguments['--smooth-fwhm'] = 8 arguments['--left-surface'] = None with pytest.raises(SystemExit): settings = ciftify_clean_img.UserSettings(arguments)
def test_exist_gracefully_if_json_not_readable(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) arguments['<func_input>'] = '/path/to/input/func.nii.gz' missing_json = '/wrong/path/missing.json' arguments['--clean-config'] = missing_json with pytest.raises(SystemExit): settings = ciftify_clean_img.UserSettings(arguments)
def test_bandpass_filter_returns_none_if_none(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) settings = ciftify_clean_img.UserSettings(arguments) assert settings.high_pass == None
def test_list_arg_returns_empty_list_for_none(self, mock_readable, mock_writable): arguments = copy.deepcopy(self.docopt_args) settings = ciftify_clean_img.UserSettings(arguments) assert settings.cf_cols == []