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

Add multi run support #26

Merged
merged 5 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
25 changes: 19 additions & 6 deletions petdeface/petdeface.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,24 @@ def init_single_subject_wf(
ses_id = ""
pet_string = f"sub-{subject_id}"

pet_wf_name = f"pet_{pet_string}_wf"
# collect run info from pet file
try:
run_id = "_" + re.search("run-[^_|\/]*", str(pet_file)).group(0)
except AttributeError:
run_id = ""
pet_wf_name = f"pet_{pet_string}{run_id}_wf"
pet_wf = Workflow(name=pet_wf_name)

weighted_average = Node(
WeightedAverage(pet_file=pet_file), name="weighted_average"
)

coreg_pet_to_t1w = Node(
MRICoreg(reference_file=t1w_file), name="coreg_pet_to_t1w"
)
# rename registration file to something more descriptive than registration.lta
# we do this here to account for mulitple runs during the same session
mricoreg = MRICoreg(reference_file=t1w_file)
bendhouseart marked this conversation as resolved.
Show resolved Hide resolved
mricoreg.inputs.out_lta_file = f"{pet_string}{run_id}_desc-pet2anat_pet.lta"

coreg_pet_to_t1w = Node(mricoreg, "coreg_pet_to_t1w")

deface_pet = Node(ApplyMideface(in_file=pet_file), name="deface_pet")

Expand All @@ -323,12 +331,17 @@ def init_single_subject_wf(
(
coreg_pet_to_t1w,
datasink,
[("out_lta_file", f"{pet_string.replace('_', '.')}.pet")],
[("out_lta_file", f"{pet_string.replace('_', '.')}.pet.@{run_id}")],
),
(
deface_pet,
datasink,
[("out_file", f"{pet_string.replace('_', '.')}.pet.@defaced")],
[
(
"out_file",
f"{pet_string.replace('_', '.')}.pet.@defaced{run_id}",
)
],
),
]
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "petdeface"
version = "0.0.1"
version = "0.0.2"
description = "A nipype PET and MR defacing pipeline for BIDS datasets utilizing FreeSurfer's MiDeFace."
authors = ["Martin Nørgaard <martin.noergaard@nru.dk>", "Anthony Galassi <28850131+bendhouseart@users.noreply.github.com>", "Murat Bilgel <bilgelm@gmail.com>"]
license = "MIT"
Expand Down