Skip to content

Commit

Permalink
Adds new commands to python API
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKiaru committed Sep 5, 2024
1 parent d8042ff commit e3e7ddb
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions src/abba_python/abba.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_java_dependencies():
'com.formdev:flatlaf:3.5',
'ch.epfl.biop:bigdataviewer-image-loaders:0.8.2',
'ch.epfl.biop:atlas:0.2.2'
]
]


def start_imagej(headless: bool = False,
Expand Down Expand Up @@ -84,11 +84,10 @@ def start_imagej(headless: bool = False,
# Adds Python information to ABBA help command
ABBAForumHelpCommand = jimport('ch.epfl.biop.atlas.aligner.command.ABBAForumHelpCommand')
from importlib.metadata import version
python_info = 'ABBA Python '+str(version("abba-python"))
python_info = 'ABBA Python ' + str(version("abba-python"))
ABBAForumHelpCommand.pythonInformation = JString(python_info)



def add_brainglobe_atlases(ij):
# TODO : check connection available or not
try:
Expand Down Expand Up @@ -142,7 +141,7 @@ def get(self):

# Specify which atlases are compatible with DeepSlice Mouse and Rat models - this only affects the GUI
DeepSliceHelper = jimport('ch.epfl.biop.atlas.aligner.DeepSliceHelper')
mouse_compatible_atlases = [ # Not sure thew all work!
mouse_compatible_atlases = [ # Not sure thew all work!
'example_mouse_100um',
'allen_mouse_10um',
'allen_mouse_25um',
Expand Down Expand Up @@ -174,9 +173,6 @@ def get(self):
DeepSliceHelper.addRatCompatibleAtlas(JString('whs_sd_rat_39um'))





class Abba:
"""Abba object which can be used to register sections to a BrainGlobe atlas object
Parameters
Expand Down Expand Up @@ -456,6 +452,22 @@ def wait_for_end_of_tasks(self):

# ---------------------- AUTOGENERATED CODE with the main method from ScijavaCommandToPython

def check_for_update(self):
"""
Check for updates
"""
ABBACheckForUpdateCommand = jimport('ch.epfl.biop.atlas.aligner.command.ABBACheckForUpdateCommand')
return self.ij.command().run(ABBACheckForUpdateCommand, True)

def cite_info(self):
"""
How to cite ABBA
"""
ABBACiteInfoCommand = jimport('ch.epfl.biop.atlas.aligner.command.ABBACiteInfoCommand')
return self.ij.command().run(ABBACiteInfoCommand, True)

def close(self):
"""
Close ABBA session
Expand All @@ -475,7 +487,7 @@ def documentation(self):

def forum_help(self):
"""
Open a new post in the image.sc forum with current installation information
Open a new post in the image.sc forum with current install information
"""
ABBAForumHelpCommand = jimport('ch.epfl.biop.atlas.aligner.command.ABBAForumHelpCommand')
Expand All @@ -500,7 +512,7 @@ def state_load(self,
ABBAStateLoadCommand = jimport('ch.epfl.biop.atlas.aligner.command.ABBAStateLoadCommand')
return self.ij.command().run(ABBAStateLoadCommand, True,
'mp', self.mp,
'state_file', state_file).get().getOutput('success')
'state_file', state_file).get()

def state_save(self,
state_file):
Expand All @@ -513,7 +525,7 @@ def state_save(self,
ABBAStateSaveCommand = jimport('ch.epfl.biop.atlas.aligner.command.ABBAStateSaveCommand')
return self.ij.command().run(ABBAStateSaveCommand, True,
'mp', self.mp,
'state_file', state_file).get().getOutput('success')
'state_file', state_file).get()

def user_feedback(self):
"""
Expand Down Expand Up @@ -558,8 +570,7 @@ def export_deformation_field_to_imagej(self,
max_number_of_iterations: int,
resolution_level: int):
"""
Exports physical coordinates of the atlas in a 3 channel (x,y,z) image that matches pixels of the initial
unregistered slice (for each selected slice). Resolution levels can be specified.
Exports physical coordinates of the atlas in a 3 channel (x,y,z) image that matches pixels of the initial unregistered slice (for each selected slice). Resolution levels can be specified.
Parameters:
downsampling (int): Extra DownSampling
Expand Down Expand Up @@ -605,8 +616,7 @@ def export_resampled_slices_to_bdv_source(self,
px_size_micron_z: float,
resolution_levels: int):
"""
Export registered (deformed) slices in the atlas coordinates. A pixel size should be specified to resample
the registered images.
Export registered (deformed) slices in the atlas coordinates. A pixel size should be specified to resample the registered images.
Parameters:
block_size_x (int): Block Size X
Expand Down Expand Up @@ -650,8 +660,7 @@ def export_slices_original_data_to_imagej(self,
resolution_level: int,
verbose: bool):
"""
Export to ImageJ the original unregistered slice data (for each selected slice).If the image has more than
2GPixels, this will fail. Resolution levels can be specified.
Export to ImageJ the original unregistered slice data (for each selected slice).If the image has more than 2GPixels, this will fail. Resolution levels can be specified.
Parameters:
channels (str): Slices channels, 0-based, comma separated, '*' for all channels
Expand Down Expand Up @@ -734,8 +743,7 @@ def export_transformed_atlas_to_imagej(self,
max_number_of_iterations: int,
resolution_level: int):
"""
Exports physical coordinates of the atlas in a 3 channel (x,y,z) image that matches pixels of the initial
unregistered slice (for each selected slice). Resolution levels can be specified.
Exports physical coordinates of the atlas in a 3 channel (x,y,z) image that matches pixels of the initial unregistered slice (for each selected slice). Resolution levels can be specified.
Parameters:
atlas_channels (str): Channels to export, '*' for all channels
Expand Down Expand Up @@ -869,8 +877,7 @@ def raster_slices(self,
def raster_slices_deformation(self,
grid_spacing_in_micrometer: float):
"""
Speed up the display of slices by precomputing and caching their deformation field (useful after spline
registrations only!).
Speed up the display of slices by precomputing and caching their deformation field (useful after spline registrations only!).
Parameters:
grid_spacing_in_micrometer (float): Deformation grid size (micrometer)
Expand All @@ -881,20 +888,20 @@ def raster_slices_deformation(self,
'grid_spacing_in_micrometer', grid_spacing_in_micrometer).get()

def register_slices_bigwarp(self,
channel_atlas: int,
channel_slice: int):
channels_atlas_csv: str,
channels_slice_csv: str):
"""
Uses BigWarp for in plane registration of selected slices
Parameters:
channel_atlas (int): Atlas channels
channel_slice (int): Slices channels
channels_atlas_csv (str): Atlas channels (channels comma separated)
channels_slice_csv (str): Slices channels (channels comma separated)
"""
RegisterSlicesBigWarpCommand = jimport('ch.epfl.biop.atlas.aligner.command.RegisterSlicesBigWarpCommand')
return self.ij.command().run(RegisterSlicesBigWarpCommand, True,
'mp', self.mp,
'channel_atlas', channel_atlas,
'channel_slice', channel_slice).get()
'channels_atlas_csv', channels_atlas_csv,
'channels_slice_csv', channels_slice_csv).get()

def register_slices_copy_and_apply(self,
model_slice_index: int,
Expand Down Expand Up @@ -1098,8 +1105,7 @@ def set_slices_thickness(self,

def set_slices_thickness_match_neighbors(self):
"""
Modifies the selected slices thickness in such a way that no space is left between slices. This is visible
only in the reconstructed volume in BigDataViewer
Modifies the selected slices thickness in such a way that no space is left between slices. This is visible only in the reconstructed volume in BigDataViewer
"""
SetSlicesThicknessMatchNeighborsCommand = jimport(
Expand Down

1 comment on commit e3e7ddb

@imagesc-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.