Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
napari-3dtimereg
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaëlle LETORT
napari-3dtimereg
Compare revisions
332578b3e364154e7001e1646147139db48ebe2f to dd7f5f836a218392141f59a8fc8b45318dcaf6be
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
gletort/napari-3dtimereg
Select target project
No results found
dd7f5f836a218392141f59a8fc8b45318dcaf6be
Select Git revision
Branches
main
Swap
Target
gletort/napari-3dtimereg
Select target project
gletort/napari-3dtimereg
1 result
332578b3e364154e7001e1646147139db48ebe2f
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
new parameters possible
· 58474d12
Gaelle Letort
authored
1 month ago
58474d12
for doc
· 25e568f2
Gaelle Letort
authored
1 month ago
25e568f2
Merge branch 'main' of
https://gitlab.pasteur.fr/gletort/napari-3dtimereg
into main
· dd7f5f83
Gaelle Letort
authored
1 month ago
dd7f5f83
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
imgs/load.png
+0
-0
0 additions, 0 deletions
imgs/load.png
setup.cfg
+1
-1
1 addition, 1 deletion
setup.cfg
src/napari_3dtimereg/movieRegistration.py
+113
-4
113 additions, 4 deletions
src/napari_3dtimereg/movieRegistration.py
with
114 additions
and
5 deletions
imgs/load.png
0 → 100644
View file @
dd7f5f83
224 KiB
This diff is collapsed.
Click to expand it.
setup.cfg
View file @
dd7f5f83
[metadata]
name
=
napari-3dtimereg
version
=
0.0.1
0
version
=
0.0.1
1
description
=
Registration of 3D movies applied to all channels
long_description
=
file: README.md
long_description_content_type
=
text/markdown
...
...
This diff is collapsed.
Click to expand it.
src/napari_3dtimereg/movieRegistration.py
View file @
dd7f5f83
...
...
@@ -177,7 +177,7 @@ def rigid_map( iterations, rig_resolution, rig_final_spacing, use_points=True ):
parameter_map_rigid
[
'
MaximumStepLength
'
]
=
[
'
2.0
'
]
parameter_map_rigid
[
"
NumberOfResolutions
"
]
=
[
rig_resolution
]
parameter_map_rigid
[
'
NumberOfSpatialSamples
'
]
=
[
'
10000
'
]
parameter_map_rigid
[
'
MaximumNumberOfSamplingAttempts
'
]
=
[
'
10
'
]
parameter_map_rigid
[
'
MaximumNumberOfSamplingAttempts
'
]
=
[
'
8
'
]
parameter_map_rigid
[
'
RequiredRatioOfValidSamples
'
]
=
[
'
0.05
'
]
parameter_map_rigid
[
'
CheckNumberOfSamples
'
]
=
[
'
false
'
]
parameter_map_rigid
[
'
FinalGridSpacingInPhysicalUnits
'
]
=
[
str
(
rig_final_spacing
)]
...
...
@@ -200,12 +200,12 @@ def bspline_map( spline_resolution, iterations, final_order, spline_final_spacin
parameter_map
[
"
NumberOfResolutions
"
]
=
[
spline_resolution
]
parameter_map
[
"
WriteIterationInfo
"
]
=
[
"
false
"
]
parameter_map
[
'
MaximumStepLength
'
]
=
[
'
2.0
'
]
parameter_map
[
'
NumberOfSpatialSamples
'
]
=
[
'
10
000
'
]
parameter_map
[
'
NumberOfSpatialSamples
'
]
=
[
'
8
000
'
]
parameter_map
[
'
MaximumNumberOfSamplingAttempts
'
]
=
[
'
10
'
]
parameter_map
[
'
RequiredRatioOfValidSamples
'
]
=
[
'
0.05
'
]
parameter_map
[
'
MaximumNumberOfIterations
'
]
=
[
iterations
]
parameter_map
[
'
FinalBSplineInterpolationOrder
'
]
=
[
final_order
]
parameter_map
[
'
BSplineInterpolationOrder
'
]
=
[
'
3
'
]
parameter_map
[
'
BSplineInterpolationOrder
'
]
=
[
'
2
'
]
parameter_map
[
'
HowToCombineTransform
'
]
=
[
'
Compose
'
]
nres
=
int
(
spline_resolution
)
spaces
=
[]
...
...
@@ -276,6 +276,111 @@ def time_registration( do_rigid, do_bspline, iterations, rigid_resolution, rigid
# transform the current slice and append it to the reconstructed stack
apply_registration
(
t
,
curr_transform_object
)
def
middle_time_registration
(
do_rigid
,
do_bspline
,
iterations
,
rigid_resolution
,
rigid_final_spacing
,
use_reference_points
,
spline_resolution
,
spline_final_spacing
,
final_order
,
show_log
=
True
):
"""
Go for frame by frame registration, reference frame middle one
"""
## Build registration parameter maps from GUI parameters
registration_parameter_object
=
itk
.
ParameterObject
.
New
()
nmap
=
0
if
do_rigid
:
pmap_rigid
=
rigid_map
(
iterations
=
str
(
iterations
),
rig_resolution
=
str
(
rigid_resolution
),
rig_final_spacing
=
int
(
rigid_final_spacing
),
use_points
=
use_reference_points
)
registration_parameter_object
.
AddParameterMap
(
pmap_rigid
)
nmap
=
nmap
+
1
if
do_bspline
:
pmap_spline
=
bspline_map
(
spline_resolution
=
str
(
spline_resolution
),
iterations
=
str
(
iterations
),
final_order
=
str
(
final_order
),
spline_final_spacing
=
int
(
spline_final_spacing
)
)
registration_parameter_object
.
AddParameterMap
(
pmap_spline
)
nmap
=
nmap
+
1
## reference frame
reft
=
int
(
resimg
.
shape
[
0
]
/
2
)
## apply "alignement" to first frame
apply_registration
(
reft
,
None
)
# initialise a parameter object to which the transforms will be appended that result from the pairwise slice registrations
curr_transform_object
=
itk
.
ParameterObject
.
New
()
# the first fixed image will be the reference slice
fixed_image_itk
=
img_to_itk
(
resimg
[
reft
])
## Register all frames to following one and add it
t
=
reft
-
1
while
t
>=
0
:
print
(
"
Calculate registration for time point
"
+
str
(
t
))
# the moving image is the current slice
moving_image_itk
=
img_to_itk
(
resimg
[
t
])
# perform the pairwise registration between two slices
elastix_object
=
itk
.
ElastixRegistrationMethod
.
New
(
fixed_image_itk
,
moving_image_itk
)
elastix_object
.
SetParameterObject
(
registration_parameter_object
)
if
use_reference_points
:
get_ref_points
(
t
+
1
,
t
)
elastix_object
.
SetFixedPointSetFileName
(
os
.
path
.
join
(
aligndir
,
imagename
+
"
_refpts_fixed.txt
"
))
elastix_object
.
SetMovingPointSetFileName
(
os
.
path
.
join
(
aligndir
,
imagename
+
"
_refpts_moving.txt
"
))
elastix_object
.
SetLogToConsole
(
show_log
==
True
)
# Update filter object (required)
elastix_object
.
UpdateLargestPossibleRegion
()
# Results of Registration
results_transform_parameters
=
elastix_object
.
GetTransformParameterObject
()
# set the current moving image as the fixed image for the registration in the next iteration
fixed_image_itk
=
moving_image_itk
# append the obtained transform to the transform parameter object
for
i
in
range
(
nmap
):
curr_transform_object
.
AddParameterMap
(
results_transform_parameters
.
GetParameterMap
(
i
))
# transform the current slice and append it to the reconstructed stack
apply_registration
(
t
,
curr_transform_object
)
## next time
t
=
t
-
1
## Next phase go from refframe to the end
t
=
reft
+
1
fixed_image_itk
=
img_to_itk
(
resimg
[
reft
]
)
curr_transform_object
=
itk
.
ParameterObject
.
New
()
while
t
<
resimg
.
shape
[
0
]:
print
(
"
Calculate registration for time point
"
+
str
(
t
))
# the moving image is the current slice
moving_image_itk
=
img_to_itk
(
resimg
[
t
])
# perform the pairwise registration between two slices
elastix_object
=
itk
.
ElastixRegistrationMethod
.
New
(
fixed_image_itk
,
moving_image_itk
)
elastix_object
.
SetParameterObject
(
registration_parameter_object
)
if
use_reference_points
:
get_ref_points
(
t
-
1
,
t
)
elastix_object
.
SetFixedPointSetFileName
(
os
.
path
.
join
(
aligndir
,
imagename
+
"
_refpts_fixed.txt
"
))
elastix_object
.
SetMovingPointSetFileName
(
os
.
path
.
join
(
aligndir
,
imagename
+
"
_refpts_moving.txt
"
))
elastix_object
.
SetLogToConsole
(
show_log
==
True
)
# Update filter object (required)
elastix_object
.
UpdateLargestPossibleRegion
()
# Results of Registration
results_transform_parameters
=
elastix_object
.
GetTransformParameterObject
()
# set the current moving image as the fixed image for the registration in the next iteration
fixed_image_itk
=
moving_image_itk
# append the obtained transform to the transform parameter object
for
i
in
range
(
nmap
):
curr_transform_object
.
AddParameterMap
(
results_transform_parameters
.
GetParameterMap
(
i
))
# transform the current slice and append it to the reconstructed stack
apply_registration
(
t
,
curr_transform_object
)
## next time
t
=
t
+
1
def
iterative_registration
():
"""
use Elastix to perform registration with possible deformation, iteratively in time
"""
...
...
@@ -294,6 +399,7 @@ def iterative_registration():
refpoints_file
=
pathlib
.
Path
(
os
.
path
.
join
(
imagedir
,
imagename
+
"
_reference_points.csv
"
)),
do_rigid
=
True
,
do_bspline
=
True
,
middle_reference_frame
=
True
,
show_advanced_parameters
=
False
,
rigid_resolution
=
4
,
spline_resolution
=
4
,
...
...
@@ -310,7 +416,10 @@ def iterative_registration():
if
use_reference_points
:
read_points
(
refpoints_file
)
#move_points = True
time_registration
(
do_rigid
=
do_rigid
,
do_bspline
=
do_bspline
,
iterations
=
iterations
,
rigid_resolution
=
rigid_resolution
,
rigid_final_spacing
=
rigid_final_spacing
,
use_reference_points
=
use_reference_points
,
spline_resolution
=
spline_resolution
,
spline_final_spacing
=
spline_final_spacing
,
final_order
=
final_order
,
show_log
=
show_log
)
if
not
middle_reference_frame
:
time_registration
(
do_rigid
=
do_rigid
,
do_bspline
=
do_bspline
,
iterations
=
iterations
,
rigid_resolution
=
rigid_resolution
,
rigid_final_spacing
=
rigid_final_spacing
,
use_reference_points
=
use_reference_points
,
spline_resolution
=
spline_resolution
,
spline_final_spacing
=
spline_final_spacing
,
final_order
=
final_order
,
show_log
=
show_log
)
else
:
middle_time_registration
(
do_rigid
=
do_rigid
,
do_bspline
=
do_bspline
,
iterations
=
iterations
,
rigid_resolution
=
rigid_resolution
,
rigid_final_spacing
=
rigid_final_spacing
,
use_reference_points
=
use_reference_points
,
spline_resolution
=
spline_resolution
,
spline_final_spacing
=
spline_final_spacing
,
final_order
=
final_order
,
show_log
=
show_log
)
finish_image
()
def
show_advanced
(
booly
):
...
...
This diff is collapsed.
Click to expand it.