Skip to content

Commit 58264f5

Browse files
committed
Pop goodvoxels out of fsLR_resampling.
1 parent af90cf9 commit 58264f5

File tree

2 files changed

+27
-36
lines changed

2 files changed

+27
-36
lines changed

fmriprep/workflows/bold/base.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,11 @@ def init_bold_wf(
509509
]) # fmt:skip
510510

511511
if config.workflow.cifti_output:
512-
from .resampling import init_bold_fsLR_resampling_wf, init_bold_grayords_wf
512+
from .resampling import (
513+
init_bold_fsLR_resampling_wf,
514+
init_bold_grayords_wf,
515+
init_goodvoxels_bold_mask_wf,
516+
)
513517

514518
bold_MNI6_wf = init_bold_volumetric_resample_wf(
515519
metadata=all_metadata[0],
@@ -520,12 +524,29 @@ def init_bold_wf(
520524
)
521525

522526
bold_fsLR_resampling_wf = init_bold_fsLR_resampling_wf(
523-
estimate_goodvoxels=config.workflow.project_goodvoxels,
524527
grayord_density=config.workflow.cifti_output,
525528
omp_nthreads=omp_nthreads,
526529
mem_gb=mem_gb["resampled"],
527530
)
528531

532+
if config.workflow.project_goodvoxels:
533+
goodvoxels_bold_mask_wf = init_goodvoxels_bold_mask_wf(mem_gb)
534+
535+
workflow.connect([
536+
(inputnode, goodvoxels_bold_mask_wf, [
537+
("bold_file", "inputnode.bold_file"),
538+
("anat_ribbon", "inputnode.anat_ribbon"),
539+
]),
540+
(goodvoxels_bold_mask_wf, bold_fsLR_resampling_wf, [
541+
("outputnode.goodvoxels_mask", "inputnode.volume_roi"),
542+
]),
543+
]) # fmt:skip
544+
545+
bold_fsLR_resampling_wf.__desc__ += """\
546+
A "goodvoxels" mask was applied during volume-to-surface sampling in fsLR space,
547+
excluding voxels whose time-series have a locally high coefficient of variation.
548+
"""
549+
529550
bold_grayords_wf = init_bold_grayords_wf(
530551
grayord_density=config.workflow.cifti_output,
531552
mem_gb=1,

fmriprep/workflows/bold/resampling.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ def _calc_lower_thr(in_stats):
501501

502502
def init_bold_fsLR_resampling_wf(
503503
grayord_density: ty.Literal['91k', '170k'],
504-
estimate_goodvoxels: bool,
505504
omp_nthreads: int,
506505
mem_gb: float,
507506
name: str = "bold_fsLR_resampling_wf",
@@ -520,7 +519,6 @@ def init_bold_fsLR_resampling_wf(
520519
521520
from fmriprep.workflows.bold.resampling import init_bold_fsLR_resampling_wf
522521
wf = init_bold_fsLR_resampling_wf(
523-
estimate_goodvoxels=True,
524522
grayord_density='92k',
525523
omp_nthreads=1,
526524
mem_gb=1,
@@ -530,9 +528,6 @@ def init_bold_fsLR_resampling_wf(
530528
----------
531529
grayord_density : :class:`str`
532530
Either ``"91k"`` or ``"170k"``, representing the total *grayordinates*.
533-
estimate_goodvoxels : :class:`bool`
534-
Calculate mask excluding voxels with a locally high coefficient of variation to
535-
exclude from surface resampling
536531
omp_nthreads : :class:`int`
537532
Maximum number of threads an individual process may use
538533
mem_gb : :class:`float`
@@ -558,15 +553,13 @@ def init_bold_fsLR_resampling_wf(
558553
Path to left and right hemisphere sphere.reg GIFTI surfaces, mapping from subject to fsLR
559554
cortex_mask : :class:`list` of :class:`str`
560555
Path to left and right hemisphere cortical masks.
561-
goodvoxels_mask : :class:`str` or Undefined
556+
volume_roi : :class:`str` or Undefined
562557
Pre-calculated goodvoxels mask. Not required.
563558
564559
Outputs
565560
-------
566561
bold_fsLR : :class:`list` of :class:`str`
567562
Path to BOLD series resampled as functional GIFTI files in fsLR space
568-
goodvoxels_mask : :class:`str`
569-
Path to mask of voxels, excluding those with locally high coefficients of variation
570563
571564
"""
572565
import templateflow.api as tf
@@ -596,7 +589,7 @@ def init_bold_fsLR_resampling_wf(
596589
'midthickness_fsLR',
597590
'sphere_reg_fsLR',
598591
'cortex_mask',
599-
'goodvoxels_mask',
592+
'volume_roi',
600593
]
601594
),
602595
name='inputnode',
@@ -615,7 +608,7 @@ def init_bold_fsLR_resampling_wf(
615608
)
616609

617610
outputnode = pe.Node(
618-
niu.IdentityInterface(fields=['bold_fsLR', 'goodvoxels_mask']),
611+
niu.IdentityInterface(fields=['bold_fsLR']),
619612
name='outputnode',
620613
)
621614

@@ -690,6 +683,7 @@ def init_bold_fsLR_resampling_wf(
690683
# Resample BOLD to native surface, dilate and mask
691684
(inputnode, volume_to_surface, [
692685
('bold_file', 'volume_file'),
686+
('volume_roi', 'volume_roi'),
693687
]),
694688
(select_surfaces, volume_to_surface, [
695689
('midthickness', 'surface_file'),
@@ -716,30 +710,6 @@ def init_bold_fsLR_resampling_wf(
716710
(joinnode, outputnode, [('bold_fsLR', 'bold_fsLR')]),
717711
]) # fmt:skip
718712

719-
if estimate_goodvoxels:
720-
workflow.__desc__ += """\
721-
A "goodvoxels" mask was applied during volume-to-surface sampling in fsLR space,
722-
excluding voxels whose time-series have a locally high coefficient of variation.
723-
"""
724-
725-
goodvoxels_bold_mask_wf = init_goodvoxels_bold_mask_wf(mem_gb)
726-
727-
workflow.connect([
728-
(inputnode, goodvoxels_bold_mask_wf, [
729-
("bold_file", "inputnode.bold_file"),
730-
("anat_ribbon", "inputnode.anat_ribbon"),
731-
]),
732-
(goodvoxels_bold_mask_wf, volume_to_surface, [
733-
("outputnode.goodvoxels_mask", "volume_roi"),
734-
]),
735-
(goodvoxels_bold_mask_wf, outputnode, [
736-
("outputnode.goodvoxels_mask", "goodvoxels_mask"),
737-
]),
738-
]) # fmt:skip
739-
else:
740-
# Won't have any effect if goodvoxels_mask is Undefined.
741-
workflow.connect([(inputnode, volume_to_surface, [('goodvoxels_mask', 'volume_roi')])])
742-
743713
return workflow
744714

745715

0 commit comments

Comments
 (0)