axon_synthesis.utils¶
Some utils for the AxonSynthesis package.
Functions
|
Update the HTML file to synchronize the cameras between the two plots. |
|
Build a dictionary with layout properties for Plotly figures. |
|
Transform the given columns to Python objects from JSON strings. |
|
Transform the given columns from Python objects to JSON strings. |
|
Compute the aspect ratios of a bounding box. |
|
Compute the bounding box of the given points and optionally apply a buffer to it. |
|
Ensure all rows of the same group belong to the same partition. |
|
Create some random source points. |
A context manager that will disable logging messages from the 'distributed' library. |
|
|
A context manager that will disable logging messages triggered during the body. |
|
Export the morphology as DataFrame for later analysis. |
|
Export a 3D vector field to a Tecplot binary file. |
|
Fill the diagonal of the given matrix. |
|
Get axons of the given morphology. |
|
Return the current file name and line number in the program. |
|
Get layer data. |
|
Return the points of a morphology and handle empty morphologies. |
|
Get all morphology paths from a given directory. |
|
Get all morphology paths from a given directory and sub directories. |
|
A context manager that will ignore warnings raised during the body. |
|
Delete neurites except the ones with a given type or index. |
|
Load a morphology a optionally recenter it. |
|
Merge several JSON files together. |
|
Transform a neurite into a graph. |
|
Transform a neurite into a graph. |
|
Extract points and segments from a neurite. |
|
Create a local cluster and process the given function on the given DataFrame. |
Permanently disable logging messages from the 'distributed' library. |
|
|
Cast all Path objects into str objects in a given dict. |
|
Update a dictionary with another with nested values. |
|
Export the given morphology to the given path. |
|
Build a seed from the name hash. |
|
Setup application logger. |
|
Get a sub-logger with specific name. |
|
Create a temporary directory. |
Classes
|
A class to create a directory that can be cleaned up. |
|
Add the morphology name and optionally the axon ID to the log entries. |
|
Class to store the parallel configuration. |
|
Backport of delete parameter for TemporaryDirectory. |
- class axon_synthesis.utils.CleanableDirectory(dir_name, *, parents=True, exist_ok=False)¶
Bases:
objectA class to create a directory that can be cleaned up.
- cleanup()¶
Clean up the directory.
- class axon_synthesis.utils.MorphNameAdapter(logger, extra=None)¶
Bases:
LoggerAdapterAdd the morphology name and optionally the axon ID to the log entries.
- process(msg: str, kwargs: MutableMapping[str, object]) tuple[str, MutableMapping[str, object]]¶
Add extra information to the log entry.
- class axon_synthesis.utils.ParallelConfig(nb_processes: int = 0, dask_config: dict | None = None, progress_bar: bool = False, use_mpi: bool = False)¶
Bases:
objectClass to store the parallel configuration.
- class axon_synthesis.utils.TemporaryDirectory(*args, delete=True, **kwargs)¶
Bases:
TemporaryDirectoryBackport of delete parameter for TemporaryDirectory.
- axon_synthesis.utils.add_camera_sync(fig_path)¶
Update the HTML file to synchronize the cameras between the two plots.
- axon_synthesis.utils.build_layout_properties(pts, relative_buffer: float | None = None, absolute_buffer: float | None = None) dict¶
Build a dictionary with layout properties for Plotly figures.
- axon_synthesis.utils.cols_from_json(df, cols)¶
Transform the given columns to Python objects from JSON strings.
- axon_synthesis.utils.cols_to_json(df, cols)¶
Transform the given columns from Python objects to JSON strings.
- axon_synthesis.utils.compute_aspect_ratios(bbox)¶
Compute the aspect ratios of a bounding box.
- axon_synthesis.utils.compute_bbox(points, relative_buffer=None, absolute_buffer=None)¶
Compute the bounding box of the given points and optionally apply a buffer to it.
- axon_synthesis.utils.create_dask_dataframe(data: DataFrame, npartitions: int, group_col='morphology')¶
Ensure all rows of the same group belong to the same partition.
- axon_synthesis.utils.create_random_morphologies(atlas, nb_morphologies: int, brain_regions: int | str | list[int | str] | None = None, output_morphology_dir: str | PathLike | None = None, output_cell_collection: str | PathLike | None = None, morphology_prefix: str | None = None, rng: None | int | Sequence[int] | SeedSequence | BitGenerator | Generator = None, logger: Logger | LoggerAdapter | None = None)¶
Create some random source points.
- axon_synthesis.utils.disable_distributed_loggers()¶
A context manager that will disable logging messages from the ‘distributed’ library.
- axon_synthesis.utils.disable_loggers(*logger_names)¶
A context manager that will disable logging messages triggered during the body.
- Parameters:
*logger_names (str) – The names of the loggers to be disabled.
- axon_synthesis.utils.export_morph_edges(morph, output_path, neurite_filter=None, logger=None)¶
Export the morphology as DataFrame for later analysis.
- axon_synthesis.utils.export_to_tecplot(voxcell_data, filename, title='Default Title')¶
Export a 3D vector field to a Tecplot binary file.
- axon_synthesis.utils.fill_diag(mat, val=1)¶
Fill the diagonal of the given matrix.
- axon_synthesis.utils.get_axons(morph, axon_ids=None)¶
Get axons of the given morphology.
- axon_synthesis.utils.get_code_location(back_frames=1)¶
Return the current file name and line number in the program.
- axon_synthesis.utils.get_layers(atlas, pos)¶
Get layer data.
- axon_synthesis.utils.get_morph_pts(morph)¶
Return the points of a morphology and handle empty morphologies.
- axon_synthesis.utils.get_morphology_paths(morph_dir, *, max_level=None)¶
Get all morphology paths from a given directory.
- axon_synthesis.utils.get_nested_morphology_paths(morph_dir, *, max_level=None)¶
Get all morphology paths from a given directory and sub directories.
- axon_synthesis.utils.ignore_warnings(*ignored_warnings)¶
A context manager that will ignore warnings raised during the body.
- Parameters:
*ignored_warnings (Warning) – The classes of the warnings to be ignored.
- axon_synthesis.utils.keep_only_neurites(morph, neurite_type=None, neurite_idx=None, *, copy=False)¶
Delete neurites except the ones with a given type or index.
Note
If both the type and index are given, the index is only applied for the neurites of the given type.
- axon_synthesis.utils.load_morphology(path, *, recenter=False)¶
Load a morphology a optionally recenter it.
- axon_synthesis.utils.merge_json_files(*files)¶
Merge several JSON files together.
The order is important: the files will be updated by all the next files in the list.
- axon_synthesis.utils.neurite_to_graph(neurite, graph_cls=<class 'networkx.classes.digraph.DiGraph'>, *, keep_section_segments=False, **graph_kwargs)¶
Transform a neurite into a graph.
- axon_synthesis.utils.neurite_to_graph_old(neurite, graph_cls=<class 'networkx.classes.digraph.DiGraph'>, **graph_kwargs)¶
Transform a neurite into a graph.
- axon_synthesis.utils.neurite_to_pts(neurite, *, keep_section_segments=False, edges_with_coords=False)¶
Extract points and segments from a neurite.
- axon_synthesis.utils.parallel_evaluator(data, func, parallel_config: ParallelConfig | None, new_columns: list, *, func_args=None, func_kwargs=None, startup_func=None, shuffle_rows: bool = True, progress_bar: bool = False, logger: Logger | LoggerAdapter | None = None)¶
Create a local cluster and process the given function on the given DataFrame.
- axon_synthesis.utils.permanently_disable_distributed_loggers()¶
Permanently disable logging messages from the ‘distributed’ library.
- axon_synthesis.utils.recursive_to_str(data)¶
Cast all Path objects into str objects in a given dict.
- axon_synthesis.utils.recursive_update(data, updates)¶
Update a dictionary with another with nested values.
- axon_synthesis.utils.save_morphology(morph: Morphology, morph_path: str | PathLike, msg: str | None = None, logger: Logger | LoggerAdapter | None = None)¶
Export the given morphology to the given path.
- axon_synthesis.utils.seed_from_name(name)¶
Build a seed from the name hash.
- axon_synthesis.utils.setup_logger(level: str = 'info', prefix: str = '', suffix: str = '')¶
Setup application logger.
- axon_synthesis.utils.sublogger(logger: Logger | LoggerAdapter | None, name: str) Logger | LoggerAdapter¶
Get a sub-logger with specific name.
- axon_synthesis.utils.temp_dir(*args, **kwargs)¶
Create a temporary directory.