Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
34e7bed
implementing bids2table for anat data configuration
Jun 5, 2024
c8295e0
building rpool
Jun 6, 2024
5ca4fb7
refactoring the rpool object to have subfields for easy browsing of r…
Jun 12, 2024
d8300d5
removing unused keys from the rpool
Jun 14, 2024
f3a6d4f
Introduced resource object in the rpool.
Jun 27, 2024
a853fc9
Added method write_to_disk(path) to the ResourcePool and Resource class.
Jun 27, 2024
ee092d6
Merge pull request #2125 from birajstha/bids_ingress
birajstha Jun 27, 2024
b1bbc36
added sub- and ses- in the relative paths
Jun 27, 2024
4aab3f7
Merge pull request #2126 from birajstha/bids_ingress
birajstha Jun 27, 2024
e85550d
only write .json files to .nii.gz image files
Jun 27, 2024
2ca9598
Merge pull request #2127 from birajstha/bids_ingress
birajstha Jun 27, 2024
b414d17
:truck: Move engine resources to own submodule
shnizzedy Jul 8, 2024
821bcaa
:construction: Split ResourcePool into three classes with docstrings
shnizzedy Jul 8, 2024
06612ff
:white_check_mark: Move BIDS examples to a fixture
shnizzedy Jul 9, 2024
7a76603
:construction: WIP :recycle: Move `ResourcePool` init from functions …
shnizzedy Jul 10, 2024
646f49d
:white_check_mark: Restore engine unit tests
shnizzedy Jul 10, 2024
3334a2a
:construction_worker: Replace non-`\w`-non-dot characters with hyphens
shnizzedy Jul 10, 2024
45dacc3
Add bids2table package to container
e-kenneally Jul 10, 2024
bbf3e97
:recycle: Fold `initiate_rpool` into `ResourcePool.__init__`
shnizzedy Jul 10, 2024
f1f7705
:recycle: Finish moving `create_func_datasource` from func to method
shnizzedy Jul 10, 2024
f55b930
Merge 'origin/develop' into bids_ingress
e-kenneally Jul 11, 2024
515b791
:recycle: EmptyConfiguration → Preconfiguration('blank')
shnizzedy Jul 11, 2024
3c2220d
:pencil2: Import Path for signature
shnizzedy Jul 11, 2024
8a24441
:recycle: Pass `part_id` through to `DataPaths`
shnizzedy Jul 11, 2024
87fb1c0
:white_check_mark: Skip NHP configs if no torch installed
shnizzedy Jul 11, 2024
3af1407
:white_check_mark: Use abspath for BIDS-examples
shnizzedy Jul 11, 2024
29cab04
fix merge error
e-kenneally Jul 11, 2024
98c8bb8
:construction: :recycle: Continue updating calls to `ResourcePool` me…
shnizzedy Jul 11, 2024
4d9934d
:construction: WIP :recycle: Fix `StratPool.__init__`
shnizzedy Jul 11, 2024
1cc3914
:art: :technologist: Clarify typing
shnizzedy Jul 12, 2024
199bd60
:white_check_mark: `pytest.Cache.makedir` → `pytest.Cache.mkdir`
shnizzedy Jul 12, 2024
ec32f34
:pencil2: Pipe inside quotation marks
shnizzedy Jul 13, 2024
b1f16ed
:art: Type `ResourcePool.get_strats`
shnizzedy Jul 13, 2024
02d1a14
:white_check_mark: Remove dir instead of file
shnizzedy Jul 13, 2024
1b11462
:technologist: Add `__repr__` method to `Resource`
shnizzedy Jul 13, 2024
bb6cbae
:bug: Fix circular import
shnizzedy Jul 15, 2024
1058c94
:art: Define `_Pool.__contains__` and `Resource.__contains__`
shnizzedy Jul 15, 2024
aaa37a9
:recycle: Move `StratDict().rpool[json]` to `StratDict().json`
shnizzedy Jul 15, 2024
4280fc6
:recycle: Dedupe loop through `self.node_blocks.items()`
shnizzedy Jul 15, 2024
c22db11
:bug: Remove extra curly braces
shnizzedy Jul 15, 2024
90d96b1
:white_check_mark: Update test for new `Resource` class
shnizzedy Jul 15, 2024
e25479f
:bug: Fix auto-`quick_single`
shnizzedy Jul 15, 2024
faf8ab9
:white_check_mark: Check if `bids-examples` is empty before moving on
shnizzedy Jul 15, 2024
5ea19ef
:twisted_rightwards_arrow: Merge `develop` into `engine/(th)r(e)esour…
shnizzedy Jul 15, 2024
abb4809
:art: Type `connect_pipeline`
shnizzedy Jul 15, 2024
4093b3b
new ResourcePool structure
Jul 16, 2024
a46218d
ResourcePool modified as per nee specs
Jul 16, 2024
b5e4131
Merge branch 'bids_ingress' of https://github.com/FCP-INDI/C-PAC into…
Jul 16, 2024
5c1eece
fixing sub_dict/sub_group variable names after branch update
Jul 16, 2024
6207348
:zap: Replace some `deepcopy` calls
shnizzedy Jul 15, 2024
588df00
:recycle: Typehint `StratPool.append_name`
shnizzedy Jul 16, 2024
fc2714a
:recycle: Clarify `ResourcePool.gather_pipes`
shnizzedy Jul 16, 2024
d30496c
:recycle: Move `connect_pipeline` from standalone function to `Resour…
shnizzedy Jul 17, 2024
a9a3c48
:coffin: Remove `_Pool.node_data` method
shnizzedy Jul 17, 2024
3613f8c
:construction_worker: Livelog pytest
shnizzedy Jul 17, 2024
4bf5f00
:recycle: Move `post_process` method back into `ResourcePool`
shnizzedy Jul 17, 2024
b0b94c9
:recycle: Move `filter_name` method into `StratPool`
shnizzedy Jul 17, 2024
29b481d
:recycle: Move `filtered_movement` property into `StratPool`
shnizzedy Jul 17, 2024
48e8b90
:recycle: Move `derivative_xfm` back into `ResourcePool`
shnizzedy Jul 17, 2024
74629ac
:coffin: Remove unused `flatten_prov` method
shnizzedy Jul 17, 2024
748b98e
:recycle: Move `get_resource_strats_from_prov` back into `ResourcePool`
shnizzedy Jul 17, 2024
52c38bf
:coffin: Remove unused `generate_prov_list` method
shnizzedy Jul 17, 2024
f2423a2
:recycle: Move `get_cpac_provenance` and `regressor_dct` into `StratP…
shnizzedy Jul 17, 2024
0f9099c
:recycle: Split `get_json` across `ResourcePool` and `StratPool`
shnizzedy Jul 17, 2024
6fb1dc1
:coffin: Remove unused `get_pipe_idxs` method
shnizzedy Jul 17, 2024
a004ab6
:coffin: Remove unused `update_resource` method
shnizzedy Jul 17, 2024
69cb603
:recycle: Move `copy_resource` method into `StratPool`
shnizzedy Jul 17, 2024
0a0b5a0
:recycle: Move `get_json_info` back into `ResourcePool`
shnizzedy Jul 17, 2024
839c7cd
:coffin: Remove unused `set_json_info` method
shnizzedy Jul 17, 2024
b8ca36c
:coffin: Remove unused `get_strat_info` method
shnizzedy Jul 17, 2024
2fc7244
:recycle: Move `get_raw_label` back into `ResourcePool`
shnizzedy Jul 17, 2024
14c3e32
:coffin: Remove unused `get_entire_rpool` method
shnizzedy Jul 17, 2024
77ffc16
:coffin: Remove unused `wrap_block` function
shnizzedy Jul 17, 2024
ef402e5
:recycle: Move `_get_pipe_number` back into `ResourcePool`
shnizzedy Jul 17, 2024
c944940
:recycle: Move `create_func_datasource` method into `ResourcePool`
shnizzedy Jul 17, 2024
cf85273
:coffin: Remove unused `get_name` method
shnizzedy Jul 17, 2024
84274b9
:recycle: Move `_config_lookup` method into `ResourcePool`
shnizzedy Jul 17, 2024
8389d5b
:recycle: Move `json_outdir_ingress` method into `ResourcePool`
shnizzedy Jul 17, 2024
2e97e51
:recycle: Move `initialize_nipype_wf` method into `ResourcePool`
shnizzedy Jul 17, 2024
a855222
:coffin: Remove unused function `run_node_blocks`
shnizzedy Jul 17, 2024
0d848b9
:recycle: Replace calls to `grab_tiered_dct` with direct config lookup
shnizzedy Jul 17, 2024
7571455
:recycle: Move `_check_null` from method to private function
shnizzedy Jul 17, 2024
4a05442
:construction_worker: Pre-clone `bids-examples`
shnizzedy Jul 17, 2024
dd0985f
:pencil2: Fix typo (~~"tpyes"~~ → "types")
shnizzedy Jul 18, 2024
7b04cc8
:white_check_mark: Unlink symlink instead of rmtree
shnizzedy Jul 18, 2024
3b00764
:twisted_rightwards_arrows: Merge 'origin/develop' into 'engine/(th)r…
shnizzedy Jul 18, 2024
75e38e0
:memo: Update CHANGELOG re: #2131
shnizzedy Jul 18, 2024
f5dd824
:art: Standardize docstring format across changes.
shnizzedy Jul 18, 2024
6c96667
:bug: Fix conflicting class name
shnizzedy Jul 18, 2024
763af4e
:art: More docstring updates for ResourcePool refactor
shnizzedy Jul 18, 2024
250de03
reconfigured Resource class and added get_resource() to the ResourceP…
Jul 19, 2024
61eeef4
:bug: Fix memoization
shnizzedy Jul 19, 2024
2402a2c
:pencil2: A little more docstring cleanup
shnizzedy Jul 19, 2024
8d80941
:art: Qualify refs to documented functions.
shnizzedy Jul 19, 2024
836d100
:art: Remove duplicate imports
shnizzedy Jul 19, 2024
0a53108
:goal_net: Catch and release no-regressors
shnizzedy Jul 19, 2024
61d8b6d
added upper/lower case insensitive check for the entity values
Jul 19, 2024
532322d
Merge pull request #2 from FCP-INDI/engine/(th)re(e)sources
sgiavasis Aug 9, 2024
494f0c7
:twisted_rightwards_arrows: Merge develop into bids_ingress
shnizzedy Aug 15, 2024
64a775b
:goal_net: Raise exception instead of warn + exit(1)
shnizzedy Aug 15, 2024
ce729d5
:bulb: Remove resolved #TODO comment
shnizzedy Aug 15, 2024
27318d7
:package: Require pandas for build
shnizzedy Aug 15, 2024
39f41bb
:memo: Update type in docstring
shnizzedy Aug 19, 2024
43a9b27
:white_check_mark: Fix test inputs
shnizzedy Aug 22, 2024
5bbc1e6
:white_check_mark: Use tmp_path for pipeline tests
shnizzedy Aug 23, 2024
d5722da
:white_check_mark: Update doctest for sub_group instead of sub_dict
shnizzedy Aug 23, 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
8 changes: 5 additions & 3 deletions .circleci/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ commands:
steps:
- run:
name: Getting Sample BIDS Data
command: git clone https://github.com/bids-standard/bids-examples.git
command: |
mkdir -p /home/circleci/project/dev/circleci_data/.pytest_cache/d/bids-examples
git clone https://github.com/bids-standard/bids-examples.git /home/circleci/project/dev/circleci_data/.pytest_cache/d/bids-examples
get-singularity:
parameters:
version:
Expand Down Expand Up @@ -156,7 +158,7 @@ commands:
then
TAG=nightly
else
TAG="${CIRCLE_BRANCH//\//_}"
TAG=`echo ${CIRCLE_BRANCH} | sed 's/[^a-zA-Z0-9._]/-/g'`
fi
DOCKER_TAG="ghcr.io/${CIRCLE_PROJECT_USERNAME,,}/${CIRCLE_PROJECT_REPONAME,,}:${TAG,,}"
if [[ -n "<< parameters.variant >>" ]]
Expand All @@ -172,7 +174,7 @@ commands:
name: Testing Singularity installation
command: |
pip install -r dev/circleci_data/requirements.txt
coverage run -m pytest --junitxml=test-results/junit.xml --continue-on-collection-errors dev/circleci_data/test_install.py
coverage run -m pytest --capture=no --junitxml=test-results/junit.xml --continue-on-collection-errors dev/circleci_data/test_install.py

jobs:
combine-coverage:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_C-PAC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
GITHUB_BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-)
if [[ ! $GITHUB_BRANCH == 'main' ]] && [[ ! $GITHUB_BRANCH == 'develop' ]]
then
TAG=${GITHUB_BRANCH//\//_}
TAG=`echo ${GITHUB_BRANCH} | sed 's/[^a-zA-Z0-9._]/-/g'`
DOCKERFILE=.github/Dockerfiles/C-PAC.develop$VARIANT-$OS.Dockerfile
elif [[ $GITHUB_BRANCH == 'develop' ]]
then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression_test_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
GITHUB_BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-)
if [[ ! $GITHUB_BRANCH == 'main' ]] && [[ ! $GITHUB_BRANCH == 'develop' ]]
then
TAG=${GITHUB_BRANCH//\//_}
TAG=`echo ${GITHUB_BRANCH} | sed 's/[^a-zA-Z0-9._]/-/g'`
elif [[ $GITHUB_BRANCH == 'develop' ]]
then
TAG=nightly
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/regression_test_lite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
if [[ ! $GITHUB_REF_NAME == 'main' ]] && [[ ! $GITHUB_REF_NAME == 'develop' ]]
then
TAG=${GITHUB_REF_NAME//\//_}
TAG=`echo ${GITHUB_REF_NAME} | sed 's/[^a-zA-Z0-9._]/-/g'`
elif [[ $GITHUB_REF_NAME == 'develop' ]]
then
TAG=nightly
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/smoke_test_participant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
GITHUB_BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-)
if [[ ! $GITHUB_BRANCH == 'main' ]] && [[ ! $GITHUB_BRANCH == 'develop' ]]
then
TAG=${GITHUB_BRANCH//\//_}
TAG=`echo ${GITHUB_BRANCH} | sed 's/[^a-zA-Z0-9._]/-/g'`
elif [[ $GITHUB_BRANCH == 'develop' ]]
then
TAG=nightly
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
GITHUB_BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-)
if [[ ! $GITHUB_BRANCH == 'main' ]] && [[ ! $GITHUB_BRANCH == 'develop' ]]
then
TAG=${GITHUB_BRANCH//\//_}
TAG=`echo ${GITHUB_BRANCH} | sed 's/[^a-zA-Z0-9._]/-/g'`
elif [[ $GITHUB_BRANCH == 'develop' ]]
then
TAG=nightly
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
GITHUB_BRANCH=$(echo ${GITHUB_REF} | cut -d '/' -f 3-)
if [[ ! $GITHUB_BRANCH == 'main' ]] && [[ ! $GITHUB_BRANCH == 'develop' ]]
then
TAG=${GITHUB_BRANCH//\//_}
TAG=`echo ${GITHUB_BRANCH} | sed 's/[^a-zA-Z0-9._]/-/g'`
elif [[ $GITHUB_BRANCH == 'develop' ]]
then
TAG=nightly
Expand Down
3 changes: 2 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ external = ["T20"] # Don't autoremove 'noqa` comments for these rules
"CPAC/utils/sklearn.py" = ["RUF003"]
"CPAC/utils/tests/old_functions.py" = ["C", "D", "E", "EM", "PLW", "RET"]
"CPAC/utils/utils.py" = ["T201"] # until `repickle` is removed
"dev/circleci_data/conftest.py" = ["F401"]
"setup.py" = ["D1"]

