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

  1. Provide a list or batch to the Batch input.

  2. Provide the element position (zero-based) to the Index input.

  3. The block outputs the element at the requested position on its Generic output.

  4. 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 Processing before this block when you want to feed grouped or streamed data and reduce memory usage.

  • Combine with Debatch to convert a batch into individual items and then use Get Element to pick a specific item from that stream.

  • Use Get Batch Size to verify the batch length before selecting an index; this prevents out-of-range selections.

  • Use Is None and Replace None after this block to handle missing values gracefully.

  • Use Data Memory to freeze or cache a batch and keep the same data available while experimenting with different index values.

  • Use Debug Input to inspect the batch or index when results are unexpected.

  • When building indexed image pipelines, combine with visualization blocks like Show Image to preview the selected image element.

πŸ› οΈ Troubleshooting

  • If you receive unexpected or empty output, confirm the Batch actually contains elements and that Index is within the valid range (0..length-1).

  • If the pipeline sometimes supplies None values, use Is None or Replace None to guard downstream processing.

  • For workflows with changing batch sizes, always check Get Batch Size before using Index to avoid invalid access.

Last updated

Was this helpful?