Flash responses¶
Rendering¶
flyvision.datasets.flashes.RenderedFlashes ¶
Bases: Directory
Render a directory with flashes for the Flashes dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
boxfilter |
Dict[str, int]
|
Parameters for the BoxEye filter. |
dict(extent=15, kernel_size=13)
|
dynamic_range |
List[float]
|
Range of intensities. E.g. [0, 1] renders flashes with decrement 0.5->0 and increment 0.5->1. |
[0, 1]
|
t_stim |
float
|
Duration of the stimulus. |
1.0
|
t_pre |
float
|
Duration of the grey stimulus. |
1.0
|
dt |
float
|
Timesteps. |
1 / 200
|
radius |
List[int]
|
Radius of the stimulus. |
[-1, 6]
|
alternations |
Tuple[int, ...]
|
Sequence of alternations between lower or upper intensity and baseline of the dynamic range. |
(0, 1, 0)
|
Attributes:
Name | Type | Description |
---|---|---|
flashes |
ArrayFile
|
Array containing rendered flash sequences. |
Source code in flyvision/datasets/flashes.py
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 |
|
Datasets¶
flyvision.datasets.flashes.Flashes ¶
Bases: SequenceDataset
Flashes dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
boxfilter |
Dict[str, int]
|
Parameters for the BoxEye filter. |
dict(extent=15, kernel_size=13)
|
dynamic_range |
List[float]
|
Range of intensities. E.g. [0, 1] renders flashes with decrement 0.5->0 and increment 0.5->1. |
[0, 1]
|
t_stim |
float
|
Duration of the stimulus. |
1.0
|
t_pre |
float
|
Duration of the grey stimulus. |
1.0
|
dt |
float
|
Timesteps. |
1 / 200
|
radius |
List[int]
|
Radius of the stimulus. |
[-1, 6]
|
alternations |
Tuple[int, ...]
|
Sequence of alternations between lower or upper intensity and baseline of the dynamic range. |
(0, 1, 0)
|
Attributes:
Name | Type | Description |
---|---|---|
dt |
Union[float, None]
|
Timestep. |
t_post |
float
|
Post-stimulus time. |
flashes_dir |
Directory containing rendered flashes. |
|
config |
Configuration object. |
|
baseline |
Baseline intensity. |
|
arg_df |
DataFrame containing flash parameters. |
Note
Zero alternation is the prestimulus and baseline. One alternation is the
central stimulus. Has to start with zero alternation. t_pre
is the
duration of the prestimulus and t_stim
is the duration of the stimulus.
Source code in flyvision/datasets/flashes.py
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 |
|
get_item ¶
get_item(key)
Index the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
int
|
Index of the item to retrieve. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
Flash sequence at the given index. |
Source code in flyvision/datasets/flashes.py
205 206 207 208 209 210 211 212 213 214 |
|
__repr__ ¶
__repr__()
Return a string representation of the dataset.
Source code in flyvision/datasets/flashes.py
216 217 218 |
|
flyvision.datasets.flashes.render_flash ¶
render_flash(
n_ommatidia,
intensity,
baseline,
t_stim,
t_pre,
dt,
alternations,
radius,
)
Generate a sequence of flashes on a hexagonal lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_ommatidia |
int
|
Number of ommatidia. |
required |
intensity |
float
|
Intensity of the flash. |
required |
baseline |
float
|
Intensity of the baseline. |
required |
t_stim |
float
|
Duration of the stimulus. |
required |
t_pre |
float
|
Duration of the grey stimulus. |
required |
dt |
float
|
Timesteps. |
required |
alternations |
Tuple[int, ...]
|
Sequence of alternations between lower or upper intensity and baseline of the dynamic range. |
required |
radius |
int
|
Radius of the stimulus. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Generated flash sequence. |
Source code in flyvision/datasets/flashes.py
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 |
|
flyvision.datasets.dots.Dots ¶
Bases: StimulusDataset
Render flashes aka dots per ommatidia.
Note
Renders directly in receptor space, does not use BoxEye or HexEye as eye-model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dot_column_radius |
int
|
Radius of the dot column. |
0
|
max_extent |
int
|
Maximum extent of the stimulus. |
15
|
bg_intensity |
float
|
Background intensity. |
0.5
|
t_stim |
float
|
Stimulus duration. |
5
|
dt |
float
|
Time step. |
1 / 200
|
t_impulse |
Optional[float]
|
Impulse duration. |
None
|
n_ommatidia |
int
|
Number of ommatidia. |
721
|
t_pre |
float
|
Pre-stimulus duration. |
2.0
|
t_post |
float
|
Post-stimulus duration. |
0
|
intensity |
float
|
Stimulus intensity. |
1
|
mode |
Literal['sustained', 'impulse']
|
Stimulus mode (‘sustained’ or ‘impulse’). |
'sustained'
|
device |
device
|
Torch device for computations. |
device
|
Attributes:
Name | Type | Description |
---|---|---|
dt |
Optional[float]
|
Time step. |
arg_df |
Optional[DataFrame]
|
DataFrame containing stimulus parameters. |
config |
Namespace containing configuration parameters. |
|
t_stim |
Stimulus duration. |
|
n_ommatidia |
Number of ommatidia. |
|
offsets |
Array of ommatidia offsets. |
|
u |
U-coordinates of the hexagonal grid. |
|
v |
V-coordinates of the hexagonal grid. |
|
extent_condition |
Boolean mask for the extent condition. |
|
max_extent |
Maximum extent of the stimulus. |
|
bg_intensity |
Background intensity. |
|
intensities |
List of stimulus intensities. |
|
device |
Torch device for computations. |
|
mode |
Stimulus mode (‘sustained’ or ‘impulse’). |
|
params |
List of stimulus parameters. |
|
t_impulse |
Impulse duration. |
Raises:
Type | Description |
---|---|
ValueError
|
If dot_column_radius is greater than max_extent. |
Source code in flyvision/datasets/dots.py
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 |
|
get_item ¶
get_item(key)
Get a stimulus item for a specific key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
int
|
Index of the item to retrieve. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
Tensor representing the stimulus sequence. |
Source code in flyvision/datasets/dots.py
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 |
|
get_stimulus_index ¶
get_stimulus_index(u, v, intensity)
Get sequence ID from given arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
float
|
U-coordinate. |
required |
v |
float
|
V-coordinate. |
required |
intensity |
float
|
Stimulus intensity. |
required |
Returns:
Type | Description |
---|---|
int
|
Sequence ID. |
Source code in flyvision/datasets/dots.py
228 229 230 231 232 233 234 235 236 237 238 239 |
|
flyvision.datasets.dots.CentralImpulses ¶
Bases: StimulusDataset
Flashes at the center of the visual field for temporal receptive field mapping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
impulse_durations |
List[float]
|
List of impulse durations. |
[0.005, 0.02, 0.05, 0.1, 0.2, 0.3]
|
dot_column_radius |
int
|
Radius of the dot column. |
0
|
bg_intensity |
float
|
Background intensity. |
0.5
|
t_stim |
float
|
Stimulus duration. |
5
|
dt |
float
|
Time step. |
0.005
|
n_ommatidia |
int
|
Number of ommatidia. |
721
|
t_pre |
float
|
Pre-stimulus duration. |
2.0
|
t_post |
float
|
Post-stimulus duration. |
0
|
intensity |
float
|
Stimulus intensity. |
1
|
mode |
str
|
Stimulus mode. |
'impulse'
|
device |
device
|
Torch device for computations. |
device
|
Attributes:
Name | Type | Description |
---|---|---|
arg_df |
Optional[DataFrame]
|
DataFrame containing stimulus parameters. |
dt |
Optional[float]
|
Time step. |
dots |
Instance of the Dots class. |
|
impulse_durations |
List of impulse durations. |
|
config |
Configuration namespace. |
|
params |
List of stimulus parameters. |
Source code in flyvision/datasets/dots.py
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 |
|
__init__ ¶
__init__(
impulse_durations=[0.005, 0.02, 0.05, 0.1, 0.2, 0.3],
dot_column_radius=0,
bg_intensity=0.5,
t_stim=5,
dt=0.005,
n_ommatidia=721,
t_pre=2.0,
t_post=0,
intensity=1,
mode="impulse",
device=flyvision.device,
)
Initialize the CentralImpulses dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
impulse_durations |
List[float]
|
List of impulse durations. |
[0.005, 0.02, 0.05, 0.1, 0.2, 0.3]
|
dot_column_radius |
int
|
Radius of the dot column. |
0
|
bg_intensity |
float
|
Background intensity. |
0.5
|
t_stim |
float
|
Stimulus duration. |
5
|
dt |
float
|
Time step. |
0.005
|
n_ommatidia |
int
|
Number of ommatidia. |
721
|
t_pre |
float
|
Pre-stimulus duration. |
2.0
|
t_post |
float
|
Post-stimulus duration. |
0
|
intensity |
float
|
Stimulus intensity. |
1
|
mode |
str
|
Stimulus mode. |
'impulse'
|
device |
device
|
Torch device for computations. |
device
|
Source code in flyvision/datasets/dots.py
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 |
|
get_item ¶
get_item(key)
Get a stimulus item for a specific key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
int
|
Index of the item to retrieve. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
Tensor representing the stimulus sequence. |
Source code in flyvision/datasets/dots.py
343 344 345 346 347 348 349 350 351 352 353 354 |
|
__repr__ ¶
__repr__()
Get string representation of the dataset.
Source code in flyvision/datasets/dots.py
366 367 368 |
|
flyvision.datasets.dots.SpatialImpulses ¶
Bases: StimulusDataset
Spatial flashes for spatial receptive field mapping.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
impulse_durations |
List[float]
|
List of impulse durations. |
[0.005, 0.02]
|
max_extent |
int
|
Maximum extent of the stimulus. |
4
|
dot_column_radius |
int
|
Radius of the dot column. |
0
|
bg_intensity |
float
|
Background intensity. |
0.5
|
t_stim |
float
|
Stimulus duration. |
5
|
dt |
float
|
Time step. |
0.005
|
n_ommatidia |
int
|
Number of ommatidia. |
721
|
t_pre |
float
|
Pre-stimulus duration. |
2.0
|
t_post |
float
|
Post-stimulus duration. |
0
|
intensity |
float
|
Stimulus intensity. |
1
|
mode |
str
|
Stimulus mode. |
'impulse'
|
device |
device
|
Torch device for computations. |
device
|
Attributes:
Name | Type | Description |
---|---|---|
arg_df |
Optional[DataFrame]
|
DataFrame containing stimulus parameters. |
dt |
Optional[float]
|
Time step. |
dots |
Instance of the Dots class. |
|
impulse_durations |
List of impulse durations. |
|
config |
Configuration namespace. |
|
params |
List of stimulus parameters. |
Source code in flyvision/datasets/dots.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
|
get_item ¶
get_item(key)
Get a stimulus item for a specific key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
int
|
Index of the item to retrieve. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
Tensor representing the stimulus sequence. |
Source code in flyvision/datasets/dots.py
461 462 463 464 465 466 467 468 469 470 471 472 |
|
__repr__ ¶
__repr__()
Get string representation of the dataset.
Source code in flyvision/datasets/dots.py
474 475 476 |
|
Analysis¶
flyvision.analysis.flash_responses ¶
Analysis of responses to flash stimuli.
Info
Relies on xarray dataset format defined in flyvision.analysis.stimulus_responses
.
flash_response_index ¶
flash_response_index(
self,
radius,
on_intensity=1.0,
off_intensity=0.0,
nonnegative=True,
)
Compute the Flash Response Index (FRI) using xarray methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self |
DataArray
|
The input DataArray containing response data. |
required |
radius |
float
|
The radius value to select data for. |
required |
on_intensity |
float
|
The intensity value for the ‘on’ state. |
1.0
|
off_intensity |
float
|
The intensity value for the ‘off’ state. |
0.0
|
nonnegative |
bool
|
If True, applies a nonnegative constraint to the data. |
True
|
Returns:
Type | Description |
---|---|
DataArray
|
xr.DataArray: The computed Flash Response Index. |
Note
Ensures that the stimulus configuration is correct for FRI computation.
Source code in flyvision/analysis/flash_responses.py
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 |
|
fri_correlation_to_known ¶
fri_correlation_to_known(fris)
Compute the correlation of the FRI to known cell type tunings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fris |
DataArray
|
DataArray containing Flash Response Index values. |
required |
Returns:
Type | Description |
---|---|
DataArray
|
xr.DataArray: Correlation of FRIs to known cell type tunings. |
Source code in flyvision/analysis/flash_responses.py
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 |
|
plot_fris ¶
plot_fris(
fris,
cell_types,
scatter_best=False,
scatter_all=True,
bold_output_type_labels=True,
output_cell_types=None,
known_first=True,
sorted_type_list=None,
figsize=[10, 1],
cmap=plt.cm.Greys_r,
ylim=(-1, 1),
color_known_types=True,
fontsize=6,
colors=None,
color="b",
showmeans=False,
showmedians=True,
scatter_edge_width=0.5,
scatter_best_edge_width=0.75,
scatter_edge_color="none",
scatter_face_color="k",
scatter_alpha=0.35,
scatter_best_alpha=1.0,
scatter_all_marker="o",
scatter_best_index=None,
scatter_best_marker="o",
scatter_best_color=None,
mean_median_linewidth=1.5,
mean_median_bar_length=1.0,
violin_alpha=0.3,
**kwargs
)
Plot flash response indices (FRIs) for the given cell types with violins.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fris |
ndarray
|
Array of FRI values (n_random_variables, n_groups, n_samples). |
required |
cell_types |
ndarray
|
Array of cell type labels, corresponding to the first axis
(n_random_variables) of |
required |
scatter_best |
bool
|
If True, scatter the best points. |
False
|
scatter_all |
bool
|
If True, scatter all points. |
True
|
bold_output_type_labels |
bool
|
If True, bold the output type labels. |
True
|
output_cell_types |
Optional[List[str]]
|
List of cell types to bold in the output. |
None
|
known_first |
bool
|
If True, sort known cell types first. |
True
|
sorted_type_list |
Optional[List[str]]
|
List of cell types to sort by. |
None
|
figsize |
List[int]
|
Figure size as [width, height]. |
[10, 1]
|
cmap |
cm
|
Colormap for the plot. |
Greys_r
|
ylim |
Tuple[float, float]
|
Y-axis limits as (min, max). |
(-1, 1)
|
color_known_types |
bool
|
If True, color known cell type labels. |
True
|
fontsize |
int
|
Font size for labels. |
6
|
colors |
Optional[List[str]]
|
List of colors for the violins. |
None
|
color |
str
|
Single color for all violins if cmap is None. |
'b'
|
showmeans |
bool
|
If True, show means on the violins. |
False
|
showmedians |
bool
|
If True, show medians on the violins. |
True
|
scatter_edge_width |
float
|
Width of scatter point edges. |
0.5
|
scatter_best_edge_width |
float
|
Width of best scatter point edges. |
0.75
|
scatter_edge_color |
str
|
Color of scatter point edges. |
'none'
|
scatter_face_color |
str
|
Color of scatter point faces. |
'k'
|
scatter_alpha |
float
|
Alpha value for scatter points. |
0.35
|
scatter_best_alpha |
float
|
Alpha value for best scatter points. |
1.0
|
scatter_all_marker |
str
|
Marker style for all scatter points. |
'o'
|
scatter_best_index |
Optional[int]
|
Index of the best scatter point. |
None
|
scatter_best_marker |
str
|
Marker style for the best scatter point. |
'o'
|
scatter_best_color |
Optional[str]
|
Color of the best scatter point. |
None
|
mean_median_linewidth |
float
|
Line width for mean/median lines. |
1.5
|
mean_median_bar_length |
float
|
Length of mean/median bars. |
1.0
|
violin_alpha |
float
|
Alpha value for violin plots. |
0.3
|
**kwargs |
Additional keyword arguments for violin_groups. |
{}
|
Returns:
Type | Description |
---|---|
Tuple[Figure, Axes]
|
Tuple containing the Figure and Axes objects. |
Source code in flyvision/analysis/flash_responses.py
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 |
|
flash_response_color_labels ¶
flash_response_color_labels(ax)
Color the labels of ON and OFF cells in the plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
Axes
|
The matplotlib Axes object to modify. |
required |
Returns:
Type | Description |
---|---|
Axes
|
The modified matplotlib Axes object. |
Source code in flyvision/analysis/flash_responses.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|