-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: revise shebangs/attribution, add dependencies
- Loading branch information
Showing
5 changed files
with
35 additions
and
151 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
# | ||
# Copyright 2021 The NiPreps Developers <[email protected]> | ||
# Copyright 2023 The NiPreps Developers <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -20,12 +20,15 @@ | |
# | ||
# https://www.nipreps.org/community/licensing/ | ||
# | ||
# STATEMENT OF CHANGES: This file was ported carrying over full git history from MRIQC, | ||
# another NiPreps project licensed under the Apache-2.0 terms, and has been changed since. | ||
# The original file this work derives from is found at: | ||
# https://github.com/nipreps/mriqc/blob/1ffd4c8d1a20b44ebfea648a7b12bb32a425d4ec/ | ||
# mriqc/interfaces/viz.py | ||
"""Visualization interfaces.""" | ||
from io import open # pylint: disable=W0622 | ||
from pathlib import Path | ||
|
||
import numpy as np | ||
from mriqc.viz.utils import plot_mosaic, plot_segmentation, plot_spikes | ||
from nipype.interfaces.base import ( | ||
BaseInterfaceInputSpec, | ||
File, | ||
|
@@ -35,16 +38,14 @@ | |
traits, | ||
) | ||
|
||
from nireports.reportlets.mriqc.utils import plot_mosaic, plot_segmentation, plot_spikes | ||
|
||
|
||
class PlotContoursInputSpec(BaseInterfaceInputSpec): | ||
in_file = File(exists=True, mandatory=True, desc="File to be plotted") | ||
in_contours = File( | ||
exists=True, mandatory=True, desc="file to pick the contours from" | ||
) | ||
in_contours = File(exists=True, mandatory=True, desc="file to pick the contours from") | ||
cut_coords = traits.Int(8, usedefault=True, desc="number of slices") | ||
levels = traits.List( | ||
[0.5], traits.Float, usedefault=True, desc="add a contour per level" | ||
) | ||
levels = traits.List([0.5], traits.Float, usedefault=True, desc="add a contour per level") | ||
colors = traits.List( | ||
["r"], | ||
traits.Str, | ||
|
@@ -159,9 +160,7 @@ def _run_interface(self, runtime): | |
cmap=self.inputs.cmap, | ||
annotate=self.inputs.annotate, | ||
) | ||
self._results["out_file"] = str( | ||
(Path(runtime.cwd) / self.inputs.out_file).resolve() | ||
) | ||
self._results["out_file"] = str((Path(runtime.cwd) / self.inputs.out_file).resolve()) | ||
return runtime | ||
|
||
|
||
|
@@ -175,9 +174,7 @@ class PlotSpikesOutputSpec(TraitedSpec): | |
|
||
|
||
class PlotSpikes(SimpleInterface): | ||
""" | ||
Plot slices of a dataset with spikes | ||
""" | ||
"""Plot slices of a dataset with spikes.""" | ||
|
||
input_spec = PlotSpikesInputSpec | ||
output_spec = PlotSpikesOutputSpec | ||
|
@@ -189,8 +186,7 @@ def _run_interface(self, runtime): | |
spikes_list = np.loadtxt(self.inputs.in_spikes, dtype=int).tolist() | ||
# No spikes | ||
if not spikes_list: | ||
with open(out_file, "w") as f: | ||
f.write("<p>No high-frequency spikes were found in this dataset</p>") | ||
Path(out_file).write_text("<p>No high-frequency spikes were found in this dataset</p>") | ||
return runtime | ||
|
||
spikes_list = [tuple(i) for i in np.atleast_2d(spikes_list).tolist()] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
# | ||
# Copyright 2021 The NiPreps Developers <[email protected]> | ||
# Copyright 2023 The NiPreps Developers <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -20,6 +20,11 @@ | |
# | ||
# https://www.nipreps.org/community/licensing/ | ||
# | ||
# STATEMENT OF CHANGES: This file was ported carrying over full git history from MRIQC, | ||
# another NiPreps project licensed under the Apache-2.0 terms, and has been changed since. | ||
# The original file this work derives from is found at: | ||
# https://github.com/nipreps/mriqc/blob/1ffd4c8d1a20b44ebfea648a7b12bb32a425d4ec/ | ||
# mriqc/viz/svg.py | ||
"""SVG handling utilities.""" | ||
|
||
|
||
|
@@ -59,9 +64,7 @@ def combine_svg(svg_list, axis="vertical"): | |
for i, els in enumerate(sizes): | ||
scales[i] = ref_size[0] / els[0] | ||
|
||
newsizes = [ | ||
tuple(size) for size in np.array(sizes) * np.array(scales)[..., np.newaxis] | ||
] | ||
newsizes = [tuple(size) for size in np.array(sizes) * np.array(scales)[..., np.newaxis]] | ||
totalsize = [newsizes[0][0], np.sum(newsizes, axis=0)[1]] | ||
|
||
elif axis == "horizontal": | ||
|
@@ -72,9 +75,7 @@ def combine_svg(svg_list, axis="vertical"): | |
for i, els in enumerate(sizes): | ||
scales[i] = ref_size[1] / els[1] | ||
|
||
newsizes = [ | ||
tuple(size) for size in np.array(sizes) * np.array(scales)[..., np.newaxis] | ||
] | ||
newsizes = [tuple(size) for size in np.array(sizes) * np.array(scales)[..., np.newaxis]] | ||
totalsize = [np.sum(newsizes, axis=0)[0], newsizes[0][1]] | ||
|
||
# Compose the views panel: total size is the width of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- | ||
# vi: set ft=python sts=4 ts=4 sw=4 et: | ||
# | ||
# Copyright 2021 The NiPreps Developers <[email protected]> | ||
# Copyright 2023 The NiPreps Developers <[email protected]> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
|
@@ -20,6 +20,11 @@ | |
# | ||
# https://www.nipreps.org/community/licensing/ | ||
# | ||
# STATEMENT OF CHANGES: This file was ported carrying over full git history from MRIQC, | ||
# another NiPreps project licensed under the Apache-2.0 terms, and has been changed since. | ||
# The original file this work derives from is found at: | ||
# https://github.com/nipreps/mriqc/blob/1ffd4c8d1a20b44ebfea648a7b12bb32a425d4ec/ | ||
# mriqc/viz/utils.py | ||
"""Visualization utilities.""" | ||
import math | ||
import os.path as op | ||
|
@@ -396,9 +401,7 @@ def plot_mosaic( | |
) | ||
naxis += 1 | ||
|
||
fig.subplots_adjust( | ||
left=0.05, right=0.95, bottom=0.05, top=0.95, wspace=0.05, hspace=0.05 | ||
) | ||
fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95, wspace=0.05, hspace=0.05) | ||
|
||
if title: | ||
fig.suptitle(title, fontsize="10") | ||
|
@@ -516,9 +519,7 @@ def _calc_fd(fd_file, fd_radius): | |
translations = np.transpose(np.abs(np.diff(cols[0:3, :]))) | ||
rotations = np.transpose(np.abs(np.diff(cols[3:6, :]))) | ||
|
||
fd_power = np.sum(translations, axis=1) + (fd_radius * pi / 180) * np.sum( | ||
rotations, axis=1 | ||
) | ||
fd_power = np.sum(translations, axis=1) + (fd_radius * pi / 180) * np.sum(rotations, axis=1) | ||
|
||
# FD is zero for the first time point | ||
fd_power = np.insert(fd_power, 0, 0) | ||
|
@@ -556,16 +557,12 @@ def plot_segmentation(anat_file, segmentation, out_file, **kwargs): | |
|
||
anat_ras = nb.as_closest_canonical(nb.load(anat_file)) | ||
anat_ras_plumb = anat_ras.__class__( | ||
anat_ras.dataobj, | ||
_dicom_real_to_card(anat_ras.affine), | ||
anat_ras.header | ||
anat_ras.dataobj, _dicom_real_to_card(anat_ras.affine), anat_ras.header | ||
) | ||
|
||
seg_ras = nb.as_closest_canonical(nb.load(segmentation)) | ||
seg_ras_plumb = seg_ras.__class__( | ||
seg_ras.dataobj, | ||
_dicom_real_to_card(seg_ras.affine), | ||
seg_ras.header | ||
seg_ras.dataobj, _dicom_real_to_card(seg_ras.affine), seg_ras.header | ||
) | ||
|
||
if kwargs.get("saturate", False): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters