Skip to content

Commit

Permalink
Bug nopriors (#264)
Browse files Browse the repository at this point in the history
* if "use_priors" in params["segment_atropos_pipe"].keys():

* post_pat

* post_pat
  • Loading branch information
davidmeunier79 authored Sep 25, 2024
1 parent 7460d22 commit f64fd2c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
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

0 comments on commit f64fd2c

Please sign in to comment.