Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output rss and peak timepoints as txt #47

Merged
merged 10 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions connPFM/cli/connPFM.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions connPFM/connPFM.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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])
Expand Down
9 changes: 6 additions & 3 deletions connPFM/connectivity/ev.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
vinferrer marked this conversation as resolved.
Show resolved Hide resolved
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)

Expand Down
5 changes: 5 additions & 0 deletions connPFM/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
17 changes: 14 additions & 3 deletions connPFM/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down