cellmaps_image_embedding package
Submodules
cellmaps_image_embedding.cellmaps_image_embeddingcmd module
- cellmaps_image_embedding.cellmaps_image_embeddingcmd.main(args)[source]
Main entry point for program
- Parameters:
args (list) – arguments passed to command line usually
sys.argv[1:]()- Returns:
return value of
cellmaps_image_embedding.runner.CellmapsImageEmbedder.run()or2if an exception is raised- Return type:
cellmaps_image_embedding.dataset module
cellmaps_image_embedding.exceptions module
cellmaps_image_embedding.models module
- class cellmaps_image_embedding.models.ArcMarginProduct(in_features, out_features)[source]
Bases:
ModuleInitialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(features)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class cellmaps_image_embedding.models.DensenetClass(backbone='densenet121', num_classes=28, in_channels=4, pretrained=None, large=False)[source]
Bases:
ModuleInitialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class cellmaps_image_embedding.models.ResnetClass(backbone='resnet34', num_classes=28, in_channels=4, pretrained=None)[source]
Bases:
ModuleInitialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- cellmaps_image_embedding.models.class_densenet121_dropout(num_classes=28, in_channels=4, pretrained=None)[source]
cellmaps_image_embedding.runner module
- class cellmaps_image_embedding.runner.CellmapsImageEmbedder(outdir=None, inputdir=None, embedding_generator=None, skip_logging=True, name=None, organization_name=None, project_name=None, input_data_dict=None, provenance_utils=<cellmaps_utils.provenance.ProvenanceUtil object>, provenance=None)[source]
Bases:
objectClass to run algorithm
Constructor
- Parameters:
outdir (str) – Directory to write the results of this tool
inputdir (str) – Directory with images that will be embedded, containing color-separated subdirectorie. Output directory from cellmaps_imagedownloader.
embedding_generator (EmbeddingGenerator) – An object implementing the embedding generation logic, typically a subclass of
EmbeddingGenerator, such asDensenetEmbeddingGeneratororFakeEmbeddingGenerator.skip_logging (bool) – If
Trueskip logging, ifNoneorFalsedo NOT skip loggingname (str or None) – Optional name for the dataset, used in provenance tracking. If not provided, it will be inferred from the RO-Crate in the input directory or fallback defaults.
organization_name (str or None) – Optional name of the organization creating the dataset. Used for provenance metadata.
project_name (str or None) – Optional name of the project associated with the dataset. Used for provenance metadata.
input_data_dict (dict or None) –
Dictionary of input parameters used for execution. This is captured and stored in metadata as part of reproducibility and provenance. If not provided, a default dictionary is generated.
Example:
{'outdir': '/output/path', 'inputdir': '/input/path'}
provenance_utils (ProvenanceUtil) – Utility class instance for handling RO-Crate creation, software registration, and FAIRSCAPE dataset tracking. Default is a new
ProvenanceUtilobject.provenance (dict or None) –
Optional dictionary containing explicit provenance metadata, such as dataset name, project, organization, keywords, and description. If present, it will override missing information in RO-Crate.
Example:
{ 'name': 'Cell Image Embedding Dataset', 'organization-name': 'CM4AI', 'project-name': 'Cell Image Project', 'keywords': ['embedding', 'microscopy'], 'description': 'Embedding of IF microscopy images.' }
- class cellmaps_image_embedding.runner.DensenetEmbeddingGenerator(inputdir, dimensions=1024, outdir=None, model_path=None, suffix='.jpg', fold=1, img_emd_translator=None)[source]
Bases:
EmbeddingGeneratorRuns densenet bundled with this tool via command line to generate embedding. Why do it this way? Easier transition from the original Densenet code and no memory leaks
Constructor
- Parameters:
inputdir (str) – Directory where red, blue, green, and yellow image directories reside
dimensions (int) – Desired size of output embedding vector
pythonbinary (str) – Path to python binary, if set to
Nonethe version of python that invoked this command will be usedpredict (str) – Path to prediction script. Default value is the script bundled with this tool
model_path (str) – Path to model file
suffix (str) – Image suffix with starting
.img_emd_translator
- get_datasets_that_need_to_be_registered()[source]
Gets model.pth dataset that needs to be registered with FAIRSCAPE.
Warning
Must not be called before invocation of
get_next_embedding()- Raises:
CellMapsImageEmbeddingError – If this method is called before at least one invocation of
get_next_embedding()- Returns:
list of tuples in format of (dict, filepath as str)
- Return type:
- class cellmaps_image_embedding.runner.EmbeddingGenerator(dimensions=1024, fold=1)[source]
Bases:
objectBase class for implementations that generate network embeddings
Constructor
- DEFAULT_FOLD = 1
- DIMENSIONS = 1024
- SUFFIX = '.jpg'
- get_datasets_that_need_to_be_registered()[source]
Gets any datasets that need to be registered with FAIRSCAPE
- Returns:
list of tuples in format of (dict, filepath as str)
- Return type:
- class cellmaps_image_embedding.runner.FakeEmbeddingGenerator(inputdir, dimensions=1024, fold=1, suffix='.jpg', img_emd_translator=None)[source]
Bases:
EmbeddingGeneratorFakes image embedding
Constructor
- Parameters:
Module contents
Top-level package for cellmaps_image_embedding.