Add segmentation of images in "native image space"#691
Merged
Conversation
d5669df to
3388bb3
Compare
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
m-reuter
reviewed
May 8, 2025
…2 components: 1. no image rotation (affine matrix stays the same, covered by the --orientation flag) and 2. no change of image dimensions (covered by the --image_size flag). This commit implements 2 versions for orientation in addition to the previous "lia" which is default and required for downstream surface reconstruction with FreeSurfer binaries. --orientation "lia" -- reformat the affine so it is always [-X 0 0, 0 0 -X, 0 X 0] with X the voxel size, --orientation "soft lia" (or "soft-lia") -- reformat the affine so the primary directions as above, but axes might not be perfectly aligned. For this, DO NOT interpolate the image. -- orientation "native" -- do not reformat the affine, keep it as is. There is a second change to native images done by conform, changing the image dimensions so all dimensions in all directions are the same (e.g. 256 for 1mm voxelsize images), but this number is different for highres images. This behavior is still the default behavior (explicitly also --image_size "auto"). However, as this will also change the native image dimensions for segmentation, additional options are available: --image_size "auto": as before/above --image_size int: directly force a specific image dimension, e.g. 256. --image_size "fov": keep the field of view consistent, i.e. if the voxel size is not touched, keep the image size the same, or -- if the voxel size is changed via --vox_size -- set the image size such that the field of view -- the region we have data for -- stays consistent. Changes to files: conform.py and its functions are heavily restructured to optimally support these features. run_prediction and run_fastsurfer get --orientation and --image_size flags (run_fastsurfer also gets the --keepgeom flag: alias for --orientation native --image_size fov) add and consistently use function to change data orientations add documentation for new flags
3388bb3 to
a32f1de
Compare
Member
Author
|
I think this should fix everything, but I will run a final check for non-isotropic images tomorrow. |
m-reuter
reviewed
May 15, 2025
m-reuter
reviewed
May 15, 2025
| * `--no_biasfield`: Deactivate the biasfield correction and calculation of partial volume-corrected statistics in the segmentation modules. | ||
| * `--orientation`: **Only supported for `--seg_only`**, select the image orientation (`lia` (default), `soft lia` or `soft-lia` -- orient to LIA orientation, but do not interpolate, `native` -- segment in the native image space). | ||
| * `--image_size`: Select the target image size (a number to use, `fov` to set the image size to the input field of view (**allows non-cube images, only supported for `--seg_only`**), or `auto` (default) expands the image so all three image dimensions are the same). | ||
| * `--keepgeom`: **Only supported for `--seg_only`**, segment in native image space (both orientation and image size), same as `--orientation native --image_size fov`. |
Member
There was a problem hiding this comment.
I think in documentation we should use native_image as it is easier to understand.
Member
Author
There was a problem hiding this comment.
I actually forgot to change this here. --orientation and --image_size no longer supported, just --keepgeom and --native_image.
m-reuter
reviewed
May 15, 2025
m-reuter
reviewed
May 15, 2025
| type=__img_size, | ||
| help="Specifies the image size to conform to. Options: <int> (dimension of the target image), 'auto' " | ||
| "(determine dimensions of image from largest field-of-view dimension, min. 256), 'fov' (determine " | ||
| "dims. of image from field of view, dims. may be differ) or 'any' (ignore this criteria, similar to fov).", |
Member
There was a problem hiding this comment.
not toally clear here what the difference between auto and fov is. maybe auto is always a cube ?
Member
Author
There was a problem hiding this comment.
"auto" is basically fov but expanded to a cube, "fov" keeps the original field of view
c077a12 to
e56093d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add segmentation of images in "native image space".
This adds the
--native_imageflag torun_fastsurfer.shand multiple more fine-grained flags toconform.pyand the variousrun_predicions.pys for more fine control over the 3 components of the image space: "orientation", "voxel size" and "image size".--orientationFor
conform.py, this commit implements additional options for orientation in addition to the previous "lia" which is default and required for downstream surface reconstruction with FreeSurfer binaries.--orientation "XXX" e.g. "lia" -- reformat the affine so it is always aligned along the primary axes, for example [-X 0 0, 0 0 -X, 0 X 0] with X the voxel size for "lia",
--orientation "soft-XXX", e.g. "soft-lia" -- reformat the affine so the primary directions as above, but axes might not be perfectly aligned. For this, DOES NOT -- by itself -- trigger an interpolate the image.
-- orientation "native" -- do not reformat the affine, keep it as is.
There is a second change to native images done by conform, changing the image dimensions so all dimensions in all directions are the same (e.g. 256 for 1mm voxelsize images), but this number is different for highres images.
This behavior is still the default behavior (explicitly also --image_size "auto").
However, as this will also change the native image dimensions for segmentation, additional options are available:
--image_size "auto": as before/above
--image_size int: directly force a specific image dimension, e.g. 256.
--image_size "fov": keep the field of view consistent, i.e. if the voxel size is not touched, keep the image size the same, or -- if the voxel size is changed via --vox_size -- set the image size such that the field of view -- the region we have data for -- stays consistent.
Changes to files:
conform.py and its functions are heavily restructured to optimally support these features.
run_prediction and run_fastsurfer get --orientation and --image_size flags (run_fastsurfer also gets the --keepgeom flag: alias for --orientation native --image_size fov)
add and consistently use function to change data orientations
add documentation for new flags