Skip to content

Commit 2a7bc9b

Browse files
committed
Add check for empty groups in set_regularisation()
1 parent 37feb2b commit 2a7bc9b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

commit/core.pyx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,19 @@ cdef class Evaluation :
11191119
if np.any(all_idx_in != all_idx):
11201120
logger.error('Group indices must contain all the indices of the input streamlines')
11211121

1122+
# check if in the provided group indices there is at least one empty group and remove it
1123+
if regularisation['regIC'] == 'group_lasso' or regularisation['regIC'] == 'sparse_group_lasso':
1124+
count_empty_groups = 0
1125+
list_non_empty_groups = []
1126+
for g in dictIC_params['group_idx']:
1127+
if g.size == 0:
1128+
count_empty_groups += 1
1129+
else:
1130+
list_non_empty_groups.append(g)
1131+
if count_empty_groups > 0:
1132+
logger.warning('At least one of the provided groups is empty; removing it from the group structure')
1133+
dictIC_params['group_idx'] = np.array(list_non_empty_groups, dtype=np.object_)
1134+
11221135
# check if group_weights_extra is consistent with the number of groups
11231136
if (regularisation['regIC'] == 'group_lasso' or regularisation['regIC'] == 'sparse_group_lasso') and 'group_weights_extra' in dictIC_params:
11241137
if type(dictIC_params['group_weights_extra']) not in [list, np.ndarray]:

0 commit comments

Comments
 (0)