Skip to content

Refactor dwi2response brain mask derivation with shell subsets#3383

Merged
Lestropie merged 1 commit into
devfrom
dwi2response_masking
Jun 3, 2026
Merged

Refactor dwi2response brain mask derivation with shell subsets#3383
Lestropie merged 1 commit into
devfrom
dwi2response_masking

Conversation

@Lestropie
Copy link
Copy Markdown
Member

Closes #2963.

Resolve a conflict in dwi2response between restricting response function
estimation to a subset of shells and deriving a brain mask. Previously, when a
shell subset was requested (or the chosen algorithm operates on a single shell)
and no mask was supplied, dwi2mask was run on the already shell-filtered data.
The command now imports the whole DWI series, derives the mask from all
available data, and only then extracts the requested shells for response
function estimation; when a mask is provided, the subset continues to be
extracted directly on import. A paragraph is added to the command documentation
explaining this behaviour and noting that, to mask from the same subset, the
user should either supply that subset as input or provide a mask generated from
it.

Session prompts:
1. > Python command dwi2response currently contains a conflict regarding the use of a subset of shells for response function estimation vs. derivation of a brain mask. If either the user specifies that they wish to compute response functions for only a subset of shells, or an algorithm nominates that it can only operate on a single b>0 shell---possibly including the b=0 shell also---then this filtering will be applied at initial import of data into the scratch directory. If this imported image is then used to derive a brain mask, because the user did not provide one themselves, then the derivation of that mask will be performed using only that particular subset of shells. The command is to be refactored as follows.
   > 1. If the user specifies a subset of shells, but does not provide a mask:
   >     1.1. The whole input DWI series will be imported into the scratch directory.
   >     1.2. Command dwi2mask will be executed on this complete DWI series.
   >     1.3. The user-requested subset of shells will be extracted using dwiextract; app.cleanup() can then be executed on the initial imported DWI.
   >     1.4. The requested dwi2response algorithm is executed taking as input the shell-filtered DWI.
   > 2. If the user specifies a subset of shells, but also provides a mask:
   >     2.1. The input DWI series will be filtered using dwiextract immediately upon import.
   >     2.2. THe requested dwi2response algorithm is executed taking this DWI series as input.
   > A paragraph shall be added to the command documentation describing that in the absence of a user-specified mask, the whole DWI series will be used for brain mask derivation; if the user wishes for the same subset of shells used for response function estimation to also be used for brain mask estimation, then they should generate that subset using eg. the dwiextract command and then provide that result as the input to dwi2response.

Generated-by: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

clang-tidy review says "All clean, LGTM! 👍"

@Lestropie Lestropie merged commit 9482c5a into dev Jun 3, 2026
6 of 7 checks passed
@Lestropie Lestropie deleted the dwi2response_masking branch June 3, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant