Skip to content

Commit

Permalink
update API and documentation, fixes #35
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKiaru committed Jan 27, 2025
1 parent 3b9f976 commit 6f1fb85
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
18 changes: 18 additions & 0 deletions examples/demo_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# examples/demo_gui.py
import jpype
import time
from abba_python.abba import Abba

def main():

abba = Abba('Adult Mouse Brain - Allen Brain Atlas V3p1')
abba.show_bdv_ui()

while jpype.isJVMStarted():
time.sleep(1)

print("JVM has shut down")


if __name__ == "__main__":
main()
54 changes: 46 additions & 8 deletions src/abba_python/abba.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ class Abba:
abba_python.ij() returns the current ij instance, which can also be reused in another
abba_python instance
slicing_mode :
should be 'coronal', 'sagittal' or 'horizontal'
TO IMPROVE : test how well this matches with the BrainGlobe API
x_axis :
See https://github.com/BIOP/ijp-imagetoatlas/blob/master/src/main/java/ch/epfl/biop/atlas/aligner/command/ABBAStartCommand.java
should be 'AP', 'PA', 'LR', 'RL', 'DV', 'VD'
y_axis :
should be 'AP', 'PA', 'LR', 'RL', 'DV', 'VD'
z_axis :
should be 'AP', 'PA', 'LR', 'RL', 'DV', 'VD'
log_level :
should be taken within LogLevel literal
Expand All @@ -210,7 +212,9 @@ def __init__(
self,
atlas_name: str = 'Adult Mouse Brain - Allen Brain Atlas V3p1',
ij=None,
slicing_mode: str = 'coronal', # or sagittal or horizontal
x_axis: str = 'RL',
y_axis: str = 'SI',
z_axis: str = 'AP',
headless: bool = False,
print_config: bool = True,
log_level: LogLevel = 'INFO'
Expand Down Expand Up @@ -257,7 +261,9 @@ def __init__(
ij.object().addObject(atlas, atlas_name) # store it in java's object service

self.atlas = Abba.opened_atlases[atlas_name]
self.slicing_mode = slicing_mode
self.x_axis = x_axis
self.y_axis = y_axis
self.z_axis = z_axis
self.atlas_name = atlas_name

# Setting logging options
Expand All @@ -272,7 +278,9 @@ def __init__(
self.print_config()

self.mp = ij.command().run(ABBAStartCommand, True,
'slicing_mode', self.slicing_mode,
'x_axis', self.x_axis,
'y_axis', self.y_axis,
'z_axis', self.z_axis,
'ba', self.atlas
).get().getOutput('mp')

Expand Down Expand Up @@ -1074,6 +1082,21 @@ def rotate_slices(self,
'angle_degrees', angle_degrees,
'axis_string', axis_string).get()


def set_slices_deselected(self,
slices_csv: str):
"""
Set the slices to deselect.
Parameters:
slices_csv (str): Slices to deselect, '*' for all slices, comma separated, 0-based
"""
SetSlicesDeselectedCommand = jimport('ch.epfl.biop.atlas.aligner.command.SetSlicesDeselectedCommand')
return self.ij.command().run(SetSlicesDeselectedCommand, True,
'mp', self.mp,
'slices_csv', slices_csv).get()


def set_slices_display_range(self,
channels_csv: str,
display_max: float,
Expand All @@ -1093,6 +1116,21 @@ def set_slices_display_range(self,
'display_max', display_max,
'display_min', display_min).get()


def set_slices_selected(self,
slices_csv: str):
"""
Set the slices to select.
Parameters:
slices_csv (str): Slices to select, '*' for all slices, comma separated, 0-based
"""
SetSlicesSelectedCommand = jimport('ch.epfl.biop.atlas.aligner.command.SetSlicesSelectedCommand')
return self.ij.command().run(SetSlicesSelectedCommand, True,
'mp', self.mp,
'slices_csv', slices_csv).get()


def set_slices_thickness(self,
thickness_in_micrometer: float):
"""
Expand Down

0 comments on commit 6f1fb85

Please sign in to comment.