[lint.flake8-import-conventions.extend-aliases]
Expand All @@ -33,7 +34,7 @@ section-order = ["future", "standard-library", "third-party", "collab", "other-f

[lint.isort.sections]
"collab" = ["nibabel", "nilearn", "nipype", "PyBASC", "pybids", "scipy", "spython"]
"other-first-party" = ["flowdump", "indi_aws", "indi_schedulers", "PyPEER"]
"other-first-party" = ["bids2table", "flowdump", "indi_aws", "indi_schedulers", "PyPEER"]

[lint.pydocstyle]
convention = "numpy"
Expand Down
3 changes: 3 additions & 0 deletions .stubs/bids2table/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._b2t import bids2table

__all__ = ["bids2table"]
50 changes: 50 additions & 0 deletions .stubs/bids2table/_b2t.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright (C) 2024 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/>.
# """Specific typing stubs for bids2table."""
from typing import Literal, Optional, overload

from elbow.typing import StrOrPath
from bids2table.table import BIDSTable

@overload
def bids2table(
root: StrOrPath,
*,
with_meta: bool = True,
persistent: bool = False,
index_path: Optional[StrOrPath] = None,
exclude: Optional[list[str]] = None,
incremental: bool = False,
overwrite: bool = False,
workers: Optional[int] = None,
worker_id: Optional[int] = None,
return_table: Literal[True] = True,
) -> BIDSTable: ...
@overload
def bids2table(
root: StrOrPath,
*,
with_meta: bool = True,
persistent: bool = False,
index_path: Optional[StrOrPath] = None,
exclude: Optional[list[str]] = None,
incremental: bool = False,
overwrite: bool = False,
workers: Optional[int] = None,
worker_id: Optional[int] = None,
return_table: Literal[False],
) -> None: ...
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Moved `pygraphviz` from requirements to `graphviz` optional dependencies group.
- Split `ResourcePool` into three classes: `Resource`, `ResourcePool`, and `StratPool`.

### Fixed

Expand Down
24 changes: 17 additions & 7 deletions CPAC/_entrypoints/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from warnings import simplefilter

import yaml
from bids2table import bids2table

from CPAC import __version__, license_notice
from CPAC.pipeline import AVAILABLE_PIPELINE_CONFIGS
Expand All @@ -37,7 +38,6 @@
from CPAC.utils.bids_utils import (
cl_strip_brackets,
create_cpac_data_config,
load_cpac_data_config,
load_yaml_config,
sub_list_filter_by_labels,
)
Expand Down Expand Up @@ -779,10 +779,20 @@ def run_main():
args.skip_bids_validator,
only_one_anat=False,
)
else:
sub_list = load_cpac_data_config(
args.data_config_file, args.participant_label, args.aws_input_creds
)
# Initializing the bidstable on the bids_directory
bids_table = bids2table(bids_dir, workers=10).flat

