-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: uses custom FloatLineEdit for metadata dialogue
- Loading branch information
Showing
5 changed files
with
266 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import os | ||
|
||
from tqdm import tqdm | ||
|
||
import qtpy.compat | ||
|
||
from cellacdc import printl, myutils, apps, load, core | ||
from cellacdc._run import _setup_app | ||
from cellacdc.utils.base import NewThreadMultipleExpBaseUtil | ||
|
||
DEBUG = True | ||
|
||
def ask_select_folder(): | ||
selected_path = qtpy.compat.getexistingdirectory( | ||
caption='Select experiment folder to analyse', | ||
basedir=myutils.getMostRecentPath() | ||
) | ||
return selected_path | ||
|
||
def get_exp_path_pos_foldernames(selected_path): | ||
folder_type = myutils.determine_folder_type(selected_path) | ||
is_pos_folder, is_images_folder, exp_path = folder_type | ||
if is_pos_folder: | ||
exp_path = os.path.dirname(selected_path) | ||
pos_foldernames = myutils.get_pos_foldernames(exp_path) | ||
elif is_images_folder: | ||
pos_path = os.path.dirname(selected_path) | ||
exp_path = os.path.dirname(pos_path) | ||
pos_foldernames = [os.path.basename(pos_path)] | ||
else: | ||
exp_path = selected_path | ||
pos_foldernames = myutils.get_pos_foldernames(exp_path) | ||
|
||
return exp_path, pos_foldernames | ||
|
||
def select_segm_masks(exp_path, pos_foldernames): | ||
infoText = 'Select which segmentation file <b>OF THE CELLS</b>:' | ||
existingEndNames = load.get_segm_endnames_from_exp_path( | ||
exp_path, pos_foldernames=pos_foldernames | ||
) | ||
win = apps.SelectSegmFileDialog( | ||
existingEndNames, exp_path, | ||
infoText=infoText, | ||
fileType='segmentation' | ||
) | ||
win.exec_() | ||
if win.cancel: | ||
return | ||
|
||
cells_segm_endname = win.selectedItemText | ||
|
||
infoText = 'Select segmentation files <b>to SPLIT</b>:' | ||
existingEndNames.discard(cells_segm_endname) | ||
win = apps.SelectSegmFileDialog( | ||
existingEndNames, exp_path, | ||
infoText=infoText, | ||
fileType='segmentation', | ||
allowMultipleSelection=True | ||
) | ||
win.exec_() | ||
if win.cancel: | ||
return | ||
|
||
list_segm_endnames_to_split = win.selectedItemTexts | ||
return cells_segm_endname, list_segm_endnames_to_split | ||
|
||
def run(): | ||
app, splashScreen = _setup_app(splashscreen=True) | ||
splashScreen.close() | ||
|
||
selected_path = ask_select_folder() | ||
if not selected_path: | ||
exit('Execution cancelled') | ||
|
||
myutils.addToRecentPaths(selected_path) | ||
exp_path, pos_foldernames = get_exp_path_pos_foldernames(selected_path) | ||
|
||
selected_segm_endnames = select_segm_masks(exp_path, pos_foldernames) | ||
if selected_segm_endnames is None: | ||
exit('Execution cancelled') | ||
|
||
cells_segm_endname, list_segm_endnames_to_split = selected_segm_endnames | ||
acdc_df_endname = cells_segm_endname.replace('segm', 'acdc_output') | ||
pbar = tqdm(total=len(pos_foldernames), ncols=100) | ||
for pos in pos_foldernames: | ||
images_path = os.path.join(exp_path, pos, 'Images') | ||
cells_segm_data = load.load_segm_file( | ||
images_path, end_name_segm_file=cells_segm_endname | ||
) | ||
acdc_df = load.load_acdc_df_file( | ||
images_path, end_name_acdc_df_file=acdc_df_endname | ||
) | ||
for segm_endname in list_segm_endnames_to_split: | ||
segm_data_to_split = load.load_segm_file( | ||
images_path, end_name_segm_file=segm_endname | ||
) | ||
core.split_segm_masks_mother_bud_line( | ||
cells_segm_data, segm_data_to_split, acdc_df, | ||
debug=DEBUG | ||
) | ||
pbar.update() | ||
|
||
pbar.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |