neuralib.imglib.labeller

SequenceLabeller

Simple CV2-based viewer/labeller GUI for image sequences

Use Cases:

  • viewing the image sequences

  • label each image and save as csv dataframe (human-eval for population neurons activity profile)

Load sequences from a directory

  • Use CLI mode

See help:

python -m neuralib.imglib.labeller -h

Example:

python neuralib.imglib.labeller -D <DIR>
  • Use API call

from neuralib.imglib.labeller import SequenceLabeller

directory = ...
labeller = SequenceLabeller.load_from_dir(directory)
labeller.main()

Load sequences from sequences array

from neuralib.imglib.labeller import SequenceLabeller

arr = ...   # numpy array with (F, H, W, <3>)
labeller = SequenceLabeller.load_sequences(arr)
labeller.main()
class neuralib.imglib.labeller.SequenceLabeller[source]
window_title: ClassVar[str] = 'SeqLabeller'
__init__(seqs_info, output=None)[source]
Parameters:
  • seqs_info (list[FrameInfo])

  • output (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader | None)

classmethod load_sequences(seqs, filenames=None, output=None)[source]
Parameters:
  • seqs (ndarray | list[ndarray])

  • filenames (list[str] | None)

  • output (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader | None)

Returns:

Return type:

Self

classmethod load_from_dir(directory, file_suffix='.tif', sort_func=None, single_frame_per_file=True, output=None)[source]
Parameters:
  • directory (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader) – directory contain image sequences

  • file_suffix (str) – sequence file suffix

  • sort_func (Callable[[Path], Any] | None) – sorted function with signature (filename:Path) -> Comparable

  • single_frame_per_file (bool)

  • output (str | Path | bytes | BinaryIO | BufferedIOBase | BufferedReader | None)

Returns:

Return type:

Self

property n_frames: int

aka. number of images

property current_frame_index: int
property text_color: float | tuple[int, int, int]
save_note()[source]

save image-related notes to file

load_note()[source]

read image-related notes from file

write_note(note, *, append_mode=False)[source]
Parameters:
  • note (str)

  • append_mode (bool)

read_note()[source]
Return type:

str | None

clear_note()[source]
check_note_changes()[source]

True if any changes in notes

Return type:

bool

goto_begin()[source]
goto_end()[source]
go_to(i)[source]
Parameters:

i (int)

handle_keycode(k)[source]
Parameters:

k (int)

handle_command(command)[source]
Parameters:

command (str)

enqueue_message(text)[source]
Parameters:

text (str)

main()[source]

main loop for the GUI