ImParams API
- class siffpy.core.utils.im_params.im_params.ImParams(num_frames=None, **param_dict)
A single simple object that guarantees some core parameters that makes it easy to pass these things around.
Behaves like a dict, more or less. This is partly just to maintain compatibility with old code when it WAS a dict, and partly because I think the dict-like interface is intuitive to people (myself included).
- CHANNEL_AXIS: int = -3
- add_roi_data(roi_data: Dict)
Adds ROI data to the ImParams object
- property all_frames: List[int]
Returns all _NON-FLYBACK_ frames… including those which will not constitute a full volume (e.g. the last half of a volume in the acquisition).
- property array_shape: Tuple[int, int, int, int, int] | Tuple[int, int, int, int, int, int]
Returns the shape that an array of frames would be in standard order: (t, z, frames_per_slice (if greater than 1), c, y, x)
- property arrival_time_bins: ndarray[Any, float64]
The time bins of the arrival time histogram in PICOSECONDS
- property axis_labels: List[str]
Labels for each array axis
- property color_list: List[int]
Guaranteed to be a list of ints
- property colors: List[int] | int
Can be int or list of ints, inherited from MATLAB
- property discard_frames: bool
Whether or not to discard frames because they are flyback frames
- property final_full_volume_frame: int
Final frame that is in a full volume
- flatten_by_timepoints(timepoint_start: int = 0, timepoint_end: int | None = None, reference_z: int | None = None, color_channel: int | None = 0) List[int]
Returns all frame indices within a set of timepoints.
If reference_z is None, returns _all_ frames, irrespective of z.
If color_channel (0-indexed) is None, returns all colors. But since timestamps for each color channel are the same, typically you expect NOT to use this.
Examples
### A single plane with 5 z slices and 1 flyback, and 1 color channel ```python
from siffpy import SiffReader reader : SiffReader
- reader.im_params.flatten_by_timepoints(
timepoint_start = 0, timepoint_end = 10, reference_z = 0, color_channel = 0
)
[0, 6, 12, 18, 24, 30, 36, 42, 48, 54]
### All planes. Note that 5 and 11 are skipped (flyback)! ```python
from siffpy import SiffReader reader : SiffReader
- reader.im_params.flatten_by_timepoints(
timepoint_start = 0, timepoint_end = 10, reference_z = None, color_channel = 0
)
[0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16]
- property flyback_frames: List[int]
Lists the indices of flyback frames
- framelist_by_color(color_channel: int, lower_bound_timepoint: int = 0, upper_bound_timepoint: int | None = None) List
List of all frames that share a color, regardless of slice. Color channel is * 0-indexed * !
- framelist_by_slice(color_channel: int | None = None, slice_idx: int | None = None) List[List[int]]
List of lists, each sublist containing the frames indices that share a z slice
If slice_idx is not None, returns a single list corresponding to that slice.
Defaults to using the lowest-numbered color channel.
color_channel is * 0-indexed *.
- framelist_by_slices(color_channel: int | None = None, lower_bound: int = 0, upper_bound: int | None = None, slices: List[int] | None = None) List[int]
Flattened list of all frames corresponding to the color channel and slices provided
- framelist_by_timepoint(color_channel: int, timepoint_start: int = 0, timepoint_end: int | None = None, slice_idx: int | None = None) List[List[int]]
If slice_idx is None: list of lists, each containing frames that share a timepoint, i.e. same stack but different slices or colors
If slice_idx is int: Returns all frames corresponding to a specific slice
color_channel is * 0-indexed *.
Examples
TODO
- property frames_per_slice: int
Number of frames per slice in one volume
- property frames_per_volume: int
Product of elements in the volume tuple
- static from_dict(header_dict: Dict, num_frames: int | None = None) ImParams
Builds an ImParams object from a dict of header data, which is easier to generate with C++ than the correct Python object — though I probably will do that at some point.
Example
```python from siffreadermodule import SiffIO from siffpy import ImParams from typing import Dict
sio = SiffIO() sio.open(‘my_file.siff’) header : ‘Dict’ = sio.get_file_header() im_pars : ‘ImParams’ = ImParams.from_dict(header) ```
- property imaging_fov: List[float]
Imaging field of view (in microns) – relies on correct objective settings
- items()
- keys()
- property lowest_color_channel: int
Lowest color channel acquired (0 indexed)
- property num_bins: int
Number of photon arrival time bins
- property num_colors: int
Number of color channels acquired
- property num_discard_flyback_frames: int
Number of frames per volume discarded due to flyback
- property num_frames: int
Total number of frames in the image set (INCLUDES FLYBACK)
- property num_slices: int
Number of slices per volume
- property num_timepoints: int
Actually the same as num_volumes, but it’s easier to read this sometimes
- property num_true_frames: int
Number of frames that are NOT flyback
- property num_volumes: int
Actually the same as num_timepoints, but it’s easier to read this sometimes
- property picoseconds_per_bin: int
Picoseconds per photon arrival time bin
- property scale: List[float]
Returns the relative scale of the spatial axes (plus a 1.0 for the time axis) in order of: [time , (frames_per_slice_in_units_time), (z), color, y , x]
- property scale_force_z: List[float]
Returns the scale, but forces a z axis to be present, even if there is only one slice.
- property scale_no_color_no_fps: List[float]
Returns the relative scale of the spatial axes (plus a 1.0 for the time axis) in order of: [time , z , y , x]
- property shape: Tuple[int, int]
Shape of one frame: (n ysize, xsize)
- property single_channel_volume: Tuple[int, ...]
Return the shape of one volume of one color channel (num_slices, ysize, xsize)
- property stack: Tuple[int, ...]
Shape of one stack: (num_slices, frames_per_slice, ysize, xsize)
- property step_size: float
Step size between slices
- values()
- property volume: Tuple[int, ...]
Shape of one full volume: (num_slices, <frames_per_slice>, num_colors, ysize, xsize) with entries in <> only printed if they are greater than 1
- property volume_one_color: Tuple[int, ...]
Shape of one full volume in one color channel
- property xsize: int
Number of pixels in the x dimension
- property ysize: int
Number of pixels in the y dimension
- property z_vals: List[float]
List of z values for each slice
- property zoom: float
Scan zoom factor