Skip to content

Commit

Permalink
Merge pull request #63 from medusabci/developers
Browse files Browse the repository at this point in the history
Developers
  • Loading branch information
esantamariavazquez authored Jun 26, 2024
2 parents 1392948 + 555a385 commit 310718d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ joblib==1.3.2
kiwisolver==1.4.5
MarkupSafe==2.1.3
matplotlib==3.8.2
medusa-kernel>=1.3.0<1.4.0
medusa-kernel>=1.3.0,<1.4.0
numpy==1.26.2
packaging==23.2
pandas==2.1.3
Expand Down
32 changes: 17 additions & 15 deletions src/gui/studies_panel/studies_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,22 @@ def open_studies_config_dialog(self, checked=None):

@exceptions.error_handler(scope='studies')
def custom_sort_key(self, element_path):
"""This function provides custom short keys for the tree model. For
instance, it will sort ['S1', 'S10', 'S2', 'S100', 'AB200', 'A1'] as
['A1', 'S1', 'S2', 'S10', 'S100', 'AB200']
"""
"""This function provides custom keys to sort the elements of the tree
model. For instance, it will sort ['S1', 'S10', 'S2', 'S100',
'AB200', 'A1'] as ['A1', 'S1', 'S2', 'S10', 'S100', 'AB200']
"""
# Split the section into alphabetical and numerical parts
element_path = os.path.basename(os.path.normpath(element_path))
re_match = re.match(r'([A-Za-z]+)(\d*)', element_path)
if re_match is not None:
alpha_part, num_part = re_match.groups()
else:
alpha_part, num_part = element_path, 0
# Convert the numerical part to an integer (treat empty string as 0)
num_value = int(num_part) if num_part else 0
return alpha_part, num_value
path_split = re.findall(r'[A-Za-z]+|\d+', element_path)
path_split = [int(s) if str.isdigit(s) else s for s in path_split]
return path_split

def sort_improved(self, array):
"""More logical sort function for the tree models of the panel """
try:
array.sort(key=self.custom_sort_key)
except:
array.sort()

@exceptions.error_handler(scope='studies')
def update_studies_panel(self, checked=None):
Expand Down Expand Up @@ -181,17 +183,17 @@ def update_studies_panel(self, checked=None):
self.studies_panel_config['root_path']), self.theme_colors)
studies = glob.glob(
'%s/*/' % self.studies_panel_config['root_path'])
studies.sort(key=self.custom_sort_key)
self.sort_improved(studies)
# Append studies
for study in studies:
subjects = glob.glob('%s/*/' % study)
subjects.sort(key=self.custom_sort_key)
self.sort_improved(subjects)
study_item = StudyItem(os.path.basename(study[0:-1]),
self.theme_colors)
# Append subjects
for subject in subjects:
sessions = glob.glob('%s/*/' % subject)
sessions.sort(key=self.custom_sort_key)
self.sort_improved(sessions)
subject_item = SubjectItem(
os.path.basename(subject[0:-1]), self.theme_colors)
for session in sessions:
Expand Down
1 change: 0 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
application = QApplication(sys.argv)
main_window = GuiMainClass()
sys.exit(application.exec())

0 comments on commit 310718d

Please sign in to comment.