Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save output with the same format as brainreg #66

Merged
merged 40 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d02d294
Added output directory field
IgorTatarnikov Dec 11, 2024
15bf1ea
WIP use output directory as output for elastix
IgorTatarnikov Dec 11, 2024
807e034
Save the deformation fields in the brainreg format to the output dire…
IgorTatarnikov Dec 11, 2024
bc1b8cd
Save deformation fields as tiff not tif
IgorTatarnikov Dec 11, 2024
b7f79eb
Add function to save output from registration
IgorTatarnikov Dec 11, 2024
b2733e7
Update elastix default to save tiff not nii
IgorTatarnikov Dec 11, 2024
189f52b
WIP writing brainreg output directory
IgorTatarnikov Dec 11, 2024
84f010f
WIP calculate area of annotations
IgorTatarnikov Dec 13, 2024
e8f745a
Remap labels outside of float precision to allow transforming of anno…
IgorTatarnikov Dec 13, 2024
2b96d46
Save all files as per brainreg, save the forward and inverse transfor…
IgorTatarnikov Dec 13, 2024
75f70f5
Make ara-tools default options with 2 registration types
IgorTatarnikov Dec 16, 2024
d42ebc6
Changed convert_atlas_labels function to avoid weird edge cases
IgorTatarnikov Dec 17, 2024
e1a5c79
Merge branch 'main' into output-deformation-fields
IgorTatarnikov Dec 17, 2024
ec01d54
Update docstrings
IgorTatarnikov Dec 17, 2024
eea29a6
Add tests for dconverting atlas labels
IgorTatarnikov Dec 17, 2024
f766fdb
Updated docstring for convert_atlas_labels
IgorTatarnikov Dec 17, 2024
c713371
Fixed tests to account for updates for changes to transform select view
IgorTatarnikov Dec 17, 2024
afa7e51
Add pandas as explicit dependency
IgorTatarnikov Dec 17, 2024
a91f176
Update docstring for calculate_areas
IgorTatarnikov Dec 17, 2024
574187b
Added tests for calculating area
IgorTatarnikov Dec 17, 2024
b23bd8f
Remove superfluous function
IgorTatarnikov Dec 17, 2024
d46f771
Remove rigid transformation option
IgorTatarnikov Dec 18, 2024
862b616
Fixed tests to account for removing rigid transformation option
IgorTatarnikov Dec 18, 2024
a3db01b
Add new test data
IgorTatarnikov Dec 20, 2024
47e8683
Update register.py testing such that affine only transforms are run o…
IgorTatarnikov Dec 20, 2024
116c14c
Added tests for register
IgorTatarnikov Dec 20, 2024
87f7c58
Tests for calculate_deformation_field, transform_image
IgorTatarnikov Dec 20, 2024
5f80694
Add tolerance when comparing transform parameter objects
IgorTatarnikov Dec 20, 2024
f53e02c
Add slack for all floating point parameters
IgorTatarnikov Dec 20, 2024
b073fed
Ensure example_mouse_100um is loaded for testing the registration_widget
IgorTatarnikov Dec 20, 2024
b4ceda3
GetImage not View from annotation array
IgorTatarnikov Dec 20, 2024
b10f636
Fixed key error for transforming annotation
IgorTatarnikov Jan 2, 2025
1f18fbb
Removed non-linear regression test files
IgorTatarnikov Jan 2, 2025
01f4ce2
merge main
adamltyson Jan 3, 2025
35f021b
Serialise registration widget to brainglobe_registration.json
IgorTatarnikov Jan 6, 2025
155c6b8
Serialise registration widget to brainglobe_registration.json
IgorTatarnikov Jan 6, 2025
498ce1a
Add debug flag to calculating deformation field
IgorTatarnikov Jan 6, 2025
668bd80
Add indentation to pretify brainglobe-registration.json
IgorTatarnikov Jan 6, 2025
de2714c
Make output_directory mandatory before running registration from the …
IgorTatarnikov Jan 6, 2025
4e276f3
Merge branch 'main' into output-deformation-fields
IgorTatarnikov Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed convert_atlas_labels function to avoid weird edge cases
IgorTatarnikov committed Dec 17, 2024
commit d42ebc6163fc68541bf03d71e0e7ab403bf6ea77
21 changes: 12 additions & 9 deletions brainglobe_registration/utils/utils.py
Original file line number Diff line number Diff line change
@@ -340,39 +340,42 @@ def calculate_areas(

def convert_atlas_labels(
annotation_image: npt.NDArray[np.uint32],
max_value=131072,
) -> Tuple[npt.NDArray[np.uint32], Dict[int, int]]:
"""
Adjust the atlas labels such that they can be represented accurately
by a single precision float (np.float32).
This is done by mapping the labels greater than the max_value 2**17 to new
values starting from 2**16.
This assumes that there are no atlas IDs between 2**16 and max_value,
and there are fewer than 2**16 atlas IDs greater than max_value.
This is done by mapping the labels greater than 2**16 to new
consecutive values starting from 2**16.
Parameters
----------
annotation_image
max_value
Returns
-------
npt.NDArray[np.uint32]
The adjusted annotation image.
Dict[int, int]
A dictionary mapping the original values to the new values
"""
# Returns a sorted array of unique values in the annotation image
values = np.unique(annotation_image)

if isinstance(values, da.Array):
values = values.compute()

# Create a mapping of the original values to the new values
# and adjust the annotation image
mapping = {}
new_value = 2**16
for value in values:
if value > max_value:
if value > new_value:
mapping[value] = new_value
annotation_image[annotation_image == value] = new_value
new_value += 1
elif value == new_value:
new_value += 1

return annotation_image, mapping