try:
# fillna
bids_table["ses"] = bids_table["ses"].fillna("None")
grouped_tab = bids_table.groupby(["sub", "ses"])
except Exception as e:
msg = f"Could not create bids table: {e}"
raise ValueError(msg) from e
# else:
# sub_list = load_cpac_data_config(
# args.data_config_file, args.participant_label, args.aws_input_creds
# )
list(sub_list)
sub_list = sub_list_filter_by_labels(
sub_list, {"T1w": args.T1w_label, "bold": args.bold_label}
Expand Down Expand Up @@ -824,7 +834,7 @@ def run_main():
data_hash = hash_data_config(sub_list)
data_config_file = f"cpac_data_config_{data_hash}_{st}.yml"

sublogdirs = [set_subject(sub, c)[2] for sub in sub_list]
sublogdirs = [set_subject(sub, c)[2] for sub in grouped_tab]
# write out the data configuration file
data_config_file = os.path.join(sublogdirs[0], data_config_file)
with open(data_config_file, "w", encoding="utf-8") as _f:
Expand Down Expand Up @@ -919,7 +929,7 @@ def run_main():

WFLOGGER.info("Starting participant level processing")
exitcode = CPAC.pipeline.cpac_runner.run(
data_config_file,
grouped_tab,
pipeline_config_file,
plugin="MultiProc" if plugin_args["n_procs"] > 1 else "Linear",
plugin_args=plugin_args,
Expand Down
2 changes: 1 addition & 1 deletion CPAC/alff/alff.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from CPAC.alff.utils import get_opt_string
from CPAC.pipeline import nipype_pipeline_engine as pe
from CPAC.pipeline.nodeblock import nodeblock
from CPAC.pipeline.engine.nodeblock import nodeblock
from CPAC.registration.registration import apply_transform
from CPAC.utils.interfaces import Function
from CPAC.utils.utils import check_prov_for_regtool
Expand Down
2 changes: 1 addition & 1 deletion CPAC/anat_preproc/anat_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
wb_command,
)
from CPAC.pipeline import nipype_pipeline_engine as pe
from CPAC.pipeline.nodeblock import nodeblock
from CPAC.pipeline.engine.nodeblock import nodeblock
from CPAC.utils.interfaces import Function
from CPAC.utils.interfaces.fsl import Merge as fslMerge

Expand Down
32 changes: 32 additions & 0 deletions CPAC/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2024 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/>.
"""Global pytest configuration."""

from pathlib import Path

import pytest


@pytest.fixture
def bids_examples(cache: pytest.Cache) -> Path:
"""Get cached example BIDS directories."""
bids_dir = cache.mkdir("bids-examples").absolute()
if not (bids_dir.exists() and list(bids_dir.iterdir())):
from git import Repo

Repo.clone_from("https://github.com/bids-standard/bids-examples.git", bids_dir)
return bids_dir
13 changes: 2 additions & 11 deletions CPAC/distortion_correction/distortion_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
run_fsl_topup,
)
from CPAC.pipeline import nipype_pipeline_engine as pe
from CPAC.pipeline.nodeblock import nodeblock
from CPAC.pipeline.engine.nodeblock import nodeblock
from CPAC.utils import function
from CPAC.utils.datasource import match_epi_fmaps
from CPAC.utils.interfaces.function import Function
Expand Down Expand Up @@ -438,11 +438,6 @@ def distcor_blip_afni_qwarp(wf, cfg, strat_pool, pipe_num, opt=None):
node, out = strat_pool.get_data("pe-direction")
wf.connect(node, out, match_epi_fmaps_node, "bold_pedir")

# interface = {'bold': (match_epi_fmaps_node, 'opposite_pe_epi'),
# 'desc-brain_bold': 'opposite_pe_epi_brain'}
# wf, strat_pool = wrap_block([bold_mask_afni, bold_masking],
# interface, wf, cfg, strat_pool, pipe_num, opt)

func_get_brain_mask = pe.Node(
interface=preprocess.Automask(), name=f"afni_mask_opposite_pe_{pipe_num}"
)
Expand Down Expand Up @@ -530,10 +525,6 @@ def distcor_blip_afni_qwarp(wf, cfg, strat_pool, pipe_num, opt=None):
wf.connect(node, out, undistort_func_mean, "reference_image")
wf.connect(convert_afni_warp, "ants_warp", undistort_func_mean, "transforms")

# interface = {'desc-preproc_bold': (undistort_func_mean, 'output_image')}
# wf, strat_pool = wrap_block([bold_mask_afni],
# interface, wf, cfg, strat_pool, pipe_num, opt)

remask = pe.Node(
interface=preprocess.Automask(), name=f"afni_remask_boldmask_{pipe_num}"
)
Expand Down Expand Up @@ -764,7 +755,7 @@ def distcor_blip_fsl_topup(wf, cfg, strat_pool, pipe_num, opt=None):
wf.connect(run_topup, "out_jacs", vnum_base, "jac_matrix_list")
wf.connect(run_topup, "out_warps", vnum_base, "warp_field_list")

