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

4TQ6 reproduction - improvement #204

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
37 changes: 25 additions & 12 deletions narps_open/pipelines/team_4TQ6.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FSLCommand, Randomise
)
from nipype.algorithms.modelgen import SpecifyModel
from nipype.interfaces.fsl.maths import MultiImageMaths
from nipype.interfaces.fsl.maths import MultiImageMaths, MathsCommand

from narps_open.utils.configuration import Configuration
from narps_open.pipelines import Pipeline
Expand Down Expand Up @@ -429,6 +429,19 @@ def get_group_level_analysis_sub_workflow(self, method):
)
group_level.connect(select_files, 'cope', get_copes, 'input_str')

# Function Node elements_in_string
# Get masks for these subjects
# Note : using a MapNode with elements_in_string requires using clean_list to remove
# None values from the out_list
get_masks = MapNode(Function(
function = elements_in_string,
input_names = ['input_str', 'elements'],
output_names = ['out_list']
),
name = 'get_masks', iterfield = 'input_str'
)
group_level.connect(select_files, 'masks', get_masks, 'input_str')

# Function Node elements_in_string
# Get variance of the estimated copes (varcope) for these subjects
# Note : using a MapNode with elements_in_string requires using clean_list to remove
Expand All @@ -452,18 +465,16 @@ def get_group_level_analysis_sub_workflow(self, method):
merge_varcopes.inputs.dimension = 't'
group_level.connect(get_varcopes, ('out_list', clean_list), merge_varcopes, 'in_files')

# Split Node - Split mask list to serve them as inputs of the MultiImageMaths node.
split_masks = Node(Split(), name = 'split_masks')
split_masks.inputs.splits = [1, len(self.subject_list) - 1]
split_masks.inputs.squeeze = True # Unfold one-element splits removing the list
group_level.connect(select_files, 'masks', split_masks, 'inlist')
# Merge Node - Merge masks for further intersection
merge_masks = Node(Merge(), name = 'merge_masks')
merge_masks.inputs.dimension = 't'
group_level.connect(get_masks, ('out_list', clean_list), merge_masks, 'in_files')

# MultiImageMaths Node - Create a subject mask by
# computing the intersection of all run masks.
mask_intersection = Node(MultiImageMaths(), name = 'mask_intersection')
mask_intersection.inputs.op_string = '-mul %s ' * (len(self.subject_list) - 1)
group_level.connect(split_masks, 'out1', mask_intersection, 'in_file')
group_level.connect(split_masks, 'out2', mask_intersection, 'operand_files')
# MathsCommand Node - Create a group mask by
# computing the intersection of all subject masks.
mask_intersection = Node(MathsCommand(), name = 'mask_intersection')
mask_intersection.inputs.args = '-Tmin -thr 0.9'
group_level.connect(merge_masks, 'merged_file', mask_intersection, 'in_file')

# MultipleRegressDesign Node - Specify model
specify_model = Node(MultipleRegressDesign(), name = 'specify_model')
Expand Down Expand Up @@ -519,6 +530,7 @@ def get_group_level_analysis_sub_workflow(self, method):
get_group_subjects.inputs.list_2 = self.subject_list
group_level.connect(get_group_subjects, 'out_list', get_copes, 'elements')
group_level.connect(get_group_subjects, 'out_list', get_varcopes, 'elements')
group_level.connect(get_group_subjects, 'out_list', get_masks, 'elements')

# Function Node get_one_sample_t_test_regressors
# Get regressors in the equalRange and equalIndifference method case
Expand All @@ -539,6 +551,7 @@ def get_group_level_analysis_sub_workflow(self, method):
# Indeed the SelectFiles node asks for all (*) subjects available
get_copes.inputs.elements = self.subject_list
get_varcopes.inputs.elements = self.subject_list
get_masks.inputs.elements = self.subject_list

# Setup a two sample t-test
specify_model.inputs.contrasts = [
Expand Down
Loading