Utility¶
Data Helper Methods¶
- class brainlit.utils.NeuroglancerSession(url: str, mip: int = 0, url_segments: Optional[str] = None, fill_missing: bool = True, use_https: bool = False)[source]¶
Utility class which pulls and pushes data.
- Parameters
url -- Precompued path either to a file URI or url URI. Defaults to mouselight brain1.
mip -- Resolution level to pull and push data at. Defaults to 0, the highest resolution.
url_segments -- Precomputed path to segmentation data. Optional, default None.
fill_missing -- Always passes directly into 'CloudVolume()' function to fill missing segent/image values with 0s.
use_https -- Always passes directly into 'CloudVolume()' function to set use_https to the desired value.
- url¶
CloudVolumePrecomputedPath to image data.
- url_segments¶
CloudVolumePrecomputedPath to segmentation data. Optional, default None. Automatically tries precomputed path url+"_segments" if None.
- cv¶
CloudVolume object for image data.
- Type
CloudVolumePrecomputed
- cv_segments¶
CloudVolume object for segmentation data. Optional, default None.
- Type
CloudVolumePrecomputed
- cv_annotations¶
CloudVolume object for segmentation data. Optional, default None.
- Type
CloudVolumePrecomputed
- mip¶
Resolution level.
- chunk_size¶
The chunk size of the volume at the specified mip, given as (x, y, z).
- scales¶
The resolution of the volume at the specified mip, given as (x, y, z).
- class brainlit.utils.NeuronTrace(path: str, seg_id: int = None, mip: int = None, rounding: bool = True, read_offset: bool = False, fill_missing: bool = True, use_https: bool = False)[source]¶
Neuron Trace class to handle neuron traces as swcs and s3 skeletons
- Parameters
path (str) -- Path to either s3 bucket (url) or swc file (filepath).
seg_id (int) -- If s3 bucket path is provided, the segment number to pull, default None.
mip (int) -- If s3 bucket path is provided, the resolution to use for scaling, default None.
rounding (bool) -- If s3 is provided, specifies if it should be rounded, default True
read_offset (bool) -- If swc is provided, whether offset should be read from file, default False.
fill_missing (bool) -- Always passes directly into 'CloudVolume()' function to fill missing skeleton values with 0s, default True.
use_https (bool) -- Always passes directly into 'CloudVolume()' function to set use_https to desired value, default True.
- df¶
Indices, coordinates, and parents of each node
- Type
pandas.DataFrame
Example
>>> swc_path = "./data/data_octree/consensus-swcs/2018-08-01_G-002_consensus.swc" >>> s3_path = "s3://open-neurodata/brainlit/brain1_segments" >>> seg_id = 11 >>> mip = 2
>>> swc_trace = NeuronTrace(swc_path) >>> s3_trace = NeuronTrace(s3_path,seg_id,mip)
- brainlit.utils.czi_to_zarr(czi_path: str, out_dir: str, fg_channel: int = 0, parallel: int = 1)[source]¶
Convert 4D czi image to a zarr file(s) at a given directory. Single channel image will produce a single zarr, two channels will produce two.
- brainlit.utils.zarr_to_omezarr(zarr_path: str, out_path: str, res: list)[source]¶
Convert 3D zarr to ome-zarr.
- Parameters
- Raises
ValueError -- If zarr to be written already exists.
ValueError -- If conversion is not 3D array.
S3 Helper Methods¶
- brainlit.utils.get_data_ranges(bin_path: List[List[str]], chunk_size: Tuple[int, int, int])[source]¶
Get ranges (x,y,z) for chunks to be stitched together in volume
- Parameters
bin_path -- Binary paths to files.
chunk_size -- The size of chunk to get ranges over.
- Returns
x-coord int bounds. y_range: y-coord int bounds. z_range: z-coord int bounds.
- Return type
x_range