Skip to content

Commit 0eb9f62

Browse files
committed
Keep working.
1 parent 06495cd commit 0eb9f62

File tree

4 files changed

+40
-39
lines changed

4 files changed

+40
-39
lines changed

xcp_d/interfaces/bids.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -259,32 +259,31 @@ def _run_interface(self, runtime):
259259
Sources = self.inputs.Sources
260260

261261
tpl = get_entity(name_source, 'tpl')
262-
res = get_entity(name_source, 'res')
263-
den = get_entity(name_source, 'den')
262+
tpl_str = f'tpl-{tpl}_' if tpl else ''
263+
if tpl:
264+
output_dir = os.path.join(output_dir, f'tpl-{tpl}')
265+
264266
cohort = get_entity(name_source, 'cohort')
267+
cohort_str = f'cohort-{cohort}_' if cohort else ''
268+
if cohort:
269+
output_dir = os.path.join(output_dir, f'cohort-{cohort}')
265270

266-
cohort_str = f'_cohort-{cohort}' if cohort else ''
271+
res = get_entity(name_source, 'res')
267272
res_str = f'_res-{res}' if res else ''
268-
den_str = f'_den-{den}' if den else ''
269273

270-
atlas_out_dir = os.path.join(output_dir, f'tpl-{tpl}')
271-
if cohort:
272-
atlas_out_dir = os.path.join(atlas_out_dir, f'cohort-{cohort}')
273-
274-
if res:
275-
out_basename = f'tpl-{tpl}{cohort_str}_atlas-{atlas}{res_str}_dseg'
276-
else:
277-
out_basename = f'tpl-{tpl}{cohort_str}_atlas-{atlas}{den_str}_dseg'
274+
den = get_entity(name_source, 'den')
275+
den_str = f'_den-{den}' if den else ''
278276

277+
out_basename = f'{tpl_str}{cohort_str}atlas-{atlas}{res_str}{den_str}_dseg'
279278
if in_file.endswith('.tsv'):
280279
extension = '.tsv'
281280
elif in_file.endswith('.dlabel.nii'):
282281
extension = '.dlabel.nii'
283282
else:
284283
extension = '.nii.gz'
285284

286-
os.makedirs(atlas_out_dir, exist_ok=True)
287-
out_file = os.path.join(atlas_out_dir, f'{out_basename}{extension}')
285+
os.makedirs(output_dir, exist_ok=True)
286+
out_file = os.path.join(output_dir, f'{out_basename}{extension}')
288287

289288
if out_file.endswith('.nii.gz') and os.path.isfile(out_file):
290289
# Check that native-resolution atlas doesn't have a different resolution from the last
@@ -300,14 +299,14 @@ def _run_interface(self, runtime):
300299
# Don't copy the file if it exists, to prevent any race conditions between parallel
301300
# processes.
302301
if not os.path.isfile(out_file):
303-
lock_file = os.path.join(atlas_out_dir, f'{out_basename}{extension}.lock')
302+
lock_file = os.path.join(output_dir, f'{out_basename}{extension}.lock')
304303
with filelock.SoftFileLock(lock_file, timeout=60):
305304
shutil.copyfile(in_file, out_file)
306305

307306
# Only write out a sidecar if metadata are provided
308307
if meta_dict or Sources:
309-
meta_file = os.path.join(atlas_out_dir, f'{out_basename}.json')
310-
lock_meta = os.path.join(atlas_out_dir, f'{out_basename}.json.lock')
308+
meta_file = os.path.join(output_dir, f'{out_basename}.json')
309+
lock_meta = os.path.join(output_dir, f'{out_basename}.json.lock')
311310
meta_dict = meta_dict or {}
312311
meta_dict = meta_dict.copy()
313312
if Sources:

