Get Element
This function block extracts a single item from a provided list (batch) by using an index value. It is useful when you need to pick one element from a collection and feed it into downstream blocks.
π₯ Inputs
Batch A list or batch of values (images, numbers, texts, etc.) from which an element will be retrieved.
Index The index position (zero-based) indicating which element to return from the batch.
π€ Outputs
Generic The selected element from the batch. The returned type matches the element type inside the input batch.
πΉοΈ Controls
This function block has no interactive widgets. It works by reading the provided input sockets each evaluation step.
π¨ Features
Simple and direct extraction of one element from a list or batch.
Works with any generic data type carried inside the batch (images, numbers, strings, shapes, etc.).
Designed for straightforward integration in flow where single-item processing is needed.
π Usage Instructions
Provide a list or batch to the
Batchinput.Provide the element position (zero-based) to the
Indexinput.The block outputs the element at the requested position on its
Genericoutput.If you provide a batch with dynamic length, ensure the index value is valid to avoid unexpected results.
π Evaluation
On each run, the block reads the current Batch and the Index values, then forwards the element at that index to the output. If the index refers to a single value, a single element is returned; when combined with batching flow control, it can be used to select specific items for further processing.
π‘ Tips and Tricks
Use
Batch Processingbefore this block when you want to feed grouped or streamed data and reduce memory usage.Combine with
Debatchto convert a batch into individual items and then useGet Elementto pick a specific item from that stream.Use
Get Batch Sizeto verify the batch length before selecting an index; this prevents out-of-range selections.Use
Is NoneandReplace Noneafter this block to handle missing values gracefully.Use
Data Memoryto freeze or cache a batch and keep the same data available while experimenting with different index values.Use
Debug Inputto inspect the batch or index when results are unexpected.When building indexed image pipelines, combine with visualization blocks like
Show Imageto preview the selected image element.
π οΈ Troubleshooting
If you receive unexpected or empty output, confirm the
Batchactually contains elements and thatIndexis within the valid range (0..length-1).If the pipeline sometimes supplies None values, use
Is NoneorReplace Noneto guard downstream processing.For workflows with changing batch sizes, always check
Get Batch Sizebefore usingIndexto avoid invalid access.
Last updated
Was this helpful?