sfftk.formats package
AmiraMesh format
sfftk.formats.am
User-facing reader classes for AmiraMesh files
- class sfftk.formats.am.AmiraMeshAnnotation(material)[source]
Bases:
AnnotationAnnotation class
- property colour
Segment colour
Colour may or may not exist. Return None if it doesn’t and the caller will determine what to do
- convert(**kwargs)[source]
Convert to
sfftkrw.SFFBiologicalAnnotationobject
- property description
Segment description
- property name
Segment name
- class sfftk.formats.am.AmiraMeshHeader(header)[source]
Bases:
objectClass defining the header of an AmiraMesh segmentation file
- class sfftk.formats.am.AmiraMeshMesh[source]
Bases:
objectMesh class
- convert(**kwargs)[source]
Convert to
sfftkrw.SFFMeshobject
- property triangles
Triangles in mesh
- property vertices
Vertices in mesh
- class sfftk.formats.am.AmiraMeshSegment(fn, header, segment_id)[source]
Bases:
SegmentSegment class
- property annotation
Segment annotation
- convert(**kwargs)[source]
Convert to
sfftkrw.SFFSegmentobject
- property material
Material may or may not exist. Return None if it doesn’t and the caller will determine what to do
- property volume
The segmentation as a volume
- class sfftk.formats.am.AmiraMeshSegmentation(fn, *args, **kwargs)[source]
Bases:
SegmentationClass representing an AmiraMesh segmentation
from sfftk.formats.am import AmiraMeshSegmentation am_seg = AmiraMeshSegmentation('file.am')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
The AmiraMesh header obtained using the
ahdspackageThe header is wrapped with a generic
ahds.headerclass
- property segments
Segments in this segmentation
- class sfftk.formats.am.AmiraMeshVolume(fn, header)[source]
Bases:
objectClass defining the 3D volume of an AmiraMesh segmentation file
- Parameters:
fn (str) – name of the AmiraMesh segmentation file
header –
AmiraMeshHeaderobject
- convert(**kwargs)[source]
Convert to
sfftkrw.SFFThreeDVolumeobject
SuRVoS format
sfftk.formats.survos
- class sfftk.formats.survos.SuRVoSSegment(segment_id, segmentation)[source]
Bases:
SegmentA single SuRVoS segment
- convert(name=None, colour=None)[source]
Convert to a
sfftkrw.SFFSegmentobject
- property segment_id
As usual, segment IDs start from 1 (not 0)
- class sfftk.formats.survos.SuRVoSSegmentation(fn, *args, **kwargs)[source]
Bases:
SegmentationSuRVoS segmentation adapter
from sfftk.formats.survos import SuRVoSSegmentation am_seg = SuRVoSSegmentation('predictions.h5')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property segments
A list of segments
CCP4 mask format
sfftk.formats.map
User-facing reader classes for CCP4/MRC masks.
There are three classes (one of which will be deprecated beginning in v0.8.0).
1 - :py:class:
- class sfftk.formats.map.BinaryMaskSegment(map_obj)[source]
Bases:
SegmentClass representing an individual binary mask segment
- property annotation
Segment annotation
- convert()[source]
Convert to a
sfftkrw.SFFSegmentobject
- class sfftk.formats.map.BinaryMaskSegmentation(fns, *args, **kwargs)[source]
Bases:
SegmentationA segmentation consisting of one or more binary masks
Warning
Results in large files
This class works by compiling a set of binary masks into a single file. The resulting file is much smaller than the original individual masks combined at the expense of the compute time required to zip and base64-encode the volume data.
Users are strongly encouraged to first merge all binary masks into a single mask using the Merging Masks then using the
sfftk.formats.map.MergedMaskSegmentationclass instead of this one.from sfftk.formats.map import BinaryMaskSegmentation map_seg = BinaryMaskSegmentation('binary_mask.mrc')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
The header is all the data from the CCP4/MRC header
- property segments
An iterable of segments
- class sfftk.formats.map.MapAnnotation(map_obj)[source]
Bases:
AnnotationAnnotation class
- property colour
Segment colour
- convert()[source]
Convert to a
sfftkrw.SFFBiologicalAnnotationobject
- property description
Segment description (concat all labels)
- property name
Segment name (filename since we have a segment per file)
- class sfftk.formats.map.MapHeader(segment)[source]
Bases:
HeaderClass defining the header in a CCP4 file
- class sfftk.formats.map.MapSegment(map_obj)[source]
Bases:
SegmentSegment class
- property annotation
Segment annotation
- convert()[source]
Convert to a
sfftkrw.SFFSegmentobject
- class sfftk.formats.map.MapSegmentation(fns, *args, **kwargs)[source]
Bases:
SegmentationClass representing an CCP4/MAP mask segmentation
Deprecated since version v0.8.0: For future versions of
sfftk, please use theMaskSegmentationclass for one or more binary masks andMergedMaskSegmentationfrom merged masks. See also Merging Masks.A
PendingDeprecationWarningis raised forsfftkearlier thanv0.8.0.from sfftk.formats.map import MapSegmentation map_seg = MapSegmentation('file.map')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
Segmentation metadata must be exactly as in one segment
- property segments
The segments in this segmentation
- class sfftk.formats.map.MaskAnnotation(map_obj, name=None)[source]
Bases:
AnnotationClass representing annotation for individual segments
- property colour
Segment colour
- convert()[source]
Convert to a
sfftkrw.SFFBiologicalAnnotationobject
- property description
Segment description (concat all labels)
- property name
Segment name (filename since we have a segment per file)
- class sfftk.formats.map.MergedMaskSegment(label, parent_label, map_obj, name=None)[source]
Bases:
SegmentClass representing an individual segment from a merged mask
- property annotation
Segment annotation
- convert()[source]
Convert to a
sfftkrw.SFFSegmentobject
- class sfftk.formats.map.MergedMaskSegmentation(fn, label_tree='merged_mask.json')[source]
Bases:
SegmentationA segmentation constructed from a merged mask derived from multiple binary masks
from sfftk.formats.map import MergedMaskSegmentation map_seg = MergedMaskSegmentation('merged_mask.mrc', label_tree='merged_mask.json')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
The header is all the data from the CCP4/MRC header
- property segments
An iterable of segments
IMOD format
sfftk.formats.mod
User-facing reader classes for IMOD files
- class sfftk.formats.mod.IMODAnnotation(header, objt)[source]
Bases:
AnnotationAnnotation class
- property colour
Segment colour
- convert()[source]
Convert to
sfftkrw.SFFBiologicalAnnotationobject
- property description
Segment description
- class sfftk.formats.mod.IMODEllipsoid(radius, x, y, z)[source]
Bases:
objectClass definition fo an ellipsoid shape primitive
- convert()[source]
Convert to
sfftkrw.SFFEllipsoidobject
- property radius
Ellipsoid radius
- property transform
A (3,4) transformation matrix that locates the shape in the space from the origin
- class sfftk.formats.mod.IMODHeader(segmentation)[source]
Bases:
HeaderClass definition for the header in an IMOD segmentation file
- class sfftk.formats.mod.IMODMesh(imod_mesh)[source]
Bases:
objectMesh class
- property normals
The normal vertices defining surface smoothness for shading
- property polygons
The polygons constituting this mesh
- property triangles
Polygons are triangles
- property vertices
The surface vertices defining this mesh’s geometry
- class sfftk.formats.mod.IMODMeshes(header, imod_meshes, args=None, *_args, **_kwargs)[source]
Bases:
UserListContainer class for IMOD meshes
- class sfftk.formats.mod.IMODSegment(header, objt)[source]
Bases:
objectSegment class
- property annotation
The annotation for this segment
- convert()[source]
Convert to
sfftkrw.SFFSegmentobject
- property meshes
The meshes in this segment
- property shapes
The shapes in this segment
- class sfftk.formats.mod.IMODSegmentation(fn, *args, **kwargs)[source]
Bases:
SegmentationClass representing an IMOD segmentation
from sfftk.formats.mod import IMODSegmentation mod_seg = IMODSegmentation('file.mod')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Method to convert an IMOD file to a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property has_mesh_or_shapes
Check whether the segmentation has meshes or shapes
If it only has contours this property is False Do not convert segmentations that only have contours
- property header
Header in segmentation
- property segments
Segments in segmentation
Segger format
sfftk.formats.seg
User-facing reader classes for Segger files
- class sfftk.formats.seg.SeggerAnnotation(segmentation, region_id)[source]
Bases:
AnnotationAnnotation class
- convert(**kwargs)[source]
Convert to a
sfftkrw.SFFBiologicalAnnotationobject
- class sfftk.formats.seg.SeggerHeader(segmentation)[source]
Bases:
HeaderHeader class
- property file_path
The path to the .seg file
- property ijk_to_xyz_transform
The image-to-physical transform
- property map_path
The path to the original segmented map
- property map_size
Map dimensions
- property name
The name of segmentation
- property parent_ids
All parent IDs
- property region_ids
All region IDs
- property root_parent_ids
Parent IDs for root segments
- property version
The version of Segger used
- class sfftk.formats.seg.SeggerSegment(segmentation, region_id)[source]
Bases:
SegmentSegment class
- convert(**kwargs)[source]
Convert to a
sfftkrw.SFFSegmentobject
- class sfftk.formats.seg.SeggerSegmentation(fn, top_level=True, *args, **kwargs)[source]
Bases:
SegmentationClass representing an Segger segmentation
from sfftk.formats.seg import SeggerSegmentation seg_seg = SeggerSegmentation('file.seg')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Method to convert a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
The header for this segmentation
- property segments
The segments in this segmentation
- class sfftk.formats.seg.SeggerVolume(segmentation)[source]
Bases:
VolumeVolume class
- convert(**kwargs)[source]
Convert to a
sfftkrw.SFFThreeDVolumeobject
Stereolithography format
sfftk.formats.stl
User-facing reader classes for Stereolithography files
- class sfftk.formats.stl.STLAnnotation(name)[source]
Bases:
AnnotationAnnotation class
- convert()[source]
Convert to a
sfftkrw.SFFBiologicalAnnotationobject
- class sfftk.formats.stl.STLHeader(segmentation)[source]
Bases:
HeaderClass definition for header in an STL segmentation file
- class sfftk.formats.stl.STLMesh(vertices, polygons)[source]
Bases:
MeshMesh class
- convert()[source]
Convert to a
sfftkrw.SFFMeshobject
- property polygons
Polygons in this mesh
- property vertices
Vertices in this mesh
- class sfftk.formats.stl.STLSegment(name, vertices, polygons)[source]
Bases:
SegmentSegment class
- property annotation
Segmentation annotation
- convert()[source]
Convert to a
sfftkrw.SFFSegmentobject
- property meshes
Segment meshes
- property name
Segment name
- class sfftk.formats.stl.STLSegmentation(fns, *args, **kwargs)[source]
Bases:
SegmentationClass representing an STL segmentation
from sfftk.formats.stl import STLSegmentation stl_seg = STLSegmentation('file.stl')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
The header in the segmentation
- property segments
The segments in the segmentation
Amira HyperSurface format
sfftk.formats.surf
User-facing reader classes for Amira HxSurface files
- class sfftk.formats.surf.AmiraHyperSurfaceAnnotation(segment)[source]
Bases:
AnnotationAnnotation class
- property colour
Segment colour
- convert()[source]
Convert to a
sfftkrw.SFFBiologicalAnnotationobject
- property name
Segment name
- class sfftk.formats.surf.AmiraHyperSurfaceHeader(header)[source]
Bases:
HeaderClass definition for an AmiraHyperSurface segmentation file
- class sfftk.formats.surf.AmiraHyperSurfaceMesh(segment)[source]
Bases:
MeshMesh class
- convert(**kwargs)[source]
Convert to a
sfftkrw.SFFMeshobject
- property polygons
List of (v1, v2, v3) (triangles)
- static translate_indexes(triangle_list, lut)[source]
Translate the values of the list of 3-tuples according to the provided look-up table
Is a generator.
- property vertices
Dictionary of vertex_id to (x, y, z)
- class sfftk.formats.surf.AmiraHyperSurfaceSegment(segment)[source]
Bases:
SegmentSegment class
- property annotation
Segment annotation
- convert(**kwargs)[source]
Convert to a
sfftkrw.SFFSegmentobject
- property id
Segment ID
- property meshes
Segment meshes
- class sfftk.formats.surf.AmiraHyperSurfaceSegmentation(fn)[source]
Bases:
SegmentationClass representing an AmiraHyperSurface segmentation
from sfftk.formats.surf import AmiraHyperSurfaceSegmentation surf_seg = AmiraHyperSurfaceSegmentation('file.surf')
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert to a
sfftkrw.SFFSegmentationobject- Parameters:
name (str) – optional name of the segmentation used in <name/>
software_version (str) – optional software version for Amira use in <software><version/></software>
processing_details (str) – optional processings used in Amira used in <software><processingDetails/></software>
details (str) – optional details associated with this segmentation used in <details/>
verbose (bool) – option to determine whether conversion should be verbose
transform (numpy.ndarray) – a 3x4 numpy.ndarray for the image-to-physical space transform
- property header
The header in the segmentation
- property segments
The segments in the segmentation
RELION STAR format
Working with STAR files
STAR files are CIF files.
To use STAR files with sfftk, the user needs to provide at least:
a STAR file
a map file (MRC, REC, MAP, CCP4, etc.)
sff convert <starfile> [--subtomogram-average <mrcfile>] -o <outputfile> [other options]
The presence of the --star flag tells sfftk that what is about to be generated is a refinement model plus transforms.
- class sfftk.formats.star.RelionMultiStarSegmentation(fn_list, particle_fn, euler_angle_convention='ZYZ', degrees=True, *_args, **_kwargs)[source]
Bases:
Segmentation- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert the segmentation to an EMDB-SFF segmentation
- property header
Return the header
- property segments
Return the segments
- class sfftk.formats.star.RelionStarHeader(map_obj)[source]
Bases:
MaskHeaderClass representing a Relion STAR file header
- class sfftk.formats.star.RelionStarSegment(particles: StarTable, euler_angle_convention='ZYZ', degrees=True, verbose=False, name='Particle refined using subtomogram averaging')[source]
Bases:
SegmentClass representing a Relion STAR file segment
- class sfftk.formats.star.RelionStarSegmentation(fn, particle_fn, euler_angle_convention='ZYZ', degrees=True, *_args, **_kwargs)[source]
Bases:
SegmentationClass that represents a Relion STAR file segmentation
- convert(name=None, software_version=None, processing_details=None, details=None, verbose=False, transform=None)[source]
Convert the segmentation to an EMDB-SFF segmentation
- property header
Return the header
- property segments
Return the segments