Skip to content

Commit f9b999a

Browse files
committed
Fix tooltips.
1 parent e44a004 commit f9b999a

File tree

3 files changed

+62
-15
lines changed

3 files changed

+62
-15
lines changed

datashuttle/configs/canonical_configs.py

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def quick_get_narrow_datatypes():
351351
return flat_narrow_datatypes
352352

353353

354-
def in_place_update_settings_for_narrow_datatype(settings: dict):
354+
def in_place_update_narrow_datatypes_if_required(user_settings: dict):
355355
"""
356356
In versions < v0.6.0, only 'broad' datatypes were implemented
357357
and available in the TUI. Since, 'narrow' datatypes are introduced
@@ -360,8 +360,39 @@ def in_place_update_settings_for_narrow_datatype(settings: dict):
360360
361361
This function converts the old format to the new format so that
362362
all broad datatype settings (on / off) are maintained in
363-
then new version.
363+
then new version. It does this by copying the full default
364+
parameters and overwriting them with the available user-set
365+
defaults. This is the best approach, as it maintains the
366+
order of the datatypes (otherwise, inserting non-existing
367+
datatypes into the user datatype dict results in the wrong order).
368+
364369
"""
370+
has_narrow_datatypes = isinstance(
371+
user_settings["tui"]["create_checkboxes_on"]["behav"], dict
372+
) # added 'narrow datatype' v0.6.0 with major refactor to dict
373+
374+
all_narrow_datatypes = quick_get_narrow_datatypes()
375+
376+
is_not_missing_narrow_datatypes = all(
377+
[
378+
dtype in all_narrow_datatypes
379+
for dtype in user_settings["tui"]["create_checkboxes_on"]
380+
]
381+
)
382+
383+
if is_not_missing_narrow_datatypes:
384+
assert all(
385+
[
386+
dtype in all_narrow_datatypes
387+
for dtype in user_settings["tui"]["transfer_checkboxes_on"]
388+
]
389+
)
390+
391+
if has_narrow_datatypes and is_not_missing_narrow_datatypes:
392+
return
393+
394+
# Copy TUI defaults that include narrow-datatype defaults
395+
365396
canonical_tui_configs = get_tui_config_defaults()
366397

367398
new_create_checkbox_configs = copy.deepcopy(
@@ -371,18 +402,35 @@ def in_place_update_settings_for_narrow_datatype(settings: dict):
371402
canonical_tui_configs["tui"]["transfer_checkboxes_on"]
372403
)
373404

405+
# Copy the pre-existing settings for broad datatypes
374406
for key in ["behav", "ephys", "funcimg", "anat"]:
375-
new_create_checkbox_configs[key]["on"] = settings["tui"][
407+
new_create_checkbox_configs[key]["on"] = user_settings["tui"][
376408
"create_checkboxes_on"
377409
][key]
378-
new_transfer_checkbox_configs[key]["on"] = settings["tui"][
410+
new_transfer_checkbox_configs[key]["on"] = user_settings["tui"][
379411
"transfer_checkboxes_on"
380412
][key]
381413

414+
# Copy the pre-existing settings for the transfer checkboxes
382415
for key in ["all", "all_datatype", "all_non_datatype"]:
383-
new_transfer_checkbox_configs[key]["on"] = settings["tui"][
416+
new_transfer_checkbox_configs[key]["on"] = user_settings["tui"][
384417
"transfer_checkboxes_on"
385418
][key]
386419

387-
settings["tui"]["create_checkboxes_on"] = new_create_checkbox_configs
388-
settings["tui"]["transfer_checkboxes_on"] = new_transfer_checkbox_configs
420+
for narrow_datatype in all_narrow_datatypes:
421+
if (
422+
narrow_datatype
423+
not in user_settings["tui"]["create_checkboxes_on"].keys()
424+
):
425+
user_settings["tui"][
426+
"create_checkboxes_on"
427+
] = new_create_checkbox_configs
428+
429+
for narrow_datatype in all_narrow_datatypes:
430+
if (
431+
narrow_datatype
432+
not in user_settings["tui"]["transfer_checkboxes_on"].keys()
433+
):
434+
user_settings["tui"][
435+
"transfer_checkboxes_on"
436+
] = new_transfer_checkbox_configs

datashuttle/datashuttle_class.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,13 +1551,10 @@ def _update_settings_with_new_canonical_keys(self, settings: Dict):
15511551
if key not in settings["tui"]:
15521552
settings["tui"][key] = canonical_tui_configs["tui"][key]
15531553

1554-
# Handle conversion to 'narrow datatype' v0.6.0
1555-
if not isinstance(
1556-
settings["tui"]["create_checkboxes_on"]["behav"], dict
1557-
):
1558-
canonical_configs.in_place_update_settings_for_narrow_datatype(
1559-
settings
1560-
)
1554+
# Handle updating with narrow datatypes
1555+
canonical_configs.in_place_update_narrow_datatypes_if_required(
1556+
settings
1557+
)
15611558

15621559
def _check_top_level_folder(self, top_level_folder):
15631560
"""

datashuttle/tui/screens/datatypes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
"behav": "behaviour",
3434
"funcimg": "functional imaging",
3535
"anat": "anatomy",
36+
"motion": "motion tracking",
3637
"ecephys": "extracellular electrophysiology",
3738
"icephys": "intracellular electrophysiology",
39+
"emg": "electromyography",
3840
"cscope": "head-mounted widefield macroscope",
3941
"f2pe": "functional 2-photon excitation imaging",
4042
"fmri": "functional magnetic resonance imaging",
41-
"fusi": "functional ultra-sound imaging",
43+
"fusi": "functional ultrasound imaging",
4244
"2pe": "2-photon excitation microscopy",
4345
"bf": "bright-field microscopy",
4446
"cars": "coherent anti-Stokes Raman spectroscopy",

0 commit comments

Comments
 (0)