diff --git a/connPFM/cli/connPFM.py b/connPFM/cli/connPFM.py index c1ca61f..7081c29 100755 --- a/connPFM/cli/connPFM.py +++ b/connPFM/cli/connPFM.py @@ -218,4 +218,11 @@ def _get_parser(): help="Prefix for path and name for the beta and fitted files of the debiasing", default=None, ) + optoptions.add_argument( + "-pp", + "--peaks_points", + dest="peaks_path", + help="Prefix for name for txt file of rss and txt file of selected timepoints", + default=None, + ) return parser diff --git a/connPFM/connPFM.py b/connPFM/connPFM.py index 2d93664..023713d 100755 --- a/connPFM/connPFM.py +++ b/connPFM/connPFM.py @@ -74,6 +74,7 @@ def _main(argv=None): options["nsurrogates"][0], history_str, options["peak_detection"][0], + afni_text=options["peaks_path"], ) LGR.info("Perform debiasing based on edge-time matrix.") debiasing( @@ -115,6 +116,7 @@ def _main(argv=None): nsurrogates=options["nsurrogates"][0], history_str=history_str, peak_detection=options["peak_detection"][0], + afni_text=options["peaks_path"], ) elif selected_workflow == "debias": ets_auc_denoised = loadtxt(options["matrix"][0]) diff --git a/connPFM/connectivity/ev.py b/connPFM/connectivity/ev.py index bc2279d..ad97df7 100755 --- a/connPFM/connectivity/ev.py +++ b/connPFM/connectivity/ev.py @@ -221,9 +221,12 @@ def ev_workflow( # Save RSS time-series as text file for easier visualization on AFNI if afni_text is not None: - rss_out = np.zeros(rss_auc.shape) - rss_out[idxpeak_auc] = rss_auc[idxpeak_auc] - np.savetxt(afni_text, rss_out) + np.savetxt(join(out_dir, afni_text) + "_peaks.txt", idxpeak_auc) + if peak_detection == "rss": + rss_out = np.zeros(rss_auc.shape) + rss_out[idxpeak_auc] = rss_auc[idxpeak_auc] + np.savetxt(join(out_dir, afni_text) + "_rss.txt", rss_auc) + np.savetxt(join(out_dir, afni_text) + "_rss_th.txt", rss_out) np.savetxt(matrix, ets_auc_denoised) diff --git a/connPFM/tests/conftest.py b/connPFM/tests/conftest.py index 410498e..1a2be79 100644 --- a/connPFM/tests/conftest.py +++ b/connPFM/tests/conftest.py @@ -160,3 +160,8 @@ def surrogate_ets_file(testpath): @pytest.fixture def surrogate_hist_file(testpath): return fetch_file("3b6ge", testpath, "surrogate_hist.npy") + + +@pytest.fixture +def ets_rss_thr_file(testpath): + return fetch_file("gn8x5", testpath, "ets_AUC_denoised_rss_th.txt") diff --git a/connPFM/tests/test_integration.py b/connPFM/tests/test_integration.py index 4416777..63d0320 100644 --- a/connPFM/tests/test_integration.py +++ b/connPFM/tests/test_integration.py @@ -30,24 +30,35 @@ def test_integration_pfm(testpath, bold_file, atlas_1roi, AUC_file, skip_integra def test_integration_ev( - testpath, bold_file, atlas_file, AUC_file, ets_auc_denoised_file, surr_dir, skip_integration + testpath, + bold_file, + atlas_file, + AUC_file, + ets_auc_denoised_file, + surr_dir, + skip_integration, + ets_rss_thr_file, ): if skip_integration: pytest.skip("Skipping integration test") subprocess.call( - "connPFM -i {} -a {} --AUC {} -d {} -m {} -tr 1 -u vferrer -nsur 50 -w ev".format( + "connPFM -i {} -a {} --AUC {} -d {} -m {} ".format( bold_file, atlas_file, AUC_file, surr_dir, join(dirname(AUC_file), "ets_AUC_denoised.txt"), - ), + ) + + "--peaks_points ets_AUC_denoised -tr 1 -u vferrer -nsur 50 -w ev", shell=True, ) ets_auc_denoised_local = np.loadtxt(join(dirname(AUC_file), "ets_AUC_denoised.txt")) ets_auc_osf = np.loadtxt(join(ets_auc_denoised_file)) + rss_out_local = np.loadtxt(join(testpath, "ets_AUC_denoised_rss_th.txt")) + rss_out_osf = np.loadtxt(ets_rss_thr_file) np.allclose(ets_auc_denoised_local, ets_auc_osf) + np.allclose(rss_out_local, rss_out_osf) def test_integration_debias(