neurotorchmz.core.session#

Module holding code to launch and manage a Neurotorch program

Classes

Edition(*values)

The edition of Neurotorch which should be launched

Session([edition])

A session is the main entry into Neurotorch.

SessionAPI(session)

A class bound to a session object, which allows the user to communicate with the Neurotorch GUI.

SessionCreateEvent(*args, **kwds)

Triggers after a session is created (not launched yet)

class neurotorchmz.core.session.Edition(*values)#

Bases: Enum

The edition of Neurotorch which should be launched

NEUROTORCH = 1#

Standard version

NEUROTORCH_DEBUG = 10#

Launches the developer version with (depending on your version) additional features and debugging output

NEUROTORCH_LIGHT = 2#

Launches Neurotorch without some external connectivity. Designed to minimize external dependencies and for bundling

class neurotorchmz.core.session.Session(edition: Edition = Edition.NEUROTORCH)#

Bases: object

A session is the main entry into Neurotorch. It stores the loaded data and provides update functions for the GUI

In contrast, if you only want to access the detection functions and don’t need Neurotorch to handle the images for you, use the API

_image_object: ImageObject | None#
_image_path: Path | None#
_roifinder_detection_result: DetectionResult#
_snalysis_detection_result: DetectionResult#
_window_thread: Thread | None#
property active_image_object: ImageObject | None#

Retreive or set the currently active ImageObject

edition: Edition#
launch(background: bool = False)#

Launches the GUI. The parameter background controls if a thread is used. Can only be called once

Raises:

RuntimeError – The GUI has already been started

notify_image_object_change()#

When changing the ImageObject, call this function to notify the GUI about the change. Will invoke a ImageChanged TabUpdateEvent on all tabs in the window.

property roifinder_detection_result: DetectionResult#

Returns the detection result object of the roi finder tab

property root: window.tk.Tk | None#

Returns the current tkinter root. If in headless mode, return None

set_active_image_object(imgObj: ImageObject | None)#

Replace the active ImageObject or remove it by setting it to zero. Creates a new SignalObject

property synapse_analysis_detection_result: DetectionResult#

Returns the detection result object of the synapses analysis tab

class neurotorchmz.core.session.SessionAPI(session: Session)#

Bases: object

A class bound to a session object, which allows the user to communicate with the Neurotorch GUI. If you want to use the API without the object management of Neurotorch, use the neurotorchmz.API instead

open_file(path: Path, run_async: bool = True) ImageObject | Task#

Opens the given path in Neurotorch

Parameters:
  • path (pathlib.Path) – The path to the file

  • run_async (bool) – Controls if the task runs in a different thread (recommended, as it will not block the window)

Returns ImageObject|Task:

The ImageObject (run_async=False) or a task object. If a task is returned, use task.add_callback(function=function) to get notified once the image is loaded

Raises:
  • AlreadyLoading – There is already a task working on this ImageObject

  • FileNotFoundError – Can’t find the file

  • UnsupportedImageError – The image is unsupported or has an error

  • ImageShapeError – The image has an invalid shape

class neurotorchmz.core.session.SessionCreateEvent(*args: Any, **kwds: Any)#

Bases: Event

Triggers after a session is created (not launched yet)

HOOKS: list[Callable[[Self], None]] = [<function on_session_created>, <function on_session_created>]#