Skip to content

Commit

Permalink
🔀 Merge develop into func_switches
Browse files Browse the repository at this point in the history
  • Loading branch information
shnizzedy committed Jul 17, 2023
2 parents ed0152f + 95271e2 commit 2f84dd3
Show file tree
Hide file tree
Showing 16 changed files with 342 additions and 158 deletions.
16 changes: 16 additions & 0 deletions .github/Dockerfiles/C-PAC.develop-lite-bionic.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright (C) 2022-2023 C-PAC Developers

# This file is part of C-PAC.

# C-PAC is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.

# C-PAC is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
FROM ghcr.io/fcp-indi/c-pac/stage-base:lite-v1.8.6.dev1
LABEL org.opencontainers.image.description "Full C-PAC image without FreeSurfer"
LABEL org.opencontainers.image.source https://github.com/FCP-INDI/C-PAC
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updates develop version numbers to adhere to [PEP440](https://peps.python.org/pep-0440) by changing `{major}.{minor}.{patch}.{SHA}-{dev}` to `{major}.{minor}.{patch}.dev{integer}+{SHA}`
- Adds checksum steps to `curl`d steps in Docker build process (for standard and `lite` images)
- Makes in-container root directory writable by all
- Updates multiword CLI commands and options to accept either standard `-`s or backwards-compatible `_`s interchangeably
- Removes `torch` from preinstalled dependencies and only installs if we're running `unet`

### Added dependency
### Added dependencies

- `click-aliases`
- `dc`

### Removed dependencies
Expand Down
75 changes: 38 additions & 37 deletions CPAC/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import pkg_resources as p
import click
from click_aliases import ClickAliasedGroup
from CPAC.utils.docs import version_report

# CLI tree
Expand Down Expand Up @@ -61,9 +62,9 @@ def version():

@main.command()
@click.argument('data_config')
@click.option('--pipe_config')
@click.option('--num_cores')
@click.option('--ndmg_mode', is_flag=True)
@click.option('--pipe-config', '--pipe_config')
@click.option('--num-cores', '--num_cores')
@click.option('--ndmg-mode', '--ndmg_mode', is_flag=True)
@click.option('--debug', is_flag=True)
def run(data_config, pipe_config=None, num_cores=None, ndmg_mode=False,
debug=False):
Expand Down Expand Up @@ -146,7 +147,7 @@ def group():


# Group analysis - FSL FEAT
@group.group()
@group.group(cls=ClickAliasedGroup)
def feat():
pass

Expand All @@ -172,17 +173,17 @@ def randomise(group_config):
cgr.run_feat(group_config, feat=False)


@feat.group()
@feat.group(aliases=['load_preset'], cls=ClickAliasedGroup)
def load_preset():
pass

@load_preset.command()
@load_preset.command(aliases=['single_grp_avg'])
@click.argument('pipeline_dir')
@click.argument('z_thresh')
@click.argument('p_thresh')
@click.argument('model_name')
@click.option('--output_dir', default=None)
@click.option('--group_participants', default=None)
@click.option('--output-dir', '--output_dir', default=None)
@click.option('--group-participants', '--group_participants', default=None)
def single_grp_avg(pipeline_dir, z_thresh, p_thresh, model_name,
output_dir=None, group_participants=None):
from CPAC.utils import create_fsl_flame_preset
Expand All @@ -193,16 +194,16 @@ def single_grp_avg(pipeline_dir, z_thresh, p_thresh, model_name,
output_dir=output_dir,
model_name=model_name)

@load_preset.command()
@load_preset.command(aliases=['single_grp_cov'])
@click.argument('pipeline_dir')
@click.argument('z_thresh')
@click.argument('p_thresh')
@click.argument('pheno_file')
@click.argument('pheno_sub')
@click.argument('covariate')
@click.argument('model_name')
@click.option('--output_dir', default=None)
@click.option('--group_participants', default=None)
@click.option('--output-dir', '--output_dir', default=None)
@click.option('--group-participants', '--group_participants', default=None)
def single_grp_cov(pipeline_dir, z_thresh, p_thresh, pheno_file,
pheno_sub, covariate, model_name, output_dir=None,
group_participants=None):
Expand All @@ -216,16 +217,16 @@ def single_grp_cov(pipeline_dir, z_thresh, p_thresh, pheno_file,
covariate=covariate, output_dir=output_dir,
model_name=model_name)

@load_preset.command()
@load_preset.command(aliases=['unpaired_two'])
@click.argument('pipeline_dir')
@click.argument('z_thresh')
@click.argument('p_thresh')
@click.argument('pheno_file')
@click.argument('pheno_sub')
@click.argument('covariate')
@click.argument('model_name')
@click.option('--output_dir', default=None)
@click.option('--group_participants', default=None)
@click.option('--output-dir', '--output_dir', default=None)
@click.option('--group-participants', '--group_participants', default=None)
def unpaired_two(pipeline_dir, z_thresh, p_thresh, pheno_file,
pheno_sub, covariate, model_name, output_dir=None,
group_participants=None):
Expand All @@ -239,15 +240,15 @@ def unpaired_two(pipeline_dir, z_thresh, p_thresh, pheno_file,
covariate=covariate, output_dir=output_dir,
model_name=model_name)

@load_preset.command()
@load_preset.command(aliases=['paired_two'])
@click.argument('pipeline_dir')
@click.argument('z_thresh')
@click.argument('p_thresh')
@click.argument('conditions')
@click.argument('condition_type')
@click.argument('model_name')
@click.option('--output_dir', default=None)
@click.option('--group_participants', default=None)
@click.option('--output-dir', '--output_dir', default=None)
@click.option('--group-participants', '--group_participants', default=None)
def paired_two(pipeline_dir, z_thresh, p_thresh, conditions,
condition_type, model_name, output_dir=None,
group_participants=None):
Expand All @@ -261,15 +262,15 @@ def paired_two(pipeline_dir, z_thresh, p_thresh, conditions,
output_dir=output_dir, model_name=model_name)


@load_preset.command()
@load_preset.command(aliases=['tripled_two'])
@click.argument('pipeline_dir')
@click.argument('z_thresh')
@click.argument('p_thresh')
@click.argument('conditions')
@click.argument('condition_type')
@click.argument('model_name')
@click.option('--output_dir', default=None)
@click.option('--group_participants', default=None)
@click.option('--output-dir', '--output_dir', default=None)
@click.option('--group-participants', '--group_participants', default=None)
def tripled_two(pipeline_dir, z_thresh, p_thresh, conditions,
condition_type, model_name, output_dir=None,
group_participants=None):
Expand Down Expand Up @@ -313,7 +314,7 @@ def qpp(group_config):


# Utilities
@main.group()
@main.group(cls=ClickAliasedGroup)
def utils():
pass

Expand All @@ -332,8 +333,8 @@ def accept_all(object, name, value):
display_crash_file(crash_file, False, False, None)


@utils.group()
@click.option('--tracking_opt-out', is_flag=True,
@utils.group(aliases=['data_config'], cls=ClickAliasedGroup)
@click.option('--tracking-opt-out', '--tracking_opt-out', is_flag=True,
help='Disable usage tracking.')
def data_config(tracking_opt_out):
if not tracking_opt_out:
Expand All @@ -342,7 +343,7 @@ def data_config(tracking_opt_out):
track_config('cli')


@data_config.command()
@data_config.command(aliases=['new_settings_template'])
def new_settings_template():
from CPAC.utils.build_data_config import util_copy_template
util_copy_template('data_settings')
Expand All @@ -355,8 +356,8 @@ def build(data_settings_file):
run(data_settings_file)


@utils.group()
@click.option('--tracking_opt-out', is_flag=True,
@utils.group(aliases=['pipe_config'], cls=ClickAliasedGroup)
@click.option('--tracking-opt-out', '--tracking_opt-out', is_flag=True,
help='Disable usage tracking.')
def pipe_config(tracking_opt_out):
if not tracking_opt_out:
Expand All @@ -365,14 +366,14 @@ def pipe_config(tracking_opt_out):
track_config('cli')


@pipe_config.command(name='new_template')
@pipe_config.command(name='new-template', aliases=['new_template'])
def new_pipeline_template():
from CPAC.utils.build_data_config import util_copy_template
util_copy_template('pipeline_config')


@utils.group()
@click.option('--tracking_opt-out', is_flag=True,
@utils.group(aliases=['group_config'], cls=ClickAliasedGroup)
@click.option('--tracking-opt-out', '--tracking_opt-out', is_flag=True,
help='Disable usage tracking.')
def group_config(tracking_opt_out):
if not tracking_opt_out:
Expand All @@ -381,25 +382,25 @@ def group_config(tracking_opt_out):
track_config('cli')


@group_config.command(name='new_template')
@group_config.command(name='new-template', aliases=['new_template'])
def new_group_template():
from CPAC.utils.build_data_config import util_copy_template
util_copy_template('group_config')


@utils.group()
@utils.group(cls=ClickAliasedGroup)
def tools():
pass


@tools.command()
@tools.command(aliases=['ants_apply_warp'])
@click.argument('moving_image')
@click.argument('reference')
@click.option('--initial', default=None)
@click.option('--rigid', default=None)
@click.option('--affine', default=None)
@click.option('--nonlinear', default=None)
@click.option('--func_to_anat', default=None)
@click.option('--func-to-anat', '--func_to_anat', default=None)
@click.option('--dim', default=3)
@click.option('--interp', default='Linear')
@click.option('--inverse', default=False)
Expand All @@ -424,12 +425,12 @@ def repickle(directory):
repickle_util(directory)


@utils.group()
@utils.group(cls=ClickAliasedGroup)
def test():
pass


@test.command()
@test.command(aliases=['run_suite'])
@click.option('--list', '-l', 'show_list', is_flag=True)
@click.option('--filter', '-f', 'pipeline_filter', default='')
def run_suite(show_list=False, pipeline_filter=''):
Expand Down Expand Up @@ -489,12 +490,12 @@ def run_suite(show_list=False, pipeline_filter=''):
print("")


@test.group()
@test.group(cls=ClickAliasedGroup)
def functions():
pass


@functions.command()
@functions.command(aliases=['gather_outputs_func'])
@click.argument('pipe_config')
def gather_outputs_func(pipe_config):
#from CPAC.pipeline.
Expand Down
22 changes: 18 additions & 4 deletions CPAC/anat_preproc/anat_preproc.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# -*- coding: utf-8 -*-
from copy import deepcopy
# Copyright (C) 2012-2023 C-PAC Developers

# This file is part of C-PAC.

# C-PAC is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.

# C-PAC is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with C-PAC. If not, see <https://www.gnu.org/licenses/>.
# from copy import deepcopy
import os
from CPAC.pipeline.nodeblock import nodeblock
from nipype import logging
from nipype.interfaces import afni
from nipype.interfaces import ants
from nipype.interfaces import fsl
Expand All @@ -20,7 +35,6 @@
VolumeRemoveIslands, \
normalize_wmparc
from CPAC.utils.interfaces.fsl import Merge as fslMerge
from CPAC.unet.function import predict_volumes


def acpc_alignment(config=None, acpc_target='whole-head', mask=False,
Expand Down Expand Up @@ -719,7 +733,7 @@ def unet_brain_connector(wf, cfg, strat_pool, pipe_num, opt):
kernel_root: 16
rescale_dim: 256
"""

from CPAC.unet.function import predict_volumes
unet_mask = pe.Node(util.Function(input_names=['model_path', 'cimg_in'],
output_names=['out_path'],
function=predict_volumes),
Expand Down
1 change: 1 addition & 0 deletions CPAC/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def get_cpac_gitversion():
REQUIREMENTS = [
"boto3",
"click",
"click-aliases",
"configparser",
"cython",
"future",
Expand Down
19 changes: 10 additions & 9 deletions CPAC/pipeline/cpac_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,16 @@ def run_workflow(sub_dict, c, run, pipeline_timing_info=None, p_name=None,
'local_functional_connectivity_density'][
'weight_options']) != 0

# Check system dependencies
check_ica_aroma = c.nuisance_corrections['1-ICA-AROMA']['run']
if isinstance(check_ica_aroma, list):
check_ica_aroma = True in check_ica_aroma
check_system_deps(check_ants='ANTS' in c.registration_workflows[
'anatomical_registration']['registration']['using'],
check_ica_aroma=check_ica_aroma,
check_centrality_degree=check_centrality_degree,
check_centrality_lfcd=check_centrality_lfcd)
if not test_config:
# Check system dependencies
check_ica_aroma = c.nuisance_corrections['1-ICA-AROMA']['run']
if isinstance(check_ica_aroma, list):
check_ica_aroma = True in check_ica_aroma
check_system_deps(check_ants='ANTS' in c.registration_workflows[
'anatomical_registration']['registration']['using'],
check_ica_aroma=check_ica_aroma,
check_centrality_degree=check_centrality_degree,
check_centrality_lfcd=check_centrality_lfcd)

# absolute paths of the dirs
c.pipeline_setup['working_directory']['path'] = os.path.join(
Expand Down
13 changes: 0 additions & 13 deletions CPAC/pipeline/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,19 +1261,6 @@ def __init__(self, node_block_functions, debug=False):
{'logging': {'workflow_level': 'INFO'}})
logging.update_logging(config)

logger.info('Connecting %s...', name)
if debug:
config.update_config(
{'logging': {'workflow_level': 'DEBUG'}})
logging.update_logging(config)
logger.debug('"inputs": %s\n\t "outputs": %s%s',
init_dct["inputs"], list(self.outputs.keys()),
f'\n\t"options": {self.options}'
if self.options != ['base'] else '')
config.update_config(
{'logging': {'workflow_level': 'INFO'}})
logging.update_logging(config)

def get_name(self):
return self.name

Expand Down
10 changes: 10 additions & 0 deletions CPAC/resources/configs/data_settings_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ scanParametersCSV: None
brain_mask_template: None


# File Path for Freesurfer Directory.
# This should be the directory for the `recon-all` output
# Each participant should contain subdirectories: label, mri, scripts, stats, surf, tmp, touch, trash
#
# Examples:
# /recon-all_path/{participant}
#
freesurfer_dir: None


# File Path Template for Field Map Phase files
# For field-map based distortion correction.
# Custom Data Format only.
Expand Down
Loading

0 comments on commit 2f84dd3

Please sign in to comment.