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

80GC reproduction #185

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
46bb1b3
80GC refac + tests
bclenet Mar 27, 2024
e562d8e
80GC as an implemented pipeline
bclenet Mar 27, 2024
0247745
Subject ids completion
bclenet Mar 27, 2024
978ef5f
Output nifti masks
bclenet Mar 27, 2024
5e5a2e9
Adding output files for 3dttest++ [skip ci]
bclenet Mar 28, 2024
39e7ed2
Select output files from 3dttest++ [skip ci]
bclenet Mar 28, 2024
3384fdc
Select output files from 3dttest++ [skip ci]
bclenet Mar 28, 2024
8aeead5
Select output files from 3dttest++ [skip ci]
bclenet Mar 28, 2024
25b618f
Test with 1 permutation [skip ci]
bclenet Mar 28, 2024
098d58d
Test of group comp with two sets [skip ci]
bclenet Mar 29, 2024
c1fbf74
Afni select dataset
bclenet Apr 2, 2024
1dd3550
Afni select dataset [skip ci]
bclenet Apr 2, 2024
4ebbb1b
Afni select dataset [skip ci]
bclenet Apr 2, 2024
5d5baa3
Afni select dataset [skip ci]
bclenet Apr 2, 2024
dea893d
Tests & new split 3dttest output function [skip ci]
bclenet Apr 2, 2024
f5f2758
Tests & new split 3dttest output function [skip ci]
bclenet Apr 2, 2024
ad49c89
Tests & new split 3dttest output function [skip ci]
bclenet Apr 2, 2024
3f534bb
Split 3dttest output function using Calc [skip ci]
bclenet Apr 2, 2024
b0c6ee1
Split 3dttest output function using Calc [skip ci]
bclenet Apr 2, 2024
13df25d
Split 3dttest output function using Calc [skip ci]
bclenet Apr 2, 2024
6f0c9cb
Tests updates [skip ci]
bclenet Apr 2, 2024
a59c41c
3dttest outputs a nii file [skip ci]
bclenet Apr 3, 2024
c42bad4
Removing clustering from 80GC group analysis
bclenet Apr 3, 2024
fc23506
80GC group analysis select files using Calc
bclenet Apr 3, 2024
b68e102
80GC group analysis select files using Calc
bclenet Apr 3, 2024
c7de3be
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
7651709
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
68e5e3e
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
9f2a1ed
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
ecb65e8
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
b766fe2
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
2e0a16d
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
710cc10
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
66f15a3
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
8da3d3d
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
21168b9
80GC group analysis select files using 3dTCat
bclenet Apr 3, 2024
2bd9d26
Using custom function for output selection [skip ci]
bclenet Apr 4, 2024
fbd8ad6
Add output file names [skip ci]
bclenet Apr 4, 2024
bc9d7c7
Add output file names [skip ci]
bclenet Apr 4, 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
File renamed without changes.
226 changes: 226 additions & 0 deletions narps_open/core/interfaces/afni.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
#!/usr/bin/python
# coding: utf-8

""" AFNI interfaces for Nipype """

from os.path import abspath

from nipype.interfaces.base import traits, File, Str, InputMultiPath, isdefined
from nipype.interfaces.afni.base import (
AFNICommand,
AFNICommandInputSpec,
AFNICommandOutputSpec
)

class TtestppInputSpec(AFNICommandInputSpec):
""" The input specification of the 3dttest++ interface """

