Generators package#
FixationGenerator class#
- class CFSVM.Generators.FixationGenerator(dirpath, parameters)#
Generates fixation targets.
Supports 6 different shapes from Thaler et al., 2013.
- Constructor Summary
- FixationGenerator(dirpath, parameters)#
- Parameters:
dirpath (
char|string
) – Fixation targets will be generated inside dirpath/Fixation/radius (
int
) – Radius in pixels of the largest shape in the fixaiton.hex_color (
char|string
) – Color of the fixation targetis_smooth_edges (
logical
) – Whether to smooth the jaggies.smoothing_cycles (
int
) – Number of smoothing cycles.is_outline (
logical
) – Whether to generate only an outline of the fixation.
- Method Summary
- A(parameters)#
Generates the circular target shape.
- Parameters:
fname (
char|string
) – Name of the image file, should end with.png
.
- AB(parameters)#
Generates the circle-inside-circle target shape.
- Parameters:
fname (
char|string
) – Name of the image file, should end with.png
.inner_circle_radius (
int
) – Radius of the inner circle.
- ABC(parameters)#
Generates the circle-inside-cross-inside-circle target shape.
- Parameters:
fname (
char|string
) – Name of the image file, should end with.png
.cross_width (
int
) – Width of the cross arms.inner_circle_radius (
int
) – Radius of the inner circle.
- AC(parameters)#
Generates the circle-inside-cross target shape.
- Parameters:
fname (
char|string
) – Name of the image file, should end with.png
.cross_width (
int
) – Width of the cross arms.circle_radius (
int
) – Radius of the inner circle.
- BC(parameters)#
Generates the cross-inside-circle target shape.
- Parameters:
fname (
char|string
) – Name of the image file, should end with.png
.cross_width (
int
) – Width of the cross arms.
- C(parameters)#
Generates the cross target shape.
- Parameters:
fname (
char|string
) – Name of the image file, should end with.png
.cross_width (
int
) – Width of the cross arms in pixels.
MondrianGenerator class#
- class CFSVM.Generators.MondrianGenerator(dirpath, parameters)#
Generates Mondrian masks for CFS experiments.
Supports shapes, like rectangles, circles, rhombi and more. Calculates PSDs for every mondrians if screen physical properties are set.
- Constructor Summary
- MondrianGenerator(dirpath, parameters)#
- Parameters:
dirpath (
char|string
) –dirpath
type (
char|string
) –type
x_pixels (
int
) –x_pixels
y_pixels (
int
) –y_pixels
min_fraction (
double
) –min_fraction
max_fraction (
double
) –max_fraction
n_figures (
int
) –n_figures
cmap (
double array|char|string
) –cmap
- Property Summary
- cmap#
Colormap. Either one of the supported colormaps by
set_cmap()
or MATLAB-styled RGB array.
- dirpath#
Mondrians will be generated inside dirpath/Masks/
- is_phys_props#
Whether physical propreties were provided.
- max_fraction#
Maximal possible radius in pixels of the type-shaped figure. Will be calculated by radius=x(y)_pixels*max_fraction
- min_fraction#
Minimal possible radius in pixels of the type-shaped figure. Will be calculated by radius=x(y)_pixels*min_fraction
- n_figures#
Number of figures to generate per 1 Mondrian mask.
- s_h_cm#
Screen height in centimetres.
- s_h_pix#
Screen height in pixels.
- s_w_cm#
Screen width in centimetres.
- s_w_pix#
Screen width in pixels.
- type#
Shape of the figures, currently available shapes are rectangle, square, ellipse, circle, rhombus and 45_rotate_square.
- view_dist#
Viewing distance in centimetres.
- x_pixels#
Width of the generated image in pixels
- y_pixels#
Height of the generated image in pixels
- Method Summary
- generate(n_images, parameters)#
Generates and saves Mondrians.
- Parameters:
n_images – Int number of Mondrians to generate.
- get_psd(img)#
Adopted and modified from CFS-crafter guandongwang/cfs_crafter
- Parameters:
img – [x_pixels, y_pixels, n_colors] array - img to calculate psd from.
- Returns:
two arrays with length=n_freqs.
- Return type:
[freqs, psds]
- set_cmap(colormap, parameters)#
Will generate MATLAB colormap gradient from white to rgb_triplet color with n_tones.
- Parameters:
colormap – One of ‘grayscale’, ‘reds’, ‘blues’, ‘greens’, ‘rgb’, ‘original’.
n_tones – (Optional) Int describing number of color tones to create, relevant only for shades colormaps
- set_physical_properties(screen_width_cm, screen_width_pixel, screen_height_cm, screen_height_pixel, viewing_distance_cm)#
Sets display’s physical properties for PSD calculation.
- set_shades(rgb_triplet, n_tones)#
Creates MATLAB colormap gradient from white to rgb_triplet color with n_tones between them.
- Parameters:
rgb_triplet (
double array
) – [R,G,B] array where R,G,B ranges from 0 to 1.n_tones (
int
) – Number of color tones to create.
CFSCrafter class#
- class CFSVM.Generators.CFSCrafter(parameters)#
Generating and modifying CFS masks.
Supported types of masks are: 1. Either solid or noise-filled circle-, square- or diamond-shaped Mondrians. 2. White or pink noise masks.
Types of modifications supported: 1. Spatial low-, high-, band-pass filters 2. Temporal low-, high-, band-pass filters 3. Orientation filter 4. Phase scrambling 5. Setting RMS contrast and mean luminance.
Types of analyses supported: 1. Radially averaged spatial power spectrum (1D) 2. Radially averaged temporal power spectrum (1D)
The code was adopted and modified from CFS-crafter: guandongwang/cfs_crafter
If you rely on this code, please consider citing the original CFS-Crafter publication: Wang, G., Alais, D., Blake, R. et al. CFS-crafter: An open-source tool for creating and analyzing images for continuous flash suppression experiments. Behav Res (2022). https://doi.org/10.3758/s13428-022-01903-7
- Constructor Summary
- CFSCrafter(parameters)#
- Property Summary
- fft_stimuli#
- mean_luminance#
- modified_stimuli#
- padded_stimuli_dim#
- refresh_rate#
- rms_contrast#
- screen_info#
- spatial_map#
- stay_frame#
- stimuli_array#
- stimuli_property#
- total_frames#
- update_rate#
- Method Summary
- play()#
- save(filepath)#
- spatial_spectrum()#
- temporal_spectrum()#
- CFSVM.Generators.band_pass_filter(type, dist_map, parameters)#
- CFSVM.Generators.convert_mask_info(obj, edge_parameters)#
- CFSVM.Generators.convert_to_grayscale(stimuli_array)#
- CFSVM.Generators.create_single_noise_mask(stimuli_height_pixel, stimuli_width_pixel, is_pink)#
- CFSVM.Generators.create_single_patterned_mask(stimuli_height_pixel, stimuli_width_pixel, patch, paste_index)#
- CFSVM.Generators.find_edge(stimuli_array, detection_method, detection_threshold)#
- CFSVM.Generators.generate_mondrians(obj, mask_resolution, sequence_duration_sec, parameters)#
- CFSVM.Generators.generate_noise(obj, mask_resolution, sequence_duration_sec, parameters)#
- CFSVM.Generators.get_spatial_amp(stimuli_array, screen_width_cm, screen_width_pixel, screen_height_cm, screen_height_pixel, viewing_distance)#
- CFSVM.Generators.get_temporal_amp(stimuli_array, sequence_duration)#
- CFSVM.Generators.orientation_filter(obj, parameters)#
- CFSVM.Generators.patch_creation(obj, stimuli_height_pixel, stimuli_width_pixel, is_noise_fill, is_colored, pattern_shape, is_pink)#
- CFSVM.Generators.phase_scramble(obj, parameters)#
- CFSVM.Generators.set_rms_and_luminance(obj, stimuli_array)#
- CFSVM.Generators.spatial_filter(obj, filter_parameters)#
- CFSVM.Generators.temporal_filter(obj, filter_parameters)#