diff --git a/fitlins/cli/run.py b/fitlins/cli/run.py index 2143f71c..23480f7f 100755 --- a/fitlins/cli/run.py +++ b/fitlins/cli/run.py @@ -261,6 +261,7 @@ def get_parser(): def run_fitlins(argv=None): import re + import nipype from nipype import logging as nlogging warnings.showwarning = _warn_redirect @@ -279,6 +280,9 @@ def run_fitlins(argv=None): for ign in opts.ignore or () ] + if opts.debug: + nipype.config.set('execution', 'remove_unnecessary_outputs', False) + log_level = 25 + 5 * (opts.quiet - opts.verbose) logger.setLevel(log_level) nlogging.getLogger('nipype.workflow').setLevel(log_level) diff --git a/fitlins/conftest.py b/fitlins/conftest.py index f2ef9586..64769714 100644 --- a/fitlins/conftest.py +++ b/fitlins/conftest.py @@ -42,7 +42,7 @@ def sample_model_dict(): }, "Model": {"X": ["trial_type.ice_cream", "trial_type.cake", "food_sweats"]}, "DummyContrasts": { - "Conditions": ["trial_type.ice_cream", "trial_type.cake"], + "Contrasts": ["trial_type.ice_cream", "trial_type.cake"], "Test": "t", }, "Contrasts": [ @@ -69,13 +69,16 @@ def sample_model_dict(): }, { "Level": "dataset", - "Name": "all_food_good_food", + "Name": "dataset", "GroupBy": ["contrast"], - "Model": {"X": [1]}, - "DummyContrasts": { - "Conditions": ["icecream_gt_cake", "eating_vs_baseline"], - "Test": "t", - }, + "Model": {"X": [1], "Type": "glm"}, + "DummyContrasts": {"Test": "t"}, + }, + { + "Level": "dataset", + "Name": "all_food_good_food", + "GroupBy": [], + "Model": {"X": ["trial_type.ice_cream", "trial_type.cake"], "Type": "glm"}, "Contrasts": [ { "Name": "all_food_good_food", @@ -90,9 +93,14 @@ def sample_model_dict(): {"Source": "run", "Destination": "subject"}, { "Source": "subject", - "Destination": "all_food_good_food", + "Destination": "dataset", "Filter": {"contrast": ["icecream_gt_cake", "eating_vs_baseline"]}, }, + { + "Source": "subject", + "Destination": "all_food_good_food", + "Filter": {"contrast": ["trial_type.ice_cream", "trial_type.cake"]}, + }, ], } diff --git a/fitlins/interfaces/afni.py b/fitlins/interfaces/afni.py index d152cfe3..2c1b954f 100644 --- a/fitlins/interfaces/afni.py +++ b/fitlins/interfaces/afni.py @@ -338,6 +338,8 @@ def save_tsnr(self, runtime, rbetas, rvars): # find the name of the constant column if 'constant' in mat.columns: const_name = 'constant' + elif 'intercept' in mat.columns: + const_name = 'intercept' else: const_name = mat.columns[np.isclose(mat, 1).all(0)].values[0] const_idx = np.where(np.array(vol_labels) == const_name)[0] diff --git a/fitlins/interfaces/nistats.py b/fitlins/interfaces/nistats.py index 8f15c585..773d7f5d 100644 --- a/fitlins/interfaces/nistats.py +++ b/fitlins/interfaces/nistats.py @@ -128,6 +128,13 @@ def _run_interface(self, runtime): add_reg_names=column_names, drift_model=drift_model, ) + # Can get two intercepts from input and nilearn ("constant") + # Normalize to "intercept" unless that exists and is really non-1 + # Force to be exactly 1, in case of weird rounding errors + intercept = 'intercept' in mat or 'constant' in mat + mat.drop(columns=['intercept', 'constant'], errors='ignore', inplace=True) + if intercept: + mat['intercept'] = np.ones(mat.shape[0], dtype='u1') mat.to_csv('design.tsv', sep='\t') self._results['design_matrix'] = os.path.join(runtime.cwd, 'design.tsv') diff --git a/fitlins/interfaces/visualizations.py b/fitlins/interfaces/visualizations.py index 53da000b..c0501bbb 100644 --- a/fitlins/interfaces/visualizations.py +++ b/fitlins/interfaces/visualizations.py @@ -115,7 +115,7 @@ def _visualize(self, data, out_name): plot_and_save( out_name, plot_corr_matrix, - data.drop(columns='constant', errors='ignore').corr(), + data.drop(columns=['intercept', 'constant'], errors='ignore').corr(), len(evs), ) diff --git a/setup.cfg b/setup.cfg index 01d07579..9c16e749 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,7 +29,7 @@ install_requires = nilearn~=0.9.1 pandas>=0.19 tables>=3.2.1 - pybids~=0.15.1 + pybids~=0.15.4 jinja2 [options.extras_require]