vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
vitrio::detector_event_image_reader Class Referencefinal

Reads an acquisition of detector events as a movie of the images its fractions render into. More...

#include <vitrio/detector_event_image_reader.hpp>

Inheritance diagram for vitrio::detector_event_image_reader:
Inheritance graph
[legend]
Collaboration diagram for vitrio::detector_event_image_reader:
Collaboration graph
[legend]

Public Member Functions

 detector_event_image_reader (std::shared_ptr< const detector_event_timeline_reader > events, detector_event_fractionation fractionation, std::shared_ptr< const detector_event_renderer > renderer)
 Construct a reader rendering the fractions of an acquisition.
 
const detector_event_fractionation & get_fractionation () const noexcept
 Get the fractionation the acquisition is read with.
 
const image_descriptor & get_descriptor () const noexcept override
 Get the shape and data type of what the file holds.
 
const image_metadata & get_metadata () const noexcept override
 Get how the samples of the file map onto physical space.
 
void read (array_ref destination, const image_transfer_plan &regions) const override
 Read a set of hyperrectangles of the file into one array.
 
- Public Member Functions inherited from vitrio::image_reader
 image_reader (const image_reader &other)=delete
 
 image_reader (image_reader &&other)=delete
 
image_reader & operator= (const image_reader &other)=delete
 
image_reader & operator= (image_reader &&other)=delete
 

Detailed Description

Reads an acquisition of detector events as a movie of the images its fractions render into.

The time of the acquisition is cut by a detector_event_fractionation, and each fraction is rendered into one image by a detector_event_renderer. A fractionation of several fractions is read as a stack of images, its first axis running along the fractions, and one of a single fraction as one image of every event.

A fraction is read and rendered as a whole when a region reaches it, and the fraction rendered last is kept, so regions of one fraction read by successive calls render it once. Rendering goes through one image, so concurrent calls to read are serialised.

Images of rank two are rendered, as a detector gives.

Constructor & Destructor Documentation

◆ detector_event_image_reader()

vitrio::detector_event_image_reader::detector_event_image_reader ( std::shared_ptr< const detector_event_timeline_reader >  events,
detector_event_fractionation  fractionation,
std::shared_ptr< const detector_event_renderer >  renderer 
)

Construct a reader rendering the fractions of an acquisition.

Parameters
eventsThe acquisition.
fractionationHow its time is cut into fractions.
rendererHow a fraction is turned into an image.
Exceptions
std::invalid_argumentIf events or renderer is null, if there are more fractions than time quanta to cut, or if renderer does not render the events of events into images of rank two.

Member Function Documentation

◆ get_descriptor()

const image_descriptor & vitrio::detector_event_image_reader::get_descriptor ( ) const
overridevirtualnoexcept

Get the shape and data type of what the file holds.

The extents are those of the file in the order it stores its axes, slowest first. How it lays its elements out within them is the format's own business and is not reported. The data type is the one a read produces without converting, which is therefore the cheapest type to ask a destination for.

A file whose format can not tell a stack of one image or volume from a single one is described as the single one.

Returns
const image_descriptor& The descriptor. It refers to storage owned by this reader.

Implements vitrio::image_reader.

◆ get_fractionation()

const detector_event_fractionation & vitrio::detector_event_image_reader::get_fractionation ( ) const
noexcept

Get the fractionation the acquisition is read with.

Returns
const detector_event_fractionation& The fractionation.

◆ get_metadata()

const image_metadata & vitrio::detector_event_image_reader::get_metadata ( ) const
overridevirtualnoexcept

Get how the samples of the file map onto physical space.

Returns
const image_metadata& The metadata. States nothing for a file that does not carry it.

Implements vitrio::image_reader.

◆ read()

void vitrio::detector_event_image_reader::read ( array_ref  destination,
const image_transfer_plan &  regions 
) const
overridevirtual

Read a set of hyperrectangles of the file into one array.

The file is the file side of the plan and destination its array side: every region names where it starts in the file and where it lands in destination, and all of them share the extents the plan carries. Passing every region in one call is what lets a reader sort the regions by their position on the storage and merge neighbouring ones into a single larger read, which one call per region can not express; it also pays for the destination's geometry once rather than once per region.

destination is the whole array, not a view of the part a region lands in, and it may be strided. The file offsets of the plan must have the rank of the file and its array offsets the rank of destination; a side whose rank exceeds that of the extents spans a single position along the axes they do not reach.

Regions may be read in any order. If two of them land on the same elements of destination, which one prevails is unspecified and thus this pattern should be avoided.

Values are converted to the data type of destination as a cast between the two types does, which preserves the numeric value where the destination can hold it. Nothing is scaled, normalised or clipped, whatever statistics the file may carry in its header; asking for the data type of get_descriptor converts nothing at all.

Thread safety
This method may be called concurrently on one reader. A reader that can not decode in parallel serialises the calls itself, so issuing them at once never costs correctness.

An empty plan reads nothing and succeeds.

Parameters
destinationWhere the regions are written. Must be initialized.
regionsThe regions to read and where each one lands.
Exceptions
std::invalid_argumentIf the file offsets do not have the rank of the file, if the array offsets do not have the rank of destination, or if destination is not initialized.
std::out_of_rangeIf a region is not contained in the file, or does not fit in destination where it is placed.
unsupported_operation_errorIf the data type of destination can not be produced from the one of the file.
image_file_format_errorIf the file turns out to be malformed or truncated where a region is read.
std::out_of_rangeIf an event lies outside the grid of the acquisition.

Implements vitrio::image_reader.


The documentation for this class was generated from the following file: