from pylinac.core.profile import FWXMProfilePhysical
from pylinac.core.image_generator import AS1200Image, AS1000Image, GaussianFilterLayer, FilteredFieldLayer

# create the synthetic images
as1000 = AS1000Image()
as1000.add_layer(
    FilteredFieldLayer(field_size_mm=(100, 100))
)
as1000.add_layer(
    GaussianFilterLayer(sigma_mm=2)
)
as1200 = AS1200Image()
as1200.add_layer(
    FilteredFieldLayer(field_size_mm=(100, 100))
)
as1200.add_layer(
    GaussianFilterLayer(sigma_mm=2)
)

# and the profiles
p1200 = as1200.image[640, :]
p1000 = as1000.image[384, :]
p1200_prof = FWXMProfilePhysical(values=p1200, dpmm=1/as1200.pixel_size)
p1000_prof = FWXMProfilePhysical(values=p1000, dpmm=1/as1000.pixel_size)

# compute gamma as a numpy array the same size as the reference profile
gamma = p1000_prof.gamma(evaluation_profile=p1200_prof, dose_to_agreement=1, gamma_cap_value=2)

# we could calculate pass rate, etc from this.
# However, we want to plot it. The helper method does this for us, plotting the profiles and gamma.
p1000_prof.plot_gamma(evaluation_profile=p1200_prof, dose_to_agreement=1, dose_threshold=0)