Skip to content

Commit

Permalink
Removed get_contrasts method to write run level contrasts as class at…
Browse files Browse the repository at this point in the history
…tributes instead [skip ci]
  • Loading branch information
bclenet committed Nov 17, 2023
1 parent 3d96719 commit ae6178e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
32 changes: 5 additions & 27 deletions narps_open/pipelines/team_T54A.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def __init__(self):
self.fwhm = 4.0
self.team_id = 'T54A'
self.contrast_list = ['1', '2']
self.run_level_contrasts = [
('gain', 'T', ['trial', 'gain', 'loss'], [0, 1, 0]),
('loss', 'T', ['trial', 'gain', 'loss'], [0, 0, 1])
]

def get_preprocessing(self):
""" No preprocessing has been done by team T54A """
Expand Down Expand Up @@ -138,25 +142,6 @@ def get_parameters_file(filepath, subject_id, run_id, working_dir):

return parameters_file

def get_run_level_contrasts():
"""
Create a list of tuples that represent contrasts.
Each contrast is in the form :
(Name,Stat,[list of condition names],[weights on those conditions])
Returns:
- contrasts: list of tuples, list of contrasts to analyze
"""
# List of condition names
conditions = ['trial', 'gain', 'loss']

# Create contrasts
gain = ('gain', 'T', conditions, [0, 1, 0])
loss = ('loss', 'T', conditions, [0, 0, 1])

# Contrast list
return [gain, loss]

def remove_smoothed_files(_, subject_id, run_id, working_dir):
"""
This method is used in a Function node to fully remove
Expand Down Expand Up @@ -240,13 +225,6 @@ def get_run_level_analysis(self):
specify_model.inputs.input_units = 'secs'
specify_model.inputs.time_repetition = TaskInformation()['RepetitionTime']

# Funcion Node get_run_level_contrasts - Get the list of contrasts
contrasts = Node(Function(
function = self.get_run_level_contrasts,
input_names = [],
output_names = ['contrasts']
), name = 'contrasts')

# Function Node get_parameters_file - Get files with movement parameters
parameters = Node(Function(
function = self.get_parameters_file,
Expand All @@ -260,6 +238,7 @@ def get_run_level_analysis(self):
model_design.inputs.bases = {'dgamma':{'derivs' : True}}
model_design.inputs.interscan_interval = TaskInformation()['RepetitionTime']
model_design.inputs.model_serial_correlations = True
model_design.inputs.contrasts = self.run_level_contrasts

# FEATModel Node - Generate run level model
model_generation = Node(FEATModel(), name = 'model_generation')
Expand Down Expand Up @@ -293,7 +272,6 @@ def get_run_level_analysis(self):
(parameters, specify_model, [('parameters_file', 'realignment_parameters')]),
(smoothing_func, specify_model, [('out_file', 'functional_runs')]),
(subject_information, specify_model, [('subject_info', 'subject_info')]),
(contrasts, model_design, [('contrasts', 'contrasts')]),
(specify_model, model_design, [('session_info', 'session_info')]),
(model_design, model_generation, [
('ev_files', 'ev_files'),
Expand Down
16 changes: 5 additions & 11 deletions tests/pipelines/test_team_T54A.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def test_create():
# 1 - check the parameters
assert pipeline.fwhm == 4.0
assert pipeline.team_id == 'T54A'
assert pipeline.contrast_list == ['1', '2']
assert pipeline.run_level_contrasts == [
('gain', 'T', ['trial', 'gain', 'loss'], [0, 1, 0]),
('loss', 'T', ['trial', 'gain', 'loss'], [0, 0, 1])
]

# 2 - check workflows
assert pipeline.get_preprocessing() is None
Expand Down Expand Up @@ -120,17 +125,6 @@ def test_subject_information(mocker):
def test_parameters_file(mocker):
""" Test the get_parameters_file method """



@staticmethod
@mark.unit_test
def test_run_level_contrasts():
""" Test the get_run_level_contrasts method """

contrasts = PipelineTeamT54A.get_run_level_contrasts()
assert contrasts[0] == ('gain', 'T', ['trial', 'gain', 'loss'], [0, 1, 0])
assert contrasts[1] == ('loss', 'T', ['trial', 'gain', 'loss'], [0, 0, 1])

@staticmethod
@mark.unit_test
def test_subgroups_contrasts(mocker):
Expand Down

0 comments on commit ae6178e

Please sign in to comment.