Fiji

We add support to Fiji [6] software by providing I/O and a runner class that enables running script with Fiji headless.

Utilities for inputs/outputs with fiji.

byotrack.fiji.io.save_detections(detections_sequence: Sequence[byotrack.Detections], path: str | os.PathLike) None

Save a sequence of detections as a stack of segmentation that can be reload by the trackmate label detector.

Parameters:
  • detections_sequence (Sequence[Detections]) – Detections for each frame. There should be one Detections object for every frame of the video (even if empty it should be provided)

  • path (str | os.PathLike) – Output path

byotrack.fiji.io.load_tracks(path: str | os.PathLike) list[byotrack.Track]

Load tracks saved by trackmate.

Format example:

<TrackMate>
    <Model>
        <AllSpots>
            <SpotsInFrame frame="0">
                <Spot ID="2811" POSITION_X="552.0" POSITION_Y="143.0" POSITION_Z="0.0">...</Spot>
                ...
            </SpotsInFrame>
            ...
        </AllSpots>
        <AllTracks>
            <Track TRACK_ID="0">
                <Edge SPOT_SOURCE_ID="24068" SPOT_TARGET_ID="20796"/>
                ...
            </Track>
        </AllTracks>
    </Model>
</TrackMate>
Parameters:

path (str | os.PathLike) – Input path

Returns:

Parsed tracks

Return type:

List[Track]

class byotrack.fiji.run.FijiRunner(fiji_path: str | os.PathLike, *, capture_outputs=False)

Bases: object

Runs fiji in headless with specified protocol and arguments.

fiji_path

Path to the fiji executable The executable can be found inside the installation folder of Fiji. Linux: Fiji.app/ImageJ-<os> Windows: Fiji.app/ImageJ-<os>.exe MacOs: Fiji.app/Contents/MacOs/ImageJ-<os>

Type:

pathlib.Path

capture_outputs

Whether to PIPE stderr and stdout into Python This will allow you to find the stdout/stderr inside last_outputs. But outputs are captured, and you do not see them while the scripts run. Default: False

Type:

bool

last_outputs

Outputs of the last subprocess.run

Type:

subprocess.CompletedProcess

run(script: str | os.PathLike, **kwargs: Any) int

Runs fiji with the given script and additional kwargs.

Parameters:
  • script (str | os.PathLike) – Path to a Fiji script file

  • **kwargs – Additional arguments given as key=value to the cmd line

Returns:

Return code of fiji

Return type:

int