nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
748 stars 530 forks source link

Fixing FSL Randomise #1329

Closed TDaltonC closed 8 years ago

TDaltonC commented 8 years ago

What's wrong with randomise, and what needs to be done to fix it? Alternatively, how can I add multiple comparisons correction to my pipeline without randomise?

satra commented 8 years ago

@TDaltonC - have you considered looking at PALM (also from FSL - but depends on octave/matlab)? should be easy to wrap properly. here is a temporary function and node i used to cover simple usage.

def run_palm(cope_file, design_file, contrast_file, group_file, mask_file, 
             cluster_threshold=3.09):
    import os
    from glob import glob
    from nipype.interfaces.base import CommandLine
    cmd = ("palm -i {cope_file} -m {mask_file} -d {design_file} -t {contrast_file} -eb {group_file} -T " 
           "-C {cluster_threshold} -Cstat extent -fdr -noniiclass -twotail -logp -zstat")
    cl = CommandLine(cmd.format(cope_file=cope_file, mask_file=mask_file, design_file=design_file, 
                                contrast_file=contrast_file,
                                group_file=group_file, cluster_threshold=cluster_threshold))
    results = cl.run(terminal_output='file')
    return [os.path.join(os.getcwd(), val) for val in sorted(glob('palm*'))]

...
            if nonparametric:
                palm = Node(Function(input_names=['cope_file', 'design_file', 'contrast_file', 
                                                  'group_file', 'mask_file', 'cluster_threshold'],
                                     output_names=['palm_outputs'],
                                     function=run_palm),
                            name='palm')
                palm.inputs.cluster_threshold = 3.09
                palm.inputs.mask_file = mask_file
                palm.plugin_args = {'sbatch_args': '-p om_all_nodes -N1 -c2 --mem=10G', 'overwrite': True}
                wk.connect(model, 'design_mat', palm, 'design_file')
                wk.connect(model, 'design_con', palm, 'contrast_file')
                wk.connect(mergecopes, 'merged_file', palm, 'cope_file')
                wk.connect(model, 'design_grp', palm, 'group_file')
...
satra commented 8 years ago

@TDaltonC - regarding your original question, one would have to look at what has been wrapped and not for the interface. also i think the key was to try and improve the parallelization more than randomise per se.

TDaltonC commented 8 years ago

Hmmm, ok. I've implemented a Randomise node doing "threshold-free cluster enhancement" and it's doing what I expect. The output has enhanced clusters; it's crazy slow compared to the FLAMEO node it replaced (but that's not unexpected considering what's going on 'under-the-hood'); and it looks like it's parallelizing nicely. I'm going to keep an eye on it, but leave it in place for now. I'll let you know if anything goes wrong.

Thanks for the help!