io#
Data Loading/Writing functions for mesoscope data
Functions to load and save ScanImage data
- labtools.mesoscope.io.bigtiff_nframes(path: Union[pathlib.Path, ScanImageTiffReader.ScanImageTiffReader]) int [source]#
Check the number of frames in a bigtiff
- labtools.mesoscope.io.iter_bigtiff(path: Optional[pathlib.Path] = None, batch_size: int = 1, reader: Optional[ScanImageTiffReader.ScanImageTiffReader] = None, start_frame: int = 0, end_frame: Optional[int] = None)[source]#
Iterate through frames in a BigTiff file
Examples
- for frame in iter_bigtiff(path):
# do something with the frame
- Parameters
path (pathlib.Path) β Path to input tiff
batch_size (int) β Number of images to yield at once
reader (ScanImageTiffReader) β Optional - an already-opened TiffReader. Either path or reader needs to be passed
- labtools.mesoscope.io.bigtiff_to_video(path: pathlib.Path, output: Optional[pathlib.Path] = None, ops: Optional[pathlib.Path] = None, start_frame: int = 0, end_frame: Optional[int] = None, source_fps: int = 30, output_fps: int = 30, codec: str = 'libx264', pix_fmt: str = 'yuv420p', input_kwargs: Optional[dict] = None, output_kwargs: Optional[dict] = None, verbosity: int = 1, brightness: float = 1, dfof_kwargs: Optional[dict] = None) pathlib.Path [source]#
Convert a bigtiff to a video file using scikit-image.
- Parameters
path (Path) β Input bigtiff path
output (Path) β Optional, output video path. If None, then just replace extension with .mp4
ops (Path) β Ops file. if None, try to get
<path>_ops.json
start_frame (int) β Frame of input to start on
end_frame (int) β Frame of input to end output video
source_fps (int) β fps of source video
output_fps (int) β fps to convert output video to
codec (str) β video codec!
pix_fmt (str) β pixel format (default
yuv420p
)input_kwargs β Passed to
skvideo.io.FFMpegWriter
output_kwargs β Passed to
skvideo.io.FFMpegWriter
brightness (float) β adjust brightness (linearly, by multiplication lmao)
dfof_kwargs (dict) β if not None, a dictionary passed to
dfof()
- Returns
Path of encoded video
References
https://github.com/MouseLand/suite2p/blob/main/suite2p/io/tiff.py
- labtools.mesoscope.io.iterative_median(reader: ScanImageTiffReader.ScanImageTiffReader, batch_size: int = 10) numpy.ndarray [source]#
Find the median of a big huge video by taking the med
- labtools.mesoscope.io.dfof(input: ScanImageTiffReader.ScanImageTiffReader, method: Literal['median', 'mean'] = 'median', iterative=False, **kwargs) numpy.ndarray [source]#
Calculate the median of each frame of a video
- labtools.mesoscope.io.restack_bigtiff(frame: numpy.ndarray, ops: dict) numpy.ndarray [source]#
bigtiffs are usually just huge vertical strips.
Use the ops file to unstack them into normal frames.
Note
This is just an approximation for the sake of making a video, donβt use this for analysis!
References
https://github.com/MouseLand/suite2p/blob/main/suite2p/io/tiff.py