Skip to content

Commit

Permalink
Added tests for register
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorTatarnikov committed Dec 20, 2024
1 parent 47e8683 commit 116c14c
Show file tree
Hide file tree
Showing 19 changed files with 387 additions and 13 deletions.
15 changes: 8 additions & 7 deletions brainglobe_registration/elastix/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,15 @@ def invert_transformation(
0, "InitialTransformParameterFileName", "NoInitialTransform"
)

file_names = [
f"{output_directory}/InverseTransformParameters.{i}.txt"
for i in range(len(parameter_list))
]
if output_directory:
file_names = [
f"{output_directory}/InverseTransformParameters.{i}.txt"
for i in range(len(parameter_list))
]

itk.ParameterObject.WriteParameterFiles(
result_transform_parameters, file_names
)
itk.ParameterObject.WriteParameterFiles(
result_transform_parameters, file_names
)

return (
np.asarray(result_image),
Expand Down
Binary file added tests/test_images/inverted_reference.tiff
Binary file not shown.
23 changes: 23 additions & 0 deletions tests/test_images/non_linear/InverseTransformParameters.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(CenterOfRotationPoint 240.40754485287607 163.18008610862196)
(CompressResultImage "false")
(DefaultPixelValue 0)
(Direction 1 0 0 1)
(FinalBSplineInterpolationOrder 3)
(FixedImageDimension 2)
(FixedInternalImagePixelType "float")
(HowToCombineTransforms "Compose")
(Index 0 0)
(InitialTransformParameterFileName "NoInitialTransform")
(MovingImageDimension 2)
(MovingInternalImagePixelType "float")
(NumberOfParameters 6)
(Origin 0 0)
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(ResultImageFormat "tiff")
(ResultImagePixelType "float")
(Size 456 320)
(Spacing 1 1)
(Transform "AffineTransform")
(TransformParameters 1.0003697638354456 -0.04720730937898214 0.06533968019388159 1.0267319116501339 -15.23350046785094 0.9448156292068727)
(UseDirectionCosines "true")
29 changes: 29 additions & 0 deletions tests/test_images/non_linear/InverseTransformParameters.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(BSplineTransformSplineOrder 3)
(CompressResultImage "false")
(DefaultPixelValue 0)
(Direction 1 0 0 1)
(FinalBSplineInterpolationOrder 3)
(FixedImageDimension 2)
(FixedInternalImagePixelType "float")
(GridDirection 1 0 0 1)
(GridIndex 0 0)
(GridOrigin -46.03680121839908 -45.021863372250095)
(GridSize 22 16)
(GridSpacing 25.716511144883096 27.444301597872055)
(HowToCombineTransforms "Compose")
(Index 0 0)
(InitialTransformParameterFileName "/home/igor/test_out/InverseTransformParameters.0.txt")
(MovingImageDimension 2)
(MovingInternalImagePixelType "float")
(NumberOfParameters 704)
(Origin 0 0)
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(ResultImageFormat "tiff")
(ResultImagePixelType "float")
(Size 456 320)
(Spacing 1 1)
(Transform "BSplineTransform")
(TransformParameters 0.5000100424426959 -0.47987149005012797 -1.3979804495456587 -2.8547277956309274 -4.5502241570579836 -6.059585364909818 -7.345999446420355 -8.946549369730024 -10.606268951868143 -11.1473965548737 -10.473698357987816 -9.415017542513622 -8.436649390149721 -8.017177574431779 -7.993555178587254 -7.350476373742639 -5.961790276867514 -4.434867063131683 -3.1091942961999757 -2.280643713398335 -2.0583715592244167 -1.1995939021094169 1.8522022127115187 0.33609045376416585 -1.3932698867152906 -3.6965674157128263 -6.412780676497511 -10.66529347781894 -14.782795537381817 -12.790197725097176 -5.940170331955437 -3.1317326256694775 -5.174088362809618 -4.956453148031578 -2.983307510400865 0.20741862287523224 3.3462638534576588 3.8155866442435245 2.581386956676334 0.7966989685477729 -0.9726982644486744 -1.7534754911149504 -1.5653574807823725 -0.9021341254235464 2.3283262241070766 0.9354240006363644 -0.9439919392174879 -3.5673528771212273 -7.084032212408747 -11.879611324984527 -11.489319772507953 -10.054692567421869 -0.3763871484399249 -0.3499621410072362 -0.5052829209823384 4.038959917130908 0.4789893359116241 4.247172747777881 12.831795833876525 14.426426738688571 12.539154690162308 5.05222067223257 0.5300047686641104 -1.3161246951654666 -0.8172418241697688 -0.22973140685877036 2.8704667676718296 3.543675756792532 2.512521581382923 -1.4610172377480493 -5.495458611867327 -14.212285639032606 -25.39384439033926 -13.51067518880629 -1.8642874333094344 5.810060003830909 4.2729739611694955 -7.523247882425695 5.574824688366521 13.952799911780827 19.874618571123197 8.562143999287638 7.9680579465131025 10.838450446668592 8.494441950163273 3.2543127411004913 3.0292962307583666 1.239236737747749 2.9115572175443343 6.983091544471669 7.602653675133541 5.538017217683476 -11.936598526175857 -19.40003429621574 -16.56380623686378 -11.583625469413631 -13.088208416384274 -7.758863015503013 3.1643974817303757 3.8698268556589626 10.678049496259707 18.611756283349838 19.146548139809646 19.661490556990163 13.634775218255635 13.099655356598262 11.059282918607607 8.802752505515235 8.238315680798769 2.830508626730203 1.6197563097215146 7.013327331924488 2.662732220663795 -0.057842647399312275 -8.083386556120372 -5.807585115709761 -6.53625728303388 -7.2647691179607685 -12.868472613729377 -13.684745040339022 -15.042946390442527 29.523781209369126 13.36393194769627 13.371940024222939 2.529067262873001 10.769483084873475 9.429774287889327 12.092018312284212 11.169593964185731 5.792834639610434 7.802996899692945 2.4707090583212645 -0.9141311302328591 2.75352947567096 -5.908907526571217 9.721492183768632 3.76707859819438 -7.003301188203652 0.6681539411222746 1.0602304418667259 -0.12988580393650953 8.156372254167465 -2.2781783410867216 -4.325265447087901 14.252522643930584 4.837488275572357 12.998293334613003 -5.401464875046264 4.605146578740874 -0.834845987012025 3.142686822805765 2.8644608193327743 1.8326166396489985 0.0018368221025914957 -3.7312723097453087 -4.152019768590544 2.3159091533208733 -10.214018838072464 -1.707337618555331 7.256920857405076 2.6281266147833375 -2.756600953319288 3.602388712744353 5.901657372832322 3.914024531315142 2.298571350111097 -11.764142396243324 2.959975542407683 -19.761456879291597 -4.150692337939346 -5.565241593335638 1.3446980799846258 1.2690273812208486 -5.1167346768686155 -4.61477876744063 -3.1566053289470832 -5.818643215994348 -11.104385504607562 -0.151843338562971 -11.64679485743334 0.15370933100578513 10.580001841988535 -13.106936021329117 11.132906868976542 -2.25462309931071 -6.629896945328162 2.3813043863517738 8.247395619845364 -8.460341168676933 8.63184478750579 4.831410693538434 -6.559411181380994 2.878504267830619 7.978193401678311 -2.198757677197328 -5.4495251880827915 -9.348109104803427 -5.667047891550435 -5.3278476051083405 -12.204898788063279 -16.673281990959648 4.684798750347721 1.3719804603176027 0.9278560111552511 -6.748159622452232 -1.7723559201149819 -12.597041766446623 8.016003809990552 5.813003840312465 -11.247490179766961 7.76490655488221 -20.07818241178933 -0.015603482433868892 -16.700795478368523 -12.428358939056444 11.351646539439827 0.17524732112204006 -2.5382140378913864 -10.817759565191643 -5.237222048587148 -2.513161305011992 -6.992889037707272 -5.524459710437396 6.77269260059668 -3.0861085603104152 23.945170669097703 10.870069161358016 6.718679265379411 9.203199977570499 -10.779148772909801 7.133574477161419 9.308799010488519 -8.202986206736682 -12.796858380321353 -11.683282495882017 -9.245186082515817 -5.6332078481238215 1.591355856004017 -12.633133564369745 -1.9012692601188854 -8.82299305327969 -1.9390044015218868 -0.029793532139320456 -0.5936566960696588 -1.473723387352643 -10.388093372906358 12.331492372779145 13.19664223220322 -0.135504734950955 -13.257330656307236 -2.6515834067487978 -0.45441181407501446 0.5396094627629079 9.774363844757609 -4.0488012865885885 17.563979572908156 -8.039087853299758 -15.502685243608914 -12.423147519855844 -4.095358005244897 -12.348405490948116 -10.203741404033869 -5.309838980420598 1.6641433234122323 1.45032235606887 4.7468296349948105 6.594094488554816 11.411422164617674 7.485342248899453 1.5105985445118022 -4.117479478009466 -11.419542144045753 2.86592474924935 3.845933327222042 -0.40911420897322787 -20.31045527196056 9.497093021057472 6.367358836450118 -9.494641633486697 -19.68915338341816 -15.069680100334866 -12.388682499782966 -7.314990789424655 -2.175749953041282 -0.17773428272595154 4.4489564912079995 2.837889491036845 7.8417716775475546 10.337012880747226 8.718601293637557 0.2512111306572238 -0.7954141224624751 -8.297982864961552 -7.252778444627056 -0.6445230227087152 1.5558639637939469 8.358149959574847 5.7107393676740195 -4.46825785974879 -5.2944002245406825 -5.6880633692567475 -8.142549497492926 -9.425097373279089 -11.493034939904433 -8.113497201041222 -1.4520525833011522 2.882159051404171 5.782361337302931 4.132655862893512 8.769567287171071 10.154044381485898 8.870060675316601 3.953727531603186 -2.3434237719610773 -7.220195220800632 -6.287348143652431 -0.941575247284583 -0.07338778473116785 -4.331656689616867 -6.536887487929226 -5.431098471218074 -3.5830226204818847 -2.369586946273331 -3.5334729347333402 -6.2074838580566 -6.763954451326269 -5.0270225693223 -1.092901064577475 3.326796002929274 5.981666046705639 4.2980660813778995 7.3714451342018785 7.578856378131812 6.582728407689533 4.199503313205171 2.3561493451721165 1.3804348328225535 0.4470647293140986 -0.6404666004522176 -1.7501355463251314 -2.737303952651764 -3.3327464720099544 -3.3670999962089576 -2.5673476543424907 -1.3159168190422807 -0.9637883528980038 -1.5696516281402335 -2.0034090912084555 -1.6941183560229784 0.031224136687058486 2.528457620938541 3.803354264710733 0.10749529759742502 -1.4645000061841498 -2.7460198057840137 -4.578043829746128 -6.3287271644284715 -7.126495466321951 -6.852151651330546 -6.358232053906831 -5.482107825665354 -2.8696533477996087 1.118144178297815 4.373386709186571 6.240486809972187 7.103261451122963 7.657751762223877 9.582658722065124 12.565358531050038 13.944343181997072 13.352334223520563 12.049953297653563 11.166923111062419 6.6089476195231995 -2.320342473786339 -3.963812273417731 -4.114000651964832 -4.182798719595812 -4.053624593859588 -4.407439868572706 -4.7033080092129005 -2.837761515577826 1.3428798921106935 8.936489134217169 9.422452182634485 10.462004256124336 11.178453023774136 6.264774988477288 5.246539815778844 8.753651904174667 13.255865746849423 16.00213936904808 16.875155560772015 16.947169212732902 17.200728417546575 11.813518795670475 -3.7096989799144318 -5.218959191008937 -4.5476190986414355 -2.6040084543546524 -0.17512712470120873 1.751942701445073 7.379305731296301 3.8491363701122134 5.183716315070565 4.677816565720591 3.6896776574131493 0.013232084509887887 5.1979647180650925 0.8409836923550496 -1.484150588846074 1.7363470584566456 5.347656690250054 14.033195518669032 17.265322931711328 18.444943888234466 18.751014876473235 13.073235988174945 -5.050749152090838 -8.052648821940414 -8.089974888129415 -3.445434065859613 7.144685084805771 10.330805604309402 -3.761140614677511 -2.0283912174607144 0.8521551137939012 0.7698817549099141 3.0916447998943037 0.2836764121854139 0.5586763261137732 -2.6710170464821394 7.5285415826346345 9.533465836588462 5.994156464251494 14.776066195324713 17.031861252577585 22.198268234680324 21.404637061564912 14.161312335307567 -5.84612026157765 -11.146529282779841 -13.10903971986539 -3.335295756653034 9.70533254321111 6.997828855422227 10.599411133121013 14.504704031265815 5.815091168948943 9.490134353756304 0.5289823636602579 11.958535371328676 7.547102254844039 1.8299102829530633 0.5416099731179087 -1.901637111081498 2.2803270367180906 15.285838054132189 19.878072793165458 26.853719215377346 23.4916097831861 14.001756368924745 -6.459592378427225 -10.89034039137899 -15.419525998163172 -5.268233286941385 1.5853449274689 13.563666108018884 14.014995765080462 1.9750175521212405 -0.5007306103049728 0.20310980808340579 10.29370558249542 -3.969334741096383 0.1857760700818587 7.030062555354462 0.9376426204626029 -2.2295662511419776 8.134993181326967 12.094040878667204 18.270975878933328 28.42524933046064 22.832305429376763 12.602626877800274 -7.117419002067247 -7.881468269891722 -11.781228377964151 -8.93695051112254 -7.163332677958966 10.791178304685936 9.513099636818708 5.470214073711477 0.99640377842369 10.016733390568483 14.096380015047195 9.328560297895656 5.408665465990177 -0.30159154459101356 16.614097294552735 0.16730812075109922 -1.9612774288091923 11.93555702640418 9.108324565909646 24.213643430480314 19.10730031996591 10.095353720062185 -8.356125575432769 -7.662652028399298 -4.94376057369847 8.346889122597817 1.5147502034569187 11.1069360810442 4.7784478998160775 1.7107211332971044 4.391947451895461 -1.0975411969638542 -0.9811606388717847 -3.5710453878012407 -3.9241629524777766 1.68463535505439 -9.574221485079192 -7.614784654002289 -16.369594700841606 10.831924496937264 6.7439330052530435 17.07400607974255 13.889912596806486 7.221487360354831 -10.006407187274782 -10.696952461278658 -6.242730257028269 9.157944432057016 14.250350271792728 18.368804413494438 -4.3232961243781185 0.334720937272033 11.751782414764723 -1.255126941412614 -10.33784354231057 -1.3434093831822258 -5.586121168499271 15.644962991392443 -0.959800558214514 -3.1079102656460558 14.142466764479556 17.031119503055002 -1.6690421567511327 5.440704876771986 7.669454773234435 4.302790326043284 -11.08890300396341 -12.67062312586599 -6.980168127628992 -4.827478448576722 1.8557985138646858 12.155004070162466 -1.5270147547943298 -18.66332080400704 6.407103030990791 -0.5730410037599911 -9.040712710938783 4.534468774741063 10.802765240891326 3.205257798073669 -1.9655785572664632 -8.753611578622655 -0.42935817729149944 13.21141043272424 -3.4088253641328485 2.8897587991352176 2.1675264750016336 1.3376517994859265 -11.341253211760785 -12.702688089597718 -11.539216473016442 -11.703824954203643 17.203040263076232 -1.408996748080057 19.689868762824112 20.946859712591042 -17.021517030829774 4.040078012532207 -4.531403919817027 0.0009015307928653037 -23.077652894607297 -10.855064591215202 9.012748583196911 -13.313057734039226 -2.6272351632651194 9.481562130691282 -1.8985348486558409 3.223944189103127 -1.9672063057883695 -1.3991712468512791 -11.004116977114808 -12.385034629531823 -9.432064697572319 -3.291342908188361 -1.1223827036763856 3.0840718509406315 7.670617564494946 25.40543186994097 10.671795729336136 -5.015468850179914 7.818247773402831 -3.28075365340924 -2.273208412359864 52.9418248598967 5.092948909165492 12.964059329303003 -2.37784818080507 -1.3971195289672786 -1.502584398797865 -3.013999467572814 -4.499947263227659 -3.292481638589315 -10.310420943513652 -12.291428060040342 -10.136106968695858 -9.86779366365077 -4.867743146270072 -3.318734685504769 4.638612243216385 8.24806231250628 7.180831846423776 5.628582703664052 4.065811354908304 5.871681820237196 8.370646093825828 21.338349004905215 -0.011715036790958292 -6.415133110938169 1.0948497416176497 -6.200431095443468 -4.25162349293132 -2.2977258556626206 -5.143748257110761 -4.282800629515219 -9.48062219085534 -12.56837135593677 -11.389747136011884 -10.028291737822318 -7.311322090857597 -11.786048524697366 -6.915612368097282 6.109491305225766 12.872456231236294 8.156206516770881 -5.640817009431896 3.42899181846976 3.0692431291809408 2.993688810311938 -1.9639094311205219 -7.119669884998472 -9.518865787340223 -9.0376552537444 -7.981467995099575 -5.942841464413813 -6.615381859625509 -4.783559349950299 -9.033929038745988 -13.336683605801593 -12.975768009819786 -12.968231045365641 -12.521510665029194 -11.204791698618507 -9.906965140031714 -3.723015499590311 6.204908110361737 10.07913275049011 7.138731081823526 5.32115797908898 4.788452325521895 -0.02169335028750035 -8.789670268414103 -15.876930444132269 -18.1254819685398 -16.87870625730836 -13.64985089277668 -10.28539114407174 -9.059251058275326 -5.1001607925362675 -6.003360797055688 -11.18315572623764 -12.500881431540694 -13.595028679708838 -13.4438713390088 -12.487741068831037 -10.233424533294867 -5.153011989737773 2.0945295941684363 8.593888971132587 12.685406471183294 13.149475527500408 9.568592571771278 1.9867260551524693 -7.825854470836641 -15.567684692161952 -19.482424728698877 -19.41082105626258 -16.226542819777713 -12.280312457999354 -9.502510185872259 -4.047137375134007)
(UseCyclicTransform "false")
(UseDirectionCosines "true")
23 changes: 23 additions & 0 deletions tests/test_images/non_linear/TransformParameters.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(CenterOfRotationPoint 213.5 158.5)
(CompressResultImage "false")
(DefaultPixelValue 0)
(Direction 1 0 0 1)
(FinalBSplineInterpolationOrder 3)
(FixedImageDimension 2)
(FixedInternalImagePixelType "float")
(HowToCombineTransforms "Compose")
(Index 0 0)
(InitialTransformParameterFileName "NoInitialTransform")
(MovingImageDimension 2)
(MovingInternalImagePixelType "float")
(NumberOfParameters 6)
(Origin 0 0)
(ResampleInterpolator "FinalBSplineInterpolator")
(Resampler "DefaultResampler")
(ResultImageFormat "tiff")
(ResultImagePixelType "float")
(Size 428 318)
(Spacing 1 1)
(Transform "AffineTransform")
(TransformParameters 0.9961694613937621 0.05137285130530663 -0.05021136724642646 0.9924908378555806 15.810583591577414 2.1548954657311192)
(UseDirectionCosines "true")
Loading

0 comments on commit 116c14c

Please sign in to comment.