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

51PW reproduction #134

Merged
merged 154 commits into from
Feb 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
6986e90
[BUG] inside unit_tests workflow
bclenet Aug 31, 2023
d6e67f3
Merge branch 'Inria-Empenn:main' into main
bclenet Aug 31, 2023
c3bfc53
Merge branch 'Inria-Empenn:main' into main
bclenet Sep 4, 2023
4b30504
Merge branch 'Inria-Empenn:main' into main
bclenet Sep 19, 2023
fd15ffc
Merge branch 'Inria-Empenn:main' into main
bclenet Sep 21, 2023
6ebe5d2
Merge branch 'Inria-Empenn:main' into main
bclenet Sep 29, 2023
0a584dd
Merge branch 'Inria-Empenn:main' into main
bclenet Sep 29, 2023
e284b80
Merge branch 'Inria-Empenn:main' into main
bclenet Sep 29, 2023
5774813
Merge branch 'Inria-Empenn:main' into main
bclenet Oct 5, 2023
8f12d3d
Merge branch 'Inria-Empenn:main' into main
bclenet Oct 5, 2023
7fde1e1
[08MQ] Preprocessing script in progress
bclenet Oct 6, 2023
2b07afc
Working on preprocessing
bclenet Oct 9, 2023
a454652
Codespell
bclenet Oct 9, 2023
aca4896
Working on pipeline 08MQ
bclenet Oct 10, 2023
91dc744
Merge branch 'Inria-Empenn:main' into main
bclenet Oct 10, 2023
8b48823
Towards a running version of the pipeline
bclenet Oct 11, 2023
ecec8c2
Conforming to Pipeline class + init test module
bclenet Oct 11, 2023
c8db382
Merge branch 'main' into 08MQ_reproduction
bclenet Oct 11, 2023
632f4ef
Towards a running version of the pipeline
bclenet Oct 11, 2023
0e97a61
Towards a running version of the pipeline
bclenet Oct 11, 2023
d3dcc00
Towards a running version of the pipeline
bclenet Oct 13, 2023
988e536
[TEST] runner test not using 08MQ as example anymore
bclenet Oct 13, 2023
ffcdf6e
Issue with SelectFiles' base_directory
bclenet Oct 13, 2023
04d835e
Towards a running version of the pipeline
bclenet Oct 13, 2023
7525309
[TEST] stop using 08MQ in tests
bclenet Oct 13, 2023
da82396
08MQ preprocessing instantiable
bclenet Oct 16, 2023
8fd2195
Compute confounds node
bclenet Oct 17, 2023
9a63118
Group analysis workflow bug
bclenet Oct 17, 2023
95fe702
Group analysis workflow bug
bclenet Oct 17, 2023
1ac7267
Group analysis workflow bug
bclenet Oct 17, 2023
ecc4977
Issue with Registration and Threshold
bclenet Oct 17, 2023
d2cd3e4
Bug with shrink factors
bclenet Oct 17, 2023
0f186a8
Bug with shrink factors
bclenet Oct 17, 2023
2c73712
Bug with shrink factors
bclenet Oct 17, 2023
8dba3d3
ANTs registration [skip ci]
bclenet Oct 18, 2023
7371a95
Testing parameters for antsRegistration [skip ci]
bclenet Oct 18, 2023
82c4f0a
Inverse coregistration transform [skip ci]
bclenet Oct 20, 2023
6495767
Inverse coregistration transform [skip ci]
bclenet Oct 20, 2023
818de15
Compute confounds parameterization [skip ci]
bclenet Oct 20, 2023
735d2f7
ANTs composite transform [skip ci]
bclenet Oct 20, 2023
a1eb020
Trying ANTs' ApplyTransforms
bclenet Oct 23, 2023
3f61b5d
Preprocessing outputs [skip ci]
bclenet Oct 23, 2023
09111a5
Preprocessing outputs [skip ci]
bclenet Oct 23, 2023
cde9f37
Add smoothing [skip ci]
bclenet Oct 23, 2023
098de9f
Motion correction outputs [skip ci]
bclenet Oct 23, 2023
a335fd6
Parse segmentation maps [skip ci]
bclenet Oct 23, 2023
7579d53
Use partial volume files from segmentation [skip ci]
bclenet Oct 23, 2023
d26e188
Use partial volume files from segmentation [skip ci]
bclenet Oct 23, 2023
23d3af9
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
6dfc51f
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
4adfe43
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
af08110
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
dbfed24
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
d2951b3
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
1e46ec0
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
3fe4ca2
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
72635b1
First try of run level analysis [skip ci]
bclenet Oct 23, 2023
4c62bf2
ANT's apply transform bug [skip ci]
bclenet Oct 23, 2023
e7217da
ANT's apply transform bug [skip ci]
bclenet Oct 23, 2023
e029f37
ANT's apply transform bug [skip ci]
bclenet Oct 24, 2023
e8f475d
ANT's apply transform bug [skip ci]
bclenet Oct 24, 2023
04bdeba
ANT's apply transform bug [skip ci]
bclenet Oct 24, 2023
858004a
First try of run level analysis [skip ci]
bclenet Oct 24, 2023
b63a052
First try of run level analysis [skip ci]
bclenet Oct 24, 2023
8ba967f
First try of subject level analysis [skip ci]
bclenet Oct 24, 2023
d39fc44
First try of subject level analysis [skip ci]
bclenet Oct 24, 2023
98abcfc
FSL's Merge disambiguataion [skip ci]
bclenet Oct 24, 2023
77515c0
Use MNI masks [skip ci]
bclenet Oct 24, 2023
8d907cd
Preprocessing sieable files removing
bclenet Oct 24, 2023
1ea7e12
Bug with contrasts Node naming
bclenet Oct 24, 2023
e79239f
Base directories
bclenet Oct 25, 2023
4dad129
Remove alignment_func_to_mni's output [skip ci]
bclenet Oct 25, 2023
26ddc3a
Autoremove intermediate results [skip ci]
bclenet Oct 25, 2023
bedc2b5
Autoremove intermediate results [skip ci]
bclenet Oct 25, 2023
fa2ebd7
Revert "Remove alignment_func_to_mni's output [skip ci]"
bclenet Oct 25, 2023
7832af2
Bug after revert [skip ci]
bclenet Oct 25, 2023
c575158
Bug after revert [skip ci]
bclenet Oct 25, 2023
f6844a5
[TEST] tests updates
bclenet Oct 26, 2023
ed4f11e
Bug with big files removal
bclenet Oct 26, 2023
8770d81
Deletinglarge files after datasink
bclenet Oct 27, 2023
8992184
[BUG] group level workflow connections [skip ci]
bclenet Nov 15, 2023
f488a7b
[BUG] group level [skip ci]
bclenet Nov 15, 2023
d93e3a6
[REFAC] equalRange > equal_range [skip ci]
bclenet Nov 15, 2023
bd13c53
Regressors function + group output [skip ci]
bclenet Nov 15, 2023
0f8f35e
Typo in regressors [skip ci]
bclenet Nov 15, 2023
3025305
Issue with list of regressors [skip ci]
bclenet Nov 15, 2023
8d14472
Issue with list of regressors [skip ci]
bclenet Nov 15, 2023
817ec31
Issue with list of regressors [skip ci]
bclenet Nov 15, 2023
e092bc5
[TEST] adding unit tests to 08MQ [skip ci]
bclenet Nov 15, 2023
4892f5c
[TEST] typo [skip ci]
bclenet Nov 15, 2023
517fc41
[TEST] static methods testing [skip ci]
bclenet Nov 15, 2023
fd9bbf3
[TEST] adding unit tests for 08MQ
bclenet Nov 15, 2023
7252864
[CODESPELL] typos
bclenet Nov 15, 2023
68adef4
[BUG] inversion between groups [skip ci]
bclenet Nov 16, 2023
c03e9d1
Merge branch 'Inria-Empenn:main' into main
bclenet Nov 20, 2023
e7e9f48
Merge branch 'main' into 08MQ_reproduction
bclenet Nov 20, 2023
c6ae521
[REFAC] Using narps_open.core functions
bclenet Nov 20, 2023
7433106
[REFAC] using narps_open.core functions [TEST] events data in a file
bclenet Nov 20, 2023
053d72c
[BUG] remove_file input naming [skip ci]
bclenet Nov 21, 2023
34b649e
[BUG] remove sub- from participants id [skip ci]
bclenet Nov 22, 2023
9700166
[BUG] typo in get_two_sample_t_test_regressors inputs [skip ci]
bclenet Nov 22, 2023
fe0d25b
Merge branch 'Inria-Empenn:main' into main
bclenet Nov 22, 2023
04d5ff2
Merge branch 'Inria-Empenn:main' into main
bclenet Nov 22, 2023
8c73773
Compute brightness threshold for SUSAN [skip ci]
bclenet Nov 28, 2023
8e736f7
Use ANTs ApplyTransforms for alignment_func_to_anat Node [skip ci]
bclenet Nov 28, 2023
36e8fdd
[narps_open.core] adding list_to_file function [skip ci]
bclenet Nov 29, 2023
b979f1c
[08MQ] custom timings as input of SliceTimer [skip ci]
bclenet Nov 29, 2023
839e53d
Typo preprocessing
bclenet Nov 30, 2023
153e747
Computing masks : output of preprocessing [skip ci]
bclenet Dec 5, 2023
01bfb8e
Computing masks : output of preprocessing [skip ci]
bclenet Dec 5, 2023
9a16b06
Back to ApplyXFM, with no_resample option [skip ci]
bclenet Dec 5, 2023
502c206
Back to ApplyXFM, with no_resample option [skip ci]
bclenet Dec 5, 2023
8adcf86
Back to ApplyXFM, with no_resample option [skip ci]
bclenet Dec 5, 2023
eb8ae1c
Mask intersection of func as input of subject_level estimate model [s…
bclenet Dec 5, 2023
2789d44
Mask intersection of func as input of subject_level estimate model [s…
bclenet Dec 5, 2023
5e02694
Mask intersection in group_level analysis [skip ci]
bclenet Dec 5, 2023
26f0e09
Mask input + mask intersection inside group level analysis [skip ci]
bclenet Dec 6, 2023
8ac81d1
Adding mask to randomise Node [skip ci]
bclenet Dec 6, 2023
ad0b24f
Actually passing mask tu compute median node [skip ci]
bclenet Dec 11, 2023
cb99973
Actually passing mask tu compute median node [skip ci]
bclenet Dec 11, 2023
09cfe2f
Actually passing mask tu compute median node [skip ci]
bclenet Dec 11, 2023
bfd163e
Adding mask to compute median node [skip ci]
bclenet Dec 11, 2023
7f5191c
Adding wm sgmentation to coregistration_sbref node working with bbr c…
bclenet Dec 12, 2023
d83d066
Adding brain extraction of sbrefs [skip ci]
bclenet Dec 12, 2023
86da1a1
Using unthresholded wm for coregistration_sbref node [skip ci]
bclenet Dec 12, 2023
483a4d0
Bug with WM selection [skip ci]
bclenet Dec 12, 2023
843eb1f
Adding back remove functions for testing on 20 subjects [skip ci]
bclenet Dec 12, 2023
e0f599f
Removing more intermediate results [skip ci]
bclenet Dec 18, 2023
cc1d7a5
First version of the pipeline [skip ci]
bclenet Dec 20, 2023
6c228f9
Force 2.0mm resampling for alignment_func_to_anat node [skip ci]
bclenet Dec 20, 2023
40a67e1
Force 2.0mm resampling for alignment_func_to_anat node [skip ci]
bclenet Dec 20, 2023
3250a6d
[TEST][PEP8] [skip ci]
bclenet Dec 20, 2023
81173dc
Preprocessing done [skip ci]
bclenet Dec 20, 2023
38acfad
Adding test features into 51PW_reproduction
bclenet Dec 20, 2023
f60c613
[TEST] updating test for 51PW
bclenet Dec 20, 2023
c9ee889
Merge branch 'Inria-Empenn:main' into main
bclenet Jan 5, 2024
9bfc89c
Merge branch 'Inria-Empenn:main' into main
bclenet Jan 10, 2024
7493f74
Merge branch 'Inria-Empenn:main' into main
bclenet Jan 11, 2024
a73f3c3
[DATALAD] change results url
bclenet Jan 11, 2024
f03f50e
Merge pull request #3 from bclenet/results
bclenet Jan 11, 2024
68a923a
Merge branch 'main' into 51PW_reproduction
bclenet Jan 15, 2024
428473b
[BUG] select files in run level analysis
bclenet Jan 18, 2024
d8bdd75
[BUG] find mask name in run-level analysis
bclenet Jan 18, 2024
9c9ebad
Remove autoregressive model fitting
bclenet Jan 19, 2024
7dfa06f
Merge branch 'main' into 51PW_reproduction
bclenet Jan 29, 2024
1bc53fe
Remove large files
bclenet Jan 29, 2024
b51c446
Bugs after remove file section
bclenet Jan 31, 2024
af4d7da
Merge branch 'main' into 51PW_reproduction
bclenet Jan 31, 2024
a16107a
Remove outputs
bclenet Feb 1, 2024
7ad084d
[TEST] test pipeline outputs for 51PW [skip ci]
bclenet Feb 1, 2024
bc9b5d2
[TEST] test pipeline outputs for 51PW [skip ci]
bclenet Feb 1, 2024
7eac2af
Output paths
bclenet Feb 1, 2024
2156ff0
Merge branch 'main' into 51PW_reproduction
bclenet Feb 7, 2024
84a823e
Mask names
bclenet Feb 7, 2024
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
Prev Previous commit
Next Next commit
Towards a running version of the pipeline
bclenet committed Oct 11, 2023
commit 8b488233f5331c76770bf8378ecf802cc6b2efa8
174 changes: 65 additions & 109 deletions narps_open/pipelines/team_08MQ.py
Original file line number Diff line number Diff line change
@@ -3,45 +3,20 @@

""" Write the work of NARPS team 08MQ using Nipype """

"""
This template can be use to reproduce a pipeline using FSL as main software.

- All lines starting with [INFO], are meant to help you during the reproduction, these can be removed
eventually.
- Also remove lines starting with [TODO], once you did what they suggested.
"""

# [TODO] Only import modules you use further in te code, remove others from the import section

from os.path import join

# [INFO] The import of base objects from Nipype, to create Workflows
from nipype import Node, Workflow # , JoinNode, MapNode

# [INFO] a list of interfaces used to manpulate data
from nipype.interfaces.utility import IdentityInterface, Function
from nipype.interfaces.io import SelectFiles, DataSink
# from nipype.algorithms.misc import Gunzip

# from nipype.algorithms.modelgen import SpecifyModel
from nipype.interfaces.fsl import (
FAST, BET, Registration, ErodeImage, PrepareFieldmap, MCFLIRT, SliceTimer,
Threshold, Info, SUSAN
FAST, BET, ErodeImage, PrepareFieldmap, MCFLIRT, SliceTimer,
Threshold, Info, SUSAN, FLIRT, ApplyWarp
)


"""
Info, ImageMaths, IsotropicSmooth, Threshold,
Level1Design, FEATModel, L2Model, Merge,
FLAMEO, ContrastMgr, FILMGLS, MultipleRegressDesign,
Cluster, SmoothEstimate
)
"""

from nipype.interfaces.ants import Registration

from narps_open.pipelines import Pipeline
from narps_open.pipelines import TaskInformation
from narps_open.pipelines.task import TaskInformation

class PipelineTeam08MQ(Pipeline):
""" A class that defines the pipeline of team 08MQ """
@@ -69,6 +44,9 @@ def get_preprocessing(self):
'func': join(
'sub-{subject_id}', 'func', 'sub-{subject_id}_task-MGT_run-{run_id}_bold.nii.gz'
),
'sbref': join(
'sub-{subject_id}', 'func', 'sub-{subject_id}_task-MGT_run-{run_id}_sbref.nii.gz'
),
'magnitude': join('sub-{subject_id}', 'fmap', 'sub-{subject_id}_magnitude1.nii.gz'),
'phasediff': join('sub-{subject_id}', 'fmap', 'sub-{subject_id}_phasediff.nii.gz')
}
@@ -143,6 +121,23 @@ def get_preprocessing(self):
# PrepareFieldmap Node - Convert phase and magnitude to fieldmap images
convert_to_fieldmap = Node(PrepareFieldmap(), name = 'convert_to_fieldmap')

# FLIRT Node - Align high contrast functional images to anatomical
# (i.e.: single-band reference images a.k.a. sbref)
registration_sbref = Node(FLIRT(), name = 'registration_sbref')
registration_sbref.inputs.interp = 'trilinear'
registration_sbref.inputs.cost = 'bbr' # boundary-based registration
#out_file
#out_matrix_file
# fieldmap (a pathlike object or string representing a file) – Fieldmap image in rads/s - must be already registered to the reference image. Maps to a command-line argument: -fieldmap %s.
# wm_seg (a pathlike object or string representing a file) – White matter segmentation volume needed by BBR cost function. Maps to a command-line argument: -wmseg %s.
# wmcoords (a pathlike object or string representing a file) – White matter boundary coordinates for BBR cost function. Maps to a command-line argument: -wmcoords %s.
# wmnorms (a pathlike object or string representing a file) – White matter boundary normals for BBR cost function. Maps to a command-line argument: -wmnorms %s.

"""
High contrast functional volume:
Alignment to anatomical image including distortion correction with field map
Calculation of inverse warp (anatomical to functional)
"""
# FLIRT was used to align the high contrast functional image to anatomical.
# The calculated transforms were then applied to the 4d functional images
# (which were aligned with the high contrast image in the motion correction step).
@@ -164,7 +159,7 @@ def get_preprocessing(self):
slice_time_correction = Node(SliceTimer(), name = 'slice_time_correction')
slice_time_correction.inputs.time_repetition = TaskInformation()['RepetitionTime']
# Slicetimer was used and was applied after motion correction. The middle slice was used as the reference slice. Sinc interpolation was used.

"""
custom_order (a pathlike object or string representing an existing file) – Filename of single-column custom interleave order file (first slice is referred to as 1 not 0). Maps to a command-line argument: --ocustom=%s.
custom_timings (a pathlike object or string representing an existing file) – Slice timings, in fractions of TR, range 0:1 (default is 0.5 = no shift). Maps to a command-line argument: --tcustom=%s.
environ (a dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’) – Environment variables. (Nipype default value: {})
@@ -175,13 +170,12 @@ def get_preprocessing(self):
output_type (‘NIFTI’ or ‘NIFTI_PAIR’ or ‘NIFTI_GZ’ or ‘NIFTI_PAIR_GZ’) – FSL output type.
slice_direction (1 or 2 or 3) – Direction of slice acquisition (x=1, y=2, z=3) - default is z. Maps to a command-line argument: --direction=%d.
time_repetition (a float) – Specify TR of data - default is 3s. Maps to a command-line argument: --repeat=%f.


"""
# SUSAN Node - smoothing of functional images
smoothing = Node(SUSAN(), name = 'smoothing')
smoothing.inputs.brightness_threshold = # ?
#smoothing.inputs.brightness_threshold = # ?
smoothing.inputs.fwhm = self.fwhm
smoothing.inputs.in_file
#smoothing.inputs.in_file

# ApplyWarp Node - Alignment of white matter
alignment_white_matter = Node(ApplyWarp(), name = 'alignment_white_matter')
@@ -232,8 +226,6 @@ def get_preprocessing(self):
preprocessing.connect([
# Inputs
(info_source, select_files, [('subject_id', 'subject_id'), ('run_id', 'run_id')]),
(select_files, node_name, [('func', 'node_input_name')]),
(node_name, data_sink, [('node_output_name', 'preprocessing.@sym_link')]),

# Anatomical images
(select_files, bias_field_correction, [('anat', 'in_files')]),
@@ -247,26 +239,29 @@ def get_preprocessing(self):
(threshold_white_matter, erode_white_matter, [('out_file', 'in_file')]),
(threshold_csf, erode_csf, [('out_file', 'in_file')]),

(erode_white_matter, , [('', '')]),
(erode_csf, , [('', '')]),
#(erode_white_matter, , [('', '')]),
#(erode_csf, , [('', '')]),

# Field maps
(select_files, brain_extraction_magnitude, [('magnitude', 'in_file')]),
(brain_extraction_magnitude, convert_to_fieldmap, [('out_file', 'in_magnitude')]),
(select_files, convert_to_fieldmap, [('phasediff', 'in_phase')]),

# High contrast functional volume
(select_files, registration_sbref, [('sbref', 'in_files')]),
(convert_to_fieldmap, registration_sbref, [('', 'fieldmap')]), # ?
(registration_anat, registration_sbref, [('', 'reference')]),

# Functional images
(select_files, brain_extraction_func, [('func', 'in_file')]),
(brain_extraction_func, motion_correction, [('out_file', 'in_file')]),
(, motion_correction, [('out_file', 'ref_file')]), # high contrast images
(motion_correction, slice_time_correction, [('out_file', 'in_file')]),
#(, motion_correction, [('out_file', 'ref_file')]), # high contrast images
#(motion_correction, slice_time_correction, [('out_file', 'in_file')]),

(, alignment_white_matter, [('', 'in_file')]),
(, alignment_white_matter, [('', 'field_file')]),
(, alignment_csf, [('', 'in_file')]),
(, alignment_csf, [('', 'field_file')])
#(, alignment_white_matter, [('', 'in_file')]),
#(, alignment_white_matter, [('', 'field_file')]),
#(, alignment_csf, [('', 'in_file')]),
#(, alignment_csf, [('', 'field_file')])
])

return preprocessing
@@ -295,7 +290,7 @@ def get_subject_information(event_file: str):
Parametric modulation of events corresponding to loss magnitude. Mean centred.
Response regressor with 1 for accept and -1 for reject. Mean centred.

Six head motion parameters plus four aCompCor regressors. >
Six head motion parameters plus four aCompCor regressors. >

Model and data had a 90s high-pass filter applied.
"""
@@ -309,8 +304,8 @@ def get_subject_information(event_file: str):
amplitudes = {}

# Creates dictionary items with empty lists for each condition.
for condition in condition_names:
onset.update({condition: []})
for condition in condition_names:
onset.update({condition: []})
duration.update({condition: []})
amplitude.update({condition: []})

@@ -461,7 +456,7 @@ def get_subject_level_analysis(self):
Function(
function = self.get_subject_information,
input_names = ['event_files', 'runs'],
output_names = ['subject_info']
output_names = ['subject_info']
),
name = 'subject_information',
)
@@ -472,7 +467,7 @@ def get_subject_level_analysis(self):
Function(
function = self.get_parameters_file,
input_names = ['event_files', 'runs'],
output_names = ['parameters_files']
output_names = ['parameters_files']
),
name = 'parameters',
)
@@ -483,7 +478,7 @@ def get_subject_level_analysis(self):
Function(
function = self.get_contrasts,
input_names = ['subject_id'],
output_names = ['contrasts']
output_names = ['contrasts']
),
name = 'contrasts',
)
@@ -495,9 +490,7 @@ def get_subject_level_analysis(self):
subject_level_analysis.connect([
(info_source, select_files, [('subject_id', 'subject_id')]),
(info_source, contrasts, [('subject_id', 'subject_id')]),
(select_files, subject_infos, [('event', 'event_files')]),
(select_files, node_name, [('func', 'node_input_name')]),
(node_name, data_sink, [('node_output_name', 'preprocess.@sym_link')]),
(select_files, subject_information, [('event', 'event_files')]),
])

return subject_level_analysis
@@ -573,10 +566,10 @@ def get_subgroups_contrasts(
if sub_id[-2][-3:] in subject_list:
varcopes_global.append(varcope)

return copes_equal_indifference, copes_equal_range,
return (copes_equal_indifference, copes_equal_range,
varcopes_equal_indifference, varcopes_equal_range,
equal_indifference_id, equal_range_id,
copes_global, varcopes_global
copes_global, varcopes_global)

def get_regressors(
equal_range_id: list,
@@ -609,21 +602,21 @@ def get_regressors(
# Each list contains n_sub values with 0 and 1 depending on the group of the participant
# For equalRange_reg list --> participants with a 1 are in the equal range group
elif method == 'groupComp':
equalRange_reg = [
equal_range_regressors = [
1 for i in range(len(equal_range_id) + len(equal_indifference_id))
]
equalIndifference_reg = [
equal_indifference_regressors = [
0 for i in range(len(equal_range_id) + len(equal_indifference_id))
]

for index, subject_id in enumerate(subject_list):
if subject_id in equal_indifference_id:
equalIndifference_reg[index] = 1
equalRange_reg[index] = 0
equal_indifference_regressors[index] = 1
equal_range_regressors[index] = 0

regressors = dict(
equalRange = equalRange_reg,
equalIndifference = equalIndifference_reg
equalRange = equal_range_regressors,
equalIndifference = equal_indifference_regressors
)

return regressors
@@ -665,7 +658,7 @@ def get_group_level_analysis_sub_workflow(self, method):
# Templates to select files node
# [TODO] Change the name of the files depending on the filenames
# of results of first level analysis
template = {
templates = {
'cope' : join(self.directories.output_dir,
'subject_level_analysis',
'_contrast_id_{contrast_id}_subject_id_*', 'cope1.nii.gz'),
@@ -692,7 +685,7 @@ def get_group_level_analysis_sub_workflow(self, method):
name = 'data_sink',
)

contrasts = Node(Function(
subgroups_contrasts = Node(Function(
function = self.get_subgroups_contrasts,
input_names=['copes', 'varcopes', 'subject_ids', 'participants_file'],
output_names=[
@@ -722,21 +715,7 @@ def get_group_level_analysis_sub_workflow(self, method):
name = 'regressors',
)
regressors.inputs.method = method
regressors.inputs.subject_list = subject_list

# [INFO] The following part has to be modified with nodes of the pipeline

# [TODO] For each node, replace 'node_name' by an explicit name, and use it for both:
# - the name of the variable in which you store the Node object
# - the 'name' attribute of the Node
# [TODO] The node_function refers to a NiPype interface that you must import
# at the beginning of the file.
node_name = Node(
node_function,
name = 'node_name'
)

# [INFO] The following part defines the nipype workflow and the connections between nodes
regressors.inputs.subject_list = self.subject_list

# Compute the number of participants used to do the analysis
nb_subjects = len(self.subject_list)
@@ -746,38 +725,15 @@ def get_group_level_analysis_sub_workflow(self, method):
base_dir = self.directories.working_dir,
name = f'group_level_analysis_{method}_nsub_{nb_subjects}'
)
group_level_analysis.connect(
[
(
info_source,
select_files,
[('contrast_id', 'contrast_id')],
),
(
info_source,
subgroups_contrasts,
[('subject_list', 'subject_ids')],
),
(
select_files,
subgroups_contrasts,
[
('cope', 'copes'),
('varcope', 'varcopes'),
('participants', 'participants_file'),
],
),
(
select_files,
node_name[('func', 'node_input_name')],
),
(
node_variable,
datasink_groupanalysis,
[('node_output_name', 'preprocess.@sym_link')],
),
]
) # Complete with other links between nodes
group_level_analysis.connect([
(info_source, select_files, [('contrast_id', 'contrast_id')]),
(info_source, subgroups_contrasts, [('subject_list', 'subject_ids')]),
(select_files, subgroups_contrasts, [
('cope', 'copes'),
('varcope', 'varcopes'),
('participants', 'participants_file'),
])
])

# [INFO] Here we define the contrasts used for the group level analysis, depending on the
# method used.