API
panda.generator.PANDA
PANDA (Python Automating Numerical Dot Algorithm).
An open algorithm dedicated to the precise generation and controlled parameterization of multi-element dot arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
Window
|
The PsychoPy window in which to display the dot array. |
required |
n_anchor
|
int
|
The number of anchor dots. Defaults to 3. |
3
|
base_ta
|
float
|
The baseline Total Surface Area. Defaults to 30000.0. |
30000.0
|
base_cha
|
float
|
The baseline Convex Hull Area. Defaults to 120000.0. |
120000.0
|
color
|
str
|
The color of the dots. Defaults to "black". |
'black'
|
seed
|
int
|
The random seed for reproducibility. Defaults to None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
win |
Window
|
The PsychoPy window instance. |
color |
str
|
The color specified for the rendered dots. |
results |
list[dict]
|
List storing generated dot array parameters and metadata. |
rng |
Generator
|
NumPy random number generator. |
n_anchor |
int
|
Number of anchor dots used for baseline metrics. |
base_ta |
float
|
Baseline Total Surface Area value. |
base_cha |
float
|
Baseline Convex Hull Area value. |
mean_r_anchor |
float
|
Calculated mean radius of anchor dots. |
base_tp |
float
|
Calculated baseline Total Perimeter. |
base_id |
float
|
Calculated baseline Inter-item Distance. |
Source code in panda\generator.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
generate_and_save(num_elements, spatial_type, size_type, output_filepath=None, sd_ratio=0.0, min_dist_factor=None, save_results=True, pause_time=0.0)
Generate, render, and display a dot array in PsychoPy, optionally capturing and saving the frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_elements
|
int
|
the number of dots to generate |
required |
spatial_type
|
str
|
the spatial condition type ('CH' for Convex Hull, 'ID' for Inter-Distance) |
required |
size_type
|
str
|
the size condition type ('TA' for Total Area, 'TP' for Total Perimeter) |
required |
output_filepath
|
Optional[str]
|
the path to save the generated image. Defaults to None. |
None
|
sd_ratio
|
float
|
standard deviation ratio of the dot sizes. Defaults to 0.0. |
0.0
|
min_dist_factor
|
Optional[float]
|
the minimum distance factor between dots. Defaults to None. |
None
|
save_results
|
bool
|
whether to save the generated results. Defaults to True. |
True
|
pause_time
|
float
|
the time to pause between frames. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
List[Circle]
|
List[visual.Circle]: the list of generated dot objects |
Source code in panda\generator.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
generate_balanced_set(num_elements, spatial_type, size_type, sd_ratio=0.0, min_dist_factor=None)
Generate a spatially balanced array of dots satisfying target geometric and size constraints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_elements
|
int
|
the number of dots to generate |
required |
spatial_type
|
str
|
the spatial condition type ('CH' for Convex Hull, 'ID' for Inter-Distance) |
required |
size_type
|
str
|
the size condition type ('TA' for Total Area, 'TP' for Total Perimeter) |
required |
sd_ratio
|
float
|
standard deviation ratio of the dot sizes. Defaults to 0.0. |
0.0
|
min_dist_factor
|
Optional[float]
|
the minimum distance factor between dots. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of elements is less than 3 for Convex Hull (CH) spatial type. |
RuntimeError
|
If unable to fit dots in the window while maintaining parameters after multiple attempts. |
Returns:
| Type | Description |
|---|---|
Tuple[List[Circle], List[float], List[List[float]]]
|
Tuple[List[visual.Circle], List[float], List[List[float]]]: A tuple containing the generated dot objects, their radii, and their positions. |
Source code in panda\generator.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
get_dataframe()
Return all logged stimulus ground-truth metrics as a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A DataFrame containing all logged ground-truth metrics for the generated dot arrays, including Total Surface Area (TSA), Total Perimeter (TP), Convex Hull Area (CHA), Inter-Distance (ID), Density, Additive Area (AA), and Mean Occupancy (MO). |
Source code in panda\generator.py
364 365 366 367 368 369 370 | |
log_ground_truth(num_elements, radii, positions)
Compute and log exact geometric ground-truth metrics for the generated dot array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_elements
|
int
|
the number of dots in the array |
required |
radii
|
list
|
a list of radii for each dot |
required |
positions
|
list
|
a list of (x, y) coordinates for each dot |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: A dictionary containing the computed ground-truth metrics for the generated dot array, including Total Surface Area (TSA), Total Perimeter (TP), Convex Hull Area (CHA), Inter-Distance (ID), Density, Additive Area (AA), and Mean Occupancy (MO). |
Source code in panda\generator.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
reset_results()
Clear all stored ground-truth metrics from internal memory.
Source code in panda\generator.py
372 373 374 375 | |
save_csv(filename)
Export all accumulated ground-truth metrics to a CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The path to the CSV file where the results will be saved. |
required |
Source code in panda\generator.py
377 378 379 380 381 382 383 384 | |