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

Merged
synchon merged 2 commits from fix/native-data-callable-mask-apply into main 2026-01-28 14:53:46 +00:00
synchon commented 2026-01-27 17:04:20 +00:00 (Migrated from github.com)

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

### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior I want to compute the epi mask on native space. Junifer fails with the following trace: ```console 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: ```python # 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: ```yml 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 ```console 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 ```shell ``` ### Anything else? _No response_
github-actions[bot] commented 2026-01-27 17:48:12 +00:00 (Migrated from github.com)
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-01-28 15:35 UTC
[PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.8.1 :---: Preview removed because the pull request was closed. 2026-01-28 15:35 UTC <!-- Sticky Pull Request Commentpr-preview -->
fraimondo (Migrated from github.com) approved these changes 2026-01-27 19:37:21 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
juaml/junifer!481
No description provided.