mean_bold = strat_pool.node_data("sbref")
mean_bold = strat_pool.get_data("sbref")

flirt = pe.Node(interface=fsl.FLIRT(), name="flirt")
flirt.inputs.dof = 6
Expand Down
23 changes: 16 additions & 7 deletions CPAC/func_preproc/func_ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@

# 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 CPAC.utils.datasource import create_func_datasource, ingress_func_metadata
"""Ingress functional data for preprocessing."""

from CPAC.utils.strategy import Strategy


def connect_func_ingress(
workflow, strat_list, c, sub_dict, subject_id, input_creds_path, unique_id=None
workflow,
strat_list: list[Strategy],
c,
sub_dict,
subject_id,
input_creds_path,
unique_id=None,
):
"""Connect functional ingress workflow."""
for num_strat, strat in enumerate(strat_list):
if "func" in sub_dict:
func_paths_dict = sub_dict["func"]
Expand All @@ -31,7 +40,9 @@ def connect_func_ingress(
else:
workflow_name = f"func_gather_{unique_id}_{num_strat}"

func_wf = create_func_datasource(func_paths_dict, workflow_name)
func_wf = strat._resource_pool.create_func_datasource(
func_paths_dict, workflow_name
)

func_wf.inputs.inputnode.set(
subject=subject_id,
Expand All @@ -47,8 +58,6 @@ def connect_func_ingress(
}
)

(workflow, strat.rpool, diff, blip, fmap_rp_list) = ingress_func_metadata(
workflow, c, strat.rpool, sub_dict, subject_id, input_creds_path, unique_id
)
diff, blip, fmap_rp_list = strat.rpool.ingress_func_metadata()

return (workflow, diff, blip, fmap_rp_list)
return strat.rpool.wf, diff, blip, fmap_rp_list
4 changes: 2 additions & 2 deletions CPAC/func_preproc/func_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
motion_power_statistics,
)
from CPAC.pipeline import nipype_pipeline_engine as pe
from CPAC.pipeline.nodeblock import nodeblock
from CPAC.pipeline.engine.nodeblock import nodeblock
from CPAC.pipeline.schema import valid_options
from CPAC.utils.interfaces.function import Function
from CPAC.utils.utils import check_prov_for_motion_tool
Expand Down Expand Up @@ -830,7 +830,7 @@ def motion_estimate_filter(wf, cfg, strat_pool, pipe_num, opt=None):
notch.inputs.lowpass_cutoff = opt.get("lowpass_cutoff")
notch.inputs.filter_order = opt.get("filter_order")