set_a_label = Str(
desc='label for setA',
argstr='-labelA %s ',
mandatory=True
)
set_a = InputMultiPath(
traits.Tuple(
File(desc='3D dataset', exists=True),
traits.Int(desc='Index of the data in the dataset'),
),
desc='specifies a set of input datasets for setA + their label.',
argstr='-setA %s ', # Data tuples will be formatted in the _format_arg method
requires=['set_a_label'],
mandatory=True
)
set_b_label = Str(
desc='label for setB',
argstr='-labelB %s ',
)
set_b = InputMultiPath(
traits.Tuple(
File(desc='3D dataset', exists=True),
traits.Int(desc='Index of the data in the dataset'),
),
desc='specifies a set of input datasets for setB + their label.',
argstr='-setB %s ', # Data tuples will be formatted in the _format_arg method
requires=['set_b_label'],
)
set_a_weight = File(
desc='Name of a file with the weights for the -setA datasets.',
argstr='-setweightA %s ',
requires=['set_a'],
exists=True,
)
set_b_weight = File(
desc='Name of a file with the weights for the -setB datasets.',
argstr='-setweightB %s ',
requires=['set_b'],
exists=True,
)
covariates = File(
desc='name of a text file with a table for the covariate(s).'
' Each column in the file is treated as a separate covariate, and each'
' row contains the values of these covariates for one sample (dataset).',
argstr='-covariates %s ',
exists=True,
)
center = traits.Enum('NONE', 'DIFF', 'SAME',
desc='how the mean across subjects of a covariate will be processed.',
argstr='-center %s ',
requires=['covariates'],
)
paired = traits.Bool(
desc='specifies the use of a paired-sample t-test to compare setA and setB.',
argstr='-paired ',
requires=['set_a', 'set_b'],
)
unpooled = traits.Bool(
desc='specifies that the variance estimates for setA and setB be computed '
'separately (not pooled together).',
argstr='-paired ',
requires=['set_a', 'set_b'],
xor=['paired', 'covariates']
)
toz = traits.Bool(
desc='convert output t-statistics to z-scores.',
argstr='-toz ',
)
rankize = traits.Bool(
desc='convert the data (and covariates, if any) into ranks before '
'doing the 2-sample analyses.',
argstr='-rankize ',
)
no1sam = traits.Bool(
desc='do not calculate 1-sample test results when '
'doing 2-sample analyses.',
argstr='-no1sam ',
)
nomeans = traits.Bool(
desc='turn off output of the `mean` sub-bricks.',
argstr='-nomeans ',
)
notests = traits.Bool(
desc='turn off output of the `test` sub-bricks.',
argstr='-notests ',
)
mask = File(
desc='Only compute results for voxels in the specified mask.',
argstr='-mask %s ',
exists=True,
)
exblur = traits.Float(
desc='Before doing the t-test, apply some extra blurring to the input datasets; '
"parameter 'b' is the Gaussian FWHM of the smoothing kernel (in mm).",
argstr='-exblur %d ',
)
brickwise = traits.Bool(
desc='carry out t-tests sub-brick by sub-brick',
argstr='-brickwise ',
position=0
)
out_file = Str(
desc='the name of the output dataset file.',
argstr='-prefix %s ',
position=-1
)
out_residuals = Str(
desc='output the residuals into a dataset with given prefix.',
argstr='-resid %s ',
position=-2
)
clustsim = traits.Bool(
desc='run the cluster-size threshold simulation program 3dClustSim.',
argstr='-Clustsim ',
position=-4
)
seed = traits.Tuple(
traits.Int, traits.Int,
desc='This option is used to set the random number seed for'
'`-randomsign` to the first positive integer. If a second integer'
'follows, then that value is used for the random number seed for `-permute`.',
argstr='-seed %d %d ',
requires=['clustsim'],
position=-3
)

class Ttestpp(AFNICommand):
""" Gosset (Student) t-test of sets of 3D datasets.

For complete details, see the `3dttest++ Documentation.
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dttest++.html>`_
"""

_cmd = '3dttest++'
input_spec = TtestppInputSpec
output_spec = AFNICommandOutputSpec

def _format_arg(self, name, trait_spec, value):
""" Format arguments before actually building the command line """
out_value = value

# For arguments -setA and -setB, we want a list such as :
# dataset1'[index]' dataset2'[index]' dataset3'[index]' ...
if name in ['set_a', 'set_b']:
out_value = ''
for set_tuple in value:
out_value += f'{set_tuple[0]}\'[{set_tuple[1]}]\' '
out_value = [out_value] # Return a list as the input value

return super()._format_arg(name, trait_spec, out_value)

def _list_outputs(self):
outputs = self.output_spec().get()

for key in outputs.keys():
if isdefined(self.inputs.get()[key]):
outputs[key] = abspath(self.inputs.get()[key])

return outputs

class SelectSBInputSpec(AFNICommandInputSpec):
""" The input specification for SelectSubBrick """
in_file = File(
desc = 'File name to select a subbrick from.',
argstr = '%s',
position = -2,
mandatory = True,
copyfile = False,
exists = True
)
index = traits.Int(
desc = 'Index of the subbrick inside in_file.',
mandatory = True
)
out_file = File(desc = 'Output image file name.', argstr = '-prefix %s', genfile = True)

class SelectSubBrick(AFNICommand):
""" Sub-brick selection from AFNI files.

For complete details, see the `3dTcat Documentation.
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dTcat.html>
"""

_cmd = '3dTcat'
input_spec = SelectSBInputSpec
output_spec = AFNICommandOutputSpec

#def _gen_filename(self, name):
# if name == 'out_file':
# return self._gen_fname(self.inputs.in_file, suffix = '_tcat')

def _list_outputs(self):
outputs = self.output_spec().get()

for key in outputs.keys():
if isdefined(self.inputs.get()[key]):
outputs[key] = abspath(self.inputs.get()[key])

return outputs

def _format_arg(self, name, trait_spec, value):
""" Format arguments before actually building the command line """
out_value = value

# For argument in_file, append index, such as : in_file'[index]'
if name == 'in_file':
out_value = f'{value}\'[{self.inputs.index}]\''

return super()._format_arg(name, trait_spec, out_value)
2 changes: 1 addition & 1 deletion narps_open/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'5G9K': None,
'6FH5': None,
'6VV2': None,
'80GC': None,
'80GC': 'PipelineTeam80GC',
'94GU': None,
'98BT': 'PipelineTeam98BT',
'9Q6R': None,
Expand Down
Loading