Skip to content

[BUG]: compute_epi_mask fails for data in native space#481

Merged
synchon merged 2 commits intomainfrom
fix/native-data-callable-mask-apply
Jan 28, 2026
Merged

[BUG]: compute_epi_mask fails for data in native space#481
synchon merged 2 commits intomainfrom
fix/native-data-callable-mask-apply

Conversation

@synchon
Copy link
Copy Markdown
Member

@synchon synchon commented Jan 27, 2026

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I want to compute the epi mask on native space. Junifer fails with the following trace:

Traceback (most recent call last):
  File "/home/fraimondo/miniforge3/envs/junifer_dev/bin/junifer", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/fraimondo/miniforge3/envs/junifer_dev/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/miniforge3/envs/junifer_dev/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/fraimondo/miniforge3/envs/junifer_dev/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/miniforge3/envs/junifer_dev/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/miniforge3/envs/junifer_dev/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/cli/cli.py", line 185, in run
    cli_func.run(
  File "/home/fraimondo/dev/tbox/junifer/junifer/api/functions.py", line 223, in run
    mc.fit(datagrabber_object[t_element])
  File "/home/fraimondo/dev/tbox/junifer/junifer/pipeline/marker_collection.py", line 103, in fit
    data = preprocessor.fit_transform(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/pipeline/pipeline_step_mixin.py", line 232, in fit_transform
    return self._fit_transform(input=input, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/preprocess/base.py", line 181, in _fit_transform
    t_out = self.preprocess(input=t_input, extra_input=extra_input)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/preprocess/_temporal_filter.py", line 148, in preprocess
    mask_img = get_data(
               ^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/data/_dispatch.py", line 160, in get_data
    return registry().get(
           ^^^^^^^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/data/masks/_masks.py", line 483, in get
    warper_spec = get_native_warper(
                  ^^^^^^^^^^^^^^^^^^
  File "/home/fraimondo/dev/tbox/junifer/junifer/data/utils.py", line 120, in get_native_warper
    raise_error(
  File "/home/fraimondo/dev/tbox/junifer/junifer/utils/logging.py", line 267, in raise_error
    raise klass(msg)
RuntimeError: Could not find correct warping specification

Indeed, the error comes from the _masks.py file, when it tries to get the warp spec to go from native (?) to native:

        # Extra data type requirement check if target space is native
        if target_space == "native":
            # Check for extra inputs
            if extra_input is None:
                raise_error(
                    "No extra input provided, requires `Warp` and `T1w` "
                    "data types in particular for transformation to "
                    f"{target_data['space']} space for further computation."
                )
            # Get native space warper spec
            warper_spec = get_native_warper(
                target_data=target_data,
                other_data=extra_input,
            )

Expected Behavior

I expect that the EPI mask is computed in native space

Steps To Reproduce

  1. With junifer latest dev
  2. Run:
workdir: /tmp

with:
  ./external/juni-private-farm/datagrabbers/juseless_ukb_bold.py
datagrabber:
    kind:  JuselessUKBBoldDataGrabber

preprocess:
    kind: TemporalFilter
    detrend: true
    standardize: true
    low_pass: 0.08
    high_pass: 0.01
    masks:
      - compute_epi_mask

markers:
  - name: Schaefer200x17-TianxS2x3TxMNInonlinear2009cAsym_FC
    kind: FunctionalConnectivityParcels
    parcellation: 
        - Schaefer200x17
        - TianxS2x3TxMNInonlinear2009cAsym
    masks:
      - inherit
storage:
  kind: HDF5FeatureStorage
  uri: /data/group/riseml/fraimondo/ukb_fcprediction/feature_storage/ukb_fc_features.h5

queue:
  jobname: EXTRACT_FC_UKB
  kind: HTCondor
  env:
    kind: conda
    name: junifer_dev
  mem: 8G

Environment

junifer:
  version: 0.0.7.dev301
python:
  version: 3.12.7
  implementation: CPython
dependencies:
  click: 8.1.7
  numpy: 1.26.4
  scipy: 1.14.1
  datalad: 1.1.4
  pandas: 2.2.3
  nibabel: 5.3.2
  nilearn: 0.10.4
  sqlalchemy: 2.0.36
  ruamel.yaml: 0.18.6
  templateflow: 24.2.2
  lazy_loader: '0.4'
  looseversion: None
  junifer_data: None
  structlog: 25.5.0
system:
  platform: Linux-6.12.9+bpo-amd64-x86_64-with-glibc2.36
environment:
  PATH: 
    /home/fraimondo/miniforge3/envs/junifer_dev/bin:/home/fraimondo/.local/bin:/home/fraimondo/miniforge3/condabin:/usr/local/bin:/home/fraimondo/miniforge3/condabin:/home/fraimondo/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/games

Relevant log output

Anything else?

No response

@fraimondo fraimondo added bug Something isn't working triage New issues waiting to be reviewed labels Jan 27, 2026
@synchon synchon self-assigned this Jan 27, 2026
@synchon synchon added mask Issues or pull requests related to masks and removed triage New issues waiting to be reviewed labels Jan 27, 2026
@synchon synchon added this to the 0.0.7 (alpha 6) milestone Jan 27, 2026
@synchon synchon changed the title [BUG]: compute_epi_mask fails for data in native space [BUG]: compute_epi_mask fails for data in native space Jan 27, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 27, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-01-28 15:35 UTC

@synchon synchon requested a review from fraimondo January 27, 2026 18:52
@synchon synchon force-pushed the fix/native-data-callable-mask-apply branch from 672d761 to 2bf62bb Compare January 28, 2026 14:53
@synchon synchon merged commit 997c9d3 into main Jan 28, 2026
6 of 14 checks passed
@synchon synchon deleted the fix/native-data-callable-mask-apply branch January 28, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mask Issues or pull requests related to masks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants