diff --git a/niworkflows/interfaces/bids.py b/niworkflows/interfaces/bids.py index ec7131dff3a..3eefaa76c2e 100644 --- a/niworkflows/interfaces/bids.py +++ b/niworkflows/interfaces/bids.py @@ -216,9 +216,7 @@ def _run_interface(self, runtime): except ValueError: pass params = parse_file_entities(in_file) - self._results = { - key: params.get(key, Undefined) for key in _BIDSInfoOutputSpec().get().keys() - } + self._results = {key: params.get(key, Undefined) for key in _BIDSInfoOutputSpec().get()} return runtime diff --git a/niworkflows/interfaces/surf.py b/niworkflows/interfaces/surf.py index 2a1fd76da21..ed01426f1bb 100644 --- a/niworkflows/interfaces/surf.py +++ b/niworkflows/interfaces/surf.py @@ -182,7 +182,7 @@ def _outputs(self): trait_change_notify=False, **{ entity: Undefined - for entity in self._pattern.groupindex.keys() + for entity in self._pattern.groupindex if entity not in self._excluded }, ) diff --git a/niworkflows/reports/core.py b/niworkflows/reports/core.py index d954fa34c97..353d77cb9ca 100644 --- a/niworkflows/reports/core.py +++ b/niworkflows/reports/core.py @@ -463,8 +463,7 @@ def _process_orderings(orderings, layout): ] # if all values are None for an entity, we do not want to keep that entity keep_idx = [ - False if (len(val_set) == 1 and None in val_set) or not val_set else True - for val_set in unique_values + not (len(val_set) == 1 and None in val_set or not val_set) for val_set in unique_values ] # the "kept" entities entities = list(compress(orderings, keep_idx)) diff --git a/niworkflows/utils/spaces.py b/niworkflows/utils/spaces.py index eb82851bd7c..e44dab9b26f 100644 --- a/niworkflows/utils/spaces.py +++ b/niworkflows/utils/spaces.py @@ -521,10 +521,7 @@ def __contains__(self, item): if not self.references: return False item = self.check_space(item) - for s in self.references: - if s == item: - return True - return False + return any(s == item for s in self.references) def __str__(self): """ @@ -730,10 +727,7 @@ def __call__(self, parser, namespace, values, option_string=None): def hasspec(value, specs): """Check whether any of the keys are in a dict.""" - for s in specs: - if s in value: - return True - return False + return any(s in value for s in specs) def format_reference(in_tuple): diff --git a/niworkflows/utils/timeseries.py b/niworkflows/utils/timeseries.py index d66b11cd726..3ac00b22350 100644 --- a/niworkflows/utils/timeseries.py +++ b/niworkflows/utils/timeseries.py @@ -42,7 +42,7 @@ def _cifti_timeseries(dataset): } seg = {label: [] for label in list(labels.values()) + ['Other']} for bm in matrix.get_index_map(1).brain_models: - label = 'Other' if bm.brain_structure not in labels else labels[bm.brain_structure] + label = labels.get(bm.brain_structure, 'Other') seg[label] += list(range(bm.index_offset, bm.index_offset + bm.index_count)) return dataset.get_fdata(dtype='float32').T, seg