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

Basic functionality #14

Merged
merged 47 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e098aad
Added default parameter sets to be used for transforms (from brainreg…
Oct 10, 2023
0adedfa
Basic magicgui that can import an atlas, translate the atlas/sample, …
Oct 10, 2023
8265262
Added a button to reset the image back to origin
Oct 10, 2023
8f37fad
Added the ability to rotate the image and reset back to original state
Oct 10, 2023
ab375f8
Added start alignment button
Oct 12, 2023
d0bf17c
Added start alignment button
Oct 12, 2023
ce73b7b
Merge remote-tracking branch 'origin/basic-functionality' into basic-…
Oct 12, 2023
d92810c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 12, 2023
ed93f0c
Transitioning basic function to qpty directly. Widget in registration…
Oct 13, 2023
65c04a6
Merge remote-tracking branch 'origin/basic-functionality' into basic-…
Oct 13, 2023
d53696f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 13, 2023
7297aec
Napari image layer is now rotated around the center not at origin
Oct 16, 2023
2125849
Tests for setup_parameter_object done
Oct 17, 2023
15a6e3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 17, 2023
35d39f0
Wrote basic tests for registration_widget and register
IgorTatarnikov Oct 24, 2023
5ee9e99
Re-factored the core registration_widget.py to split off each individ…
IgorTatarnikov Oct 24, 2023
4a7de5f
Added a run settings widget to allow selection of transform types and…
IgorTatarnikov Oct 24, 2023
d141831
Added tabs on the left side of the main widget, parameter_list_view r…
IgorTatarnikov Oct 24, 2023
6fd7270
Can dynamically load default values from the 3 provided sources and l…
IgorTatarnikov Oct 24, 2023
e635d81
Param dictionaries are updated when fields are altered in the table t…
IgorTatarnikov Oct 25, 2023
d7e072f
Parameter table now expands when new entries are added
IgorTatarnikov Oct 25, 2023
b0dea23
Fixed merge conflicts with renaming main
IgorTatarnikov Nov 1, 2023
72259cb
Plugin runs successfully after renaming
IgorTatarnikov Nov 1, 2023
f015b7a
Param dictionaries passed to the backend directly
IgorTatarnikov Nov 2, 2023
44c0d02
First version of transform selection widget allowing arbitrary number…
IgorTatarnikov Nov 3, 2023
eb635e8
Each column now dynamically imports the correct default file based on…
IgorTatarnikov Nov 3, 2023
b668c7e
Parameters are now read as lists from files, arbitrary numbers of par…
IgorTatarnikov Nov 6, 2023
89065b2
Moving image adjusts immediately after values are entered, removed ad…
IgorTatarnikov Nov 7, 2023
cc1ec57
When reading parameter files anything after a '\' will now be discard…
IgorTatarnikov Nov 8, 2023
5e93b54
Updated tests for braingblobe_registration/register.py, added tests f…
IgorTatarnikov Nov 9, 2023
381e2b9
Added tests for brainglobe_registration/widgets/select_images_view.py
IgorTatarnikov Nov 9, 2023
fb0dc0e
Started tests for brainglobe_registration/widgets/parameter_list_view.py
IgorTatarnikov Nov 9, 2023
6945993
Finished tests for brainglobe/registration/widgets/parameter_list_vie…
IgorTatarnikov Nov 10, 2023
f9e1d90
Started tests for transform_select_view.py
IgorTatarnikov Nov 10, 2023
8b51abc
Updating README.md
IgorTatarnikov Nov 22, 2023
c3db983
Update README.md
IgorTatarnikov Nov 22, 2023
b6eadfc
Updated README.md
IgorTatarnikov Nov 23, 2023
63de272
Added tests, added dynamic fetching for sample selection
IgorTatarnikov Nov 23, 2023
1cef635
Update README.md
IgorTatarnikov Nov 23, 2023
beaa9ad
Refactored test_registration_widget.py to account for funcitons movin…
IgorTatarnikov Nov 24, 2023
b325d56
Fixed line lengths
IgorTatarnikov Nov 24, 2023
a19a95c
WIP transforming annotations after registration
IgorTatarnikov Nov 24, 2023
1e7de58
WIP transform annotations after registration
IgorTatarnikov Nov 24, 2023
b188101
Transformed annotation and boundaries images from atlas to sample space
IgorTatarnikov Nov 27, 2023
9614ce8
Registered boundaries are now added as an image layer, boundaries ove…
IgorTatarnikov Nov 28, 2023
cdd5f1d
Changed the source link in the widget header
IgorTatarnikov Nov 28, 2023
77c28c9
Removed tutorial section of the header
IgorTatarnikov Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ venv/

# written by setuptools_scm
**/_version.py

# Other test files
Logs/
rand_test.ipynb
66 changes: 66 additions & 0 deletions parameters/ara_tools/affine.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//Affine Transformation - updated May 2012

// Description: affine, MI, ASGD

//ImageTypes
(FixedInternalImagePixelType "float")
(FixedImageDimension 3)
(MovingInternalImagePixelType "float")
(MovingImageDimension 3)

//Components
(Registration "MultiResolutionRegistration")
(FixedImagePyramid "FixedSmoothingImagePyramid")
(MovingImagePyramid "MovingSmoothingImagePyramid")
(Interpolator "BSplineInterpolator")
(Metric "AdvancedMattesMutualInformation")
(Optimizer "AdaptiveStochasticGradientDescent")
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(Transform "AffineTransform")

(ErodeMask "false" )

(NumberOfResolutions 4)

(HowToCombineTransforms "Compose")
(AutomaticTransformInitialization "true")
(AutomaticScalesEstimation "true")

(WriteTransformParametersEachIteration "false")
(WriteResultImage "true")
(ResultImageFormat "tiff")
(CompressResultImage "false")
(WriteResultImageAfterEachResolution "false")
(ShowExactMetricValue "false")

//Maximum number of iterations in each resolution level:
(MaximumNumberOfIterations 500 )

//Number of grey level bins in each resolution level:
(NumberOfHistogramBins 32 )
(FixedLimitRangeRatio 0.0)
(MovingLimitRangeRatio 0.0)
(FixedKernelBSplineOrder 3)
(MovingKernelBSplineOrder 3)

//Number of spatial samples used to compute the mutual information in each resolution level:
(ImageSampler "RandomCoordinate")
(FixedImageBSplineInterpolationOrder 3)
(UseRandomSampleRegion "false")
(NumberOfSpatialSamples 4000 )
(NewSamplesEveryIteration "true")
(CheckNumberOfSamples "true")
(MaximumNumberOfSamplingAttempts 10)

//Order of B-Spline interpolation used in each resolution level:
(BSplineInterpolationOrder 3)

//Order of B-Spline interpolation used for applying the final deformation:
(FinalBSplineInterpolationOrder 3)

//Default pixel value for pixels that come from outside the picture:
(DefaultPixelValue 0)

//SP: Param_A in each resolution level. a_k = a/(A+k+1)^alpha
(SP_A 20.0 )
74 changes: 74 additions & 0 deletions parameters/ara_tools/bspline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//Bspline Transformation - updated May 2012

//ImageTypes
(FixedInternalImagePixelType "float")
(FixedImageDimension 3)
(MovingInternalImagePixelType "float")
(MovingImageDimension 3)

//Components
(Registration "MultiResolutionRegistration")
(FixedImagePyramid "FixedSmoothingImagePyramid")
(MovingImagePyramid "MovingSmoothingImagePyramid")
(Interpolator "BSplineInterpolator")
(Metric "AdvancedMattesMutualInformation")
(Optimizer "StandardGradientDescent")
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(Transform "BSplineTransform")

(ErodeMask "false" )

(NumberOfResolutions 3)
(FinalGridSpacingInVoxels 25.000000 25.000000 25.000000)

(HowToCombineTransforms "Compose")

(WriteTransformParametersEachIteration "false")
(ResultImageFormat "tiff")
(WriteResultImage "true")
(CompressResultImage "false")
(WriteResultImageAfterEachResolution "false")
(ShowExactMetricValue "false")
(WriteDiffusionFiles "true")

// Option supported in elastix 4.1:
(UseFastAndLowMemoryVersion "true")

//Maximum number of iterations in each resolution level:
(MaximumNumberOfIterations 5000 )

//Number of grey level bins in each resolution level:
(NumberOfHistogramBins 32 )
(FixedLimitRangeRatio 0.0)
(MovingLimitRangeRatio 0.0)
(FixedKernelBSplineOrder 3)
(MovingKernelBSplineOrder 3)

//Number of spatial samples used to compute the mutual information in each resolution level:
(ImageSampler "RandomCoordinate")
(FixedImageBSplineInterpolationOrder 1 )
(UseRandomSampleRegion "true")
(SampleRegionSize 50.0 50.0 50.0)
(NumberOfSpatialSamples 10000 )
(NewSamplesEveryIteration "true")
(CheckNumberOfSamples "true")
(MaximumNumberOfSamplingAttempts 10)

//Order of B-Spline interpolation used in each resolution level:
(BSplineInterpolationOrder 3)

//Order of B-Spline interpolation used for applying the final deformation:
(FinalBSplineInterpolationOrder 3)

//Default pixel value for pixels that come from outside the picture:
(DefaultPixelValue 0)

//SP: Param_a in each resolution level. a_k = a/(A+k+1)^alpha
(SP_a 10000.0 )

//SP: Param_A in each resolution level. a_k = a/(A+k+1)^alpha
(SP_A 100.0 )

//SP: Param_alpha in each resolution level. a_k = a/(A+k+1)^alpha
(SP_alpha 0.6 )
237 changes: 237 additions & 0 deletions parameters/brainregister_IBL/affine.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
// ********** Affine Transformation **********
// --------------------------------------------------------------------------------
// Optimised Affine transform for Mouse Brain serial section 2-photon datasets
//
// Steven J. West, SWC, UCL, UK 2020


// ********** ImageTypes **********
// --------------------------------------------------------------------------------

(FixedInternalImagePixelType "float") // automatically converted to this type
(FixedImageDimension 3)

(MovingInternalImagePixelType "float") // automatically converted to this type
(MovingImageDimension 3)

(UseDirectionCosines "true")
// Setting it to false means that you choose to ignore important information
// from the image, which relates voxel coordinates to world coordinates
// Ignoring it may easily lead to left/right swaps for example, which could
// screw up a (medical) analysis


// ********** Registration **********
// --------------------------------------------------------------------------------

(Registration "MultiResolutionRegistration")
// the default


// ********** Pyramid **********
// --------------------------------------------------------------------------------

(FixedImagePyramid "FixedSmoothingImagePyramid")
// Applies gaussian smoothing and no down-sampling

(MovingImagePyramid "MovingSmoothingImagePyramid")
// Applies gaussian smoothing and no down-sampling

(NumberOfResolutions 4)
// 4 levels

(ImagePyramidSchedule 8 8 8 4 4 4 2 2 2 1 1 1)
// sigma: 8/2 XYZ, 4/2 XYZ, 2/2 XYZ, 1/2 XYZ

(ErodeMask "false" )
// information from inside any mask will flow into the ROI due to the
// smoothing step


// ********** Metric **********
// --------------------------------------------------------------------------------

(Metric "AdvancedMattesMutualInformation")
// Cost Function Metric
// quantifies the "amount of information" (in units of shannons, commonly called
// bits) obtained about one random variable through observing the other random
// variable
// only a relation between the probability distributions of the intensities of
// the fixed and moving image is assumed
// often a good choice for image registration

(NumberOfHistogramBins 32 )
(NumberOfFixedHistogramBins 32 )
(NumberOfMovingHistogramBins 32 )
// The size of the histogram. Must be given for each resolution, or for all
// resolutions at once

(FixedKernelBSplineOrder 3)
(MovingKernelBSplineOrder 3)
// The B-spline order of the Parzen window, used to estimate the joint histogram

(FixedLimitRangeRatio 0.0)
(MovingLimitRangeRatio 0.0)
// The relative extension of the intensity range of the fixed image.
// 0.0 - turned off


(ShowExactMetricValue "false" "false" "false" "false")
// get exact metric on final resolution
// computes the exact metric value (computed on all voxels rather than on the
// set of spatial samples) and shows it each iteration
// Must be given for each resolution
// This is very SLOW for large images


(UseMultiThreadingForMetrics "true")
// Whether to compute metric with multi-threading

(UseFastAndLowMemoryVersion "true")
// select between two methods for computing mutual information metric
// false : computes the derivatives of the joint histogram to each transformation
// parameter
// true : computes the mutual information via another route

(UseJacobianPreconditioning "false")
// whether to implement the preconditioning technique by Nicholas Tustison:
// "Directly Manipulated Freeform Deformations"

(FiniteDifferenceDerivative "false")
// Experimental feature, do not use.

(ASGDParameterEstimationMethod "Original")
// ASGD parameter estimation method used in this optimizer


// ********** ImageSampler **********
// --------------------------------------------------------------------------------

(ImageSampler "RandomCoordinate")

(NumberOfSpatialSamples 4000 )
// Number of spatial samples used to compute
// the mutual information in each resolution level

(NewSamplesEveryIteration "true" "true" "true" "true")
// whether to select a new set of spatial samples in every iteration

(UseRandomSampleRegion "false")
// whether to randomly select a subregion of the image in each iteration

(CheckNumberOfSamples "true")
// whether to check if at least a certain fraction (default 1/4) of the samples map
// inside the moving image.

(MaximumNumberOfSamplingAttempts 10 10 10 10)
// maximum number of sampling attempts


// ********** Interpolator and Resampler **********
// --------------------------------------------------------------------------------

(Interpolator "BSplineInterpolator")
// The interpolator to use during registration process
// BSpline : Evaluates the Values of non-voxel Positions in the Moving Image
// Basis Function for Splines - set of Piecewise Polynomial Lines

(BSplineInterpolationOrder 3)
// Order of B-Spline interpolation used in each resolution level
// 0 Nearest Neighbour, 1 Linear interpolation,
// 2+ non-linear curves with increasing degrees of freedom/power


// Order of B-Spline interpolation used when interpolating the fixed
// image - if using MultiInputRandomCoordinate sampler
(FixedImageBSplineInterpolationOrder 3)

//Default pixel value for pixels that come from outside the picture:
(DefaultPixelValue 0)

(Resampler "DefaultResampler")
// Either DefaultResampler or OpenCLResampler

(ResampleInterpolator "FinalBSplineInterpolator")
// The interpolator to use to generate the resulting deformed moving image
// BSpline : Evaluates the Values of non-voxel Positions in the Moving Image
// Basis Function for Splines - set of Piecewise Polynomial Lines

(FinalBSplineInterpolationOrder 3)
// Order of B-Spline interpolation used for applying the final deformation
// 0 Nearest Neighbour, 1 Linear interpolation,
// 2+ non-linear curves with increasing degrees of freedom/power


// ********** Transform **********
// --------------------------------------------------------------------------------

(Transform "AffineTransform")
// translate, rotate, scale, shear

(AutomaticScalesEstimation "true")
// if "true" the Scales parameter is ignored and the scales are determined
// automatically.

(AutomaticTransformInitialization "true")
// whether the initial translation between images should be estimated as the
// distance between their centers.

(AutomaticTransformInitializationMethod "GeometricalCenter")
// how to initialize this transform

(HowToCombineTransforms "Compose")
// Always use Compose for combining transforms


// ********** Optimizer **********
// --------------------------------------------------------------------------------

(Optimizer "AdaptiveStochasticGradientDescent")
// take the search direction as the negative gradient of the cost function
// Adaptive version: requires less parameters to be set and tends to be
// more robust.

(MaximumNumberOfIterations 500 500 500 500)
// Maximum number of iterations in each resolution level

(SP_A 20.0)
// SP: Param_A in each resolution level. a_k = a/(A+k+1)^alpha

(SigmoidInitialTime 0.0)
// initial time input for the sigmoid
// When increased, the optimization starts with smaller steps
// If set to 0.0, the method starts with with the largest step allowed

(MaxBandCovSize 192)
(NumberOfBandStructureSamples 10)
(UseAdaptiveStepSizes "true")
(AutomaticParameterEstimation "true")
(UseConstantStep "false")
(MaximumStepLengthRatio 1)
(NumberOfGradientMeasurements 0)
(NumberOfJacobianMeasurements 1000)
(NumberOfSamplesForExactGradient 100000)
(SigmoidScaleFactor 0.1)


// ********** Output **********
// --------------------------------------------------------------------------------

(WriteResultImage "true")
// Whether to write the final deformed image when elastix has optimised the
// transformation.

(ResultImageFormat "tiff") // commented out as not writing any images
// What image format to write the image as
// can use: "tiff" "dcm" "nrrd" "png"

// (CompressResultImage "false")
// whether lossless compression of the written image is performed


(WriteTransformParametersEachIteration "false")
// whether to save a transform parameter file to disk in every iteration

(WriteResultImageAfterEachResolution "false" "false" "false" "false")
// whether the intermediate result image is resampled and written after
// each resolution