Skip to content

Commit

Permalink
Merge pull request #593 from Teranis/main
Browse files Browse the repository at this point in the history
feat: adds utility and GUI function to combine multiple channels with math operations
  • Loading branch information
ElpadoCan authored Feb 14, 2025
2 parents d5fea13 + dcb2ace commit ff966d1
Show file tree
Hide file tree
Showing 16 changed files with 2,121 additions and 122 deletions.
52 changes: 45 additions & 7 deletions cellacdc/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from .utils import createConnected3Dsegm as utilsConnected3Dsegm
from .utils import fucciPreprocess as utilsFucciPreprocess
from .utils import customPreprocess as utilsCustomPreprocess
from .utils import combineChannels as utilsCombineChannels
from .utils import filterObjFromCoordsTable as utilsFilterObjsFromTable
from .utils import stack2Dinto3Dsegm as utilsStack2Dto3D
from .utils import computeMultiChannel as utilsComputeMultiCh
Expand Down Expand Up @@ -434,6 +435,7 @@ def createMenuBar(self):
dataPrepMenu.addAction(self.resizeImagesAction)
dataPrepMenu.addAction(self.fucciPreprocessAction)
dataPrepMenu.addAction(self.customPreprocessAction)
dataPrepMenu.addAction(self.combineChannelsAction)

utilsMenu.addAction(self.renameAction)

Expand Down Expand Up @@ -733,6 +735,10 @@ def createActions(self):
self.customPreprocessAction = QAction(
'Setup and run custom image preprocessing...'
)

self.combineChannelsAction = QAction(
'Combine channels...'
)

self.createConnected3Dsegm = QAction(
'Create connected 3D segmentation mask from z-slices segmentation...'
Expand Down Expand Up @@ -831,6 +837,10 @@ def connectActions(self):
self.customPreprocessAction.triggered.connect(
self.launchCustomPreprocessUtil
)

self.combineChannelsAction.triggered.connect(
self.launchCombineChannelsUtil
)

self.createConnected3Dsegm.triggered.connect(
self.launchConnected3DsegmActionUtil
Expand Down Expand Up @@ -988,18 +998,21 @@ def getSelectedPosPath(self, utilityName):

return posPath

def getSelectedExpPaths(self, utilityName, exp_folderpath=None):
def getSelectedExpPaths(self, utilityName, exp_folderpath=None, custom_txt=None):
# self._debug()

if exp_folderpath is None:
self.logger.info('Asking to select experiment folders...')
msg = widgets.myMessageBox()
txt = html_utils.paragraph("""
After you click "Ok" on this dialog you will be asked
to <b>select the experiment folders</b>, one by one.<br><br>
Next, you will be able to <b>choose specific Positions</b>
from each selected experiment.
""")
if custom_txt:
txt = html_utils.paragraph(custom_txt)
else:
txt = html_utils.paragraph("""
After you click "Ok" on this dialog you will be asked
to <b>select the experiment folders</b>, one by one.<br><br>
Next, you will be able to <b>choose specific Positions</b>
from each selected experiment.
""")
msg.information(
self, f'{utilityName}', txt,
buttonsTexts=('Cancel', 'Ok')
Expand Down Expand Up @@ -1397,6 +1410,31 @@ def launchCustomPreprocessUtil(self):
parent=self
)
self.customPreprocessWin.show()

def launchCombineChannelsUtil(self):
self.logger.info(f'Launching utility "{self.sender().text()}"')
custom_txt = """
After you click "Ok" on this dialog you will be asked
to <b>select the experiment folders</b>, one by one.<br><br>
If you select multiple, later you will only be able to choose
channels which are <b>present in all</b> positions you slected, and the
recepies will be applied to all of them.
"""
selectedExpPaths = self.getSelectedExpPaths(
'Combine Channels',
custom_txt=custom_txt
)
if selectedExpPaths is None:
return

title = 'Combine Channels'
infoText = 'Launching combine channels utility...'
progressDialogueTitle = 'Combine Channels'
self.CombineChannelsWin = utilsCombineChannels.CombineChannelsUtil(
selectedExpPaths, self.app, title, infoText, progressDialogueTitle,
parent=self
)
self.CombineChannelsWin.show()

def launchConnected3DsegmActionUtil(self):
self.logger.info(f'Launching utility "{self.sender().text()}"')
Expand Down
Loading

0 comments on commit ff966d1

Please sign in to comment.