xcp_d/workflows/anatomical/parcellation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ def init_parcellate_surfaces_wf(files_to_parcellate, name='parcellate_surfaces_w
179179
name=f'ds_parcellated_{file_to_parcellate}',
180180
run_without_submitting=True,
181181
mem_gb=1,
182-
iterfield=['segmentation', 'in_file'],
182+
iterfield=['atlas', 'in_file'],
183183
)
184184
workflow.connect([
185185
(inputnode, ds_parcellated_surface, [
186186
(file_to_parcellate, 'source_file'),
187-
('atlas_names', 'segmentation'),
187+
('atlas_names', 'atlas'),
188188
]),
189189
(add_hash_parcellated_surface, ds_parcellated_surface, [('out_file', 'in_file')]),
190190
]) # fmt:skip

xcp_d/workflows/bold/outputs.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def init_postproc_derivatives_wf(
208208
DerivativesDataSink(
209209
source_file=name_source,
210210
dismiss_entities=dismiss_hash(
211-
['segmentation', 'den', 'res', 'space', 'cohort', 'desc']
211+
['atlas', 'den', 'res', 'space', 'cohort', 'desc']
212212
),
213213
suffix='motion',
214214
extension='.tsv',
@@ -269,7 +269,7 @@ def init_postproc_derivatives_wf(
269269
ds_temporal_mask = pe.Node(
270270
DerivativesDataSink(
271271
dismiss_entities=dismiss_hash(
272-
['segmentation', 'den', 'res', 'space', 'cohort', 'desc']
272+
['atlas', 'den', 'res', 'space', 'cohort', 'desc']
273273
),
274274
suffix='outliers',
275275
extension='.tsv',
@@ -484,10 +484,10 @@ def init_postproc_derivatives_wf(
484484
name='ds_coverage',
485485
run_without_submitting=True,
486486
mem_gb=1,
487-
iterfield=['segmentation', 'in_file', 'meta_dict'],
487+
iterfield=['atlas', 'in_file', 'meta_dict'],
488488
)
489489
workflow.connect([
490-
(inputnode, ds_coverage, [('atlas_names', 'segmentation')]),
490+
(inputnode, ds_coverage, [('atlas_names', 'atlas')]),
491491
(add_hash_coverage, ds_coverage, [
492492
('out_file', 'in_file'),
493493
('metadata', 'meta_dict'),
@@ -537,10 +537,10 @@ def init_postproc_derivatives_wf(
537537
name='ds_timeseries',
538538
run_without_submitting=True,
539539
mem_gb=1,
540-
iterfield=['segmentation', 'in_file', 'meta_dict'],
540+
iterfield=['atlas', 'in_file', 'meta_dict'],
541541
)
542542
workflow.connect([
543-
(inputnode, ds_timeseries, [('atlas_names', 'segmentation')]),
543+
(inputnode, ds_timeseries, [('atlas_names', 'atlas')]),
544544
(add_hash_timeseries, ds_timeseries, [
545545
('out_file', 'in_file'),
546546
('metadata', 'meta_dict'),
@@ -612,10 +612,10 @@ def init_postproc_derivatives_wf(
612612
name='ds_correlations',
613613
run_without_submitting=True,
614614
mem_gb=1,
615-
iterfield=['segmentation', 'in_file', 'meta_dict'],
615+
iterfield=['atlas', 'in_file', 'meta_dict'],
616616
)
617617
workflow.connect([
618-
(inputnode, ds_correlations, [('atlas_names', 'segmentation')]),
618+
(inputnode, ds_correlations, [('atlas_names', 'atlas')]),
619619
(add_hash_correlations, ds_correlations, [
620620
('out_file', 'in_file'),
621621
('metadata', 'meta_dict'),
@@ -636,11 +636,11 @@ def init_postproc_derivatives_wf(
636636
name='ds_coverage_ciftis',
637637
run_without_submitting=True,
638638
mem_gb=1,
639-
iterfield=['segmentation', 'in_file', 'meta_dict'],
639+
iterfield=['atlas', 'in_file', 'meta_dict'],
640640
)
641641
workflow.connect([
642642
(inputnode, ds_coverage_ciftis, [
643-
('atlas_names', 'segmentation'),
643+
('atlas_names', 'atlas'),
644644
('coverage_ciftis', 'in_file'),
645645
]),
646646
(add_denoised_to_src, ds_coverage_ciftis, [('metadata', 'meta_dict')]),
@@ -676,11 +676,11 @@ def init_postproc_derivatives_wf(
676676
name='ds_timeseries_ciftis',
677677
run_without_submitting=True,
678678
mem_gb=1,
679-
iterfield=['segmentation', 'in_file', 'meta_dict'],
679+
iterfield=['atlas', 'in_file', 'meta_dict'],
680680
)
681681
workflow.connect([
682682
(inputnode, ds_timeseries_ciftis, [
683-
('atlas_names', 'segmentation'),
683+
('atlas_names', 'atlas'),
684684
('timeseries_ciftis', 'in_file'),
685685
]),
686686
(add_ccoverage_to_src, ds_timeseries_ciftis, [('metadata', 'meta_dict')]),
@@ -741,11 +741,11 @@ def init_postproc_derivatives_wf(
741741
name='ds_correlation_ciftis',
742742
run_without_submitting=True,
743743
mem_gb=1,
744-
iterfield=['segmentation', 'in_file', 'meta_dict'],
744+
iterfield=['atlas', 'in_file', 'meta_dict'],
745745
)
746746
workflow.connect([
747747
(inputnode, ds_correlation_ciftis, [
748-
('atlas_names', 'segmentation'),
748+
('atlas_names', 'atlas'),
749749
('correlation_ciftis', 'in_file'),
750750
]),
751751
(make_ccorrs_meta_dict2, ds_correlation_ciftis, [('metadata', 'meta_dict')]),
@@ -786,10 +786,10 @@ def init_postproc_derivatives_wf(
786786
name=f'ds_correlations_exact_{i_exact_scan}',
787787
run_without_submitting=True,
788788
mem_gb=1,
789-
iterfield=['segmentation', 'in_file'],
789+
iterfield=['atlas', 'in_file'],
790790
)
791791
workflow.connect([
792-
(inputnode, ds_correlations_exact, [('atlas_names', 'segmentation')]),
792+
(inputnode, ds_correlations_exact, [('atlas_names', 'atlas')]),
793793
(add_hash_correlations_exact, ds_correlations_exact, [('out_file', 'in_file')]),
794794
]) # fmt:skip
795795

@@ -876,10 +876,10 @@ def init_postproc_derivatives_wf(
876876
name='ds_parcellated_reho',
877877
run_without_submitting=True,
878878
mem_gb=1,
879-
iterfield=['segmentation', 'in_file', 'meta_dict'],
879+
iterfield=['atlas', 'in_file', 'meta_dict'],
880880
)
881881
workflow.connect([
882-
(inputnode, ds_parcellated_reho, [('atlas_names', 'segmentation')]),
882+
(inputnode, ds_parcellated_reho, [('atlas_names', 'atlas')]),
883883
(add_hash_parcellated_reho, ds_parcellated_reho, [
884884
('out_file', 'in_file'),
885885
('metadata', 'meta_dict'),
@@ -988,10 +988,10 @@ def init_postproc_derivatives_wf(
988988
name='ds_parcellated_alff',
989989
run_without_submitting=True,
990990
mem_gb=1,
991-
iterfield=['segmentation', 'in_file', 'meta_dict'],
991+
iterfield=['atlas', 'in_file', 'meta_dict'],
992992
)
993993
workflow.connect([
994-
(inputnode, ds_parcellated_alff, [('atlas_names', 'segmentation')]),
994+
(inputnode, ds_parcellated_alff, [('atlas_names', 'atlas')]),
995995
(add_hash_parcellated_alff, ds_parcellated_alff, [
996996
('out_file', 'in_file'),
997997
('metadata', 'meta_dict'),

xcp_d/workflows/parcellation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def init_load_atlases_wf(name='load_atlases_wf'):
6969
file_format=config.workflow.file_format,
7070
bids_filters=config.execution.bids_filters,
7171
)
72+
# TODO: Grab the atlas-<label>_description.json at the top of the dataset and
73+
# copy it to the output directory.
7274

7375
# Reorganize the atlas file information
7476
atlas_names, atlas_files, atlas_labels_files, atlas_metadata = [], [], [], []

0 commit comments

Comments
 (0)