movement_parameters = strat_pool.node_data("desc-movementParameters_motion")
movement_parameters = strat_pool.get_data("desc-movementParameters_motion")
wf.connect(
movement_parameters.node, movement_parameters.out, notch, "motion_params"
)
Expand Down
4 changes: 2 additions & 2 deletions CPAC/func_preproc/func_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from CPAC.func_preproc.utils import nullify
from CPAC.pipeline import nipype_pipeline_engine as pe
from CPAC.pipeline.nodeblock import nodeblock
from CPAC.pipeline.engine.nodeblock import nodeblock
from CPAC.utils.interfaces import Function
from CPAC.utils.interfaces.ants import (
AI, # niworkflows
Expand Down Expand Up @@ -993,7 +993,7 @@ def bold_mask_fsl_afni(wf, cfg, strat_pool, pipe_num, opt=None):
# and this function has been changed.

# CHANGES:
# * Converted from a plain function to a CPAC.pipeline.nodeblock.NodeBlockFunction
# * Converted from a plain function to a CPAC.pipeline.engine.nodeblock.NodeBlockFunction
# * Removed Registration version check
# * Hardcoded Registration parameters instead of loading epi_atlasbased_brainmask.json
# * Uses C-PAC's ``FSL-AFNI-brain-probseg`` template in place of ``templateflow.api.get("MNI152NLin2009cAsym", resolution=1, label="brain", suffix="probseg")``
Expand Down
Loading