pynsn_demo

In [1]:

    import pynsn as nsn
    from pynsn import distributions as distr

    PyNSN 0.13.0

To generate a random nsn stimulus, you have to define

1. an NSN factory
2. a distribution for the object size

In [2]:

    factory = nsn.NSNFactory(target_area_radius=150)
    factory.set_appearance_dot(diameter=distr.Normal(mu=13, sigma=4, min_max=(10,25)))

In [3]:

    # Generate random nsn stimulus with 15 dots
    stimulus = factory.create_random_array(n_objects=15)

Make picture of the stimulus

In [4]:

    from pynsn.image import pil_image
    pil_image.create(stimulus)

Out[4]:
In [5]:

    # example: to plot field area and center of mass, just define the repective colours and plot
    my_colours = nsn.ImageColours(target_area="yellow",
                              field_area_positions="red",
                              field_area="green",
                              center_of_mass="lightblue",
                              center_of_field_area="blue",
                              background="gray",
                              default_object_colour="darkmagenta")
    pil_image.create(stimulus, colours=my_colours)

Out[5]:

# Incremental¶

In [6]:

    factory.target_area_radius=75

    stim_iterator = factory.create_incremental_random_array(n_objects=20)
    for stim in stim_iterator:
        img = pil_image.create(stim)
        display(img)