diff --git a/.maint/update_authors.py b/.maint/update_authors.py index 3b8658e1..15266b71 100755 --- a/.maint/update_authors.py +++ b/.maint/update_authors.py @@ -188,7 +188,7 @@ def zenodo( misses = set(miss_creators).intersection(miss_contributors) if misses: print( - "Some people made commits, but are missing in .maint/ " f"files: {', '.join(misses)}", + f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}", file=sys.stderr, ) @@ -268,7 +268,7 @@ def _aslist(value): if misses: print( - "Some people made commits, but are missing in .maint/ " f"files: {', '.join(misses)}", + f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}", file=sys.stderr, ) diff --git a/nireports/assembler/misc.py b/nireports/assembler/misc.py index 6677fb35..6688d654 100644 --- a/nireports/assembler/misc.py +++ b/nireports/assembler/misc.py @@ -144,7 +144,7 @@ def dict2html(indict, table_id): if not rows: return None - width = max([len(row) for row in rows]) + width = max(len(row) for row in rows) result_str = '\n' % table_id td = "{0}".format diff --git a/nireports/assembler/report.py b/nireports/assembler/report.py index 65aa6fb8..774c2db4 100644 --- a/nireports/assembler/report.py +++ b/nireports/assembler/report.py @@ -255,15 +255,11 @@ def __init__( if bids_filters.get("subject"): subject_id = bids_filters["subject"] - bids_filters["subject"] = ( - subject_id[4:] if subject_id.startswith("sub-") else subject_id - ) + bids_filters["subject"] = subject_id.removeprefix("sub-") if bids_filters.get("session"): session_id = bids_filters["session"] - bids_filters["session"] = ( - session_id[4:] if session_id.startswith("ses-") else session_id - ) + bids_filters["session"] = session_id.removeprefix("ses-") if bids_filters and out_filename == "report.html": out_filename = build_path(bids_filters, OUTPUT_NAME_PATTERN) @@ -493,9 +489,9 @@ def _process_orderings(orderings, hits): tuple(bids_file.get_entities().get(k, None) for k in orderings) for bids_file in hits } # remove the all None member if it exists - none_member = tuple([None for k in orderings]) + none_member = (None,) * len(orderings) if none_member in all_value_combos: - all_value_combos.remove(tuple([None for k in orderings])) + all_value_combos.remove(none_member) # see what values exist for each entity unique_values = [ {value[idx] for value in all_value_combos} for idx in range(len(orderings)) diff --git a/nireports/interfaces/__init__.py b/nireports/interfaces/__init__.py index 7445a1ac..5b637635 100644 --- a/nireports/interfaces/__init__.py +++ b/nireports/interfaces/__init__.py @@ -33,9 +33,9 @@ __all__ = ( "CompCorVariancePlot", "ConfoundsCorrelationPlot", - "RaincloudPlot", "FMRISummary", "PlotContours", "PlotMosaic", "PlotSpikes", + "RaincloudPlot", ) diff --git a/nireports/interfaces/nuisance.py b/nireports/interfaces/nuisance.py index bbb032b1..47f27a46 100644 --- a/nireports/interfaces/nuisance.py +++ b/nireports/interfaces/nuisance.py @@ -109,7 +109,7 @@ class _ConfoundsCorrelationPlotInputSpec(BaseInterfaceInputSpec): ignore_initial_volumes = traits.Int( 0, usedefault=True, - desc="Number of non-steady-state volumes at the beginning of the scan " "to ignore.", + desc="Number of non-steady-state volumes at the beginning of the scan to ignore.", ) diff --git a/nireports/interfaces/reporting/masks.py b/nireports/interfaces/reporting/masks.py index 4dba645c..9d9343b7 100644 --- a/nireports/interfaces/reporting/masks.py +++ b/nireports/interfaces/reporting/masks.py @@ -59,7 +59,7 @@ def _run_interface(self, runtime): if self.generate_report: self.inputs.mask = True - return super(BETRPT, self)._run_interface(runtime) + return super()._run_interface(runtime) def _post_run_hook(self, runtime): """generates a report showing slices from each axis of an arbitrary @@ -76,7 +76,7 @@ def _post_run_hook(self, runtime): self._mask_file, ) - return super(BETRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _BrainExtractionInputSpecRPT( @@ -114,7 +114,7 @@ def _post_run_hook(self, runtime): self._mask_file, ) - return super(BrainExtractionRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _ACompCorInputSpecRPT(nrb._SVGReportCapableInputSpec, confounds.CompCorInputSpec): @@ -148,7 +148,7 @@ def _post_run_hook(self, runtime): self._mask_file, ) - return super(ACompCorRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _TCompCorInputSpecRPT(nrb._SVGReportCapableInputSpec, confounds.TCompCorInputSpec): @@ -184,7 +184,7 @@ def _post_run_hook(self, runtime): self.aggregate_outputs(runtime=runtime).high_variance_masks, ) - return super(TCompCorRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _SimpleShowMaskInputSpec(nrb._SVGReportCapableInputSpec): @@ -201,7 +201,7 @@ def _post_run_hook(self, runtime): self._seg_files = [self.inputs.mask_file] self._masked = True - return super(SimpleShowMaskRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _ROIsPlotInputSpecRPT(nrb._SVGReportCapableInputSpec): diff --git a/nireports/interfaces/reporting/registration.py b/nireports/interfaces/reporting/registration.py index 4b817db2..2d0fe983 100644 --- a/nireports/interfaces/reporting/registration.py +++ b/nireports/interfaces/reporting/registration.py @@ -67,7 +67,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - return super(ApplyTOPUPRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _FUGUEInputSpecRPT(nrb._SVGReportCapableInputSpec, fsl.preprocess.FUGUEInputSpec): @@ -94,7 +94,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - return super(FUGUERPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _FLIRTInputSpecRPT(nrb._SVGReportCapableInputSpec, fsl.preprocess.FLIRTInputSpec): @@ -119,7 +119,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - return super(FLIRTRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _ApplyXFMInputSpecRPT(nrb._SVGReportCapableInputSpec, fsl.preprocess.ApplyXFMInputSpec): @@ -183,7 +183,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - return super(BBRegisterRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _MRICoregInputSpecRPT(nrb._SVGReportCapableInputSpec, fs.registration.MRICoregInputSpec): @@ -230,7 +230,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - return super(MRICoregRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _SimpleBeforeAfterInputSpecRPT(nrb._SVGReportCapableInputSpec): @@ -259,7 +259,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - return super(SimpleBeforeAfterRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _ResampleBeforeAfterInputSpecRPT(_SimpleBeforeAfterInputSpecRPT): @@ -291,7 +291,7 @@ def _post_run_hook(self, runtime): self._moving_image, ) - runtime = super(ResampleBeforeAfterRPT, self)._post_run_hook(runtime) + runtime = super()._post_run_hook(runtime) _LOGGER.info("Successfully created report (%s)", self._out_report) os.unlink(fname) diff --git a/nireports/interfaces/reporting/segmentation.py b/nireports/interfaces/reporting/segmentation.py index d1213322..fe0365cc 100644 --- a/nireports/interfaces/reporting/segmentation.py +++ b/nireports/interfaces/reporting/segmentation.py @@ -50,7 +50,7 @@ def _run_interface(self, runtime): if self.generate_report: self.inputs.segments = True - return super(FASTRPT, self)._run_interface(runtime) + return super()._run_interface(runtime) def _post_run_hook(self, runtime): """generates a report showing nine slices, three per axis, of an @@ -72,7 +72,7 @@ def _post_run_hook(self, runtime): outputs.tissue_class_files, ) - return super(FASTRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _ReconAllInputSpecRPT( @@ -104,14 +104,14 @@ def _post_run_hook(self, runtime): _LOGGER.info("Generating report for ReconAll (subject %s)", outputs.subject_id) - return super(ReconAllRPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) class _MELODICInputSpecRPT(nrb._SVGReportCapableInputSpec, fsl.model.MELODICInputSpec): out_report = File( "melodic_reportlet.svg", usedefault=True, - desc="Filename for the visual" " report generated " "by Nipype.", + desc="Filename for the visual report generated by Nipype.", ) report_mask = File( desc="Mask used to draw the outline on the reportlet. " @@ -129,12 +129,12 @@ class MELODICRPT(fsl.MELODIC): _out_report = None def __init__(self, generate_report=False, **kwargs): - super(MELODICRPT, self).__init__(**kwargs) + super().__init__(**kwargs) self.generate_report = generate_report def _post_run_hook(self, runtime): # Run _post_run_hook of super class - runtime = super(MELODICRPT, self)._post_run_hook(runtime) + runtime = super()._post_run_hook(runtime) # leave early if there's nothing to do if not self.generate_report: return runtime @@ -163,7 +163,7 @@ def _post_run_hook(self, runtime): def _list_outputs(self): try: - outputs = super(MELODICRPT, self)._list_outputs() + outputs = super()._list_outputs() except NotImplementedError: outputs = {} if self._out_report is not None: @@ -187,7 +187,7 @@ class _ICA_AROMAInputSpecRPT(nrb._SVGReportCapableInputSpec, fsl.aroma.ICA_AROMA out_report = File( "ica_aroma_reportlet.svg", usedefault=True, - desc="Filename for the visual" " report generated " "by Nipype.", + desc="Filename for the visual report generated by Nipype.", ) report_mask = File( desc="Mask used to draw the outline on the reportlet. " @@ -221,4 +221,4 @@ def _post_run_hook(self, runtime): _LOGGER.info("Generating report for ICA AROMA") - return super(ICA_AROMARPT, self)._post_run_hook(runtime) + return super()._post_run_hook(runtime) diff --git a/nireports/reportlets/modality/func.py b/nireports/reportlets/modality/func.py index 385d9039..558b56f8 100644 --- a/nireports/reportlets/modality/func.py +++ b/nireports/reportlets/modality/func.py @@ -36,14 +36,14 @@ class fMRIPlot: """Generates the fMRI Summary Plot.""" __slots__ = ( - "timeseries", - "segments", - "tr", "confounds", - "spikes", "nskip", - "sort_carpet", "paired_carpet", + "segments", + "sort_carpet", + "spikes", + "timeseries", + "tr", ) def __init__( diff --git a/nireports/reportlets/xca.py b/nireports/reportlets/xca.py index 6826f0cb..823b37bf 100644 --- a/nireports/reportlets/xca.py +++ b/nireports/reportlets/xca.py @@ -105,9 +105,7 @@ def plot_melodic_components( else: mask_img = nb.load(report_mask) - mask_sl = [] - for j in range(3): - mask_sl.append(transform_to_2d(mask_img.get_fdata(), j)) + mask_sl = [transform_to_2d(mask_img.get_fdata(), j) for j in range(3)] timeseries = np.loadtxt(os.path.join(melodic_dir, "melodic_mix")) power = np.loadtxt(os.path.join(melodic_dir, "melodic_FTmix")) diff --git a/nireports/tools/timeseries.py b/nireports/tools/timeseries.py index cd2d6060..0a5bf468 100644 --- a/nireports/tools/timeseries.py +++ b/nireports/tools/timeseries.py @@ -73,7 +73,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