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

Bug nopriors #264

Merged
merged 3 commits into from
Sep 25, 2024
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
19 changes: 11 additions & 8 deletions macapype/pipelines/full_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,14 +638,17 @@ def create_brain_segment_from_mask_pipe(
segment_atropos_pipe = create_segment_atropos_seg_pipe(
params=parse_key(params, "segment_atropos_pipe"))

if "register_NMT_pipe" in params:
brain_segment_pipe.connect(
register_NMT_pipe, 'outputnode.native_template_seg',
segment_atropos_pipe, "inputnode.seg_file")
elif "reg" in params:
brain_segment_pipe.connect(
register_seg_to_nat, 'out_file',
segment_atropos_pipe, "inputnode.seg_file")
# linking priors if "use_priors" in params
if "use_priors" in params["segment_atropos_pipe"].keys():

if "register_NMT_pipe" in params:
brain_segment_pipe.connect(
register_NMT_pipe, 'outputnode.native_template_seg',
segment_atropos_pipe, "inputnode.seg_file")
elif "reg" in params:
brain_segment_pipe.connect(
register_seg_to_nat, 'out_file',
segment_atropos_pipe, "inputnode.seg_file")
else:
print("#### create_segment_atropos_pipe (3 tissues) ")

Expand Down
44 changes: 23 additions & 21 deletions macapype/pipelines/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def create_segment_atropos_seg_pipe(params={}, name="segment_atropos_pipe"):

# merging probseg
for tissue, index_tissue in tissue_dict.items():

if "use_priors" in params.keys():
post_pat = "SegmentationPosteriors{:02d}"
else:
post_pat = "SegmentationPosteriors{}"

if isinstance(index_tissue, list):

# Merging as file list
Expand All @@ -182,7 +188,7 @@ def create_segment_atropos_seg_pipe(params={}, name="segment_atropos_pipe"):
segment_pipe.connect(
seg_at,
('segmented_files', get_pattern,
"SegmentationPosteriors{:02d}".format(
post_pat.format(
int(sub_index_tissue))),
merge_list, 'in' + str(index+1))

Expand All @@ -207,7 +213,7 @@ def create_segment_atropos_seg_pipe(params={}, name="segment_atropos_pipe"):
segment_pipe.connect(
seg_at,
('segmented_files', get_pattern,
"SegmentationPosteriors{:02d}".format(int(index_tissue))),
post_pat.format(int(index_tissue))),
outputnode, 'prob_'+tissue)

return segment_pipe
Expand Down Expand Up @@ -444,6 +450,12 @@ def create_segment_atropos_pipe(params={}, name="segment_atropos_pipe"):

# merging probseg
for tissue, index_tissue in tissue_dict.items():

if "use_priors" in params.keys():
post_pat = "SegmentationPosteriors{:02d}"
else:
post_pat = "SegmentationPosteriors{}"

if isinstance(index_tissue, list):

# Merging as file list
Expand All @@ -453,9 +465,9 @@ def create_segment_atropos_pipe(params={}, name="segment_atropos_pipe"):
for index, sub_index_tissue in enumerate(index_tissue):
segment_pipe.connect(
seg_at,
('segmented_files', get_pattern,
"SegmentationPosteriors{:02d}".format(
int(sub_index_tissue))),
('segmented_files',
get_pattern,
post_pat.format(int(sub_index_tissue))),
merge_list, 'in' + str(index+1))

# Merging files in the same nifti
Expand All @@ -475,22 +487,12 @@ def create_segment_atropos_pipe(params={}, name="segment_atropos_pipe"):

else:

if "use_priors" in params.keys():

# prob output
segment_pipe.connect(
seg_at,
('segmented_files', get_pattern,
"SegmentationPosteriors{:02d}".format(int(index_tissue))),
outputnode, 'prob_'+tissue)
else:

# prob output
segment_pipe.connect(
seg_at,
('segmented_files', get_pattern,
"SegmentationPosteriors{}".format(int(index_tissue))),
outputnode, 'prob_'+tissue)
# prob output
segment_pipe.connect(
seg_at,
('segmented_files', get_pattern,
post_pat.format(int(index_tissue))),
outputnode, 'prob_'+tissue)

return segment_pipe

Expand Down
Loading