diff --git a/tedana/tests/test_integration.py b/tedana/tests/test_integration.py index 51d111000..4a050deaa 100644 --- a/tedana/tests/test_integration.py +++ b/tedana/tests/test_integration.py @@ -72,14 +72,20 @@ def download_test_data(osf, outpath): def test_integration_five_echo(skip_integration): - """Integration test of the full tedana workflow using five-echo test data""" + """Integration test of the full tedana workflow using five-echo test data.""" if skip_integration: pytest.skip("Skipping five-echo integration test") + out_dir = "/tmp/data/five-echo/TED.five-echo" + out_dir_manual = "/tmp/data/five-echo/TED.five-echo-manual" + if os.path.exists(out_dir): shutil.rmtree(out_dir) + if os.path.exists(out_dir_manual): + shutil.rmtree(out_dir_manual) + # download data and run the test download_test_data("https://osf.io/9c42e/download", os.path.dirname(out_dir)) prepend = "/tmp/data/five-echo/p06.SBJ01_S09_Task11_e" @@ -103,8 +109,7 @@ def test_integration_five_echo(skip_integration): assert isinstance(df, pd.DataFrame) # Test re-running, but use the CLI - out_dir2 = "/tmp/data/five-echo/TED.five-echo-manual" - acc_comps = df.loc[df["classification"] == "accepted"].index.values + acc_comps = df.loc[df["classification"] == "ignored"].index.values acc_comps = [str(c) for c in acc_comps] mixing = os.path.join(out_dir, "desc-ICA_mixing.tsv") t2smap = os.path.join(out_dir, "T2starmap.nii.gz") @@ -115,7 +120,7 @@ def test_integration_five_echo(skip_integration): + [str(te) for te in echo_times] + [ "--out-dir", - out_dir2, + out_dir_manual, "--debug", "--verbose", "--manacc", @@ -140,10 +145,16 @@ def test_integration_four_echo(skip_integration): if skip_integration: pytest.skip("Skipping four-echo integration test") + out_dir = "/tmp/data/four-echo/TED.four-echo" + out_dir_manual = "/tmp/data/four-echo/TED.four-echo-manual" + if os.path.exists(out_dir): shutil.rmtree(out_dir) + if os.path.exists(out_dir_manual): + shutil.rmtree(out_dir_manual) + # download data and run the test download_test_data("https://osf.io/gnj73/download", os.path.dirname(out_dir)) prepend = "/tmp/data/four-echo/" @@ -161,8 +172,30 @@ def test_integration_four_echo(skip_integration): verbose=True, ) + # Test re-running with the component table + mixing_matrix = os.path.join(out_dir, "desc-ICA_mixing.tsv") + comptable = os.path.join(out_dir, "desc-tedana_metrics.tsv") + temporary_comptable = os.path.join(out_dir, "temporary_metrics.tsv") + comptable_df = pd.read_table(comptable) + comptable_df.loc[comptable_df["classification"] == "ignored", "classification"] = "accepted" + comptable_df.to_csv(temporary_comptable, sep="\t", index=False) + tedana_cli.tedana_workflow( + data=datalist, + tes=[11.8, 28.04, 44.28, 60.52], + out_dir=out_dir_manual, + tedpca="kundu-stabilize", + gscontrol=["gsr", "mir"], + png_cmap="bone", + mixm=mixing_matrix, + ctab=temporary_comptable, + debug=True, + verbose=False, + ) + os.remove(temporary_comptable) + # compare the generated output files fn = resource_filename("tedana", "tests/data/fiu_four_echo_outputs.txt") + check_integration_outputs(fn, out_dir) @@ -171,11 +204,16 @@ def test_integration_three_echo(skip_integration): if skip_integration: pytest.skip("Skipping three-echo integration test") + out_dir = "/tmp/data/three-echo/TED.three-echo" - out_dir2 = "/tmp/data/three-echo/TED.three-echo-rerun" + out_dir_manual = "/tmp/data/three-echo/TED.three-echo-rerun" + if os.path.exists(out_dir): shutil.rmtree(out_dir) + if os.path.exists(out_dir_manual): + shutil.rmtree(out_dir_manual) + # download data and run the test download_test_data("https://osf.io/rqhfc/download", os.path.dirname(out_dir)) tedana_cli.tedana_workflow( @@ -195,7 +233,7 @@ def test_integration_three_echo(skip_integration): "38.5", "62.5", "--out-dir", - out_dir2, + out_dir_manual, "--debug", "--verbose", "--ctab", diff --git a/tedana/workflows/tedana.py b/tedana/workflows/tedana.py index 91c1a1a85..d24fc9112 100644 --- a/tedana/workflows/tedana.py +++ b/tedana/workflows/tedana.py @@ -736,6 +736,7 @@ def tedana_workflow( ) comptable, metric_metadata = selection.kundu_selection_v2(comptable, n_echos, n_vols) else: + LGR.info("Using supplied component table for classification") comptable = pd.read_table(ctab) # Change rationale value of rows with NaN to empty strings comptable.loc[comptable.rationale.isna(), "rationale"] = ""