Skip to content

Commit

Permalink
Merge pull request #39 from vinferrer/deb_out
Browse files Browse the repository at this point in the history
Deb output
  • Loading branch information
vinferrer authored Dec 8, 2021
2 parents acda4c6 + fc8c63f commit 7ca2ade
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
7 changes: 7 additions & 0 deletions connPFM/cli/connPFM.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,11 @@ def _get_parser():
help="activate quiet logger mode",
default=False,
)
optoptions.add_argument(
"-pd",
"--prefix_debias",
dest="prefix",
help="Prefix for path and name for the beta and fitted files of the debiasing",
default=None,
)
return parser
6 changes: 4 additions & 2 deletions connPFM/connPFM.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def _main(argv=None):
options["atlas"][0],
ets_auc_denoised,
options["tr"][0],
os.path.dirname(options["auc"][0]),
os.path.dirname(options["data"][0]),
options["prefix"],
history_str,
)
elif selected_workflow == "pfm":
Expand Down Expand Up @@ -120,7 +121,8 @@ def _main(argv=None):
options["atlas"][0],
ets_auc_denoised,
options["tr"][0],
os.path.dirname(options["auc"][0]),
os.path.dirname(options["data"][0]),
options["prefix"],
history_str,
)
else:
Expand Down
12 changes: 6 additions & 6 deletions connPFM/debiasing/debiasing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Main debiasing workflow."""
import logging
import subprocess
from os.path import basename, join
from os.path import join

import numpy as np
from nilearn.input_data import NiftiLabelsMasker
Expand All @@ -13,7 +13,7 @@
LGR = logging.getLogger(__name__)


def debiasing(data_file, mask, mtx, tr, out_dir, history_str):
def debiasing(data_file, mask, mtx, tr, out_dir, prefix, history_str):
"""Perform debiasing based on denoised edge-time matrix."""
LGR.info("Performing debiasing based on denoised edge-time matrix...")
masker = NiftiLabelsMasker(
Expand Down Expand Up @@ -59,15 +59,15 @@ def debiasing(data_file, mask, mtx, tr, out_dir, history_str):

# Transform results back to 4D
beta_4D = masker.inverse_transform(beta)
beta_file = join(out_dir, f"{basename(data_file[:-7])}_beta_ETS.nii.gz")
beta_file = join(out_dir, f"{prefix}_beta_ETS.nii.gz")
beta_4D.to_filename(beta_file)
atlas_mod.inverse_transform(beta_file, data_file)
subprocess.run(f"3dNotes {join(out_dir, beta_file)} -h {history_str}", shell=True)
subprocess.run(f"3dNotes {beta_file} -h {history_str}", shell=True)

fitt_4D = masker.inverse_transform(fitt)
fitt_file = join(out_dir, f"{basename(data_file[:-7])}_fitt_ETS.nii.gz")
fitt_file = join(out_dir, f"{prefix}_fitt_ETS.nii.gz")
fitt_4D.to_filename(fitt_file)
subprocess.run(f"3dNotes {join(out_dir, fitt_file)} -h {history_str}", shell=True)
subprocess.run(f"3dNotes {fitt_file} -h {history_str}", shell=True)
atlas_mod.inverse_transform(fitt_file, data_file)

LGR.info("Debiasing finished and files saved.")
Expand Down
12 changes: 9 additions & 3 deletions connPFM/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ def test_integration_debias(
if skip_integration:
pytest.skip("Skipping integration test")
subprocess.call(
"connPFM -i {} -a {} --AUC {} -d {} -m {} -tr 1 -u vferrer -nsur 50 -w debias".format(
bold_file, atlas_file, AUC_file, surr_dir, ets_auc_denoised_file
),
"connPFM -i {} -a {} --AUC {} -d {} -m {} --prefix {} ".format(
bold_file,
atlas_file,
AUC_file,
surr_dir,
ets_auc_denoised_file,
f"{basename(bold_file[:-7])}",
)
+ "-tr 1 -u vferrer -nsur 50 -w debias",
shell=True,
)
masker = NiftiLabelsMasker(
Expand Down

0 comments on commit 7ca2ade

Please sign in to comment.