Skip to content

Commit c7ec669

Browse files
committed
🔀 Merge develop into fix/minimal-schema
2 parents e9740cf + 776e7e6 commit c7ec669

File tree

16 files changed

+206
-44
lines changed

16 files changed

+206
-44
lines changed

.github/Dockerfiles/Ubuntu.bionic-non-free.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ RUN groupadd -r c-pac && \
107107
libxp-dev && \
108108
add-apt-repository --remove --yes ppa:zeehio/libxp && \
109109
apt-get update && \
110-
curl -sO https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh && \
111-
bash Miniconda3-py37_4.8.2-Linux-x86_64.sh -b -p /usr/local/miniconda && \
112-
rm Miniconda3-py37_4.8.2-Linux-x86_64.sh && chmod -R 777 /usr/local/miniconda && \
110+
curl -sO https://repo.anaconda.com/miniconda/Miniconda3-py37_4.12.0-Linux-x86_64.sh && \
111+
bash Miniconda3-py37_4.12.0-Linux-x86_64.sh -b -p /usr/local/miniconda && \
112+
rm Miniconda3-py37_4.12.0-Linux-x86_64.sh && chmod -R 777 /usr/local/miniconda && \
113113
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
114114
echo $TZ > /etc/timezone && \
115115
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \

.github/Dockerfiles/Ubuntu.xenial-20200114.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ RUN apt-get update && \
120120
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
121121

122122
# Installing and setting up miniconda
123-
RUN curl -sSLO https://repo.continuum.io/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh && \
124-
bash Miniconda3-4.5.11-Linux-x86_64.sh -b -p /usr/local/miniconda && \
125-
rm Miniconda3-4.5.11-Linux-x86_64.sh && chmod -R 777 /usr/local/miniconda
123+
RUN curl -sSLO https://repo.continuum.io/miniconda/Miniconda3-py37_4.12.0-Linux-x86_64.sh && \
124+
bash Miniconda3-py37_4.12.0-Linux-x86_64.sh -b -p /usr/local/miniconda && \
125+
rm Miniconda3-py37_4.12.0-Linux-x86_64.sh && chmod -R 777 /usr/local/miniconda
126126

127127
# Set CPATH for packages relying on compiled libs (e.g. indexed_gzip)
128128
ENV PATH="/usr/local/miniconda/bin:$PATH" \

.github/scripts/get_package_id.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
def get_packages(owner, tag, api_token=None):
1313
"""Function to collect GHCR packages for a given owner & tag
14-
14+
1515
Parameters
1616
----------
1717
owner : str
1818
username or org name
19-
19+
2020
tag : str
2121
image tag (part left of the colon)
2222
2323
api_token : str or None
2424
GitHub API personal access token with read.packages permission
25-
25+
2626
Returns
2727
-------
2828
list
@@ -32,11 +32,11 @@ def get_packages(owner, tag, api_token=None):
3232

3333
def fetch(url):
3434
"""Method to make API call and return response, given a URL
35-
35+
3636
Parameters
3737
----------
3838
url : str
39-
39+
4040
Returns
4141
-------
4242
dict or list
@@ -59,34 +59,36 @@ def fetch(url):
5959
'$VERSION_TAG $GITHUB_TOKEN`'
6060
]))
6161
return response
62-
packages = fetch(
62+
_packages = fetch(
6363
f'https://api.github.com/orgs/{owner}/packages/container/'
6464
f'{tag}/versions')
65-
if packages.get('message', 'Not Found') == 'Not Found':
66-
packages = fetch(
67-
f'https://api.github.com/users/{owner}/packages/container/'
68-
f'{tag}/versions')
65+
packages = []
66+
for _package in _packages:
67+
if _package.get('message', 'Not Found') == 'Not Found':
68+
packages += fetch(
69+
f'https://api.github.com/users/{owner}/packages/container/'
70+
f'{tag}/versions')
6971
return packages
7072

7173

7274
def id_from_tag(owner, image, tag, api_token=None):
7375
"""Function to return a package ID given an image version tag
74-
76+
7577
Parameters
7678
----------
7779
owner : str
7880
GitHub username or org name
79-
81+
8082
image : str
8183
Image tag (the part to the left of the colon)
82-
84+
8385
tag : str
8486
Image version tag (the part to the right of the colon)
8587
8688
api_token: str or None
8789
GitHub API personal access token with read.packages permission
8890
"""
89-
packages = get_packages(owner, image)
91+
packages = get_packages(owner, image, api_token)
9092
versions = [image['id'] for image in packages if tag in image.get(
9193
'metadata', {}
9294
).get('container', {}).get('tags', [])]

.github/workflows/build_stages.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
DOCKER_TAG=$(echo "ghcr.io/${{ github.repository }}/$TAG" | tr '[:upper:]' '[:lower:]')
6767
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_ENV
6868
docker manifest inspect $DOCKER_TAG >/dev/null
69-
echo "::set-output name=not_yet_exists::$?"
69+
echo "not_yet_exists=$?" >> $GITHUB_OUTPUT
7070
- name: Set up Docker Buildx
7171
uses: docker/[email protected]
7272
if: contains(steps.changed-files-base.outputs.all_changed_files, matrix.Dockerfile) || contains(steps.changed-files.outputs.all_changed_files, matrix.Dockerfile)
@@ -156,7 +156,7 @@ jobs:
156156
DOCKER_TAG=$(echo "ghcr.io/${{ github.repository }}/$TAG" | tr '[:upper:]' '[:lower:]')
157157
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_ENV
158158
docker manifest inspect $DOCKER_TAG >/dev/null
159-
echo "::set-output name=not_yet_exists::$?"
159+
echo "not_yet_exists=$?" >> $GITHUB_OUTPUT
160160
if: contains(steps.changed-files-base.outputs.all_changed_files, matrix.Dockerfile) || contains(steps.changed-files.outputs.all_changed_files, matrix.Dockerfile)
161161
- name: Prep Dockerfiles for forked repository
162162
if: github.repository_owner != 'FCP-INDI' && contains(steps.changed-files-base.outputs.all_changed_files, matrix.Dockerfile) || contains(steps.changed-files.outputs.all_changed_files, matrix.Dockerfile)
@@ -230,7 +230,7 @@ jobs:
230230
DOCKER_TAG=$(echo "ghcr.io/${{ github.repository }}/$TAG" | tr '[:upper:]' '[:lower:]')
231231
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_ENV
232232
docker manifest inspect $DOCKER_TAG >/dev/null
233-
echo "::set-output name=not_yet_exists::$?"
233+
echo "not_yet_exists=$?" >> $GITHUB_OUTPUT
234234
id: docker_tag
235235
- name: Clear up some space on runner
236236
if: always() && steps.changed-files-base.outputs.any_changed == 'true' || steps.changed-files.outputs.any_changed == 'true' || steps.docker_tag.not_yet_exists == 1

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Added the ability to ingress TotalReadoutTime from epi field map meta-data from the JSON sidecars.
2222
- Added the ability to use TotalReadoutTime of epi field maps in the calculation of FSL topup distortion correction.
2323
- Difference method (``-``) for ``CPAC.utils.configuration.Configuration`` instances
24+
- Calculate reho and alff when timeseries in template space
2425

2526
### Changed
2627
- Added a level of depth to `working` directories to match `log` and `output` directory structure

CPAC/alff/alff.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def alff_falff(wf, cfg, strat_pool, pipe_num, opt=None):
246246
"switch": ["run"],
247247
"option_key": "None",
248248
"option_val": "None",
249-
"inputs": [["desc-cleanedNofilt_bold", "desc-brain_bold",
249+
"inputs": [["desc-denoisedNofilt_bold", "desc-brain_bold",
250250
"desc-preproc_bold", "bold"],
251251
"space-bold_desc-brain_mask"],
252252
"outputs": ["alff",
@@ -262,7 +262,7 @@ def alff_falff(wf, cfg, strat_pool, pipe_num, opt=None):
262262
alff.get_node('hp_input').iterables = ('hp', alff.inputs.hp_input.hp)
263263
alff.get_node('lp_input').iterables = ('lp', alff.inputs.lp_input.lp)
264264

265-
node, out = strat_pool.get_data(["desc-cleanedNofilt_bold", "desc-brain_bold",
265+
node, out = strat_pool.get_data(["desc-denoisedNofilt_bold", "desc-brain_bold",
266266
"desc-preproc_bold", "bold"])
267267
wf.connect(node, out, alff, 'inputspec.rest_res')
268268

@@ -275,3 +275,38 @@ def alff_falff(wf, cfg, strat_pool, pipe_num, opt=None):
275275
}
276276

277277
return (wf, outputs)
278+
279+
def alff_falff_space_template(wf, cfg, strat_pool, pipe_num, opt=None):
280+
'''
281+
{"name": "alff_falff_space_template",
282+
"config": ["amplitude_low_frequency_fluctuation"],
283+
"switch": ["run"],
284+
"option_key": "None",
285+
"option_val": "None",
286+
"inputs": [["space-template_desc-denoisedNofilt_bold"],
287+
"space-template_desc-bold_mask"],
288+
"outputs": ["space-template_alff",
289+
"space-template_falff"]}
290+
'''
291+
292+
alff = create_alff(f'alff_falff_{pipe_num}')
293+
294+
alff.inputs.hp_input.hp = \
295+
cfg.amplitude_low_frequency_fluctuation['highpass_cutoff']
296+
alff.inputs.lp_input.lp = \
297+
cfg.amplitude_low_frequency_fluctuation['lowpass_cutoff']
298+
alff.get_node('hp_input').iterables = ('hp', alff.inputs.hp_input.hp)
299+
alff.get_node('lp_input').iterables = ('lp', alff.inputs.lp_input.lp)
300+
301+
node, out = strat_pool.get_data(["space-template_desc-denoisedNofilt_bold"])
302+
wf.connect(node, out, alff, 'inputspec.rest_res')
303+
304+
node, out = strat_pool.get_data("space-template_desc-bold_mask")
305+
wf.connect(node, out, alff, 'inputspec.rest_mask')
306+
307+
outputs = {
308+
'space-template_alff': (alff, 'outputspec.alff_img'),
309+
'space-template_falff': (alff, 'outputspec.falff_img')
310+
}
311+
312+
return (wf, outputs)

CPAC/info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def get_cpac_gitversion():
177177
"future",
178178
"INDI-Tools",
179179
"lockfile==0.12.2",
180+
"joblib==1.0.1",
180181
"matplotlib==3.1.3",
181182
"networkx==2.4",
182183
"nibabel==2.3.3",

CPAC/nuisance/nuisance.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,6 @@ def nuisance_regression(wf, cfg, strat_pool, pipe_num, opt, space):
25322532
outputs = {
25332533
desc_keys[0]: (nuis, 'outputspec.residual_file_path'),
25342534
desc_keys[1]: (nuis, 'outputspec.residual_file_path'),
2535-
desc_keys[2]: (nuis, 'outputspec.residual_file_path')
25362535
}
25372536

25382537
return (wf, outputs)
@@ -2587,13 +2586,10 @@ def nuisance_regression_template(wf, cfg, strat_pool, pipe_num, opt=None):
25872586
"dvars"),
25882587
"TR"],
25892588
"outputs": {"space-template_desc-preproc_bold": {
2590-
"Description": "Preprocessed BOLD image that was nuisance-"
2589+
"Description": "Preprocessed BOLD image that was nusiance-"
25912590
"regressed in template space"},
25922591
"space-template_desc-cleaned_bold": {
2593-
"Description": "Preprocessed BOLD image that was nuisance-"
2594-
"regressed in template space"},
2595-
"space-template_desc-denoisedNofilt_bold": {
2596-
"Description": "Preprocessed BOLD image that was nuisance-"
2592+
"Description": "Preprocessed BOLD image that was nusiance-"
25972593
"regressed in template space"},
25982594
"regressors": {
25992595
"Description": "Regressors that were applied in template space"}}}

CPAC/pipeline/cpac_pipeline.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
warp_bold_mean_to_T1template,
103103
warp_bold_mask_to_T1template,
104104
warp_deriv_mask_to_T1template,
105+
warp_denoiseNofilt_to_T1template,
105106
warp_timeseries_to_EPItemplate,
106107
warp_bold_mean_to_EPItemplate,
107108
warp_bold_mask_to_EPItemplate,
@@ -183,8 +184,8 @@
183184
multiple_regression
184185
)
185186

186-
from CPAC.alff.alff import alff_falff
187-
from CPAC.reho.reho import reho
187+
from CPAC.alff.alff import alff_falff, alff_falff_space_template
188+
from CPAC.reho.reho import reho, reho_space_template
188189

189190
from CPAC.vmhc.vmhc import (
190191
smooth_func_vmhc,
@@ -1282,6 +1283,10 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
12821283
if not rpool.check_rpool('space-template_desc-bold_mask'):
12831284
pipeline_blocks += [warp_bold_mask_to_T1template,
12841285
warp_deriv_mask_to_T1template]
1286+
1287+
target_space_alff = cfg.amplitude_low_frequency_fluctuation['target_space']
1288+
if 'Template' in target_space_alff and not rpool.check_rpool('space-template_desc-denoisedNofilt_bold'):
1289+
pipeline_blocks += [warp_denoiseNofilt_to_T1template]
12851290

12861291
template = cfg.registration_workflows['functional_registration']['func_registration_to_template']['target_template']['using']
12871292

@@ -1324,6 +1329,7 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
13241329
tse_atlases, sca_atlases = gather_extraction_maps(cfg)
13251330
cfg.timeseries_extraction['tse_atlases'] = tse_atlases
13261331
cfg.seed_based_correlation_analysis['sca_atlases'] = sca_atlases
1332+
target_space_reho = cfg.regional_homogeneity['target_space']
13271333

13281334
if not rpool.check_rpool('desc-Mean_timeseries') and \
13291335
'Avg' in tse_atlases:
@@ -1349,11 +1355,21 @@ def build_workflow(subject_id, sub_dict, cfg, pipeline_name=None,
13491355
'MultReg' in sca_atlases:
13501356
pipeline_blocks += [multiple_regression]
13511357

1352-
if not rpool.check_rpool('alff'):
1353-
pipeline_blocks += [alff_falff]
1354-
1355-
if not rpool.check_rpool('reho'):
1356-
pipeline_blocks += [reho]
1358+
if 'Native' in target_space_alff:
1359+
if not rpool.check_rpool('alff'):
1360+
pipeline_blocks += [alff_falff]
1361+
1362+
if 'Template' in target_space_alff:
1363+
if not rpool.check_rpool('space-template_alff'):
1364+
pipeline_blocks += [alff_falff_space_template]
1365+
1366+
if 'Native' in target_space_reho:
1367+
if not rpool.check_rpool('reho'):
1368+
pipeline_blocks += [reho]
1369+
1370+
if 'Template' in target_space_reho:
1371+
if not rpool.check_rpool('space-template_reho'):
1372+
pipeline_blocks += [reho_space_template]
13571373

13581374
if not rpool.check_rpool('vmhc'):
13591375
pipeline_blocks += [smooth_func_vmhc,

CPAC/pipeline/engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ def __init__(self, rpool=None, name=None, cfg=None, pipe_list=None):
8888

8989
self.run_smoothing = 'smoothed' in cfg.post_processing[
9090
'spatial_smoothing']['output']
91+
self.smoothing_bool = cfg.post_processing['spatial_smoothing']['run']
9192
self.run_zscoring = 'z-scored' in cfg.post_processing[
9293
'z-scoring']['output']
94+
self.zscoring_bool = cfg.post_processing['z-scoring']['run']
9395
self.fwhm = cfg.post_processing['spatial_smoothing']['fwhm']
9496
self.smooth_opts = cfg.post_processing['spatial_smoothing'][
9597
'smoothing_method']
@@ -697,7 +699,7 @@ def post_process(self, wf, label, connection, json_info, pipe_idx, pipe_x,
697699
mask_idx = self.generate_prov_string(mask_prov)[1]
698700
break
699701

700-
if self.run_smoothing:
702+
if self.smoothing_bool:
701703
if label in Outputs.to_smooth:
702704
for smooth_opt in self.smooth_opts:
703705

@@ -736,7 +738,7 @@ def post_process(self, wf, label, connection, json_info, pipe_idx, pipe_x,
736738
pipe_idx, f'spatial_smoothing_{smooth_opt}',
737739
fork=True)
738740

739-
if self.run_zscoring:
741+
if self.zscoring_bool:
740742
for label_con_tpl in post_labels:
741743
label = label_con_tpl[0]
742744
connection = (label_con_tpl[1], label_con_tpl[2])

0 commit comments

Comments
 (0)