unravel.image_io.img_to_points module#
Use io_img_to_points (i2p
) from UNRAVEL to convert non-zero voxels in a 3D image to a set of points, accounting for voxel intensity (e.g., number of detections).
- Input image types:
.czi, .nii.gz, .ome.tif series, .tif series, .h5, .zarr
- Output:
A CSV file where each row represents a point corresponding to a detection in the 3D image.
The coordinates (x, y, z) are derived from the voxel locations in the image, with multiple points generated for voxels with intensities greater than 1.
An optional ‘Region_ID’ column is added based on the corresponding atlas image.
Usage:#
io_img_to_points -i path/image [-a path/atlas_image.nii.gz] [-o path/points.csv] [-v]
- unravel.image_io.img_to_points.img_to_points(img, atlas_img=None)[source]#
Converts non-zero voxel coordinates in a 3D ndarray to a list of points, accounting for voxel intensity. Optionally adds a ‘Region_ID’ based on the corresponding atlas image.
Parameters:#
- imgnumpy.ndarray
The 3D array representing the image data, where voxel intensities > 0 indicate the number of detections.
- atlas_imgnumpy.ndarray, optional
The 3D array representing the atlas image data. If provided, a ‘Region_ID’ column will be added to the output points.
Returns:#
- pointsnumpy.ndarray
An array of points where each row corresponds to the (x, y, z) coordinates of a detection. If atlas_img is provided, each point will have an additional ‘Region_ID’ column.
Note:#
Convert the points to a DataFrame using: >>> points_df = pd.DataFrame(points_ndarray, columns=[‘x’, ‘y’, ‘z’]) or >>> points_df = pd.DataFrame(points_ndarray, columns=[‘x’, ‘y’, ‘z’, ‘Region_ID’]) # With atlas_img