nipreps/nibabies

Improve handling of low timepoint BOLDs

Open

#539 opened on Apr 1, 2026

 (3 comments) (0 reactions) (0 assignees)Python (16 forks)auto 404
enhancementgood first issue

Repository metrics

Stars
 (39 stars)
PR merge metrics
 (PR metrics pending)

Description

What happened?

Running nibabies with freesurfer using this command. During reference scan, crashed out on each scan. Scan protocol and dicom -> bids conversion unchanged from previous runs. Only difference is using freesurfer and not mcribs or infant-freesurfer.

What command did you use?

nipreps/nibabies:unstable
        /input /output participant -v
        -w /work
        --participant-label 006 
        --session-id 01
        --fs-license-file /opt/freesurfer/license.txt
        --derivatives /seg
        --age-months 29
        --surface-recon-method freesurfer
        --cifti-output 91k
        --debug registration
        --project-goodvoxels
        --multi-step-reg
        --norm-csf
        --output-spaces fsLR MNIInfant:cohort-9 MNI152NLin6Asym:res-2 T2w
        --omp-nthreads 8
        --mem 300000
        --nprocs 8
        --stop-on-first-crash
        --skip_bids_validation

What version of NiBabies are you using?

unstable

Relevant log output

Node: nibabies_26_0_wf.single_subject_sub-006_ses-01_wf.bold_ses_01_task_rest_run_06_wf.bold_fit_wf.hmc_boldref_wf.select_frames
Working directory: /work/nibabies_26_0_wf/single_subject_sub-006_ses-01_wf/bold_ses_01_task_rest_run_06_wf/bold_fit_wf/hmc_boldref_wf/select_frames

Node inputs:

dummy_scans = <undefined>
function_str = def _select_frames(
    in_file: str, ref_frame_start: int, dummy_scans: int | None
) -> tuple[int, list]:
    import warnings

    import nibabel as nb
    import numpy as np

    img = nb.load(in_file)
    img_len = img.shape[3]

    # Ensure start index is the largest of the two
    # Will usually be `ref_frame_start`
    start_frame = max(ref_frame_start, dummy_scans) if dummy_scans else ref_frame_start

    if start_frame >= img_len:
        warnings.warn(
            f'Caculating the BOLD reference starting on frame {start_frame} but only {img_len} '
            'volumes in BOLD file, so using last volume.',
            stacklevel=1,
        )
        start_frame = img_len - 1

    t_mask = np.array([False] * img_len, dtype=bool)
    t_mask[start_frame:] = True
    return start_frame, list(t_mask)

in_file = <undefined>
ref_frame_start = 16

Traceback (most recent call last):
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node
    result["result"] = node.run(updatehash=updatehash)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 525, in run
    result = self._run_interface(execute=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 643, in _run_interface
    return self._run_command(execute)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/pipeline/engine/nodes.py", line 769, in _run_command
    raise NodeExecutionError(msg)
nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node select_frames.

Traceback:
        Traceback (most recent call last):
          File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/interfaces/base/core.py", line 401, in run
            runtime = self._run_interface(runtime)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          File "/opt/conda/envs/nibabies/lib/python3.12/site-packages/nipype/interfaces/utility/wrappers.py", line 139, in _run_interface
            out = function_handle(**args)
                  ^^^^^^^^^^^^^^^^^^^^^^^
          File "<string>", line 10, in _select_frames
        IndexError: tuple index out of range

Add any additional information or context about the problem here.

No response

Contributor guide