<jupyter_start><jupyter_text>Transform generators We can generate ants/itk transforms with ANTsPy generator classes.   These can also be chained together.  Parameters are generated from user-set gaussian distributions (mean and standard deviation).  First, we show 2D.<jupyter_code>import ants
img = ants.image_read(ants.get_ants_data("r16"))
rRotGenerator = ants.contrib.RandomRotate2D( ( 0, 40 ), reference=img )
rShearGenerator=ants.contrib.RandomShear2D( (0,50), reference=img )
tx1 = rRotGenerator.transform()
tx2 = rShearGenerator.transform()
rSrR = ants.compose_ants_transforms([tx1, tx2])
ants.plot( rSrR.apply_to_image( img ) )<jupyter_output><empty_output><jupyter_text>We can call the generator(s) again to get a new transforms.<jupyter_code>tx1 = rRotGenerator.transform()
tx2 = rShearGenerator.transform()
rSrR = ants.compose_ants_transforms([tx2, tx1]) # switch order
ants.plot( rSrR.apply_to_image( img ) )<jupyter_output><empty_output><jupyter_text>The code for 3D is nearly identical.<jupyter_code>import ants
img = ants.image_read(ants.get_ants_data("ch2"))
rRotGenerator = ants.contrib.RandomRotate3D( ( 0, 40 ), reference=img )
rShearGenerator=ants.contrib.RandomShear3D( (0,50), reference=img )
tx1 = rRotGenerator.transform()
tx2 = rShearGenerator.transform()
rSrR = ants.compose_ants_transforms([tx1, tx2])
ants.plot( rSrR.apply_to_image( img ), nslices = 24, ncol=8 )<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11611541168191415, 'fraction_numerical': 0.025334271639690358, 'mean_word_length': 7.267441860465116, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '259024', 'license': 'Apache-2.0', 'n_tokens_mistral': 530, 'n_tokens_neox': 495, 'n_words': 107, 'path': 'tutorials/Transform Generators.ipynb', 'repo_name': 'halirutan/ANTsPy', 'size': '1421'}